Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6.1 #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion geometry-datatype/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<version>0.1.0-SNAPSHOT</version>

<properties>
<pentaho.version>5.4.0.1-130</pentaho.version>
<pentaho.version>6.1.0.14-354</pentaho.version>
<license.organizationName>Atol CD</license.organizationName>
<license.licenseName>lgpl_v3</license.licenseName>
<license.inceptionYear>2015</license.inceptionYear>
Expand Down Expand Up @@ -100,4 +100,34 @@
<version>1.3.3</version>
</dependency>
</dependencies>

<repositories>
<!-- Local repository -->
<repository>
<id>local-maven-repo</id>
<name>Local Maven Repo</name>
<url>file://${project.basedir}/../local-maven-repo</url>
</repository>
<repository>
<id>pentaho-releases</id>
<url>http://repository.pentaho.org/artifactory/repo/</url>
</repository>
<repository>
<id>lds-main</id>
<name>Main Approved LDS Repo</name>
<url>http://code.lds.org/nexus/content/groups/main-repo</url>
</repository>
<repository>
<id>maven-us.nuxeo.org</id>
<name>maven-us.nuxeo.org</name>
<url>http://maven-us.nuxeo.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>axiomalaska</id>
<name>axiomalaska</name>
<url>http://nexus.axiomalaska.com/nexus/content/groups/public/</url>
</repository>
</repositories>


</project>
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.sql.Types;
import java.util.Date;

import com.vividsolutions.jts.geom.Coordinate;
import oracle.spatial.geometry.JGeometry;
import oracle.spatial.util.WKT;
import oracle.sql.STRUCT;
Expand All @@ -60,7 +61,6 @@
import org.postgis.binary.BinaryParser;
import org.postgis.binary.BinaryWriter;

