Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
splitted geotools based classes into own submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
autermann committed Mar 7, 2014
1 parent ce25866 commit 6847af2
Show file tree
Hide file tree
Showing 157 changed files with 1,574 additions and 1,249 deletions.
8 changes: 8 additions & 0 deletions 52n-wps-ags/pom.xml
Expand Up @@ -40,6 +40,14 @@
<groupId>${project.groupId}</groupId>
<artifactId>52n-wps-algorithm</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>52n-wps-io-geotools</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>52n-wps-mc</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>52n-wps-server</artifactId>
Expand Down
Expand Up @@ -39,10 +39,11 @@
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.n52.wps.ags.workspace.AGSWorkspace;
import org.n52.wps.io.data.IData;
import org.n52.wps.io.data.GenericFileData;
import org.n52.wps.io.data.GenericFileDataConstants;
import org.n52.wps.io.data.IData;
import org.n52.wps.io.data.binding.complex.GenericFileDataBinding;
import org.n52.wps.server.IAlgorithm;
import org.n52.wps.server.feed.movingcode.AlgorithmParameterType;
Expand All @@ -55,53 +56,53 @@
*
*/
public class ArcToolboxProcessDelegator implements IAlgorithm{
private static Logger LOGGER = LoggerFactory.getLogger(ArcToolboxProcessDelegator.class);

private static final Logger LOGGER = LoggerFactory.getLogger(ArcToolboxProcessDelegator.class);
private AGSWorkspace agsWorkspace;

private final File toolWorkspace;
private final File workspaceBase;

private MovingCodeObject mco;
protected List<String> errors;

private String[] toolParameters;


protected ArcToolboxProcessDelegator(MovingCodeObject templateMCO, File workspaceBase) throws IOException{
this.workspaceBase = workspaceBase;
errors = new ArrayList<String>();
mco = templateMCO.createChild(workspaceBase);
toolParameters = new String[mco.getParameters().size()];
toolWorkspace = new File(mco.getInstanceWorkspace().getCanonicalPath());
}


public Map<String, IData> run(Map<String, List<IData>> inputData) {

//initialize arcObjects
AGSProperties.getInstance().bootstrapArcobjectsJar();

//create the workspace
agsWorkspace = new AGSWorkspace(toolWorkspace);

//retrieve path to the toolbox
String toolbox = toolWorkspace.getAbsolutePath() + mco.getAlgorithmURL().getPublicPath();
//retrieve the tool
String tool = mco.getAlgorithmURL().getPrivatePath();

List<AlgorithmParameterType> params = mco.getParameters();
HashMap<String, String> outputs = new HashMap<String,String>();
System.gc();

// assign parameters
for (AlgorithmParameterType currentParam : params){
String wpsInputID = currentParam.getWpsInputID();
String wpsOutputID = currentParam.getWpsOutputID();
int positionID = currentParam.getPositionID().intValue();

CommandLineParameter cmdParam = null;

// input parameters
if(!wpsInputID.equalsIgnoreCase("")){
if(inputData.containsKey(wpsInputID)){
Expand All @@ -119,34 +120,34 @@ public Map<String, IData> run(Map<String, List<IData>> inputData) {
} else if (!wpsOutputID.equalsIgnoreCase("")){ // output only parameters !!ONLY SINGLE OUTPUT ITEMS SUPPORTED BY WPS!!
// create CommanLineParameter Object
cmdParam = new CommandLineParameter(currentParam.getPrefixString(), currentParam.getSuffixString(), currentParam.getSeparatorString());

// retrieve the default mimeType
String mimeType = mco.getDefaultMimeType(wpsOutputID);

// prepare output filename
String extension = GenericFileDataConstants.mimeTypeFileTypeLUT().get(mimeType);
String fileName = UUID.randomUUID().toString().substring(0,7) + "." + extension; // geoprocessor can't handle points, dashes etc in output file name
// String fileName = UUID.randomUUID() + "." + extension;
fileName = toolWorkspace.getAbsolutePath() + File.separator + fileName;
cmdParam.addValue(fileName);
}

//prepare the output - files only
if (!wpsOutputID.equalsIgnoreCase("")){
String fileName = cmdParam.getAsPlainString();
outputs.put(wpsOutputID, fileName);
}


// create a new parameter in the tool's Parameter Array
if (cmdParam == null){
toolParameters[positionID] = "";
} else {
toolParameters[positionID] = cmdParam.getAsCommandString();
}

}

//execute
LOGGER.info("Executing ArcGIS tool " + toolbox + File.pathSeparator + tool + " . Parameter array contains " + toolParameters.length + " parameters.");
try {
Expand All @@ -156,7 +157,7 @@ public Map<String, IData> run(Map<String, List<IData>> inputData) {
errors.add(e1.getMessage());
throw new RuntimeException(e1.getMessage()); // otherwise WPS tries to zip and return non-existing files => null pointer
}

//create the output - files only
HashMap<String, IData> result = new HashMap<String, IData>();
for (String wpsOutputID : outputs.keySet()){
Expand All @@ -176,10 +177,10 @@ public Map<String, IData> run(Map<String, List<IData>> inputData) {
e.printStackTrace();
}
}

return result;
}

public List<String> getErrors() {
return errors;
}
Expand All @@ -203,7 +204,7 @@ public Class<?> getInputDataType(String id) {
public Class<?> getOutputDataType(String id) {
return MovingCodeUtils.getOutputDataType(mco, id);
}

//delete the current workspace
protected void finalize(){
try {
Expand All @@ -213,5 +214,5 @@ protected void finalize(){
e.printStackTrace();
}
}

}
97 changes: 97 additions & 0 deletions 52n-wps-algorithm-geotools/pom.xml
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>52n-wps-parent</artifactId>
<groupId>org.n52.wps</groupId>
<version>3.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>52n-wps-algorithm-geotools</artifactId>
<name>52North WPS Geotools Algorithm Implementations</name>
<description>Geotools Implementations of geospatial algorithms for raster and vector data.</description>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<header>../misc/licenses/license_header.txt</header>
</configuration>
</plugin>
<plugin>
<groupId>org.jasig.maven</groupId>
<artifactId>maven-notice-plugin</artifactId>
<executions>
<execution>
<id>check-licenses</id>
<phase></phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.n52.wps</groupId>
<artifactId>52n-wps-algorithm</artifactId>
</dependency>
<dependency>
<groupId>org.n52.wps</groupId>
<artifactId>52n-wps-io-geotools</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>52n-wps-io</artifactId>
</dependency>
<dependency>
<artifactId>gt-referencing</artifactId>
<groupId>org.geotools</groupId>
</dependency>
<dependency>
<artifactId>gt-main</artifactId>
<groupId>org.geotools</groupId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<artifactId>gt-coverage</artifactId>
<groupId>org.geotools</groupId>
</dependency>
<dependency>
<artifactId>jai_core</artifactId>
<groupId>javax.media</groupId>
</dependency>
<dependency>
<artifactId>jts</artifactId>
<groupId>com.vividsolutions</groupId>
</dependency>
<dependency>
<artifactId>gt-api</artifactId>
<groupId>org.geotools</groupId>
</dependency>
<dependency>
<artifactId>axis-jaxrpc</artifactId>
<groupId>axis</groupId>
</dependency>
<dependency>
<artifactId>gt-opengis</artifactId>
<groupId>org.geotools</groupId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

@@ -1,3 +1,5 @@
package org.n52.wps.server.algorithm;

/**
* Copyright (C) 2007
* by 52 North Initiative for Geospatial Open Source Software GmbH
Expand All @@ -21,7 +23,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA or
* visit the Free Software Foundation web page, http://www.fsf.org.
*/
package org.n52.wps.server.algorithm;


import java.util.Iterator;
import java.util.UUID;
Expand Down

0 comments on commit 6847af2

Please sign in to comment.