Make geopoint more robust
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 3 Nov 2023 07:00:38 +0000 (08:00 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 3 Nov 2023 07:00:38 +0000 (08:00 +0100)
org.argeo.app.geo/src/org/argeo/app/geo/acr/GeoEntityUtils.java

index 62b432e7f42e59155d3f0a5f383b9057b087ef7d..48c3c1b438113f263f36296fff809f5fe8cb8d1e 100644 (file)
@@ -54,6 +54,13 @@ public class GeoEntityUtils {
                } catch (IOException e) {
                        throw new UncheckedIOException("Cannot add geometry " + name + " to " + c, e);
                }
+
+//             try (BufferedReader in = new BufferedReader(
+//                             new InputStreamReader(geom.open(InputStream.class), StandardCharsets.UTF_8))) {
+//                     System.out.println(in.readLine());
+//             } catch (IOException e) {
+//                     throw new UncheckedIOException("Cannot parse " + c, e);
+//             }
                updateBoundingBox(c);
        }
 
@@ -91,7 +98,7 @@ public class GeoEntityUtils {
        }
 
        public static Point toPoint(Content c) {
-               if (c.hasContentClass(EntityType.geopoint)) {
+               if (c.containsKey(WGS84PosName.lon) && c.containsKey(WGS84PosName.lat)) {
                        Double lat = c.get(WGS84PosName.lat, Double.class).orElseThrow();
                        Double lon = c.get(WGS84PosName.lon, Double.class).orElseThrow();
                        return JTS.GEOMETRY_FACTORY_WGS84.createPoint(new Coordinate(lat, lon));