How to read GML attributes

2 messages Options
Embed this post
Permalink
jmf

How to read GML attributes

Reply Threaded More More options
Print post
Permalink
Hi,

My main purpose at this moment is to use openlayers to show interactive (onclick, onmouseover) point feature layers with data from oracle spatial. Every layer has its simbology (icon). Then I need to get not only geometry but also some feature data, including layer name, feature id, ...

I use:

openLayers.events.register('moveend',this,_mapMoveEnd);

to capture "move end" event to refresh my interactive layers everytime map changes (zoom, pan, ...). Inside _mapMoveEnd function I do an AJAX request to get layer data in GML format.

Exemple of Oracle spatial query generates:

<Element xmlns:gml="http://www.opengis.net/gml">
<Name>Test name</Name>
<Id>203</Id>
<Layer>Test layer</Layer>
<gml:geometryProperty>
<gml:Point srsName="SDO:82341" xmlns:gml="http://www.opengis.net/gml">
         <gml:coordinates decimal="." cs="," ts=" ">453035.87675187894,4600288.721536965,0</gml:coordinates>
</gml:Point>
</gml:geometryProperty>
</Element>

where "Name" and "Id" are feature attributes.

Now I need to read this response text to get an array of feature objects. Then I will add the features to corresponding vector layers previously created.

My first question is: How to read this GML content?

I try with:

features =  new OpenLayers.Format.GML.v2(gmlOptionsIn).read(sRequestResponseText);

But it does not work.

Other question is: Is this the best way to my main purpose?

Thanks in advance.
jmf





lilianxu

Re: How to read GML attributes

Reply Threaded More More options
Print post
Permalink

jmf wrote:
Hi,

My main purpose at this moment is to use openlayers to show interactive (onclick, onmouseover) point feature layers with data from oracle spatial. Every layer has its simbology (icon). Then I need to get not only geometry but also some feature data, including layer name, feature id, ...

I use:

openLayers.events.register('moveend',this,_mapMoveEnd);

to capture "move end" event to refresh my interactive layers everytime map changes (zoom, pan, ...). Inside _mapMoveEnd function I do an AJAX request to get layer data in GML format.

Exemple of Oracle spatial query generates:

<Element xmlns:gml="http://www.opengis.net/gml">
<Name>Test name</Name>
<Id>203</Id>
<Layer>Test layer</Layer>
<gml:geometryProperty>
<gml:Point srsName="SDO:82341" xmlns:gml="http://www.opengis.net/gml">
         <gml:coordinates decimal="." cs="," ts=" ">453035.87675187894,4600288.721536965,0</gml:coordinates>
</gml:Point>
</gml:geometryProperty>
</Element>

where "Name" and "Id" are feature attributes.

Now I need to read this response text to get an array of feature objects. Then I will add the features to corresponding vector layers previously created.

My first question is: How to read this GML content?

I try with:

features =  new OpenLayers.Format.GML.v2(gmlOptionsIn).read(sRequestResponseText);

But it does not work.

Other question is: Is this the best way to my main purpose?

Thanks in advance.
jmf





 
         for(var feat in features) {
         
         
            for (var j in features[feat].attributes) {
}}

this maybe useful