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

drop "geotools" dependency #5

Merged
merged 2 commits into from
Sep 4, 2018
Merged
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
6 changes: 0 additions & 6 deletions oshdb-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geometry</artifactId>
<version>${geotools.version}</version>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
Expand Down
7 changes: 0 additions & 7 deletions oshdb-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>

<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>${geotools.version}</version>
<type>jar</type>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.heigit.bigspatialdata.oshdb.util.geometry;

import com.vividsolutions.jts.geom.*;
import org.geotools.geometry.jts.JTS;
import org.heigit.bigspatialdata.oshdb.util.OSHDBBoundingBox;

/**
Expand Down Expand Up @@ -146,8 +145,7 @@ public static double ringArea(LinearRing ring) {
// =====================

public static Geometry clip(Geometry obj, OSHDBBoundingBox bbox) {
Envelope envelope = new Envelope(bbox.getMinLon(), bbox.getMaxLon(), bbox.getMinLat(), bbox.getMaxLat());
return obj.intersection(JTS.toGeometry(envelope));
return obj.intersection(OSHDBGeometryBuilder.getGeometry(bbox));
}

public static <P extends Geometry & Polygonal> Geometry clip(Geometry obj, P poly) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.stream.Stream;

import javax.annotation.Nonnull;
import org.geotools.geometry.jts.JTS;
import org.heigit.bigspatialdata.oshdb.osh.OSHEntity;
import org.heigit.bigspatialdata.oshdb.osm.OSMEntity;
import org.heigit.bigspatialdata.oshdb.osm.OSMMember;
Expand Down Expand Up @@ -283,7 +282,12 @@ public static <P extends Geometry & Polygonal, T extends OSMEntity> Geometry get
* @return com.vividsolutions.jts.geom.Geometry
*/
public static Polygon getGeometry(OSHDBBoundingBox bbox) {
return JTS.toGeometry(new Envelope(bbox.getMinLon(), bbox.getMaxLon(), bbox.getMinLat(), bbox.getMaxLat()));
GeometryFactory gf = new GeometryFactory();
Geometry g = gf.toGeometry(new Envelope(bbox.getMinLon(), bbox.getMaxLon(), bbox.getMinLat(), bbox.getMaxLat()));
if (g instanceof Polygon)
return (Polygon) g;
else
return gf.createPolygon((LinearRing) null);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.function.Predicate;
import org.heigit.bigspatialdata.oshdb.util.geometry.OSHDBGeometryBuilder;

/**
* Fast bounding-box in (multi)polygon test inspired by
Expand Down Expand Up @@ -42,14 +41,14 @@ public <P extends Geometry & Polygonal> FastBboxInPolygon(P geom) {
*/
@Override
public boolean test(OSHDBBoundingBox boundingBox) {
Polygon g = OSHDBGeometryBuilder.getGeometry(boundingBox);
Point p1 = g.getExteriorRing().getPointN(0);
GeometryFactory gf = new GeometryFactory();
Point p1 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMinLat()));
if (crossingNumber(p1, true) % 2 == 0) {
return false;
}
Point p2 = g.getExteriorRing().getPointN(1);
Point p3 = g.getExteriorRing().getPointN(2);
Point p4 = g.getExteriorRing().getPointN(3);
Point p2 = gf.createPoint(new Coordinate(boundingBox.getMaxLon(), boundingBox.getMinLat()));
Point p3 = gf.createPoint(new Coordinate(boundingBox.getMaxLon(), boundingBox.getMaxLat()));
Point p4 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMaxLat()));
if (crossingNumber(p1, true) != crossingNumber(p2, true) ||
crossingNumber(p3, true) != crossingNumber(p4, true) ||
crossingNumber(p2, false) != crossingNumber(p3, false) ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.heigit.bigspatialdata.oshdb.util.geometry.fip;

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.MultiPolygon;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Polygon;
Expand All @@ -13,7 +15,6 @@
import java.util.List;
import java.util.function.Predicate;
import org.heigit.bigspatialdata.oshdb.util.OSHDBBoundingBox;
import org.heigit.bigspatialdata.oshdb.util.geometry.OSHDBGeometryBuilder;

/**
* Fast bounding-box in (multi)polygon test inspired by
Expand Down Expand Up @@ -44,14 +45,14 @@ public <P extends Geometry & Polygonal> FastBboxOutsidePolygon(P geom) {
*/
@Override
public boolean test(OSHDBBoundingBox boundingBox) {
Polygon g = OSHDBGeometryBuilder.getGeometry(boundingBox);
Point p1 = g.getExteriorRing().getPointN(0);
GeometryFactory gf = new GeometryFactory();
Point p1 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMinLat()));
if (crossingNumber(p1, true) % 2 == 1) {
return false;
}
Point p2 = g.getExteriorRing().getPointN(1);
Point p3 = g.getExteriorRing().getPointN(2);
Point p4 = g.getExteriorRing().getPointN(3);
Point p2 = gf.createPoint(new Coordinate(boundingBox.getMaxLon(), boundingBox.getMinLat()));
Point p3 = gf.createPoint(new Coordinate(boundingBox.getMaxLon(), boundingBox.getMaxLat()));
Point p4 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMaxLat()));
if (crossingNumber(p1, true) != crossingNumber(p2, true) ||
crossingNumber(p3, true) != crossingNumber(p4, true) ||
crossingNumber(p2, false) != crossingNumber(p3, false) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryCollection;
import com.vividsolutions.jts.geom.MultiPolygon;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Polygonal;
import java.io.Serializable;
import java.util.ArrayList;
import org.geotools.geometry.jts.JTS;
import org.heigit.bigspatialdata.oshdb.util.geometry.Geo;

public class FastPolygonOperations implements Serializable {
private final int AvgVerticesPerBlock = 40; // todo: finetune this value
Expand All @@ -30,6 +27,8 @@ public <P extends Geometry & Polygonal> FastPolygonOperations(P geom) {
envWidth = env.getMaxX() - env.getMinX();
envHeight = env.getMaxY() - env.getMinY();

GeometryFactory gf = new GeometryFactory();

for (int x = 0; x < numBands; x++) {
for (int y = 0; y < numBands; y++) {
Envelope envPart = new Envelope(
Expand All @@ -39,7 +38,7 @@ public <P extends Geometry & Polygonal> FastPolygonOperations(P geom) {
env.getMinY() + envHeight * (y+1)/numBands
);
blocks.add(// index: y + x*numBands,
geom.intersection(JTS.toGeometry(envPart))
geom.intersection(gf.toGeometry(envPart))
);
}
}
Expand Down

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

6 changes: 0 additions & 6 deletions oshdb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
<artifactId>RoaringBitmap</artifactId>
<version>${roaringbitmap.version}</version>
</dependency>

<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-main</artifactId>
<version>${geotools.version}</version>
</dependency>

<dependency>
<groupId>com.googlecode.json-simple</groupId>
Expand Down
Loading