Geometry clip(Geometry obj, P poly) { diff --git a/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/OSHDBGeometryBuilder.java b/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/OSHDBGeometryBuilder.java index 6ca587a45..08404b657 100644 --- a/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/OSHDBGeometryBuilder.java +++ b/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/OSHDBGeometryBuilder.java @@ -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; @@ -283,7 +282,12 @@ public static
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); } diff --git a/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/fip/FastBboxInPolygon.java b/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/fip/FastBboxInPolygon.java index 1b338225a..e6e14e5e3 100644 --- a/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/fip/FastBboxInPolygon.java +++ b/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/fip/FastBboxInPolygon.java @@ -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 @@ -42,14 +41,14 @@ public
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) || diff --git a/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/fip/FastBboxOutsidePolygon.java b/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/fip/FastBboxOutsidePolygon.java index 7851bfcc8..30093a887 100644 --- a/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/fip/FastBboxOutsidePolygon.java +++ b/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/fip/FastBboxOutsidePolygon.java @@ -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; @@ -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 @@ -44,14 +45,14 @@ public
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) || diff --git a/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/fip/FastPolygonOperations.java b/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/fip/FastPolygonOperations.java index 62be97b57..489ecd6e1 100644 --- a/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/fip/FastPolygonOperations.java +++ b/oshdb-util/src/main/java/org/heigit/bigspatialdata/oshdb/util/geometry/fip/FastPolygonOperations.java @@ -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 @@ -30,6 +27,8 @@ public
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( @@ -39,7 +38,7 @@ public
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))
);
}
}
diff --git a/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.VERSION.txt b/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.VERSION.txt
deleted file mode 100644
index fcdb2e109..000000000
--- a/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.VERSION.txt
+++ /dev/null
@@ -1 +0,0 @@
-4.0.0
diff --git a/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.cpg b/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.cpg
deleted file mode 100644
index 3ad133c04..000000000
--- a/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.cpg
+++ /dev/null
@@ -1 +0,0 @@
-UTF-8
\ No newline at end of file
diff --git a/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.dbf b/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.dbf
deleted file mode 100644
index 132a6583f..000000000
Binary files a/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.dbf and /dev/null differ
diff --git a/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.prj b/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.prj
deleted file mode 100644
index f45cbadf0..000000000
--- a/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.prj
+++ /dev/null
@@ -1 +0,0 @@
-GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
\ No newline at end of file
diff --git a/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.shp b/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.shp
deleted file mode 100644
index 6ec7f46aa..000000000
Binary files a/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.shp and /dev/null differ
diff --git a/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.shx b/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.shx
deleted file mode 100644
index c6f76ca89..000000000
Binary files a/oshdb-util/src/main/resources/ne_10m_admin_0_map_units/ne_10m_admin_0_map_units.shx and /dev/null differ
diff --git a/oshdb-util/src/test/java/org/heigit/bigspatialdata/oshdb/util/geometry/CountryTest.java b/oshdb-util/src/test/java/org/heigit/bigspatialdata/oshdb/util/geometry/CountryTest.java
deleted file mode 100644
index 94daa1be0..000000000
--- a/oshdb-util/src/test/java/org/heigit/bigspatialdata/oshdb/util/geometry/CountryTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.heigit.bigspatialdata.oshdb.util.geometry;
-
-import org.heigit.bigspatialdata.oshdb.util.OSHDBBoundingBox;
-import com.vividsolutions.jts.geom.MultiPolygon;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-public class CountryTest {
-
- public CountryTest() {
- }
-
- @Test
- public void testGetGeometry() throws Exception {
- CountryCodeType type = CountryCodeType.GEOUNIT;
- String name = "Andorra";
- String expResult = getAndorra();
- MultiPolygon result = Country.getGeometry(type, name);
- assertEquals(expResult, result.toString());
- }
-
- @Test
- public void testGetBBX() throws Exception {
- String name = "France";
- OSHDBBoundingBox expResult = new OSHDBBoundingBox(-5.132802, 9.559581, 41.365912, 51.087541);
-
- OSHDBBoundingBox result = Country.getBoundingBox(name);
- assertEquals(expResult.toString(), result.toString());
- }
-
- private String getAndorra() {
- return "MULTIPOLYGON (((1.707006470000067 42.5027814740001, 1.6974980060000746 42.49446156900012, 1.6863358960000596 42.49061167500008, 1.6742436110000654 42.49050832100005, 1.6623580320000428 42.493712260000024, 1.659774210000137 42.49681284600007, 1.6569836830000781 42.49763966900008, 1.6539864500000476 42.4965286260001, 1.6503691000000629 42.49340220200014, 1.6395170490001192 42.46642710400002, 1.6074776610001038 42.456427714000085, 1.5444324140000845 42.45035573400014, 1.5388513590000628 42.44565317800007, 1.534510539000081 42.439917094000094, 1.5282060140000908 42.43423268600006, 1.5166304930001218 42.42950429300009, 1.5084656170001267 42.42867747000005, 1.4479008380000664 42.43464609800009, 1.4364286700000548 42.44095062300008, 1.4364286700000548 42.4534821580001, 1.4075932210000985 42.48676178000005, 1.4245430900000144 42.49247202600009, 1.4302274980000504 42.493557231000096, 1.449967895000043 42.50407338400004, 1.4465572510000868 42.51988637400004, 1.4289872640001136 42.531461894000074, 1.4064563390001013 42.529239808000085, 1.4097636310000894 42.540608622000065, 1.4263000900000975 42.56179596000004, 1.4264034420001224 42.56564585400008, 1.4180318600000419 42.56983164500011, 1.419272095000082 42.579262594000085, 1.4248531500001036 42.5893653360001, 1.4292973220001102 42.595385641000064, 1.4514148360001116 42.60205190100007, 1.4668144120001045 42.641455180000065, 1.4984403890000806 42.64024078400004, 1.527792602000062 42.6485348520001, 1.5430888270001333 42.64936167400003, 1.5973490810000612 42.62192148900007, 1.6083044840001435 42.61812327100003, 1.7219926350000492 42.60985504200008, 1.7133109950000858 42.58954620400007, 1.7294340410000473 42.58200144500012, 1.752688435000067 42.576678772000065, 1.761107147000132 42.567646197000016, 1.7650907800001505 42.56337209100005, 1.7399760330001186 42.561640930000095, 1.7216825770001378 42.54851511600003, 1.7106238200001371 42.527741191000075, 1.707006470000067 42.5027814740001)))";
- }
-
-}
diff --git a/oshdb/pom.xml b/oshdb/pom.xml
index a49be4045..1a613b104 100644
--- a/oshdb/pom.xml
+++ b/oshdb/pom.xml
@@ -25,12 +25,6 @@