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

Merge branch 'no_renjin' into 'develop'

No renjin

See merge request VIPS/VIPSCommon!5
parents 1cc36d17 bc15d444
No related branches found
No related tags found
No related merge requests found
...@@ -100,18 +100,13 @@ ...@@ -100,18 +100,13 @@
<dependency> <dependency>
<groupId>org.geotools</groupId> <groupId>org.geotools</groupId>
<artifactId>gt-api</artifactId> <artifactId>gt-api</artifactId>
<version>20.3</version> <version>20.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.geotools</groupId> <groupId>org.geotools</groupId>
<artifactId>gt-epsg-hsql</artifactId> <artifactId>gt-epsg-hsql</artifactId>
<version>20.3</version> <version>20.5</version>
</dependency> </dependency>
<dependency>
<groupId>org.renjin</groupId>
<artifactId>renjin-script-engine</artifactId>
<version>RELEASE</version>
</dependency>
<dependency> <dependency>
<groupId>com.bedatadriven</groupId> <groupId>com.bedatadriven</groupId>
...@@ -135,19 +130,32 @@ ...@@ -135,19 +130,32 @@
<artifactId>unit-ri</artifactId> <artifactId>unit-ri</artifactId>
<version>1.0.3</version> <version>1.0.3</version>
</dependency> </dependency>
<dependency>
<groupId>org.renjin</groupId>
<artifactId>renjin-script-engine</artifactId>
<version>3.5-beta76</version>
</dependency>
</dependencies> </dependencies>
<repositories> <repositories>
<repository> <repository>
<id>bedatadriven</id> <id>bedatadriven</id>
<name>bedatadriven public repo</name> <name>bedatadriven public repo</name>
<url>https://nexus.bedatadriven.com/content/groups/public/</url> <url>https://nexus.bedatadriven.com/content/groups/public/</url>
</repository> </repository>
<repository> <repository>
<id>osgeo</id> <id>osgeo</id>
<name>OSGEO</name> <name>OSGeo Release Repository</name>
<url>https://download.osgeo.org/webdav/geotools/</url> <url>https://repo.osgeo.org/repository/release/</url>
</repository> <snapshots><enabled>false</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</repository>
<repository>
<id>osgeo-snapshot</id>
<name>OSGeo Snapshot Repository</name>
<url>https://repo.osgeo.org/repository/snapshot/</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>false</enabled></releases>
</repository>
<repository> <repository>
<id>jitpack.io</id> <id>jitpack.io</id>
<url>https://jitpack.io</url> <url>https://jitpack.io</url>
......
/* /*
* Copyright (c) 2017 NIBIO <http://www.nibio.no/>. * Copyright (c) 2017 NIBIO <http://www.nibio.no/>.
* *
* This file is part of VIPSCommon. * This file is part of VIPSCommon.
* VIPSCommon is free software: you can redistribute it and/or modify * VIPSCommon is free software: you can redistribute it and/or modify
* it under the terms of the NIBIO Open Source License as published by * 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 * NIBIO, either version 1 of the License, or (at your option) any
* later version. * later version.
* *
* VIPSCommon is distributed in the hope that it will be useful, * VIPSCommon is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* NIBIO Open Source License for more details. * NIBIO Open Source License for more details.
* *
* You should have received a copy of the NIBIO Open Source License * You should have received a copy of the NIBIO Open Source License
* along with VIPSCommon. If not, see <http://www.nibio.no/licenses/>. * along with VIPSCommon. If not, see <http://www.nibio.no/licenses/>.
* *
*/ */
package no.nibio.vips.model; package no.nibio.vips.model;
...@@ -26,51 +26,45 @@ import org.renjin.script.RenjinScriptEngineFactory; ...@@ -26,51 +26,45 @@ import org.renjin.script.RenjinScriptEngineFactory;
import org.renjin.sexp.ExternalPtr; import org.renjin.sexp.ExternalPtr;
/** /**
* When implementing a model using Renjin (http://www.renjin.org/ - R on the Java Virtual Machine), * When implementing a model using Renjin (http://www.renjin.org/ - R on the
* Java Virtual Machine),
* you must extend this class. * you must extend this class.
* * @copyright 2017
* @copyright 2017 <a href="http://www.nibio.no/">NIBIO</a> * <a href="http://www.nibio.no/">NIBIO</a> * @author Tor-Einar Skog
* @author Tor-Einar Skog <tor-einar.skog@nibio.no> * <tor-einar.skog@nibio.no>
*/ */
public abstract class RenjinModel { public abstract class RenjinModel {
protected ScriptEngine engine; protected ScriptEngine engine;
public RenjinModel() public RenjinModel() {
{ // create a Renjin engine:
// create a Renjin engine:
RenjinScriptEngineFactory factory = new RenjinScriptEngineFactory(); RenjinScriptEngineFactory factory = new RenjinScriptEngineFactory();
engine = factory.getScriptEngine(); engine = factory.getScriptEngine();
} }
/** /**
* Run an R script file available on the classpath * Run an R script file available on the classpath * @param scriptPath *
* @param scriptPath * @throws ScriptException
* @throws ScriptException
*/ */
public void runRScript(String scriptPath) throws ScriptException public void runRScript(String scriptPath) throws ScriptException {
{
InputStreamReader fr = new java.io.InputStreamReader(this.getClass().getResourceAsStream(scriptPath)); InputStreamReader fr = new java.io.InputStreamReader(this.getClass().getResourceAsStream(scriptPath));
engine.eval(fr); engine.eval(fr);
} }
/** /**
* Place a Java object in the Renjin script engine * Place a Java object in the Renjin script engine * @param objectName *
* @param objectName * @param object
* @param object
*/ */
public void placeObjectInScriptEngine(String objectName, Object object) public void placeObjectInScriptEngine(String objectName, Object object) {
{
engine.put(objectName, object); engine.put(objectName, object);
} }
/** /**
* * @param objectName * @return a Java object from the Renjin script
* @param objectName * engine
* @return a Java object from the Renjin script engine
*/ */
public Object getObjectFromScriptEngine(String objectName) public Object getObjectFromScriptEngine(String objectName) {
{
ExternalPtr ptr = (ExternalPtr) engine.get(objectName); ExternalPtr ptr = (ExternalPtr) engine.get(objectName);
return ptr.getInstance(); return ptr.getInstance();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment