I'm developing a gis Application with java. I use Spring 4.0.1 and GeoTools-13-RC1 in server side and OpenLayers 2.13.1 in client side. In client side, I have a wfs layer and it is as follow:
var saveStrategy = new OpenLayers.Strategy.Save();wfs_Layer = new OpenLayers.Layer.Vector("Editable Features", { strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy], projection: new OpenLayers.Projection("EPSG:4326"), protocol: new OpenLayers.Protocol.WFS({ version: "1.1.0", srsName: "EPSG:4326", url: 'point/read', featureType: "point", featureNS: "http://itsme.opengeo.org", geometryName: "the_geom", readFormat: new OpenLayers.Format.GeoJSON({}), })});wfs_layer get all features from server. Sever return features with follow code:
try { Map params = new HashMap(); params.put("dbtype", "postgis"); params.put("host", "localhost"); params.put("port", 5432); params.put("schema", "public"); params.put("database", "template_postgis"); params.put("user", "postgres"); params.put("passwd", "postgres"); DataStore dataStore = DataStoreFinder.getDataStore(params); SimpleFeatureStore pointStore = (SimpleFeatureStore) dataStore.getFeatureSource("point"); SimpleFeatureCollection featuresCollection = pointStore.getFeatures(); SimpleFeatureIterator features = featuresCollection.features(); FeatureJSON fjson = new FeatureJSON(); StringWriter writer = new StringWriter(); fjson.writeFeatureCollection(featuresCollection, writer); String json = writer.toString(); return json;} catch (IOException ex) { Logger.getLogger(PointController.class.getName()).log(Level.SEVERE, null, ex);}The returned features format is as bellow:
{ "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [40, 45] }, "properties": { "name": "itsme 1" }, "id": "point.1" }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [35, 40] }, "properties": { "name": "itsme 2" }, "id": "point.2" }]}User can edit this layer in client side and with saveStrategy.save() send edited features to server. Browser send edited features as follows:Request Payload:
the_geom 48.694467049643556 35.41594833365911 name itsme edited Now I want to modify featuers in server side. How do I do?
أكثر...
var saveStrategy = new OpenLayers.Strategy.Save();wfs_Layer = new OpenLayers.Layer.Vector("Editable Features", { strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy], projection: new OpenLayers.Projection("EPSG:4326"), protocol: new OpenLayers.Protocol.WFS({ version: "1.1.0", srsName: "EPSG:4326", url: 'point/read', featureType: "point", featureNS: "http://itsme.opengeo.org", geometryName: "the_geom", readFormat: new OpenLayers.Format.GeoJSON({}), })});wfs_layer get all features from server. Sever return features with follow code:
try { Map params = new HashMap(); params.put("dbtype", "postgis"); params.put("host", "localhost"); params.put("port", 5432); params.put("schema", "public"); params.put("database", "template_postgis"); params.put("user", "postgres"); params.put("passwd", "postgres"); DataStore dataStore = DataStoreFinder.getDataStore(params); SimpleFeatureStore pointStore = (SimpleFeatureStore) dataStore.getFeatureSource("point"); SimpleFeatureCollection featuresCollection = pointStore.getFeatures(); SimpleFeatureIterator features = featuresCollection.features(); FeatureJSON fjson = new FeatureJSON(); StringWriter writer = new StringWriter(); fjson.writeFeatureCollection(featuresCollection, writer); String json = writer.toString(); return json;} catch (IOException ex) { Logger.getLogger(PointController.class.getName()).log(Level.SEVERE, null, ex);}The returned features format is as bellow:
{ "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [40, 45] }, "properties": { "name": "itsme 1" }, "id": "point.1" }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [35, 40] }, "properties": { "name": "itsme 2" }, "id": "point.2" }]}User can edit this layer in client side and with saveStrategy.save() send edited features to server. Browser send edited features as follows:Request Payload:
the_geom 48.694467049643556 35.41594833365911 name itsme edited Now I want to modify featuers in server side. How do I do?
أكثر...