Fix lat/lon vs. lon/lat issues
[gpl/argeo-suite.git] / org.argeo.app.geo / src / org / argeo / app / geo / http / WfsHttpHandler.java
index c9a1e85c8c5867708b773a2b3d1345b6cad92090..8c143dbf01510d7eb10a56b588ec50b82ac819ea 100644 (file)
@@ -34,8 +34,11 @@ import org.argeo.app.geo.GeoJson;
 import org.argeo.app.geo.GeoUtils;
 import org.argeo.app.geo.GpxUtils;
 import org.argeo.app.geo.JTS;
+import org.argeo.app.geo.acr.GeoEntityUtils;
 import org.argeo.cms.acr.json.AcrJsonUtils;
+import org.argeo.cms.auth.RemoteAuthUtils;
 import org.argeo.cms.http.HttpHeader;
+import org.argeo.cms.http.RemoteAuthHttpExchange;
 import org.argeo.cms.http.server.HttpServerUtils;
 import org.argeo.cms.util.LangUtils;
 import org.geotools.api.feature.GeometryAttribute;
@@ -57,7 +60,6 @@ import org.geotools.wfs.GML.Version;
 import org.locationtech.jts.geom.Coordinate;
 import org.locationtech.jts.geom.Envelope;
 import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.Point;
 import org.locationtech.jts.geom.Polygon;
 
 import com.sun.net.httpserver.HttpExchange;
@@ -200,7 +202,10 @@ public class WfsHttpHandler implements HttpHandler {
                                if (featureAdapter == null)
                                        throw new IllegalStateException("No feature adapter found for " + typeName);
                                // f.isContentClass(typeName);
-                               featureAdapter.addConstraintsForFeature((AndFilter) search.getWhere(), typeName);
+                               RemoteAuthUtils.doAs(() -> {
+                                       featureAdapter.addConstraintsForFeature((AndFilter) search.getWhere(), typeName);
+                                       return null;
+                               }, new RemoteAuthHttpExchange(exchange));
                        }
 
                        if (bbox != null) {
@@ -356,12 +361,7 @@ public class WfsHttpHandler implements HttpHandler {
 
        protected Geometry getDefaultGeometry(Content content) {
                if (content.hasContentClass(EntityType.geopoint)) {
-                       double latitude = content.get(WGS84PosName.lat, Double.class).get();
-                       double longitude = content.get(WGS84PosName.lon, Double.class).get();
-
-                       Coordinate coordinate = new Coordinate(longitude, latitude);
-                       Point the_geom = JTS.GEOMETRY_FACTORY.createPoint(coordinate);
-                       return the_geom;
+                       return GeoEntityUtils.toPoint(content);
                }
                return null;
        }