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 am trying to get the list of feature layers on GeoServer and then user can add layers into map at anytime they want. my question is: when using OpenLayers.Protocol.WFS loading a layer, is "geometryName" required?

since from the response of "WFSGetCapabilities" request to Geoserver, for each featureType, there are only "name, title, srsName, and featureNS". If “geometryName” is required, I have to retrive this from "DescribeFeatureType" request by enumerating the feature's properties . however, these two requests are asynchronous, I am not sure how to load this layer without user's interaction input.

anybody helps? appreciated!!

share|improve this question
add comment

2 Answers 2

Even better you might not have to retrieve it at all, but it depends very much on the OpenLayers version.

2.10: geometryName is not required. If a value is not provided it will default to 'the_geom' which might not work for you, but that also depends on the WFS version you are using. If using geoserver as a backend I would try the default.

2.11 (currently in dev): no more required and (here's the great news) for WFS versions > 1 OL should figure it out by itself as per the documentation on the OL WFS proto:

http://dev.openlayers.org/docs/files/OpenLayers/Protocol/WFS/v1-js.html#OpenLayers.Protocol.WFS.v1.geometryName

share|improve this answer
add comment

I suppose you can do a nested async call. The outer one would be a DescribeFeatureType and the inner one would be the OpenLayers.Protocol.WFS call.

Something like (not tested):

var request = OpenLayers.Request.GET({
    url: 'http://myGeoserver:8080/geoserver/wfs?service=wfs&version=1.1.0&request=DescribeFeatureType',
    success: function (response) {

        var myGeometryName = parseResponseForgeometryName(response);

        var protocol = new OpenLayers.Protocol.WFS({
            version: "1.1.0",
            EndPointURL: "http://myGeoserver:8080/geoserver/wfs",
            featurePrefix: "catalog", //worspace 
            featureType: "myLayer", // Layer Name
            featureNS: "http://mydomain.com/catalog", // Edit Workspace Namespace URI
            geometryName: myGeometryName,
            srsName: myProjections.Mercator
        });

        var response = protocol.read({
            maxFeatures: 500,
            callback: function () {
                alert('complete');
            }
        });

    }
});
share|improve this answer
add comment

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.