From bbe2f591999fe640f3ea8f356fbee813574c127b Mon Sep 17 00:00:00 2001 From: rng Date: Mon, 20 Jan 2025 13:42:56 +1100 Subject: [PATCH] Fix bug, need to setup type to Point --- .../server/core/mapper/StacToCollections.java | 2 +- .../core/mapper/StacToFeatureCollection.java | 4 +-- .../ogcapi/server/features/RestApiTest.java | 25 +++++++++++++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/core/mapper/StacToCollections.java b/server/src/main/java/au/org/aodn/ogcapi/server/core/mapper/StacToCollections.java index bd0c6004..dad013c7 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/core/mapper/StacToCollections.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/core/mapper/StacToCollections.java @@ -23,7 +23,7 @@ public abstract class StacToCollections implements Converter model, Filter filter) { - List collections = model.getCollections().stream() + List collections = model.getCollections().parallelStream() .map(m -> getCollection(m, filter, hostname)) .collect(Collectors.toList()); diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/core/mapper/StacToFeatureCollection.java b/server/src/main/java/au/org/aodn/ogcapi/server/core/mapper/StacToFeatureCollection.java index d580f5c1..29fa4070 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/core/mapper/StacToFeatureCollection.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/core/mapper/StacToFeatureCollection.java @@ -22,7 +22,7 @@ public FeatureCollectionGeoJSON convert(ElasticSearch.SearchResult features = model.getCollections().stream() + List features = model.getCollections().parallelStream() .map(i -> { FeatureGeoJSON feature = new FeatureGeoJSON(); feature.setType(FeatureGeoJSON.TypeEnum.FEATURE); @@ -34,7 +34,7 @@ public FeatureCollectionGeoJSON convert(ElasticSearch.SearchResult (BigDecimal)item) .toList(); - feature.setGeometry(new PointGeoJSON().coordinates(c)); + feature.setGeometry(new PointGeoJSON().type(PointGeoJSON.TypeEnum.POINT).coordinates(c)); } } feature.setProperties(i.getProperties()); diff --git a/server/src/test/java/au/org/aodn/ogcapi/server/features/RestApiTest.java b/server/src/test/java/au/org/aodn/ogcapi/server/features/RestApiTest.java index 0af66a61..00e37c90 100644 --- a/server/src/test/java/au/org/aodn/ogcapi/server/features/RestApiTest.java +++ b/server/src/test/java/au/org/aodn/ogcapi/server/features/RestApiTest.java @@ -467,7 +467,10 @@ public void verifyAggregationFeatureSummaryCorrect() throws IOException { // Sample1 FeatureGeoJSON featureGeoJSON1 = new FeatureGeoJSON(); featureGeoJSON1.setType(FeatureGeoJSON.TypeEnum.FEATURE); - featureGeoJSON1.setGeometry(new PointGeoJSON().coordinates(List.of(BigDecimal.valueOf(159.26), BigDecimal.valueOf(-24.72)))); + featureGeoJSON1.setGeometry(new PointGeoJSON() + .type(PointGeoJSON.TypeEnum.POINT) + .coordinates(List.of(BigDecimal.valueOf(159.26), BigDecimal.valueOf(-24.72))) + ); featureGeoJSON1.setProperties(Map.of( FeatureProperty.COUNT.getValue(), 42.0, FeatureProperty.START_TIME.getValue(), "2023-02-01T00:00:00.000Z", @@ -479,7 +482,10 @@ public void verifyAggregationFeatureSummaryCorrect() throws IOException { // Sample3 FeatureGeoJSON featureGeoJSON2 = new FeatureGeoJSON(); featureGeoJSON2.setType(FeatureGeoJSON.TypeEnum.FEATURE); - featureGeoJSON2.setGeometry(new PointGeoJSON().coordinates(List.of(BigDecimal.valueOf(154.81), BigDecimal.valueOf(-26.2)))); + featureGeoJSON2.setGeometry(new PointGeoJSON() + .type(PointGeoJSON.TypeEnum.POINT) + .coordinates(List.of(BigDecimal.valueOf(154.81), BigDecimal.valueOf(-26.2))) + ); featureGeoJSON2.setProperties(Map.of( FeatureProperty.COUNT.getValue(), 48.0, FeatureProperty.START_TIME.getValue(), "2023-02-01T00:00:00.000Z", @@ -490,7 +496,10 @@ public void verifyAggregationFeatureSummaryCorrect() throws IOException { FeatureGeoJSON featureGeoJSON3 = new FeatureGeoJSON(); featureGeoJSON3.setType(FeatureGeoJSON.TypeEnum.FEATURE); - featureGeoJSON3.setGeometry(new PointGeoJSON().coordinates(List.of(BigDecimal.valueOf(153.56), BigDecimal.valueOf(-26.59)))); + featureGeoJSON3.setGeometry(new PointGeoJSON() + .type(PointGeoJSON.TypeEnum.POINT) + .coordinates(List.of(BigDecimal.valueOf(153.56), BigDecimal.valueOf(-26.59))) + ); featureGeoJSON3.setProperties(Map.of( FeatureProperty.COUNT.getValue(), 14.0, FeatureProperty.START_TIME.getValue(), "2023-02-01T00:00:00.000Z", @@ -538,7 +547,10 @@ public void verifyAggregationFeatureSummaryWithPageCorrect() throws IOException // Sample1 FeatureGeoJSON featureGeoJSON1 = new FeatureGeoJSON(); featureGeoJSON1.setType(FeatureGeoJSON.TypeEnum.FEATURE); - featureGeoJSON1.setGeometry(new PointGeoJSON().coordinates(List.of(BigDecimal.valueOf(163.56), BigDecimal.valueOf(-26.59)))); + featureGeoJSON1.setGeometry(new PointGeoJSON() + .type(PointGeoJSON.TypeEnum.POINT) + .coordinates(List.of(BigDecimal.valueOf(163.56), BigDecimal.valueOf(-26.59))) + ); featureGeoJSON1.setProperties(Map.of( FeatureProperty.COUNT.getValue(), 14.0, FeatureProperty.START_TIME.getValue(), "2023-02-01T00:00:00.000Z", @@ -550,7 +562,10 @@ public void verifyAggregationFeatureSummaryWithPageCorrect() throws IOException // Sample5 FeatureGeoJSON featureGeoJSON2 = new FeatureGeoJSON(); featureGeoJSON2.setType(FeatureGeoJSON.TypeEnum.FEATURE); - featureGeoJSON2.setGeometry(new PointGeoJSON().coordinates(List.of(BigDecimal.valueOf(163.56), BigDecimal.valueOf(-126.59)))); + featureGeoJSON2.setGeometry(new PointGeoJSON() + .type(PointGeoJSON.TypeEnum.POINT) + .coordinates(List.of(BigDecimal.valueOf(163.56), BigDecimal.valueOf(-126.59))) + ); featureGeoJSON2.setProperties(Map.of( FeatureProperty.COUNT.getValue(), 20.0, FeatureProperty.START_TIME.getValue(), "2022-12-01T00:00:00.000Z",