Skip to content

Commit

Permalink
Change to flatter lng / lat to allow sort
Browse files Browse the repository at this point in the history
  • Loading branch information
utas-raymondng committed Jan 16, 2025
1 parent 169c9c0 commit b277920
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,7 @@ public static synchronized void init() {
*/
public static Map<?,?> createGeoShapeJson(BigDecimal lng, BigDecimal lat) {
Point point = factory.createPoint(new Coordinate(lng.doubleValue(), lat.doubleValue()));

try (StringWriter writer = new StringWriter()) {
geometryJson.write(point, writer);

Map<?, ?> values = objectMapper.readValue(writer.toString(), HashMap.class);

if(values == null) {
logger.warn("Convert geometry to JSON result in null, {}", writer.toString());
}

Map<String, Object> feature = new HashMap<>();
Map<String, Object> properties = new HashMap<>();

feature.put("type", "Feature");
feature.put("properties", properties);
feature.put("geometry", values);

return feature;
}
catch(Exception e) {
return null;
}
return createGeoShapeJson(List.of(List.of(point)));
}
/**
* @param polygons - Assume to be EPSG:4326, as GeoJson always use this encoding.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"id": "35234913-aa3c-48ec-b9a4-77f822f66ef8|2024-02|170.33|-33.87|530.00",
"geometry": {
"geometry": {
"coordinates": [
170.33,
-33.87
],
"type": "Point"
},
"type": "Feature",
"properties": {}
"geometries": [
{
"type": "Point",
"coordinates": [
170.33,
-33.87
]
}
],
"type": "GeometryCollection"
},
"properties": {
"lng": 170.33,
"time": "2024-02-01T00:00:00Z",
"count": 15,
"depth": 530.0,
"lat": -33.87
"lng_lat": -33.87,
"lng": 170.33
},
"collection": "35234913-aa3c-48ec-b9a4-77f822f66ef8",
"type": "Feature",
"stac_version": "1.0.0",
"stac_extensions": [
"https://stac-extensions.github.io/scientific/v1.0.0/schema.json",
Expand All @@ -28,5 +28,6 @@
"https://stac-extensions.github.io/language/v1.0.0/schema.json",
"https://stac-extensions.github.io/themes/v1.0.0/schema.json",
"https://stac-extensions.github.io/web-map-links/v1.2.0/schema.json"
]
],
"type": "Feature"
}

0 comments on commit b277920

Please sign in to comment.