Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a web-gis application based on openlayers and geoserver. I need to modify a shape layer. I'm able to show the shape using the OpenLayers.Layer.WMS method. In fact i published the shape in geoserver and called it in the openlayers map file.

My idea is to copy the shape layer in a vector layer. In this way i can modify the vector layer before to save it.

My problem is: how can i copy the shape layer in a vector layer? How can i do that?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

why dont you use WFS-T in geoserver. you know A transactional Web Feature Service (WFS-T) allows all CRUD Operations as creation, deletion, and updating of features. i know that GeoServer supports WFS-T which they have told in wikipedia as:

In addition, one can edit data via the WFS transactional profile (WFS-T).

and in reference page you can find sth:

The Transaction operation performs edits of actual data that is exposed by the WFS. A transaction can add, modify and remove features. Each transaction consists of zero or more Insert, Update and Delete elements. Each element is performed in order....

and the last thing if you search any tutorial about how can you achieve WFS-T operation, you should read OpenLayers WFS-T Using a GeoServer Hosted PostGIS Layer which realy giving excellent information about what you search...

from that site, maybe this is important before reading :)

This is an advanced OpenLayers tutorial which explains how to setup your own WFS-T example using a combination of GeoServer and PostgreSQL/PostGIS. In order to complete this tutorial, a user must have administrative access to both GeoServer and PostgreSQL running on a server. Users must also have an intermediate understanding of programming OpenLayers for developing web mapping applications.

i hope it helps you...

share|improve this answer

At the end i've found the way to visualize the layer.

The problem was that it seems that i needed to define the bounds of the map. What is not exactly clear is why, once you have defined a starting bounds, if you move the map over the bounds, you still can see the layer.

By the way, it doesn't matter. The important is to have clear how to set a wfs layer.

share|improve this answer

Sorry for the delay of the answer but i wanted to follow everything of what you suggested, included the proxy setting for my webserver. Everything seems to work fine:

I have this code in my map file:

 var options = {
  projection: new OpenLayers.Projection("EPSG:900913"),
  //displayProjection: new OpenLayers.Projection("EPSG:32632"),
  displayProjection: new OpenLayers.Projection("EPSG:23032"),
  units: "m",
  //maxResolution: 156543.0339,
  maxResolution: 99.22366015624993,
  maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34)
 };

...

    var saveStrategy = new OpenLayers.Strategy.Save();

    v1497_wfs = new OpenLayers.Layer.Vector("Editable Features", {
        strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
        //projection: new OpenLayers.Projection("EPSG:23032"),
        protocol: new OpenLayers.Protocol.WFS({
            version: "1.1.0",
            //srsName: "EPSG:23032",
            url: "http://localhost/geoserver/wfs",
            featureNS :  "http://www.opengeospatial.net/cite",
            featureType: "v1497_db_wfs",
            geometryName: "the_geom",
            maxExtent:  map.maxExtent.left + ',' + map.maxExtent.bottom,
            schema: "http://localhost/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=cite:v1497_db_wfs"
        })
    });

  map.addLayer(v1497_wfs);
  v1497_wfs.setVisibility(true);

and if i try to navigate on the url:

http://localhost/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=cite:v1497_db_wfs

i have the following response from the browser:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:abcweb="www.abcweb.it" xmlns:aset="http://www.aset.it" xmlns:castelli="http://www.guidacastelli.it" xmlns:cite="http://www.opengeospatial.net/cite" xmlns:gml="http://www.opengis.net/gml" xmlns:it.geosolutions="http://www.geo-solutions.it" xmlns:nurc="http://www.nurc.nato.int" xmlns:sde="http://geoserver.sf.net" xmlns:sf="http://www.openplans.org/spearfish" xmlns:sitap="http://localhost:8080/geoserver/wfs" xmlns:test_ws="http://test_ws" xmlns:tiger="http://www.census.gov" xmlns:topp="http://www.openplans.org/topp" elementFormDefault="qualified" targetNamespace="http://www.opengeospatial.net/cite">
<xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://localhost:80/geoserver/schemas/gml/3.1.1/base/gml.xsd"/>
<xsd:complexType name="v1497_db_wfsType">
<xsd:complexContent>
<xsd:extension base="gml:AbstractFeatureType">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="codvr" nillable="true" type="xsd:decimal"/>
<xsd:element maxOccurs="1" minOccurs="0" name="uso" nillable="true" type="xsd:int"/>
<xsd:element maxOccurs="1" minOccurs="0" name="objectid" nillable="true" type="xsd:decimal"/>
<xsd:element maxOccurs="1" minOccurs="0" name="area__mq_" nillable="true" type="xsd:double"/>
<xsd:element maxOccurs="1" minOccurs="0" name="perim__m_" nillable="true" type="xsd:double"/>
<xsd:element maxOccurs="1" minOccurs="0" name="the_geom" nillable="true" type="gml:MultiSurfacePropertyType"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="v1497_db_wfs" substitutionGroup="gml:_Feature" type="cite:v1497_db_wfsType"/>
</xsd:schema>

But, even if i can see the checkbox in the layerswitcher, i can't see anything in the map. any idea?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.