File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
outstack-spring-repo/src/main/java/com/cloudimpl/outstack/repo/core/geo Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ public static byte[] convertToGeo(GeoMetry geo) {
2828 return GeoUtil .WKB_WRITER .write (GeoUtil .GEOMETRY_FACTORY .createPolygon (convertCoordinates (polygon .getPoints ())));
2929// Geometry geometry = GeoUtil.GEOMETRY_FACTORY.createPolygon(convertCoordinates(polygon.getPoints()));
3030// return WKB_WRITER.write(getGeometryForPolygon(getPolygon(convertCoordinates(polygon.getPoints()))));
31+ } else if (geo instanceof Polygons ) {
32+ Polygons polygons = (Polygons ) geo ;
33+ return GeoUtil .WKB_WRITER .write (GeoUtil .GEOMETRY_FACTORY .createMultiPolygon (convertToMultiPolygon (polygons .getPolygons ())));
3134 }
3235 throw new RepoException ("uknown geometry " + geo .getClass ().getName ());
3336 }
@@ -54,4 +57,11 @@ public static Coordinate[] convertCoordinates(double[][] geometry) {
5457 .map (points -> new Coordinate (points [0 ], points [1 ]))
5558 .toArray (Coordinate []::new );
5659 }
60+
61+ public static com .vividsolutions .jts .geom .Polygon [] convertToMultiPolygon (double [][][] geometry ) {
62+ return Arrays .stream (geometry )
63+ .map (GeoUtil ::convertCoordinates )
64+ .map (GEOMETRY_FACTORY ::createPolygon )
65+ .toArray (com .vividsolutions .jts .geom .Polygon []::new );
66+ }
5767}
Original file line number Diff line number Diff line change 1+ package com .cloudimpl .outstack .repo .core .geo ;
2+
3+ import lombok .AllArgsConstructor ;
4+ import lombok .Getter ;
5+
6+
7+ @ AllArgsConstructor
8+ @ Getter
9+ public class Polygons implements GeoMetry {
10+
11+ private double [][][] polygons ;
12+
13+ }
You can’t perform that action at this time.
0 commit comments