Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSCommon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIPS
VIPSCommon
Commits
bc15d444
Commit
bc15d444
authored
5 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Reintroducing Renjin
parent
9ef2605f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pom.xml
+23
-10
23 additions, 10 deletions
pom.xml
src/main/java/no/nibio/vips/model/RenjinModel.java
+71
-0
71 additions, 0 deletions
src/main/java/no/nibio/vips/model/RenjinModel.java
with
94 additions
and
10 deletions
pom.xml
+
23
−
10
View file @
bc15d444
...
...
@@ -100,12 +100,12 @@
<dependency>
<groupId>
org.geotools
</groupId>
<artifactId>
gt-api
</artifactId>
<version>
20.
3
</version>
</dependency>
<dependency>
<version>
20.
5
</version>
</dependency>
<dependency>
<groupId>
org.geotools
</groupId>
<artifactId>
gt-epsg-hsql
</artifactId>
<version>
20.
3
</version>
<version>
20.
5
</version>
</dependency>
<dependency>
...
...
@@ -130,19 +130,32 @@
<artifactId>
unit-ri
</artifactId>
<version>
1.0.3
</version>
</dependency>
<dependency>
<groupId>
org.renjin
</groupId>
<artifactId>
renjin-script-engine
</artifactId>
<version>
3.5-beta76
</version>
</dependency>
</dependencies>
<repositories>
<repository>
<repository>
<id>
bedatadriven
</id>
<name>
bedatadriven public repo
</name>
<url>
https://nexus.bedatadriven.com/content/groups/public/
</url>
</repository>
<repository>
<repository>
<id>
osgeo
</id>
<name>
OSGEO
</name>
<url>
https://download.osgeo.org/webdav/geotools/
</url>
</repository>
<name>
OSGeo Release Repository
</name>
<url>
https://repo.osgeo.org/repository/release/
</url>
<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>
<id>
jitpack.io
</id>
<url>
https://jitpack.io
</url>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/no/nibio/vips/model/RenjinModel.java
0 → 100644
+
71
−
0
View file @
bc15d444
/*
* 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
java.io.InputStreamReader
;
import
javax.script.ScriptEngine
;
import
javax.script.ScriptException
;
import
org.renjin.script.RenjinScriptEngineFactory
;
import
org.renjin.sexp.ExternalPtr
;
/**
* When implementing a model using Renjin (http://www.renjin.org/ - R 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
RenjinModel
{
protected
ScriptEngine
engine
;
public
RenjinModel
()
{
// create a Renjin engine:
RenjinScriptEngineFactory
factory
=
new
RenjinScriptEngineFactory
();
engine
=
factory
.
getScriptEngine
();
}
/**
* Run an R script file available on the classpath * @param scriptPath *
* @throws ScriptException
*/
public
void
runRScript
(
String
scriptPath
)
throws
ScriptException
{
InputStreamReader
fr
=
new
java
.
io
.
InputStreamReader
(
this
.
getClass
().
getResourceAsStream
(
scriptPath
));
engine
.
eval
(
fr
);
}
/**
* Place a Java object in the Renjin script engine * @param objectName *
* @param object
*/
public
void
placeObjectInScriptEngine
(
String
objectName
,
Object
object
)
{
engine
.
put
(
objectName
,
object
);
}
/**
* @param objectName * @return a Java object from the Renjin script
* engine
*/
public
Object
getObjectFromScriptEngine
(
String
objectName
)
{
ExternalPtr
ptr
=
(
ExternalPtr
)
engine
.
get
(
objectName
);
return
ptr
.
getInstance
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment