[OpenLayers-Users] OpenLayers.Ajax.getElementsByTagNameNS ???

Sébastien Geindre sebastien.geindre at meteo.fr
Tue Mar 27 11:24:46 EDT 2007


hi everybody...

Who could explain to me the OpenLayers.Ajax.getElementsByTagNameNS 
function ???

I try to parse my own GML polygon structure :
 <gml:FeatureCollection>
    <gml:featureMember>
      <wims:WIMSCAT>
        <wims:CATPolygon>
           <wims:shape_major> 
             <gml:Polygon>
               <gml:exterior>
                 <gml:LinearRing>
                  <gml:coordinates> -2.30,53.80 -2.30,53.80 -1.90,54.20 
-1.50,54.60 -1.30, ..... </gml:coordinates>
               </gml:LinearRing>
            </gml:exterior>
        </gml:Polygon>
      </wims:shape_major>
    <wims:shape_minor>
    <gml:Polygon><gml:exterior><gml:LinearRing>
          <gml:coordinates>2.50,47.10 2.50,47.10 2.50,47.40 2.50,47.60 
2.60,47.70 2.70,47.70 2.90,47.70 3.00,47.60 3.00,47.40 3.00,47.20 
3.00,47.10 2.50,47.10 </gml:coordinates>
     </gml:LinearRing></gml:exterior></gml:Polygon>
</wims:shape_minor>
....

with the following mosified code of OL/format/GML.js, but it never goes 
through ....

    parseFeature: function(xmlNode) {
        var geom, polygon;
        var p; // [points,bounds]

        var feature = new OpenLayers.Feature.Vector();

        if (xmlNode.firstChild.attributes && 
xmlNode.firstChild.attributes['fid']) {
            feature.fid = xmlNode.firstChild.attributes['fid'].nodeValue;
        }
          // match WIMSCAT
        if (OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, 
"wims", "WIMSCAT").length != 0) {
            var WIMSCAT = 
OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "wims", 
"WIMSCAT")[0];
            geom = new OpenLayers.Geometry.MultiPolygon();
           
            if (OpenLayers.Ajax.getElementsByTagNameNS(WIMSCAT, 
this.gmlns, "wims", "CATPolygon").length != 0) {
               var CATPolygon = 
OpenLayers.Ajax.getElementsByTagNameNS(WIMSCAT,this.gmlns, "wims", 
"CATPolygon");
              
               for (var i = 0; i < CATPolygon.length; i++) {          
                   if 
(OpenLayers.Ajax.getElementsByTagNameNS(CATPolygon, this.gmlns, "wims", 
"shape_major").length != 0) {
                        var shape_major = 
OpenLayers.Ajax.getElementsByTagNameNS(CATPolygon,this.gmlns, "wims", 
"shape_major")[0];
                        polygon = 
this.parsePolygonNode(shape_major[0],geom);
                        geom.addComponents(polygon);   
                   }                   
                   if 
(OpenLayers.Ajax.getElementsByTagNameNS(CATPolygon, this.gmlns, "wims", 
"shape_minor").length != 0) {
                        var shape_minor = 
OpenLayers.Ajax.getElementsByTagNameNS(CATPolygon,this.gmlns, "wims", 
"shape_minor");
                        for (var i = 0; i < shape_minor.length; i++) {
                           polygon = 
this.parsePolygonNode(shape_minor[i],geom);
                           geom.addComponents(polygon);   
                        }
                   }                       
               }
            }
        } else  .....

-- 
Sébastien Geindre
DPREVI/AERO/DEV
sebastien.geindre at meteo.fr
05 61 07 84 93






More information about the Users mailing list