Skip to content
Snippets Groups Projects
Commit 27e20835 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Merge branch 'main' into 'release'

Renovate updates Jan 2024

See merge request VIPS/VIPSCommon!37
parents a7a802e2 36c89aeb
No related branches found
No related tags found
No related merge requests found
![VIPS Logo](vipslogo_512.png)
# VIPSCommon
This is a jar file that contains the entities and util classes that are used throughout the VIPS system
This is a jar file that contains the entities and util classes that are used throughout the VIPS system.
## Requirements
* Java >= 14
* Java >= 17
* **TODO** What else?
## Development
**TODO TODO**
......@@ -9,7 +9,7 @@
</parent>
<artifactId>VIPSCommon</artifactId>
<version>2.0.2</version>
<version>2.0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>VIPSCommon</name>
......@@ -19,61 +19,54 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.13.1</version>
<version>2.16.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.13.1</version>
<version>2.16.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.7</version>
<version>1.8.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.13.1</version>
<version>2.16.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.1</version>
<version>2.16.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
<version>4.5.14</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.15</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.python</groupId>
<artifactId>jython-standalone</artifactId>
<version>2.7.2</version>
<version>4.4.16</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>1.18.2</version>
<version>1.19.0</version>
<type>jar</type>
</dependency>
<dependency>
......@@ -91,27 +84,32 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<version>2.15.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
<version>1.16.0</version>
</dependency>
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>70.1</version>
<version>74.2</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-api</artifactId>
<version>20.5</version>
<version>30.1</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-main</artifactId>
<version>30.1</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-hsql</artifactId>
<version>20.5</version>
<version>30.1</version>
</dependency>
<dependency>
<groupId>com.kjetland</groupId>
......@@ -127,13 +125,13 @@
<!--groupId>com.github.bjornharrtell</groupId-->
<groupId>org.wololo</groupId>
<artifactId>jts2geojson</artifactId>
<version>0.16.1</version>
<version>0.18.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jscience/jscience -->
<dependency>
<groupId>javax.measure</groupId>
<artifactId>unit-api</artifactId>
<version>2.1.3</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>tec.units</groupId>
......@@ -184,7 +182,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.1</version>
<version>3.6.3</version>
<configuration>
<tags>
<tag>
......@@ -199,20 +197,20 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<version>3.2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.12.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<version>3.6.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
......
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"baseBranches": ["renovate-updates"]
}
......@@ -28,12 +28,12 @@ import org.locationtech.jts.geom.PrecisionModel;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.geotools.geometry.jts.JTS;
import org.geotools.api.referencing.FactoryException;
import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
import org.geotools.api.referencing.operation.MathTransform;
import org.geotools.api.referencing.operation.TransformException;
import org.geotools.referencing.CRS;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import org.geotools.geometry.jts.JTS;
import org.wololo.geojson.Feature;
import org.wololo.geojson.FeatureCollection;
import org.wololo.geojson.GeoJSONFactory;
......
/*
* Copyright (c) 2017 NIBIO <http://www.nibio.no/>.
*
* This file is part of VIPSCommon.
* VIPSCommon is free software: you can redistribute it and/or modify
* it under the terms of the NIBIO Open Source License as published by
* NIBIO, either version 1 of the License, or (at your option) any
* later version.
*
* VIPSCommon is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* NIBIO Open Source License for more details.
*
* You should have received a copy of the NIBIO Open Source License
* along with VIPSCommon. If not, see <http://www.nibio.no/licenses/>.
*
*/
package no.nibio.vips.model;
import org.python.util.PythonInterpreter;
/**
* When implementing a model using Jython (Python on the Java Virtual Machine),
* you must extend this class.
*
* @copyright 2017 <a href="http://www.nibio.no/">NIBIO</a>
* @author Tor-Einar Skog <tor-einar.skog@nibio.no>
*/
public abstract class JythonModel{
public JythonModel()
{
// Adding possible paths to the python module
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.exec("import sys");
// Adding path to the containing JAR (if any) or code source
String jarPath = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
// For some reason weird prefixes and suffixes are added to the path. We try to
// remove them. This removal might ned to be revised when new deployment situations occur
jarPath = jarPath.replaceFirst("file:", "").replace("!", "");
interpreter.exec("sys.path.append('" + jarPath + "python')");
//interpreter.exec("print sys.path");
}
/**
* Assumes the python modules are found under the [jarPath]/python folder
* @param moduleName
* @param className
* @return
*/
protected Model getPythonModel(String moduleName, String className){
JythonObjectFactory f = new JythonObjectFactory(
Model.class, moduleName, className
);
return (Model) f.createObject();
}
}
/*
* Copyright (c) 2017 NIBIO <http://www.nibio.no/>.
*
* This file is part of VIPSCommon.
* VIPSCommon is free software: you can redistribute it and/or modify
* it under the terms of the NIBIO Open Source License as published by
* NIBIO, either version 1 of the License, or (at your option) any
* later version.
*
* VIPSCommon is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* NIBIO Open Source License for more details.
*
* You should have received a copy of the NIBIO Open Source License
* along with VIPSCommon. If not, see <http://www.nibio.no/licenses/>.
*
*/
package no.nibio.vips.model;
/**
* @copyright 2017 <a href="http://www.nibio.no/">NIBIO</a>
* @author Tor-Einar Skog <tor-einar.skog@nibio.no>
*/
import java.util.Properties;
import org.python.core.Py;
import org.python.core.PyObject;
import org.python.core.PySystemState;
/**
* Jython Object Factory using PySystemState
* Found here: http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html#more-efficient-version-of-loosely-coupled-object-factory
*/
public class JythonObjectFactory {
private final Class interfaceType;
private final PyObject klass;
// Constructor obtains a reference to the importer, module, and the class name
public JythonObjectFactory(PySystemState state, Class interfaceType, String moduleName, String className) {
this.interfaceType = interfaceType;
PyObject importer = state.getBuiltins().__getitem__(Py.newString("__import__"));
PyObject module = importer.__call__(Py.newString(moduleName));
klass = module.__getattr__(className);
//System.err.println("module=" + module + ",class=" + klass);
}
// This constructor passes through to the other constructor
public JythonObjectFactory(Class interfaceType, String moduleName, String className) {
this(new PySystemState(), interfaceType, moduleName, className);
}
// All of the followng methods return
// a coerced Jython object based upon the pieces of information
// that were passed into the factory. The differences are
// between them are the number of arguments that can be passed
// in as arguents to the object.
public Object createObject() {
return klass.__call__().__tojava__(interfaceType);
}
public Object createObject(Object arg1) {
return klass.__call__(Py.java2py(arg1)).__tojava__(interfaceType);
}
public Object createObject(Object arg1, Object arg2) {
return klass.__call__(Py.java2py(arg1), Py.java2py(arg2)).__tojava__(interfaceType);
}
public Object createObject(Object arg1, Object arg2, Object arg3)
{
return klass.__call__(Py.java2py(arg1), Py.java2py(arg2),
Py.java2py(arg3)).__tojava__(interfaceType);
}
public Object createObject(Object args[], String keywords[]) {
PyObject convertedArgs[] = new PyObject[args.length];
for (int i = 0; i < args.length; i++) {
convertedArgs[i] = Py.java2py(args[i]);
}
return klass.__call__(convertedArgs, keywords).__tojava__(interfaceType);
}
public Object createObject(Object... args) {
return createObject(args, Py.NoKeywords);
}
/**
* Adds user.dir into python.path to make Jython look for python modules in working directory in all cases
* (both standalone and not standalone modes)
* @param props
* @return props
*/
private Properties setDefaultPythonPath(Properties props) {
String pythonPathProp = props.getProperty("python.path");
String new_value;
if (pythonPathProp==null)
{
new_value = System.getProperty("user.dir");
} else {
new_value = pythonPathProp +java.io.File.pathSeparator + System.getProperty("user.dir") + java.io.File.pathSeparator;
}
props.setProperty("python.path",new_value);
return props;
}
}
......@@ -1024,7 +1024,7 @@ public class WeatherUtil {
{
newObs.setValue(0.0);
}
System.out.println("Appending this: " + newObs);
//System.out.println("Appending this: " + newObs);
list.add(newObs);
}
}
......
......@@ -67,7 +67,7 @@ public class DataTransformerTest extends TestCase {
try
{
List<WeatherObservation> result = instance.getVIPSWeatherData(IPMWeatherData);
result.forEach(obs->System.out.println(obs));
//result.forEach(obs->System.out.println(obs));
assertEquals(IPMWeatherData.getLocationWeatherData().get(0).getLength() * IPMWeatherData.getLocationWeatherData().get(0).getWidth(), result.size());
}catch(DataTransformerException ex)
{
......
......@@ -369,7 +369,7 @@ public class WeatherUtilTest extends TestCase {
// Test 1 // Result have same length as input data
assertEquals(TM.size(), result.size());
// Starts with same timestamp
result.stream().forEach(o->System.out.println(o));
//result.stream().forEach(o->System.out.println(o));
assertEquals(TM.get(0).getTimeMeasured(), result.get(0).getTimeMeasured());
// Ends with same timestamp
assertEquals(TM.get(TM.size()-1).getTimeMeasured(), result.get(TM.size()-1).getTimeMeasured());
......
......@@ -124,7 +124,7 @@ public class WebUtilTest extends TestCase {
Map<String, String[]> arrP = new HashMap<>();
arrP.put("wp", weatherParams);
String result = WebUtil.getOutputFromPostRequest(URL, queryParams, arrP);
System.out.println(result);
//System.out.println(result);
assertNotNull(expResult, result);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment