Select to view content in your preferred language

Creating an ogc Spatial filter

5021
4
09-25-2012 08:03 PM
Labels (1)
JosephShanahan
Emerging Contributor
I an using Data Interop and and have added a WFS service.
I want to know how to implement a spatial filter. Got a literal one going easy enough but the spatial one is a problem.
I have started with this one. Just return all of the polylines within a given distance

I get a message the "DataSet appears to be invalid".

One of the things that confuses me is what do I insert for PropertyName. Is it geometry, SHAPE, polygon etc

<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc xmlns:gml="http://www.opengis.net/gml xmlns:wfs="http://www.opengis.net/wfs">
<ogc:DWithin><ogc:PropertyName>Polygon</ogc:PropertyName><gml:Point>
      <gml:pos>152.540349 -32.444276</gml:pos></gml:Point><ogc:Distance> ogc:units='m'>60000</ogc:Distance>
      </ogc:DWithin>
</ogc:Filter>

Advancing form this then I shall need to construct a spatial filter to return all of the features inside a feature polygon.


I tried the following and got the same results

<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc xmlns:gml="http://www.opengis.net/gml xmlns:wfs="http://www.opengis.net/wfs">
<ogc:Within><ogc:PropertyName>Geometry</ogc:PropertyName>
<gml:Polygon srsName="LL-GDA94">
<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>145.27626508549,-38.2022631817624 145.306722186365,-38.2003596129578 145.315526192086,-38.211067187484 145.314098515483,-38.2286751989272 145.292921312531,-38.2201091393061 145.27626508549,-38.2022631817624</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>
</gml:Polygon>
<ogc:PropertyName>Geometry</ogc:PropertyName>
</ogc:Within>
</ogc:Filter>



Any help appreciated as there is not anything I can get a handle on to get this going.




PS: i don't know how to stop all of those smiles appearing in the xml

Regards
Joseph Shanahan
Esri Australia.
0 Kudos
4 Replies
BruceHarold
Esri Regular Contributor
Hi

We'll take a look but in the meantime here is an alternate approach.

Regards
0 Kudos
MelitaKennedy
Esri Notable Contributor
Hi Joseph,

Try wrapping the XML with CODE tags. If you have "standard editor" set, it's a hash (#) button.


<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc xmlns:gml="http://www.opengis.net/gml xmlns:wfs="http://www.opengis.net/wfs">
 <ogc:DWithin><ogc:PropertyName>Polygon</ogc:PropertyName><gml:Point>
      <gml:pos>152.540349 -32.444276</gml:pos></gml:Point><ogc:Distance> ogc:units='m'>60000</ogc:Distance>
      </ogc:DWithin>
</ogc:Filter>


Or, this appears to work too, at least when previewing the post. In the "Additional Options", check on "Disable smilies in text".

<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc xmlns:gml="http://www.opengis.net/gml xmlns:wfs="http://www.opengis.net/wfs">
<ogc:DWithin><ogc:PropertyName>Polygon</ogc:PropertyName><gml:Point>
      <gml:pos>152.540349 -32.444276</gml:pos></gml:Point><ogc:Distance> ogc:units='m'>60000</ogc:Distance>
      </ogc:DWithin>
</ogc:Filter>

Hope this helps,
Melita
0 Kudos
JosephShanahan
Emerging Contributor
I did post one issue, I had forgotten to close off the namespaces with a "
Latest posted one is correct but I still have the same issues.

<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.opengis.net/wfs">
<ogc:Intersects>
<ogc:PropertyName>GEOMETRY</ogc:PropertyName>
<gml:Polygon srsName="LL-GDA94">
<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>145.27626508549,-38.2022631817624 145.306722186365,-38.2003596129578 145.315526192086,-38.211067187484 145.314098515483,-38.2286751989272 145.292921312531,-38.2201091393061 145.27626508549,-38.2022631817624</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>
</gml:Polygon>
</ogc:Intersects>
</ogc:Filter>


An answer to the following might make it clearer
should the line be
<ogc:PropertyName>GEOMETRY</ogc:PropertyName>
or
<ogc:PropertyName>SHAPE</ogc:PropertyName>
or

<ogc:PropertyName>SHAPE*</ogc:PropertyName>

or something else.

I have it working for a straight non spatial filter and I just inserted the name of the field.

Regards
Joseph Shanahan
0 Kudos
JosephShanahan
Emerging Contributor
I tried a lot of things to get this to go and I'm not sure which one eventually got it.
When you create a connection using data interop it is created in
C:\Users\jshanahan\AppData\Roaming\Safe Software\Interoperability

I moved the connection to a unc shared directory



Another is to be carefully to get the latitude and and longitude in the correct order.
I had them the wrong way around.
If you look in the capabilities file it will tell you the correct way to set them.


- <ows:Constraint name="serviceAxisOrderForSwappableSRS">
  <ows:Value>latitude,longitude</ows:Value>
  </ows:Constraint>


Also when you get a problem it is good to look in the server logs, they will tell you a lot.


Here is a sample filter that works

<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.opengis.net/wfs">
<ogc:Overlaps>
  <ogc:PropertyName>shape</ogc:PropertyName>
  <gml:Polygon srsName="EPSG:4283">
<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-30.639482384733,132.012620960283 -35.2080475159278,156.568658540454 -41.7753598920203,154.427143635207 -42.7747335144692,150.572416805761 -30.639482384733,132.012620960283</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>
    </gml:Polygon>
</ogc:Overlaps>
</ogc:Filter>

Regards
Joseph Shanahan
0 Kudos