Work on GeoJSon ans JTS support
[gpl/argeo-suite.git] / org.argeo.app.geo / src / org / argeo / app / geo / http / WfsHttpHandler.java
index 8b2d1597ca587b1ba2b0c0cf9941f02f00236ed6..4ab3654f456ffd1f9cd53703b22f618ff4d12244 100644 (file)
@@ -18,7 +18,6 @@ import javax.xml.namespace.QName;
 
 import org.argeo.api.acr.Content;
 import org.argeo.api.acr.ContentSession;
-import org.argeo.api.acr.DName;
 import org.argeo.api.acr.NamespaceUtils;
 import org.argeo.api.acr.ldap.LdapAttr;
 import org.argeo.api.acr.search.AndFilter;
@@ -27,10 +26,12 @@ import org.argeo.api.cms.CmsLog;
 import org.argeo.app.api.EntityName;
 import org.argeo.app.api.EntityType;
 import org.argeo.app.api.WGS84PosName;
+import org.argeo.app.api.geo.FeatureAdapter;
 import org.argeo.app.geo.CqlUtils;
 import org.argeo.app.geo.GeoJSon;
 import org.argeo.app.geo.GpxUtils;
 import org.argeo.app.geo.JTS;
+import org.argeo.cms.acr.json.AcrJsonUtils;
 import org.argeo.cms.http.HttpHeader;
 import org.argeo.cms.http.server.HttpServerUtils;
 import org.argeo.cms.util.LangUtils;
@@ -116,8 +117,7 @@ public class WfsHttpHandler implements HttpHandler {
                        if (cql != null) {
                                CqlUtils.filter(search.from(path), cql);
                        } else {
-                               search.from(path).where((and) -> {
-                               });
+                               search.from(path);
                        }
 //                     search.getWhere().any((f) -> {
                        for (QName typeName : typeNames) {
@@ -202,13 +202,16 @@ public class WfsHttpHandler implements HttpHandler {
                        if (featureId != null)
                                generator.write("id", featureId);
                        GeoJSon.writeBBox(generator, defaultGeometry);
+                       generator.writeStartObject(GeoJSon.GEOMETRY);
                        GeoJSon.writeGeometry(generator, defaultGeometry);
+                       generator.writeEnd();// geometry object
 
-                       generator.writeStartObject("properties");
-                       writeTimeProperties(generator, c);
-                       writeProperties(generator, c);
+                       generator.writeStartObject(GeoJSon.PROPERTIES);
+                       AcrJsonUtils.writeTimeProperties(generator, c);
                        if (featureAdapter != null)
                                featureAdapter.writeProperties(generator, c, typeName);
+                       else
+                               writeProperties(generator, c);
                        generator.writeEnd();// properties object
 
                        generator.writeEnd();// feature object
@@ -243,24 +246,7 @@ public class WfsHttpHandler implements HttpHandler {
                return uuid;
        }
 
-       private final QName JCR_CREATED = NamespaceUtils.parsePrefixedName("jcr:created");
-
-       private final QName JCR_LAST_MODIFIED = NamespaceUtils.parsePrefixedName("jcr:lastModified");
-
-       protected void writeTimeProperties(JsonGenerator g, Content content) {
-               String creationDate = content.attr(DName.creationdate);
-               if (creationDate == null)
-                       creationDate = content.attr(JCR_CREATED);
-               if (creationDate != null)
-                       g.write(DName.creationdate.get(), creationDate);
-               String lastModified = content.attr(DName.getlastmodified);
-               if (lastModified == null)
-                       lastModified = content.attr(JCR_LAST_MODIFIED);
-               if (lastModified != null)
-                       g.write(DName.getlastmodified.get(), lastModified);
-       }
-
-       protected void writeProperties(JsonGenerator generator, Content content) {
+       public void writeProperties(JsonGenerator generator, Content content) {
                String path = content.getPath();
                generator.write("path", path);
                if (content.hasContentClass(EntityType.local)) {