X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.app.geo%2Fsrc%2Forg%2Fargeo%2Fapp%2Fgeo%2Fhttp%2FWfsHttpHandler.java;h=b10a10f4b186844500034fc65b97948c6696a648;hb=7877822780b4d4b98e117e403a4c34034807dd54;hp=bccf98ecd287c077374aae3bbe3c20d2626e7f23;hpb=455df52702432311c1825f366e01d01abd0319e2;p=gpl%2Fargeo-suite.git diff --git a/org.argeo.app.geo/src/org/argeo/app/geo/http/WfsHttpHandler.java b/org.argeo.app.geo/src/org/argeo/app/geo/http/WfsHttpHandler.java index bccf98e..b10a10f 100644 --- a/org.argeo.app.geo/src/org/argeo/app/geo/http/WfsHttpHandler.java +++ b/org.argeo.app.geo/src/org/argeo/app/geo/http/WfsHttpHandler.java @@ -19,6 +19,7 @@ import org.argeo.app.api.EntityName; import org.argeo.app.api.EntityType; import org.argeo.app.api.WGS84PosName; import org.argeo.app.geo.CqlUtils; +import org.argeo.app.geo.GeoTools; import org.argeo.app.geo.GpxUtils; import org.argeo.cms.http.HttpHeader; import org.argeo.cms.http.server.HttpServerUtils; @@ -35,6 +36,7 @@ import org.geotools.wfs.GML.Version; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; +import org.locationtech.jts.geom.Polygon; import org.opengis.feature.GeometryAttribute; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; @@ -124,21 +126,19 @@ public class WfsHttpHandler implements HttpHandler { // SimpleFeatureType featureType = DataUtilities.simple(parsed); SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType); - GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); DefaultFeatureCollection featureCollection = new DefaultFeatureCollection(); res.forEach((c) -> { // boolean gpx = false; Geometry the_geom = null; - Geometry the_area = null; + Polygon the_area = null; // if (gpx) { Content area = c.getContent("gpx/area.gpx").orElse(null); if (area != null) { try (InputStream in = area.open(InputStream.class)) { - SimpleFeature feature = GpxUtils.parseGpxToPolygon(in); - the_area = (Geometry) feature.getDefaultGeometry(); + the_area = GpxUtils.parseGpxTrackTo(in, Polygon.class); } catch (IOException e) { throw new UncheckedIOException("Cannot parse " + c, e); } @@ -149,14 +149,14 @@ public class WfsHttpHandler implements HttpHandler { double longitude = c.get(WGS84PosName.lng, Double.class).get(); Coordinate coordinate = new Coordinate(longitude, latitude); - the_geom = geometryFactory.createPoint(coordinate); + the_geom = GeoTools.GEOMETRY_FACTORY.createPoint(coordinate); } // } if (the_geom != null) featureBuilder.set(new NameImpl(namespace, "geopoint"), the_geom); if (the_area != null) - featureBuilder.set(new NameImpl(namespace, "area"), the_geom); + featureBuilder.set(new NameImpl(namespace, "area"), the_area); List attrDescs = featureType.getAttributeDescriptors(); for (AttributeDescriptor attrDesc : attrDescs) {