Firstly, thank you Alexandre for helping to point me to the right point in the source. I had been debugging with firebug and was able to locate the point at which the points were being parsed in OL.Format.GML.v3.js, but was stumped as to why the layer.features continued to remain empty.

Secondly, it appears this problem existed at two separate points. The first point was that I was not specifying the geometryName in my initial script. Since my geometry name was not "the_geom" (which is the default value) by "msGeometry" nothing was being parsed correctly.

When I added the geometryName property I also (foolishly) added a "version" property and set this to 1.1.0. At this point, when I stepped through the code I could clearly see the points being parsed, but nothing would render. After removing "version" (or setting it to 1.0.0) my vectors rendered.

Thank you again Alexandre, you helped me to understand that I can set the wfs_namespace_prefix in my map, which may well be a smarter approach than having to specify it in the js. I will explore the merits of this option.

Cheers!

Mark K. Zanfardino

On 06/08/2011 08:47 AM, Alexandre Dube wrote:
Hi,

This seems to be a matter of feature namespace. In OpenLayers, XML is read using the namespaces of a node as the way to detect the according reader for it. If not set in the protocol, OpenLayers sets "feature" as default prefix for feature nodes. In MapServer, the default value outputed in the GML is "ms" as you can see in yours. You can either adjust OpenLayers to your MapServer settings [1] or the opposite [2] in order to read the nodes accordingly.

[1] set feature prefix and namespace in your protocol (OpenLayers) according to MapServer settings

protocol: new OpenLayers.Protocol.WFS({
          url: mapPath,
          featureType: "tenszones",
          featurePrefix: "ms",
          featureNS: "http://mapserver.gis.umn.edu/mapserver";
      }),

[2] or set your feature namespace to OpenLayers default value in your mapfile (in your MAP, METADATA tag):

"wfs_namespace_prefix" "feature"
"wfs_namespace_uri" "http://localhost";

Before making any changes, you could use firebug with an uncompressed version of OpenLayers (2.10) and set a breakpoint in ./lib/OpenLayers/Format/XML.js on line 621 : var group = this.readers[node.namespaceURI ? this.namespaceAlias[node.namespaceURI]: this.defaultPrefix];

Inspect the elements there until you reach your node that doesn't get read properly and you'll see why it isn't and how it works as well.

HTH,

Alexandre


On 11-06-08 11:12 AM, Mark K. Zanfardino wrote:
OpenLayers version 2.10
MapServer version 5.6.6

Goal: Render vector layer based on WFS protocol

I'm trying to understand why a vector layer will not render on my map. I can clearly see the layer in the layerSwitcher control so I presume the layer is being presented, but there are no actual features rendered.

The vector layer is defined using a WFS protocol:

    tens = new OpenLayers.Layer.Vector("TENS",
          {
          strategies: [new OpenLayers.Strategy.BBOX()],
          protocol: new OpenLayers.Protocol.WFS({
              url: mapPath,
              featureType: "tenszones",
          }),
          styleMap: new OpenLayers.StyleMap({
              strokeWidth: 3,
              strokeColor: "#333333"
          }),
          filter: new OpenLayers.Filter.Logical({
              type: OpenLayers.Filter.Logical.NOT,
              filters: [
              new OpenLayers.Filter.Comparison({
                  type: OpenLayers.Filter.Comparison.EQUAL_TO,
                  property: "name",
                  value: "County0"
              })
              ]
          })
          },
          {
          isBaseLayer: false,
          buffer: 0
          }
      );

When I watch the page load I can clearly see the XML results from the WFS call (see XML output) but no features are rendered on the map. I'm following from the 'WFS Protocol and Filter' example. Any help would be appreciated.

<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection
   xmlns:ms="http://mapserver.gis.umn.edu/mapserver";
   xmlns:wfs="http://www.opengis.net/wfs";
   xmlns:gml="http://www.opengis.net/gml";
   xmlns:ogc="http://www.opengis.net/ogc";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://mapserver.gis.umn.edu/mapserver http://localhost/cgi-bin/mapserv?map=/home/mark/htdocs/sandbox/contra_costa/mapdata/cws.map&amp;SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=tenszones&amp;OUTPUTFORMAT=XMLSCHEMA";>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-122.430673,37.902872 -121.783758,38.058186</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ms:tenszones fid="tenszones.2">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-121.882119,38.004151 -121.822493,38.034986</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:Polygon srsName="EPSG:4326">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>-121.826546,38.024671 -121.825545,38.018151 -121.822493,38.015989 -121.832033,38.004151 -121.847393,38.007365 -121.876296,38.018261 -121.875579,38.022347 -121.882119,38.024341 -121.880209,38.032456 -121.878309,38.034986 -121.826546,38.024671 </gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</ms:msGeometry>
<ms:gid>2</ms:gid>
<ms:area>0.00104289122555201</ms:area>
<ms:perimeter>0.147388060113902</ms:perimeter>
<ms:name>DOW0</ms:name>
</ms:tenszones>
</gml:featureMember>
<gml:featureMember>
<ms:tenszones fid="tenszones.3">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-121.837932,37.999340 -121.819430,38.024672</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:Polygon srsName="EPSG:4326">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>-121.826535,38.024672 -121.819800,38.022000 -121.819430,38.004870 -121.821310,37.999340 -121.837932,38.003598 -121.836350,38.005070 -121.832027,38.004150 -121.822495,38.015991 -121.825510,38.018100 -121.826535,38.024672 </gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</ms:msGeometry>
<ms:gid>3</ms:gid>
<ms:area>0.000183226789886248</ms:area>
<ms:perimeter>0.0794914873797834</ms:perimeter>
<ms:name>DOW1</ms:name>
</ms:tenszones>
</gml:featureMember>
</wfs:FeatureCollection>


_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users


--
Alexandre Dubé
Mapgears
www.mapgears.com


_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to