</service>
<property name="context.path" type="String" value="/api/wfs/" />
<reference bind="setContentRepository" cardinality="1..1" interface="org.argeo.api.acr.spi.ProvidedRepository" name="ProvidedRepository" policy="static"/>
- <reference bind="addFeatureAdapter" cardinality="0..n" interface="org.argeo.app.geo.http.FeatureAdapter" name="FeatureAdapter" policy="dynamic" unbind="removeFeatureAdapter"/>
+ <reference bind="addFeatureAdapter" cardinality="0..n" interface="org.argeo.app.api.geo.FeatureAdapter" name="FeatureAdapter" policy="dynamic" unbind="removeFeatureAdapter"/>
</scr:component>
--- /dev/null
+package org.argeo.app.api.geo;
+
+import javax.xml.namespace.QName;
+
+import org.argeo.api.acr.Content;
+import org.argeo.api.acr.search.AndFilter;
+import org.argeo.app.api.EntityType;
+import org.argeo.app.api.WGS84PosName;
+import org.argeo.app.geo.JTS;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.geom.Point;
+
+import jakarta.json.stream.JsonGenerator;
+
+public interface FeatureAdapter {
+ default Geometry getDefaultGeometry(Content c, QName targetFeature) {
+ // TODO deal with more defaults
+ // TODO deal with target feature
+ if (c.hasContentClass(EntityType.geopoint)) {
+ double latitude = c.get(WGS84PosName.lat, Double.class).get();
+ double longitude = c.get(WGS84PosName.lon, Double.class).get();
+
+ Coordinate coordinate = new Coordinate(longitude, latitude);
+ Point the_geom = JTS.GEOMETRY_FACTORY.createPoint(coordinate);
+ return the_geom;
+ }
+ return null;
+ }
+
+ void writeProperties(JsonGenerator g, Content content, QName targetFeature);
+
+ void addConstraintsForFeature(AndFilter filter, QName targetFeature);
+}
+++ /dev/null
-package org.argeo.app.geo.http;
-
-import javax.xml.namespace.QName;
-
-import org.argeo.api.acr.Content;
-import org.argeo.api.acr.search.AndFilter;
-import org.argeo.app.api.EntityType;
-import org.argeo.app.api.WGS84PosName;
-import org.argeo.app.geo.JTS;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.Point;
-
-import jakarta.json.stream.JsonGenerator;
-
-public interface FeatureAdapter {
- default Geometry getDefaultGeometry(Content c, QName targetFeature) {
- // TODO deal with more defaults
- // TODO deal with target feature
- if (c.hasContentClass(EntityType.geopoint)) {
- double latitude = c.get(WGS84PosName.lat, Double.class).get();
- double longitude = c.get(WGS84PosName.lon, Double.class).get();
-
- Coordinate coordinate = new Coordinate(longitude, latitude);
- Point the_geom = JTS.GEOMETRY_FACTORY.createPoint(coordinate);
- return the_geom;
- }
- return null;
- }
-
- void writeProperties(JsonGenerator g, Content content, QName targetFeature);
-
- void addConstraintsForFeature(AndFilter filter, QName targetFeature);
-}
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;
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;
GeoJSon.writeGeometry(generator, defaultGeometry);
generator.writeStartObject("properties");
- writeTimeProperties(generator, c);
- writeProperties(generator, c);
+ AcrJsonUtils.writeTimeProperties(generator, c);
if (featureAdapter != null)
featureAdapter.writeProperties(generator, c, typeName);
+ else
+ writeProperties(generator, c);
generator.writeEnd();// properties object
generator.writeEnd();// feature object
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)) {