Skip to content

Commit 4be2283

Browse files
committed
removed polygon normalisation
1 parent 9718b36 commit 4be2283

File tree

14 files changed

+82
-88
lines changed

14 files changed

+82
-88
lines changed

core/src/main/java/com/bc/fiduceo/geometry/s2/BcS2GeometryFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public BcS2GeometryFactory() {
4242
public Geometry parse(String wkt) {
4343
final Object geometry = s2WKTReader.read(wkt);
4444
if (geometry instanceof S2Polygon) {
45+
//normalizePolygon((S2Polygon) geometry);
4546
return new BcS2Polygon(geometry);
4647
} else if (geometry instanceof S2Polyline) {
4748
return new BcS2LineString((S2Polyline) geometry);
@@ -53,6 +54,7 @@ public Geometry parse(String wkt) {
5354
final ArrayList<Polygon> polygonList = new ArrayList<>();
5455
final List<S2Polygon> googlePolygonList = (List<S2Polygon>) geometry;
5556
for (S2Polygon googlePolygon : googlePolygonList) {
57+
//normalizePolygon(googlePolygon);
5658
polygonList.add(new BcS2Polygon(googlePolygon));
5759
}
5860
return new BcS2MultiPolygon(polygonList);

core/src/test/java/com/bc/fiduceo/GeometryUtilTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public void testToKml_simplePolygon() {
5454
" <outerBoundaryIs>\n" +
5555
" <LinearRing>\n" +
5656
" <coordinates>\n" +
57-
" 1.0,0.0,0\n" +
58-
" 0.9999999999999998,1.0,0\n" +
59-
" 0.0,1.0,0\n" +
6057
" 0.0,0.0,0\n" +
58+
" 0.0,1.0,0\n" +
59+
" 0.9999999999999998,1.0,0\n" +
6160
" 1.0,0.0,0\n" +
61+
" 0.0,0.0,0\n" +
6262
" </coordinates>\n" +
6363
" </LinearRing>\n" +
6464
" </outerBoundaryIs>\n" +

core/src/test/java/com/bc/fiduceo/TestData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public class TestData {
124124
public static final String DATA_FILE_PATH = "the_data.file";
125125

126126
public static SatelliteObservation createSatelliteObservation(Date startTime, Date stopTime, GeometryFactory geometryFactory) {
127-
return createSatelliteObservation(startTime, stopTime, "POLYGON ((10 5, 10 7, 12 7, 12 5, 10 5))", geometryFactory);
127+
return createSatelliteObservation(startTime, stopTime, "POLYGON ((10 5, 12 5, 12 7, 10 7, 10 5))", geometryFactory);
128128
}
129129

130130
public static SatelliteObservation createSatelliteObservation(Date startTime, Date stopTime, String boundaryWkt, GeometryFactory geometryFactory) {

core/src/test/java/com/bc/fiduceo/db/MongoDbDriverTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void testConvertToGeoJSON_polygon() {
6363

6464
final com.mongodb.client.model.geojson.Geometry geoJSON = MongoDbDriver.convertToGeoJSON(polygon);
6565
assertNotNull(geoJSON);
66-
assertEquals("{\"type\": \"Polygon\", \"coordinates\": [[[-6.0, -2.0], [-6.0, -1.0], [-7.999999999999998, -1.0], [-7.999999999999998, -1.9999999999999996], [-6.0, -2.0]]]}",
66+
assertEquals("{\"type\": \"Polygon\", \"coordinates\": [[[-7.999999999999998, -1.9999999999999996], [-7.999999999999998, -1.0], [-6.0, -1.0], [-6.0, -2.0], [-7.999999999999998, -1.9999999999999996]]]}",
6767
geoJSON.toJson());
6868
}
6969

@@ -133,7 +133,7 @@ public void testConvertToGeoJSON_GeometryCollection() {
133133

134134

135135
assertEquals(2, convertedGeometries.size());
136-
assertEquals("Polygon{exterior=[Position{values=[-6.0, -2.0]}, Position{values=[-6.0, -1.0]}, Position{values=[-7.999999999999998, -1.0]}, Position{values=[-7.999999999999998, -1.9999999999999996]}, Position{values=[-6.0, -2.0]}]}",
136+
assertEquals("Polygon{exterior=[Position{values=[-7.999999999999998, -1.9999999999999996]}, Position{values=[-7.999999999999998, -1.0]}, Position{values=[-6.0, -1.0]}, Position{values=[-6.0, -2.0]}, Position{values=[-7.999999999999998, -1.9999999999999996]}]}",
137137
convertedGeometries.get(0).toString());
138138

139139
assertEquals("MultiPolygon{coordinates=[PolygonCoordinates{exterior=[Position{values=[20.0, 0.0]}, " +
@@ -155,7 +155,7 @@ public void testConvertToGeoJSON_GeometryCollection_oneEntry() {
155155
com.mongodb.client.model.geojson.Geometry mongoGeometry = MongoDbDriver.convertToGeoJSON(geometryCollection);
156156
assertNotNull(mongoGeometry);
157157
assertTrue(mongoGeometry instanceof com.mongodb.client.model.geojson.Polygon);
158-
assertEquals("{\"type\": \"Polygon\", \"coordinates\": [[[-4.0, -2.0], [-4.000000000000001, -1.0], [-6.0, -1.0], [-6.0, -2.0], [-4.0, -2.0]]]}",
158+
assertEquals("{\"type\": \"Polygon\", \"coordinates\": [[[-6.0, -2.0], [-6.0, -1.0], [-4.000000000000001, -1.0], [-4.0, -2.0], [-6.0, -2.0]]]}",
159159
mongoGeometry.toJson());
160160
}
161161

core/src/test/java/com/bc/fiduceo/db/StorageTest_SatelliteObservation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void testInsert_andGet() throws SQLException {
120120

121121
final Geometry geoBoundsFromDb = observationFromDb.getGeoBounds();
122122
final String geoBoundsWkt = geometryFactory.format(geoBoundsFromDb);
123-
assertEquals("POLYGON((12.0 4.999999999999998,12.000000000000004 7.000000000000001,9.999999999999998 7.0,9.999999999999998 4.999999999999998,12.0 4.999999999999998))", geoBoundsWkt);
123+
assertEquals("POLYGON((9.999999999999998 4.999999999999998,12.0 4.999999999999998,12.000000000000004 7.000000000000001,9.999999999999998 7.0,9.999999999999998 4.999999999999998))", geoBoundsWkt);
124124

125125
assertEquals(observation.getSensor().getName(), observationFromDb.getSensor().getName());
126126
assertEquals(observation.getDataFilePath().toString(), observationFromDb.getDataFilePath().toString());
@@ -220,7 +220,7 @@ public void testInsert_andGet_L3TimeAxis() throws SQLException {
220220

221221
final Geometry multiLineString = geometryFactory.parse("MULTILINESTRING((-2 3, -1 5), (-56 3, 56 4))");
222222
final L3TimeAxis l3TimeAxis = new L3TimeAxis(TimeUtils.create(1440000000000L), TimeUtils.create(1450000000000L), multiLineString);
223-
final TimeAxis[] timeAxes = new TimeAxis[] {l3TimeAxis};
223+
final TimeAxis[] timeAxes = new TimeAxis[]{l3TimeAxis};
224224
observation.setTimeAxes(timeAxes);
225225

226226
storage.insert(observation);
@@ -280,7 +280,7 @@ public void testUpdate() throws SQLException {
280280
final SatelliteObservation updatedObservation = result.get(0);
281281
assertEquals(1440000000000L, updatedObservation.getStartTime().getTime());
282282
assertEquals(1440001000000L, updatedObservation.getStopTime().getTime());
283-
assertEquals("POLYGON((13.0 4.999999999999998,13.0 6.999999999999999,11.0 6.999999999999999,11.0 4.999999999999998,13.0 4.999999999999998))", geometryFactory.format(updatedObservation.getGeoBounds()));
283+
assertEquals("POLYGON((11.0 4.999999999999998,11.0 6.999999999999999,13.0 6.999999999999999,13.0 4.999999999999998,11.0 4.999999999999998))", geometryFactory.format(updatedObservation.getGeoBounds()));
284284

285285
final TimeAxis[] timeAxes = observation.getTimeAxes();
286286
assertEquals(1, timeAxes.length);

core/src/test/java/com/bc/fiduceo/geometry/s2/BcS2GeometryFactoryTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ public void testParseMultiLineString() {
8383
Point[] coordinates = geometry.getCoordinates();
8484
assertEquals(4, coordinates.length);
8585
assertEquals(0.0, coordinates[0].getLon(), 1e-8);
86-
assertEquals( 1.0, coordinates[0].getLat(),1e-8);
86+
assertEquals(1.0, coordinates[0].getLat(), 1e-8);
8787

88-
assertEquals( 3.0, coordinates[3].getLon(),1e-8);
89-
assertEquals( 4.0, coordinates[3].getLat(),1e-8);
88+
assertEquals(3.0, coordinates[3].getLon(), 1e-8);
89+
assertEquals(4.0, coordinates[3].getLat(), 1e-8);
9090
}
9191

9292
@Test
@@ -245,10 +245,10 @@ public void testCreateMultiPolygonFromPolygonList() {
245245
final Point[] coordinates = multiPolygon.getCoordinates();
246246
assertEquals(10, coordinates.length);
247247

248-
assertEquals(0.0, coordinates[2].getLon(), 1e-8);
248+
assertEquals(1.0, coordinates[2].getLon(), 1e-8);
249249
assertEquals(1.0, coordinates[2].getLat(), 1e-8);
250250

251-
assertEquals(3.0, coordinates[6].getLon(), 1e-8);
251+
assertEquals(1.0, coordinates[6].getLon(), 1e-8);
252252
assertEquals(1.0, coordinates[6].getLat(), 1e-8);
253253
}
254254

@@ -283,7 +283,7 @@ public void testToStorageFormat_polygon() {
283283
final Geometry point = factory.parse("POLYGON((1 8, 2 8.5, 3 8.2, 1 8))");
284284

285285
final byte[] storageFormat = factory.toStorageFormat(point);
286-
assertEquals("POLYGON((3.0000000000000004 8.2,2.0 8.5,1.0 7.999999999999998,3.0000000000000004 8.2))", new String(storageFormat));
286+
assertEquals("POLYGON((1.0 7.999999999999998,2.0 8.5,3.0000000000000004 8.2,1.0 7.999999999999998))", new String(storageFormat));
287287
}
288288

289289
@Test
@@ -323,12 +323,12 @@ public void testFromStorageFormat_polygon() {
323323

324324
final Point[] coordinates = polygonGeometry.getCoordinates();
325325
assertEquals(4, coordinates.length);
326-
assertEquals(3, coordinates[0].getLon(), 1e-8);
327-
assertEquals(8.2, coordinates[0].getLat(), 1e-8);
328-
assertEquals(1, coordinates[2].getLon(), 1e-8);
329-
assertEquals(8, coordinates[2].getLat(), 1e-8);
330-
assertEquals(3, coordinates[3].getLon(), 1e-8);
331-
assertEquals(8.2, coordinates[3].getLat(), 1e-8);
326+
assertEquals(1, coordinates[0].getLon(), 1e-8);
327+
assertEquals(8, coordinates[0].getLat(), 1e-8);
328+
assertEquals(3, coordinates[2].getLon(), 1e-8);
329+
assertEquals(8.2, coordinates[2].getLat(), 1e-8);
330+
assertEquals(1, coordinates[3].getLon(), 1e-8);
331+
assertEquals(8, coordinates[3].getLat(), 1e-8);
332332
}
333333

334334
@Test

0 commit comments

Comments
 (0)