import com.atolcd.pentaho.di.gis.utils.GeometryUtils;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.io.ByteOrderValues;
Expand Down Expand Up @@ -129,7 +129,7 @@ public String getString(Object object) throws KettleValueException {

Geometry geometry = getGeometry(object);

if (GeometryUtils.getCoordinateDimension(geometry) == 3) {
if (getCoordinateDimension(geometry) == 3) {
string = new WKTWriter(3).write(geometry);
} else {
string = new WKTWriter(2).write(geometry);
Expand Down Expand Up @@ -377,7 +377,7 @@ public Geometry getGeometry(Object object) throws KettleValueException {
protected Geometry convertStringToGeometry(String object) throws KettlePluginException {

try {
return GeometryUtils.getGeometryFromEWKT(object);
return getGeometryFromEWKT(object);
} catch (Exception e) {
throw new KettlePluginException(e);
}
Expand Down Expand Up @@ -676,7 +676,7 @@ public void setPreparedStatementValue(DatabaseMeta databaseMeta, PreparedStateme

String wkt = null;

if (GeometryUtils.getCoordinateDimension(geometry) == 3) {
if (getCoordinateDimension(geometry) == 3) {
wkt = new WKTWriter(3).write(geometry);
} else {
wkt = new WKTWriter(2).write(geometry);
Expand Down Expand Up @@ -711,7 +711,7 @@ public void setPreparedStatementValue(DatabaseMeta databaseMeta, PreparedStateme
* 3005 MULTILINE 2006 3006 MULTIPOLYGON 2007 3007
*/

if (GeometryUtils.getCoordinateDimension(geometry) == 3) {
if (getCoordinateDimension(geometry) == 3) {
throw new KettleDatabaseException(toStringMeta() + " : Unable to set Geometry 3D on prepared statement on index " + index);
} else {
wkt = new WKTWriter(2).write(geometry);
Expand Down Expand Up @@ -855,4 +855,95 @@ public int compare(Object data1, Object data2) throws KettleValueException {
}
}

/**
* Returns 3 if z coordinate otherwise 2
*
* @param geometry
* @return
*/
public static Integer getCoordinateDimension(Geometry geometry) {

if (!isNullOrEmptyGeometry(geometry)) {
Coordinate firstCoordinate = geometry.getCoordinates()[0];
if (!Double.isNaN(firstCoordinate.z)) {
return 3;
} else {
return 2;
}
}

return null;

}

/**
* Returns true if geometry object is null or JTS geometry is empty
*
* @param geometry
* @return
*/
public static boolean isNullOrEmptyGeometry(Geometry geometry) {

if (geometry != null && !geometry.isEmpty()) {
return false;
} else {
return true;
}

}

/**
* Returns a geometry from WKT/EWKT string
*
* @param wkt
* @return
* @throws Exception
*/
public static Geometry getGeometryFromEWKT(String wkt) throws Exception {

Geometry outputGeometry = null;

try {

String wktParts[] = wkt.toUpperCase().split(";");

if (wktParts[0].replace("SRID=", "").matches("[0-9]+")) {

outputGeometry = new WKTReader().read(wktParts[1]);
outputGeometry.setSRID(Integer.valueOf(wktParts[0].replace("SRID=", "")));

} else {

outputGeometry = new WKTReader().read(wktParts[0]);
}

} catch (ParseException e) {
throw new Exception("The value \"" + wkt + "\" is not a WKT/EWKT valid string");
}

return getNonEmptyGeometry(outputGeometry.getSRID(), outputGeometry);
}

/**
* Returns null if the JTS geometry is empty otherwise geometry
*
* @param geometry
* @return
*/
public static Geometry getNonEmptyGeometry(Integer srid, Geometry geometry) {

if (!isNullOrEmptyGeometry(geometry)) {

if (srid != null) {
geometry.setSRID(srid);
return geometry;
} else {
return geometry;
}

} else {
return null;
}
}

}
30 changes: 29 additions & 1 deletion geometry-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,35 @@
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
<version>5.4.0.1-130</version>
<version>6.1.0.14-354</version>
</dependency>
</dependencies>

<repositories>
<!-- Local repository -->
<repository>
<id>local-maven-repo</id>
<name>Local Maven Repo</name>
<url>file://${project.basedir}/../local-maven-repo</url>
</repository>
<repository>
<id>pentaho-releases</id>
<url>http://repository.pentaho.org/artifactory/repo/</url>
</repository>
<repository>
<id>lds-main</id>
<name>Main Approved LDS Repo</name>
<url>http://code.lds.org/nexus/content/groups/main-repo</url>
</repository>
<repository>
<id>maven-us.nuxeo.org</id>
<name>maven-us.nuxeo.org</name>
<url>http://maven-us.nuxeo.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>axiomalaska</id>
<name>axiomalaska</name>
<url>http://nexus.axiomalaska.com/nexus/content/groups/public/</url>
</repository>
</repositories>
</project>
7 changes: 6 additions & 1 deletion pentaho-gis-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<description>Pentaho's Data Integrator GIS Plugins</description>

<properties>
<pentaho.version>5.4.0.1-130</pentaho.version>
<pentaho.version>6.1.0.14-354</pentaho.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

Expand Down Expand Up @@ -215,6 +215,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<artifactId>geometry-datatype</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.atolcd.pentaho.di</groupId>
<artifactId>geometry-interface</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
</dependencies>

<organization>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
package com.atolcd.pentaho.di.gis.io;

/*
* #%L
* Pentaho Data Integrator GIS Plugin
* %%
* Copyright (C) 2015 Atol CD
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/

package com.atolcd.pentaho.di.gis.io;
/*
* #%L
* Pentaho Data Integrator GIS Plugin
* %%
* Copyright (C) 2015 Atol CD
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/

import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs2.FileSystemException;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.vfs.KettleVFS;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
package com.atolcd.pentaho.di.gis.io;

/*
* #%L
* Pentaho Data Integrator GIS Plugin
* %%
* Copyright (C) 2015 Atol CD
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/

package com.atolcd.pentaho.di.gis.io;
/*
* #%L
* Pentaho Data Integrator GIS Plugin
* %%
* Copyright (C) 2015 Atol CD
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/

import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs2.FileSystemException;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.vfs.KettleVFS;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.atolcd.pentaho.di.gis.io.features.Feature;
import com.atolcd.pentaho.di.gis.io.features.Field;
import com.atolcd.pentaho.di.gis.io.features.Field.FieldType;
import com.atolcd.pentaho.di.gis.utils.GeometryUtils;
import com.atolcd.pentaho.di.utils.GeometryUtils;

public class DXFReader extends AbstractFileReader {

Expand Down
Loading