diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/LineString.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/LineString.java index 8eee047745dd486fc91ac4287b491525e9572c5e..f01b2824b7aecc2a32c242bbd7fe73eaa30ecd80 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/LineString.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/LineString.java @@ -14,7 +14,10 @@ package org.opengroup.osdu.indexer.model.geojson; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.List; import lombok.NoArgsConstructor; +import org.opengroup.osdu.indexer.model.geojson.jackson.CoordinatesDeserializer; @NoArgsConstructor public class LineString extends MultiPoint { @@ -22,4 +25,10 @@ public class LineString extends MultiPoint { public LineString(Position... points) { super(points); } + + @Override + @JsonDeserialize(using = CoordinatesDeserializer.class) + public void setCoordinates(List<Position> coordinates) { + super.setCoordinates(coordinates); + } } diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiLineString.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiLineString.java index 2e16db6e8ac5d06565cd9af8ccfa2e91da1faca6..f8ea7ad479f6f2143ad17eb03a2823b9e7864eb6 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiLineString.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiLineString.java @@ -14,9 +14,10 @@ package org.opengroup.osdu.indexer.model.geojson; -import lombok.NoArgsConstructor; - +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.util.List; +import lombok.NoArgsConstructor; +import org.opengroup.osdu.indexer.model.geojson.jackson.MultiLineStringDeserializer; @NoArgsConstructor public class MultiLineString extends Geometry<List<Position>> { @@ -24,4 +25,10 @@ public class MultiLineString extends Geometry<List<Position>> { public MultiLineString(List<Position> line) { add(line); } + + @Override + @JsonDeserialize(using = MultiLineStringDeserializer.class) + public void setCoordinates(List<List<Position>> coordinates) { + super.setCoordinates(coordinates); + } } diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiPoint.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiPoint.java index aabbdda84f31e9c4b30c986e6c5b4ae805788c05..e39802af80e9b63f832d20a8ea30a8645e26a825 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiPoint.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiPoint.java @@ -14,7 +14,10 @@ package org.opengroup.osdu.indexer.model.geojson; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.List; import lombok.NoArgsConstructor; +import org.opengroup.osdu.indexer.model.geojson.jackson.CoordinatesDeserializer; @NoArgsConstructor public class MultiPoint extends Geometry<Position> { @@ -22,4 +25,10 @@ public class MultiPoint extends Geometry<Position> { public MultiPoint(Position... points) { super(points); } + + @Override + @JsonDeserialize(using = CoordinatesDeserializer.class) + public void setCoordinates(List<Position> coordinates) { + super.setCoordinates(coordinates); + } } diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiPolygon.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiPolygon.java index 6c9d8af0cd6b7f43d7b0a1b0ff5b7a106856b210..ec6e2cf05271a35a7dfe01ccb0022bbcda5fd20e 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiPolygon.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiPolygon.java @@ -14,9 +14,10 @@ package org.opengroup.osdu.indexer.model.geojson; -import lombok.NoArgsConstructor; - +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.util.List; +import lombok.NoArgsConstructor; +import org.opengroup.osdu.indexer.model.geojson.jackson.MultiPolygonDeserializer; @NoArgsConstructor public class MultiPolygon extends Geometry<List<List<Position>>> { @@ -29,4 +30,10 @@ public class MultiPolygon extends Geometry<List<List<Position>>> { coordinates.add(polygon.getCoordinates()); return this; } + + @Override + @JsonDeserialize(using = MultiPolygonDeserializer.class) + public void setCoordinates(List<List<List<Position>>> coordinates) { + super.setCoordinates(coordinates); + } } diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/CoordinatesDeserializer.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/CoordinatesDeserializer.java new file mode 100644 index 0000000000000000000000000000000000000000..061ad2268b9ecd9dcc574b3d9ed976c6fee0258a --- /dev/null +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/CoordinatesDeserializer.java @@ -0,0 +1,44 @@ +/* + * Copyright 2020-2022 Google LLC + * Copyright 2020-2022 EPAM Systems, Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.osdu.indexer.model.geojson.jackson; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.opengroup.osdu.indexer.model.geojson.Position; + +public class CoordinatesDeserializer extends JsonDeserializer<List<Position>> { + + @Override + public List<Position> deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException { + ArrayList<Position> positions = new ArrayList<>(); + ObjectCodec codec = jsonParser.getCodec(); + JsonNode positionsNode = codec.readTree(jsonParser); + if (positionsNode.isArray()) { + for (JsonNode node : positionsNode) { + positions.add(codec.treeToValue(node, Position.class)); + } + } + return positions; + } +} diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/MultiLineStringDeserializer.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/MultiLineStringDeserializer.java new file mode 100644 index 0000000000000000000000000000000000000000..0df0f0fddf2f3c7668c309eba52f55c08076acc2 --- /dev/null +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/MultiLineStringDeserializer.java @@ -0,0 +1,48 @@ +/* + * Copyright 2020-2022 Google LLC + * Copyright 2020-2022 EPAM Systems, Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.osdu.indexer.model.geojson.jackson; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.opengroup.osdu.indexer.model.geojson.Position; + +public class MultiLineStringDeserializer extends JsonDeserializer<List<List<Position>>> { + + @Override + public List<List<Position>> deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException { + List<List<Position>> multiLineStringCoordinatesList = new ArrayList<>(); + ObjectCodec codec = jsonParser.getCodec(); + JsonNode coordinatesNode = codec.readTree(jsonParser); + if (coordinatesNode.isArray()) { + for (JsonNode jsonNode : coordinatesNode) { + ArrayList<Position> positionsList = new ArrayList<>(); + for (JsonNode positionNode : jsonNode) { + positionsList.add(codec.treeToValue(positionNode, Position.class)); + } + multiLineStringCoordinatesList.add(positionsList); + } + } + return multiLineStringCoordinatesList; + } +} diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/MultiPolygonDeserializer.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/MultiPolygonDeserializer.java new file mode 100644 index 0000000000000000000000000000000000000000..00f39fda23db655491c45c1b7bd848c7d5690d63 --- /dev/null +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/MultiPolygonDeserializer.java @@ -0,0 +1,52 @@ +/* + * Copyright 2020-2022 Google LLC + * Copyright 2020-2022 EPAM Systems, Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.osdu.indexer.model.geojson.jackson; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.opengroup.osdu.indexer.model.geojson.Position; + +public class MultiPolygonDeserializer extends JsonDeserializer<List<List<List<Position>>>> { + + @Override + public List<List<List<Position>>> deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException { + List<List<List<Position>>> multiPolygonCoordinatesList = new ArrayList<>(); + ObjectCodec codec = jsonParser.getCodec(); + JsonNode coordinatesNodes = codec.readTree(jsonParser); + if (coordinatesNodes.isArray()) { + for (JsonNode innerNodes : coordinatesNodes) { + ArrayList<List<Position>> innerList = new ArrayList<>(); + for (JsonNode jsonNode : innerNodes) { + ArrayList<Position> positionsList = new ArrayList<>(); + for (JsonNode positionNode : jsonNode) { + positionsList.add(codec.treeToValue(positionNode, Position.class)); + } + innerList.add(positionsList); + } + multiPolygonCoordinatesList.add(innerList); + } + } + return multiPolygonCoordinatesList; + } +} diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/parser/GeoShapeParserTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/parser/GeoShapeParserTest.java index 17b19f60270deafaa05d6a1fb58324229d39ad46..2b47f5ab3a525cdceccd5b65d7f055f51c7468cb 100644 --- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/parser/GeoShapeParserTest.java +++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/parser/GeoShapeParserTest.java @@ -16,7 +16,11 @@ package org.opengroup.osdu.indexer.util.parser; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; import joptsimple.internal.Strings; +import lombok.SneakyThrows; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -49,123 +53,129 @@ public class GeoShapeParserTest { @Test public void should_throwException_parseInvalidPoint() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-205.01621,39.57422]}}]}"; - + String shapeJson = getGeoShapeFromFile("input/invalid_point.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "unable to parse FeatureCollection"); } @Test public void should_throwException_parseInvalidPoint_NaN() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-205.01621,NaN]}}]}"; - + String shapeJson = getGeoShapeFromFile("input/invalid_point_nan.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "unable to parse FeatureCollection"); } @Test public void should_throwException_parseInvalidPoint_missingLatitude() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-105.01621]}}]}"; - + String shapeJson = getGeoShapeFromFile("input/invalid_point_missing_latitude.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "unable to parse FeatureCollection"); } @Test public void should_throwException_missingMandatoryAttribute() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"mistype\":\"Point\",\"coordinates\":[-205.01621,39.57422]}}]}"; - + String shapeJson = getGeoShapeFromFile("input/missing_mandatory_attribute.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "must be a valid FeatureCollection"); } @Test public void should_throwException_parseInvalidShape() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"InvalidShape\",\"coordinates\":[-105.01621,39.57422]}}]}"; - + String shapeJson = getGeoShapeFromFile("input/invalid_shape.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "must be a valid FeatureCollection"); } @Test public void should_parseValidPoint() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-105.01621,39.57422]}}]}"; - String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"point\",\"coordinates\":[-105.01621,39.57422]}]}"; - + String shapeJson = getGeoShapeFromFile("input/valid_point.json"); + String expectedParsedShape = getGeoShapeFromFile("expected/valid_point.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY); } @Test public void should_parseValidMultiPoint() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPoint\",\"coordinates\":[[-105.01621,39.57422],[-80.666513,35.053994]]}}]}"; - String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"multipoint\",\"coordinates\":[[-105.01621,39.57422],[-80.666513,35.053994]]}]}"; - + String shapeJson = getGeoShapeFromFile("input/valid_multi_point.json"); + String expectedParsedShape = getGeoShapeFromFile("expected/valid_multi_point.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY); } @Test public void should_parseValidLineString() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[-101.744384,39.32155],[-101.552124,39.330048],[-101.403808,39.330048],[-101.332397,39.364032],[-101.041259,39.368279],[-100.975341,39.304549],[-100.914916,39.245016],[-100.843505,39.164141],[-100.805053,39.104488],[-100.491943,39.100226],[-100.437011,39.095962],[-100.338134,39.095962],[-100.195312,39.027718],[-100.008544,39.010647],[-99.865722,39.00211],[-99.684448,38.972221],[-99.51416,38.929502],[-99.382324,38.920955],[-99.321899,38.895308],[-99.113159,38.869651],[-99.0802,38.85682],[-98.822021,38.85682],[-98.448486,38.848264],[-98.206787,38.848264],[-98.020019,38.878204],[-97.635498,38.873928]]}}]}"; - String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"linestring\",\"coordinates\":[[-101.744384,39.32155],[-101.552124,39.330048],[-101.403808,39.330048],[-101.332397,39.364032],[-101.041259,39.368279],[-100.975341,39.304549],[-100.914916,39.245016],[-100.843505,39.164141],[-100.805053,39.104488],[-100.491943,39.100226],[-100.437011,39.095962],[-100.338134,39.095962],[-100.195312,39.027718],[-100.008544,39.010647],[-99.865722,39.00211],[-99.684448,38.972221],[-99.51416,38.929502],[-99.382324,38.920955],[-99.321899,38.895308],[-99.113159,38.869651],[-99.0802,38.85682],[-98.822021,38.85682],[-98.448486,38.848264],[-98.206787,38.848264],[-98.020019,38.878204],[-97.635498,38.873928]]}]}"; - + String shapeJson = getGeoShapeFromFile("input/valid_line_string.json"); + String expectedParsedShape = getGeoShapeFromFile("expected/valid_line_string.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY); } @Test public void should_parseValidMultiLineString() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiLineString\",\"coordinates\":[[[-105.021443,39.578057],[-105.021507,39.577809],[-105.021572,39.577495],[-105.021572,39.577164],[-105.021572,39.577032],[-105.021529,39.576784]],[[-105.019898,39.574997],[-105.019598,39.574898],[-105.019061,39.574782]],[[-105.017173,39.574402],[-105.01698,39.574385],[-105.016636,39.574385],[-105.016508,39.574402],[-105.01595,39.57427]],[[-105.014276,39.573972],[-105.014126,39.574038],[-105.013825,39.57417],[-105.01331,39.574452]]]}}]}"; - String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"multilinestring\",\"coordinates\":[[[-105.021443,39.578057],[-105.021507,39.577809],[-105.021572,39.577495],[-105.021572,39.577164],[-105.021572,39.577032],[-105.021529,39.576784]],[[-105.019898,39.574997],[-105.019598,39.574898],[-105.019061,39.574782]],[[-105.017173,39.574402],[-105.01698,39.574385],[-105.016636,39.574385],[-105.016508,39.574402],[-105.01595,39.57427]],[[-105.014276,39.573972],[-105.014126,39.574038],[-105.013825,39.57417],[-105.01331,39.574452]]]}]}"; - + String shapeJson = getGeoShapeFromFile("input/valid_multi_line_string.json"); + String expectedParsedShape = getGeoShapeFromFile("expected/valid_multi_line_string.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY); } @Test public void should_parseValidPolygon() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[100,0],[101,0],[101,1],[100,1],[100,0]]]}}]}"; - String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"polygon\",\"coordinates\":[[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]]]}]}"; - + String shapeJson = getGeoShapeFromFile("input/valid_polygon.json"); + String expectedParsedShape = getGeoShapeFromFile("expected/valid_polygon.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY); } @Test public void should_throwException_parseInvalidPolygon_malformedLatitude() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[100,\"afgg\"],[101,0],[101,1],[100,1],[100,0]]]}}]}"; - + String shapeJson = getGeoShapeFromFile("input/invalid_polygon_malformed_latitude.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "unable to parse FeatureCollection"); } @Test public void should_parseValidMultiPolygon() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPolygon\",\"coordinates\":[[[[107,7],[108,7],[108,8],[107,8],[107,7]]],[[[100,0],[101,0],[101,1],[100,1],[100,0]]]]}}]}"; - String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"multipolygon\",\"coordinates\":[[[[107.0,7.0],[108.0,7.0],[108.0,8.0],[107.0,8.0],[107.0,7.0]]],[[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]]]]}]}"; - + String shapeJson = getGeoShapeFromFile("input/valid_multi_polygon.json"); + String expectedParsedShape = getGeoShapeFromFile("expected/valid_multi_polygon.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY); } @Test public void should_parseValidGeometryCollection() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"GeometryCollection\",\"geometries\":[{\"type\":\"Point\",\"coordinates\":[-80.660805,35.049392]},{\"type\":\"Polygon\",\"coordinates\":[[[-80.664582,35.044965],[-80.663874,35.04428],[-80.662586,35.04558],[-80.663444,35.046036],[-80.664582,35.044965]]]},{\"type\":\"LineString\",\"coordinates\":[[-80.662372,35.059509],[-80.662693,35.059263],[-80.662844,35.05893],[-80.66308,35.058332],[-80.663595,35.057753],[-80.663874,35.057401],[-80.66441,35.057033],[-80.664861,35.056787],[-80.665419,35.056506],[-80.665633,35.056312],[-80.666019,35.055891],[-80.666191,35.055452],[-80.666191,35.055171],[-80.666255,35.05489],[-80.666213,35.054222],[-80.666213,35.053924],[-80.665955,35.052905],[-80.665698,35.052044],[-80.665504,35.051482],[-80.665762,35.050481],[-80.66617,35.049725],[-80.666513,35.049286],[-80.666921,35.048531],[-80.667006,35.048215],[-80.667071,35.047775],[-80.667049,35.047389],[-80.666964,35.046985],[-80.666813,35.046353],[-80.666599,35.045966],[-80.666406,35.045615],[-80.665998,35.045193],[-80.665526,35.044877],[-80.664989,35.044543],[-80.664496,35.044174],[-80.663852,35.043876],[-80.663037,35.043717]]}]}}]}"; - String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"point\",\"coordinates\":[-80.660805,35.049392]},{\"type\":\"polygon\",\"coordinates\":[[[-80.664582,35.044965],[-80.663874,35.04428],[-80.662586,35.04558],[-80.663444,35.046036],[-80.664582,35.044965]]]},{\"type\":\"linestring\",\"coordinates\":[[-80.662372,35.059509],[-80.662693,35.059263],[-80.662844,35.05893],[-80.66308,35.058332],[-80.663595,35.057753],[-80.663874,35.057401],[-80.66441,35.057033],[-80.664861,35.056787],[-80.665419,35.056506],[-80.665633,35.056312],[-80.666019,35.055891],[-80.666191,35.055452],[-80.666191,35.055171],[-80.666255,35.05489],[-80.666213,35.054222],[-80.666213,35.053924],[-80.665955,35.052905],[-80.665698,35.052044],[-80.665504,35.051482],[-80.665762,35.050481],[-80.66617,35.049725],[-80.666513,35.049286],[-80.666921,35.048531],[-80.667006,35.048215],[-80.667071,35.047775],[-80.667049,35.047389],[-80.666964,35.046985],[-80.666813,35.046353],[-80.666599,35.045966],[-80.666406,35.045615],[-80.665998,35.045193],[-80.665526,35.044877],[-80.664989,35.044543],[-80.664496,35.044174],[-80.663852,35.043876],[-80.663037,35.043717]]}]}"; - + String shapeJson = getGeoShapeFromFile("input/valid_geometry_collection.json"); + String expectedParsedShape = getGeoShapeFromFile("expected/valid_geometry_collection.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY); } @Test public void should_parseValidFeatureCollection() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[1.9496737127045984,58.41415669686543],[1.8237672363511042,58.42946998193435],[1.8422735102001124,58.471472136376455],[1.9683241046247606,58.45614207250076],[1.9496737127045984,58.41415669686543]]]}}]}"; - String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"polygon\",\"coordinates\":[[[1.9496737127045984,58.41415669686543],[1.8237672363511042,58.42946998193435],[1.8422735102001124,58.471472136376455],[1.9683241046247606,58.45614207250076],[1.9496737127045984,58.41415669686543]]]}]}"; - + String shapeJson = getGeoShapeFromFile("input/valid_feature_collection.json"); + String expectedParsedShape = getGeoShapeFromFile("expected/valid_feature_collection.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY); } @Test public void should_parseValidFeatureCollection_withZCoordinate() { - String shapeJson = "{\"type\":\"FeatureCollection\",\"bbox\":null,\"features\":[{\"type\":\"Feature\",\"bbox\":null,\"geometry\":{\"type\":\"Point\",\"bbox\":null,\"coordinates\":[5.7500000010406245,59.000000000399105, 1.0]},\"properties\":{}}],\"properties\":{},\"persistableReferenceCrs\":null,\"persistableReferenceUnitZ\":\"{\\\"scaleOffset\\\":{\\\"scale\\\":1.0,\\\"offset\\\":0.0},\\\"symbol\\\":\\\"m\\\",\\\"baseMeasurement\\\":{\\\"ancestry\\\":\\\"Length\\\",\\\"type\\\":\\\"UM\\\"},\\\"type\\\":\\\"USO\\\"}\"}"; - String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"point\",\"coordinates\":[5.7500000010406245,59.000000000399105,1.0]}]}"; - + String shapeJson = getGeoShapeFromFile("input/valid_feature_collection_with_z_coordinate.json"); + String expectedParsedShape = getGeoShapeFromFile("expected/valid_feature_collection_with_z_coordinate.json"); this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY); } @Test public void should_throwException_parseUnsupportedType_feature() { - String shapeJson = "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-80.724878,35.265454],[-80.722646,35.260338],[-80.720329,35.260618],[-80.718698,35.260267],[-80.715093,35.260548],[-80.71681,35.255361],[-80.710887,35.255361],[-80.703248,35.265033],[-80.704793,35.268397],[-80.70857,35.268257],[-80.712518,35.270359],[-80.715179,35.267696],[-80.721359,35.267276],[-80.724878,35.265454]]]},\"properties\":{\"name\":\"Plaza Road Park\"}}"; + String shapeJson = getGeoShapeFromFile("input/valid_feature_collection_with_z_coordinate.json"); + String expectedParsedShape = getGeoShapeFromFile("expected/valid_feature_collection_with_z_coordinate.json"); + this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY); + } - this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "must be a valid FeatureCollection"); + @Test + public void shouldParseValidMultiPolygonWithZCoordinates(){ + String shapeJson = getGeoShapeFromFile("input/multi_polygon_with_z_coordinates.json"); + String expectedParsedShape = getGeoShapeFromFile("expected/multi_polygon_with_z_coordinates.json"); + this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY); + } + + @Test + public void shouldParseValidLineStringWithZCoordinates(){ + String shapeJson = getGeoShapeFromFile("input/line_string_with_z_coordinate.json"); + String expectedParsedShape = getGeoShapeFromFile("expected/line_string_with_z_coordinate.json"); + this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY); + } + + @Test + public void shouldParseValidMultiLineStringWithZCoordinates(){ + String shapeJson = getGeoShapeFromFile("input/valid_milti_line_string_with_z_coordinate.json"); + String expectedParsedShape = getGeoShapeFromFile("expected/valid_multi_line_string_with_z_coordinate.json"); + this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY); } private void validateInput(Function<Map<String, Object>, Map<String, Object>> parser, String shapeJson, String expectedParsedShape, String errorMessage) { @@ -187,4 +197,17 @@ public class GeoShapeParserTest { } } } + + @SneakyThrows + private String getGeoShapeFromFile(String file) { + InputStream inStream = this.getClass().getResourceAsStream("/geojson/parsing/" + file); + BufferedReader br = new BufferedReader(new InputStreamReader(inStream)); + StringBuilder stringBuilder = new StringBuilder(); + String sCurrentLine; + while ((sCurrentLine = br.readLine()) != null) + { + stringBuilder.append(sCurrentLine).append("\n"); + } + return stringBuilder.toString(); + } } diff --git a/indexer-core/src/test/resources/geojson/parsing/expected/line_string_with_z_coordinate.json b/indexer-core/src/test/resources/geojson/parsing/expected/line_string_with_z_coordinate.json new file mode 100644 index 0000000000000000000000000000000000000000..cb22417c3c30566d696b0464ec51c19b4f83b184 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/expected/line_string_with_z_coordinate.json @@ -0,0 +1,25 @@ +{ + "type": "geometrycollection", + "geometries": [ + { + "type": "linestring", + "coordinates": [ + [ + 34.51305348816962, + 0.035298719063461145, + 7.0 + ], + [ + 34.513062650895186, + 0.030790856372375844, + 7.0 + ], + [ + 34.513071785973196, + 0.0262829935696415, + 7.0 + ] + ] + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/expected/multi_polygon_with_z_coordinates.json b/indexer-core/src/test/resources/geojson/parsing/expected/multi_polygon_with_z_coordinates.json new file mode 100644 index 0000000000000000000000000000000000000000..1c6643bdbe9c62498b76418110ed0e28814c63ec --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/expected/multi_polygon_with_z_coordinates.json @@ -0,0 +1,34 @@ +{ + "type": "geometrycollection", + "geometries": [ + { + "type": "multipolygon", + "coordinates": [ + [ + [ + [ + 34.51305348816962, + 0.035298719063461145, + 5.0 + ], + [ + 34.513062650895186, + 0.030790856372375844, + 5.0 + ], + [ + 34.513071785973196, + 0.0262829935696415, + 5.5 + ], + [ + 34.51305348816962, + 0.035298719063461145, + 5.8 + ] + ] + ] + ] + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/expected/valid_feature_collection.json b/indexer-core/src/test/resources/geojson/parsing/expected/valid_feature_collection.json new file mode 100644 index 0000000000000000000000000000000000000000..bffd2f63726f44a71910e51616ee2fa25f5bfd52 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/expected/valid_feature_collection.json @@ -0,0 +1,32 @@ +{ + "type": "geometrycollection", + "geometries": [ + { + "type": "polygon", + "coordinates": [ + [ + [ + 1.9496737127045984, + 58.41415669686543 + ], + [ + 1.8237672363511042, + 58.42946998193435 + ], + [ + 1.8422735102001124, + 58.471472136376455 + ], + [ + 1.9683241046247606, + 58.45614207250076 + ], + [ + 1.9496737127045984, + 58.41415669686543 + ] + ] + ] + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/expected/valid_feature_collection_with_z_coordinate.json b/indexer-core/src/test/resources/geojson/parsing/expected/valid_feature_collection_with_z_coordinate.json new file mode 100644 index 0000000000000000000000000000000000000000..7599d52c27037e74475085657069f31483a1495d --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/expected/valid_feature_collection_with_z_coordinate.json @@ -0,0 +1,13 @@ +{ + "type": "geometrycollection", + "geometries": [ + { + "type": "point", + "coordinates": [ + 5.7500000010406245, + 59.000000000399105, + 1.0 + ] + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/expected/valid_geometry_collection.json b/indexer-core/src/test/resources/geojson/parsing/expected/valid_geometry_collection.json new file mode 100644 index 0000000000000000000000000000000000000000..3637c60711c27b2724e592c9a1435a29ef087988 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/expected/valid_geometry_collection.json @@ -0,0 +1,188 @@ +{ + "type": "geometrycollection", + "geometries": [ + { + "type": "point", + "coordinates": [ + -80.660805, + 35.049392 + ] + }, + { + "type": "polygon", + "coordinates": [ + [ + [ + -80.664582, + 35.044965 + ], + [ + -80.663874, + 35.04428 + ], + [ + -80.662586, + 35.04558 + ], + [ + -80.663444, + 35.046036 + ], + [ + -80.664582, + 35.044965 + ] + ] + ] + }, + { + "type": "linestring", + "coordinates": [ + [ + -80.662372, + 35.059509 + ], + [ + -80.662693, + 35.059263 + ], + [ + -80.662844, + 35.05893 + ], + [ + -80.66308, + 35.058332 + ], + [ + -80.663595, + 35.057753 + ], + [ + -80.663874, + 35.057401 + ], + [ + -80.66441, + 35.057033 + ], + [ + -80.664861, + 35.056787 + ], + [ + -80.665419, + 35.056506 + ], + [ + -80.665633, + 35.056312 + ], + [ + -80.666019, + 35.055891 + ], + [ + -80.666191, + 35.055452 + ], + [ + -80.666191, + 35.055171 + ], + [ + -80.666255, + 35.05489 + ], + [ + -80.666213, + 35.054222 + ], + [ + -80.666213, + 35.053924 + ], + [ + -80.665955, + 35.052905 + ], + [ + -80.665698, + 35.052044 + ], + [ + -80.665504, + 35.051482 + ], + [ + -80.665762, + 35.050481 + ], + [ + -80.66617, + 35.049725 + ], + [ + -80.666513, + 35.049286 + ], + [ + -80.666921, + 35.048531 + ], + [ + -80.667006, + 35.048215 + ], + [ + -80.667071, + 35.047775 + ], + [ + -80.667049, + 35.047389 + ], + [ + -80.666964, + 35.046985 + ], + [ + -80.666813, + 35.046353 + ], + [ + -80.666599, + 35.045966 + ], + [ + -80.666406, + 35.045615 + ], + [ + -80.665998, + 35.045193 + ], + [ + -80.665526, + 35.044877 + ], + [ + -80.664989, + 35.044543 + ], + [ + -80.664496, + 35.044174 + ], + [ + -80.663852, + 35.043876 + ], + [ + -80.663037, + 35.043717 + ] + ] + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/expected/valid_line_string.json b/indexer-core/src/test/resources/geojson/parsing/expected/valid_line_string.json new file mode 100644 index 0000000000000000000000000000000000000000..94920713aab237bbea26e156db4546a9a6d5bde2 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/expected/valid_line_string.json @@ -0,0 +1,114 @@ +{ + "type": "geometrycollection", + "geometries": [ + { + "type": "linestring", + "coordinates": [ + [ + -101.744384, + 39.32155 + ], + [ + -101.552124, + 39.330048 + ], + [ + -101.403808, + 39.330048 + ], + [ + -101.332397, + 39.364032 + ], + [ + -101.041259, + 39.368279 + ], + [ + -100.975341, + 39.304549 + ], + [ + -100.914916, + 39.245016 + ], + [ + -100.843505, + 39.164141 + ], + [ + -100.805053, + 39.104488 + ], + [ + -100.491943, + 39.100226 + ], + [ + -100.437011, + 39.095962 + ], + [ + -100.338134, + 39.095962 + ], + [ + -100.195312, + 39.027718 + ], + [ + -100.008544, + 39.010647 + ], + [ + -99.865722, + 39.00211 + ], + [ + -99.684448, + 38.972221 + ], + [ + -99.51416, + 38.929502 + ], + [ + -99.382324, + 38.920955 + ], + [ + -99.321899, + 38.895308 + ], + [ + -99.113159, + 38.869651 + ], + [ + -99.0802, + 38.85682 + ], + [ + -98.822021, + 38.85682 + ], + [ + -98.448486, + 38.848264 + ], + [ + -98.206787, + 38.848264 + ], + [ + -98.020019, + 38.878204 + ], + [ + -97.635498, + 38.873928 + ] + ] + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/expected/valid_multi_line_string.json b/indexer-core/src/test/resources/geojson/parsing/expected/valid_multi_line_string.json new file mode 100644 index 0000000000000000000000000000000000000000..ff6e8e073febf11cad8f879b6d34ecdc13a2926c --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/expected/valid_multi_line_string.json @@ -0,0 +1,90 @@ +{ + "type": "geometrycollection", + "geometries": [ + { + "type": "multilinestring", + "coordinates": [ + [ + [ + -105.021443, + 39.578057 + ], + [ + -105.021507, + 39.577809 + ], + [ + -105.021572, + 39.577495 + ], + [ + -105.021572, + 39.577164 + ], + [ + -105.021572, + 39.577032 + ], + [ + -105.021529, + 39.576784 + ] + ], + [ + [ + -105.019898, + 39.574997 + ], + [ + -105.019598, + 39.574898 + ], + [ + -105.019061, + 39.574782 + ] + ], + [ + [ + -105.017173, + 39.574402 + ], + [ + -105.01698, + 39.574385 + ], + [ + -105.016636, + 39.574385 + ], + [ + -105.016508, + 39.574402 + ], + [ + -105.01595, + 39.57427 + ] + ], + [ + [ + -105.014276, + 39.573972 + ], + [ + -105.014126, + 39.574038 + ], + [ + -105.013825, + 39.57417 + ], + [ + -105.01331, + 39.574452 + ] + ] + ] + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/expected/valid_multi_line_string_with_z_coordinate.json b/indexer-core/src/test/resources/geojson/parsing/expected/valid_multi_line_string_with_z_coordinate.json new file mode 100644 index 0000000000000000000000000000000000000000..0dba36808a67d611d28a04d389e484803e48d1ec --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/expected/valid_multi_line_string_with_z_coordinate.json @@ -0,0 +1,108 @@ +{ + "type": "geometrycollection", + "geometries": [ + { + "type": "multilinestring", + "coordinates": [ + [ + [ + -105.021443, + 39.578057, + 7.0 + ], + [ + -105.021507, + 39.577809, + 7.0 + ], + [ + -105.021572, + 39.577495, + 7.0 + ], + [ + -105.021572, + 39.577164, + 7.0 + ], + [ + -105.021572, + 39.577032, + 7.0 + ], + [ + -105.021529, + 39.576784, + 7.0 + ] + ], + [ + [ + -105.019898, + 39.574997, + 7.0 + ], + [ + -105.019598, + 39.574898, + 7.0 + ], + [ + -105.019061, + 39.574782, + 7.0 + ] + ], + [ + [ + -105.017173, + 39.574402, + 7.0 + ], + [ + -105.01698, + 39.574385, + 7.0 + ], + [ + -105.016636, + 39.574385, + 7.0 + ], + [ + -105.016508, + 39.574402, + 7.0 + ], + [ + -105.01595, + 39.57427, + 7.0 + ] + ], + [ + [ + -105.014276, + 39.573972, + 7.0 + ], + [ + -105.014126, + 39.574038, + 7.0 + ], + [ + -105.013825, + 39.57417, + 7.0 + ], + [ + -105.01331, + 39.574452, + 7.0 + ] + ] + ] + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/expected/valid_multi_point.json b/indexer-core/src/test/resources/geojson/parsing/expected/valid_multi_point.json new file mode 100644 index 0000000000000000000000000000000000000000..ea9c0909c8bfac478316a9d2ca46b1826cd0aeed --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/expected/valid_multi_point.json @@ -0,0 +1,18 @@ +{ + "type": "geometrycollection", + "geometries": [ + { + "type": "multipoint", + "coordinates": [ + [ + -105.01621, + 39.57422 + ], + [ + -80.666513, + 35.053994 + ] + ] + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/expected/valid_multi_polygon.json b/indexer-core/src/test/resources/geojson/parsing/expected/valid_multi_polygon.json new file mode 100644 index 0000000000000000000000000000000000000000..6d18cc2eb7c18c3894368c875839e161576521ac --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/expected/valid_multi_polygon.json @@ -0,0 +1,58 @@ +{ + "type": "geometrycollection", + "geometries": [ + { + "type": "multipolygon", + "coordinates": [ + [ + [ + [ + 107.0, + 7.0 + ], + [ + 108.0, + 7.0 + ], + [ + 108.0, + 8.0 + ], + [ + 107.0, + 8.0 + ], + [ + 107.0, + 7.0 + ] + ] + ], + [ + [ + [ + 100.0, + 0.0 + ], + [ + 101.0, + 0.0 + ], + [ + 101.0, + 1.0 + ], + [ + 100.0, + 1.0 + ], + [ + 100.0, + 0.0 + ] + ] + ] + ] + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/expected/valid_point.json b/indexer-core/src/test/resources/geojson/parsing/expected/valid_point.json new file mode 100644 index 0000000000000000000000000000000000000000..198a80cd69eba1bca858177f57fc4573dc8b8426 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/expected/valid_point.json @@ -0,0 +1,12 @@ +{ + "type": "geometrycollection", + "geometries": [ + { + "type": "point", + "coordinates": [ + -105.01621, + 39.57422 + ] + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/expected/valid_polygon.json b/indexer-core/src/test/resources/geojson/parsing/expected/valid_polygon.json new file mode 100644 index 0000000000000000000000000000000000000000..65c3b461c499aaef09f565b64f308dc6bc41fd05 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/expected/valid_polygon.json @@ -0,0 +1,32 @@ +{ + "type": "geometrycollection", + "geometries": [ + { + "type": "polygon", + "coordinates": [ + [ + [ + 100.0, + 0.0 + ], + [ + 101.0, + 0.0 + ], + [ + 101.0, + 1.0 + ], + [ + 100.0, + 1.0 + ], + [ + 100.0, + 0.0 + ] + ] + ] + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/invalid_point.json b/indexer-core/src/test/resources/geojson/parsing/input/invalid_point.json new file mode 100644 index 0000000000000000000000000000000000000000..f03acc0d34601bc4d5f134ae6218e72f848237fb --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/invalid_point.json @@ -0,0 +1,15 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -205.01621, + 39.57422 + ] + } + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/invalid_point_missing_latitude.json b/indexer-core/src/test/resources/geojson/parsing/input/invalid_point_missing_latitude.json new file mode 100644 index 0000000000000000000000000000000000000000..9d7e004ff66d38787c1862b82ee27e1d11da0438 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/invalid_point_missing_latitude.json @@ -0,0 +1,14 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -105.01621 + ] + } + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/invalid_point_nan.json b/indexer-core/src/test/resources/geojson/parsing/input/invalid_point_nan.json new file mode 100644 index 0000000000000000000000000000000000000000..d72347188e2e31765d5ac3276697b5ded6cc0afd --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/invalid_point_nan.json @@ -0,0 +1,15 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -205.01621, + NaN + ] + } + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/invalid_polygon_malformed_latitude.json b/indexer-core/src/test/resources/geojson/parsing/input/invalid_polygon_malformed_latitude.json new file mode 100644 index 0000000000000000000000000000000000000000..0ae1e3f22f389a95b3e3a897399eeee2aae2626e --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/invalid_polygon_malformed_latitude.json @@ -0,0 +1,35 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 100, + "afgg" + ], + [ + 101, + 0 + ], + [ + 101, + 1 + ], + [ + 100, + 1 + ], + [ + 100, + 0 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/invalid_shape.json b/indexer-core/src/test/resources/geojson/parsing/input/invalid_shape.json new file mode 100644 index 0000000000000000000000000000000000000000..5cbfb243f9810796faf2de92741baf981e29fb90 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/invalid_shape.json @@ -0,0 +1,15 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "InvalidShape", + "coordinates": [ + -105.01621, + 39.57422 + ] + } + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/line_string_with_z_coordinate.json b/indexer-core/src/test/resources/geojson/parsing/input/line_string_with_z_coordinate.json new file mode 100644 index 0000000000000000000000000000000000000000..28fc39aaf3fb24c04aedaae2a83dd96068f2233e --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/line_string_with_z_coordinate.json @@ -0,0 +1,46 @@ +{ + "type": "FeatureCollection", + "bbox": null, + "features": [ + { + "type": "Feature", + "bbox": null, + "geometry": { + "type": "LineString", + "bbox": null, + "coordinates": [ + [ + 34.51305348816962, + 0.035298719063461145, + 7.0 + ], + [ + 34.513062650895186, + 0.030790856372375844, + 7.0 + ], + [ + 34.513071785973196, + 0.0262829935696415, + 7.0 + ] + ] + }, + "properties": {} + } + ], + "properties": null, + "persistableReferenceCrs": null, + "persistableReferenceUnitZ": { + "scaleOffset": { + "scale": 1.0, + "offset": 0.0 + }, + "symbol": "m", + "baseMeasurement": { + "ancestry": "Length", + "type": "UM" + }, + "type": "USO" + } +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/missing_mandatory_attribute.json b/indexer-core/src/test/resources/geojson/parsing/input/missing_mandatory_attribute.json new file mode 100644 index 0000000000000000000000000000000000000000..219a80caffba3d5fb24a9012079f7bd48d21e27e --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/missing_mandatory_attribute.json @@ -0,0 +1,15 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "mistype": "Point", + "coordinates": [ + -205.01621, + 39.57422 + ] + } + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/multi_polygon_with_z_coordinates.json b/indexer-core/src/test/resources/geojson/parsing/input/multi_polygon_with_z_coordinates.json new file mode 100644 index 0000000000000000000000000000000000000000..f479ebac0a2cd9b255df8f878a075c1aec1ae260 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/multi_polygon_with_z_coordinates.json @@ -0,0 +1,55 @@ +{ + "type": "FeatureCollection", + "bbox": null, + "features": [ + { + "type": "Feature", + "bbox": null, + "geometry": { + "type": "MultiPolygon", + "bbox": null, + "coordinates": [ + [ + [ + [ + 34.51305348816962, + 0.035298719063461145, + 5.0 + ], + [ + 34.513062650895186, + 0.030790856372375844, + 5.0 + ], + [ + 34.513071785973196, + 0.0262829935696415, + 5.5 + ], + [ + 34.51305348816962, + 0.035298719063461145, + 5.8 + ] + ] + ] + ] + }, + "properties": {} + } + ], + "properties": null, + "persistableReferenceCrs": null, + "persistableReferenceUnitZ": { + "scaleOffset": { + "scale": 1.0, + "offset": 0.0 + }, + "symbol": "m", + "baseMeasurement": { + "ancestry": "Length", + "type": "UM" + }, + "type": "USO" + } +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/unsupported_type_feature.json b/indexer-core/src/test/resources/geojson/parsing/input/unsupported_type_feature.json new file mode 100644 index 0000000000000000000000000000000000000000..2534038f93e3c184730880a59f2e8f52e6973a01 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/unsupported_type_feature.json @@ -0,0 +1,69 @@ +{ + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -80.724878, + 35.265454 + ], + [ + -80.722646, + 35.260338 + ], + [ + -80.720329, + 35.260618 + ], + [ + -80.718698, + 35.260267 + ], + [ + -80.715093, + 35.260548 + ], + [ + -80.71681, + 35.255361 + ], + [ + -80.710887, + 35.255361 + ], + [ + -80.703248, + 35.265033 + ], + [ + -80.704793, + 35.268397 + ], + [ + -80.70857, + 35.268257 + ], + [ + -80.712518, + 35.270359 + ], + [ + -80.715179, + 35.267696 + ], + [ + -80.721359, + 35.267276 + ], + [ + -80.724878, + 35.265454 + ] + ] + ] + }, + "properties": { + "name": "Plaza Road Park" + } +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/valid_feature_collection.json b/indexer-core/src/test/resources/geojson/parsing/input/valid_feature_collection.json new file mode 100644 index 0000000000000000000000000000000000000000..b295ebc69b4343ff210e77aed140ae2e872a7d65 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/valid_feature_collection.json @@ -0,0 +1,35 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 1.9496737127045984, + 58.41415669686543 + ], + [ + 1.8237672363511042, + 58.42946998193435 + ], + [ + 1.8422735102001124, + 58.471472136376455 + ], + [ + 1.9683241046247606, + 58.45614207250076 + ], + [ + 1.9496737127045984, + 58.41415669686543 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/valid_feature_collection_with_z_coordinate.json b/indexer-core/src/test/resources/geojson/parsing/input/valid_feature_collection_with_z_coordinate.json new file mode 100644 index 0000000000000000000000000000000000000000..056379d5fe8880675a8cf690813219a2e0e77d2c --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/valid_feature_collection_with_z_coordinate.json @@ -0,0 +1,23 @@ +{ + "type": "FeatureCollection", + "bbox": null, + "features": [ + { + "type": "Feature", + "bbox": null, + "geometry": { + "type": "Point", + "bbox": null, + "coordinates": [ + 5.7500000010406245, + 59.000000000399105, + 1.0 + ] + }, + "properties": {} + } + ], + "properties": {}, + "persistableReferenceCrs": null, + "persistableReferenceUnitZ": "{\"scaleOffset\":{\"scale\":1.0,\"offset\":0.0},\"symbol\":\"m\",\"baseMeasurement\":{\"ancestry\":\"Length\",\"type\":\"UM\"},\"type\":\"USO\"}" +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/valid_geometry_collection.json b/indexer-core/src/test/resources/geojson/parsing/input/valid_geometry_collection.json new file mode 100644 index 0000000000000000000000000000000000000000..546d8b345c39eaa286e688ad7b8edc7408891c44 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/valid_geometry_collection.json @@ -0,0 +1,196 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Point", + "coordinates": [ + -80.660805, + 35.049392 + ] + }, + { + "type": "Polygon", + "coordinates": [ + [ + [ + -80.664582, + 35.044965 + ], + [ + -80.663874, + 35.04428 + ], + [ + -80.662586, + 35.04558 + ], + [ + -80.663444, + 35.046036 + ], + [ + -80.664582, + 35.044965 + ] + ] + ] + }, + { + "type": "LineString", + "coordinates": [ + [ + -80.662372, + 35.059509 + ], + [ + -80.662693, + 35.059263 + ], + [ + -80.662844, + 35.05893 + ], + [ + -80.66308, + 35.058332 + ], + [ + -80.663595, + 35.057753 + ], + [ + -80.663874, + 35.057401 + ], + [ + -80.66441, + 35.057033 + ], + [ + -80.664861, + 35.056787 + ], + [ + -80.665419, + 35.056506 + ], + [ + -80.665633, + 35.056312 + ], + [ + -80.666019, + 35.055891 + ], + [ + -80.666191, + 35.055452 + ], + [ + -80.666191, + 35.055171 + ], + [ + -80.666255, + 35.05489 + ], + [ + -80.666213, + 35.054222 + ], + [ + -80.666213, + 35.053924 + ], + [ + -80.665955, + 35.052905 + ], + [ + -80.665698, + 35.052044 + ], + [ + -80.665504, + 35.051482 + ], + [ + -80.665762, + 35.050481 + ], + [ + -80.66617, + 35.049725 + ], + [ + -80.666513, + 35.049286 + ], + [ + -80.666921, + 35.048531 + ], + [ + -80.667006, + 35.048215 + ], + [ + -80.667071, + 35.047775 + ], + [ + -80.667049, + 35.047389 + ], + [ + -80.666964, + 35.046985 + ], + [ + -80.666813, + 35.046353 + ], + [ + -80.666599, + 35.045966 + ], + [ + -80.666406, + 35.045615 + ], + [ + -80.665998, + 35.045193 + ], + [ + -80.665526, + 35.044877 + ], + [ + -80.664989, + 35.044543 + ], + [ + -80.664496, + 35.044174 + ], + [ + -80.663852, + 35.043876 + ], + [ + -80.663037, + 35.043717 + ] + ] + } + ] + } + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/valid_line_string.json b/indexer-core/src/test/resources/geojson/parsing/input/valid_line_string.json new file mode 100644 index 0000000000000000000000000000000000000000..8ec5ef519008dca392d9d375bc67a41472531363 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/valid_line_string.json @@ -0,0 +1,117 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "LineString", + "coordinates": [ + [ + -101.744384, + 39.32155 + ], + [ + -101.552124, + 39.330048 + ], + [ + -101.403808, + 39.330048 + ], + [ + -101.332397, + 39.364032 + ], + [ + -101.041259, + 39.368279 + ], + [ + -100.975341, + 39.304549 + ], + [ + -100.914916, + 39.245016 + ], + [ + -100.843505, + 39.164141 + ], + [ + -100.805053, + 39.104488 + ], + [ + -100.491943, + 39.100226 + ], + [ + -100.437011, + 39.095962 + ], + [ + -100.338134, + 39.095962 + ], + [ + -100.195312, + 39.027718 + ], + [ + -100.008544, + 39.010647 + ], + [ + -99.865722, + 39.00211 + ], + [ + -99.684448, + 38.972221 + ], + [ + -99.51416, + 38.929502 + ], + [ + -99.382324, + 38.920955 + ], + [ + -99.321899, + 38.895308 + ], + [ + -99.113159, + 38.869651 + ], + [ + -99.0802, + 38.85682 + ], + [ + -98.822021, + 38.85682 + ], + [ + -98.448486, + 38.848264 + ], + [ + -98.206787, + 38.848264 + ], + [ + -98.020019, + 38.878204 + ], + [ + -97.635498, + 38.873928 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/valid_milti_line_string_with_z_coordinate.json b/indexer-core/src/test/resources/geojson/parsing/input/valid_milti_line_string_with_z_coordinate.json new file mode 100644 index 0000000000000000000000000000000000000000..e023a2ef8a14cfe3db79f7731e6662be8ae3c4dd --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/valid_milti_line_string_with_z_coordinate.json @@ -0,0 +1,111 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "MultiLineString", + "coordinates": [ + [ + [ + -105.021443, + 39.578057, + 7.0 + ], + [ + -105.021507, + 39.577809, + 7.0 + ], + [ + -105.021572, + 39.577495, + 7.0 + ], + [ + -105.021572, + 39.577164, + 7.0 + ], + [ + -105.021572, + 39.577032, + 7.0 + ], + [ + -105.021529, + 39.576784, + 7.0 + ] + ], + [ + [ + -105.019898, + 39.574997, + 7.0 + ], + [ + -105.019598, + 39.574898, + 7.0 + ], + [ + -105.019061, + 39.574782, + 7.0 + ] + ], + [ + [ + -105.017173, + 39.574402, + 7.0 + ], + [ + -105.01698, + 39.574385, + 7.0 + ], + [ + -105.016636, + 39.574385, + 7.0 + ], + [ + -105.016508, + 39.574402, + 7.0 + ], + [ + -105.01595, + 39.57427, + 7.0 + ] + ], + [ + [ + -105.014276, + 39.573972, + 7.0 + ], + [ + -105.014126, + 39.574038, + 7.0 + ], + [ + -105.013825, + 39.57417, + 7.0 + ], + [ + -105.01331, + 39.574452, + 7.0 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/valid_multi_line_string.json b/indexer-core/src/test/resources/geojson/parsing/input/valid_multi_line_string.json new file mode 100644 index 0000000000000000000000000000000000000000..c52f29ea94d6590b96402b16c6de469575a00c03 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/valid_multi_line_string.json @@ -0,0 +1,93 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "MultiLineString", + "coordinates": [ + [ + [ + -105.021443, + 39.578057 + ], + [ + -105.021507, + 39.577809 + ], + [ + -105.021572, + 39.577495 + ], + [ + -105.021572, + 39.577164 + ], + [ + -105.021572, + 39.577032 + ], + [ + -105.021529, + 39.576784 + ] + ], + [ + [ + -105.019898, + 39.574997 + ], + [ + -105.019598, + 39.574898 + ], + [ + -105.019061, + 39.574782 + ] + ], + [ + [ + -105.017173, + 39.574402 + ], + [ + -105.01698, + 39.574385 + ], + [ + -105.016636, + 39.574385 + ], + [ + -105.016508, + 39.574402 + ], + [ + -105.01595, + 39.57427 + ] + ], + [ + [ + -105.014276, + 39.573972 + ], + [ + -105.014126, + 39.574038 + ], + [ + -105.013825, + 39.57417 + ], + [ + -105.01331, + 39.574452 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/valid_multi_point.json b/indexer-core/src/test/resources/geojson/parsing/input/valid_multi_point.json new file mode 100644 index 0000000000000000000000000000000000000000..6d5bfc20d949a5ccac21798476e62d81828229b6 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/valid_multi_point.json @@ -0,0 +1,21 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + -105.01621, + 39.57422 + ], + [ + -80.666513, + 35.053994 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/valid_multi_polygon.json b/indexer-core/src/test/resources/geojson/parsing/input/valid_multi_polygon.json new file mode 100644 index 0000000000000000000000000000000000000000..3f8b185020a3b00af9ee1d8b9530712d66e55a37 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/valid_multi_polygon.json @@ -0,0 +1,61 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ + 107, + 7 + ], + [ + 108, + 7 + ], + [ + 108, + 8 + ], + [ + 107, + 8 + ], + [ + 107, + 7 + ] + ] + ], + [ + [ + [ + 100, + 0 + ], + [ + 101, + 0 + ], + [ + 101, + 1 + ], + [ + 100, + 1 + ], + [ + 100, + 0 + ] + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/valid_point.json b/indexer-core/src/test/resources/geojson/parsing/input/valid_point.json new file mode 100644 index 0000000000000000000000000000000000000000..be3116d9550cb95132e2355d6b6593367202f267 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/valid_point.json @@ -0,0 +1,15 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -105.01621, + 39.57422 + ] + } + } + ] +} \ No newline at end of file diff --git a/indexer-core/src/test/resources/geojson/parsing/input/valid_polygon.json b/indexer-core/src/test/resources/geojson/parsing/input/valid_polygon.json new file mode 100644 index 0000000000000000000000000000000000000000..822914e09700767d9e07f678a85eb1bd27744d77 --- /dev/null +++ b/indexer-core/src/test/resources/geojson/parsing/input/valid_polygon.json @@ -0,0 +1,35 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 100, + 0 + ], + [ + 101, + 0 + ], + [ + 101, + 1 + ], + [ + 100, + 1 + ], + [ + 100, + 0 + ] + ] + ] + } + } + ] +} \ No newline at end of file