Question

wfs query

  • 8 February 2019
  • 6 replies
  • 29 views

Badge +1

H?,

I want to do a wfs query with fme.  as normal url =>

http://cbsservis.tkgm.gov.tr/tkgm.ows/wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=TKGM:parseller&cql_filter=durum=3&maxfeatures=10

 if the result =>

0684Q00000ArCU9QAN.png

I want to query according to a certain value . 0684Q00000ArC9qQAF.png

 

I want to get values that are only 3  .

<TKGM:durum>3</TKGM:durum>

I've tried using xml filter. 

 

Is there any idea? 

 

Thank you.


6 replies

Userlevel 2
Badge +17

Do you need to delete every <gml:featureMember> element whose descendant element <TKGM:durum> has a value other than 3?

Badge +16

Hallo @ssisman06,

Something like this should work:

<Filter>

<PropertyIsEqualTo>

<PropertyName>durum</PropertyName>

<Literal>3</Literal>

</PropertyIsEqualTo>

</Filter>

In the filter settings of the WFS reader, but that depends if the service supports it, check the get capabilities to make sure.

Hope this helps.

Badge +1

h? @itay ,

Thanks for the help. I have some things to solve. my wfs service gives a maximum of 1000 results per query. i need to download big data.

divided my work area. ( 16000 grid)

0684Q00000ArLuoQAF.png

My WorkBench =>

0684Q00000ArLntQAF.png0684Q00000ArLk7QAF.png

this is working correctly.

 

then I want to use xml filter.

I want to get values that are only 3 .

<TKGM:durum>3</TKGM:durum>

the two do not work together.

xml filter actually works correctly.

0684Q00000ArLc2QAF.png

 

How can I use two queries together . I need to apply both the spatial filter and the xml filter.

Is there any idea?

 

Thank you.

Badge +4

h? @itay ,

Thanks for the help. I have some things to solve. my wfs service gives a maximum of 1000 results per query. i need to download big data.

divided my work area. ( 16000 grid)

0684Q00000ArLuoQAF.png

My WorkBench =>

0684Q00000ArLntQAF.png0684Q00000ArLk7QAF.png

this is working correctly.

 

then I want to use xml filter.

I want to get values that are only 3 .

<TKGM:durum>3</TKGM:durum>

the two do not work together.

xml filter actually works correctly.

0684Q00000ArLc2QAF.png

 

How can I use two queries together . I need to apply both the spatial filter and the xml filter.

Is there any idea?

 

Thank you.

If you need to download a big area with over a 1000 results why not use a tiler to cut your area into smaller pieces? That always works for me when downloading from WFS. You only might need to remove duplicates with a duplicatefilter afterwards.

Badge +3

Hi @ssisman06,

Not sure if you already found a proper solution to your problem. I seems to me that there are two items you liked answered:

  1. Is there a work around for the WFS limitation of querying 1000 features at a time?
  2. Can two queries be combined?

A useful link to both items can be found from the question:

https://knowledge.safe.com/questions/39574/wfs-reader-filtering-a-non-spatial-class-by-attrib.html

 

1.

As is discussed there, if the WFS has support for version 2.0.0 you might be able to use WFS paging. You can check this from a 'GetCapabilities' request, i.e.: http://cbsservis.tkgm.gov.tr/tkgm.ows/wfs?request=GetCapabilities&service=WFS.

Unfortunately I noticed that the WFS requires a login, so I can't do this for you. Anyway, you should check for some XML fragment similar to the following:

0684Q00000ArLqvQAF.png

When supported by the WFS server, within the WFS parameters you can set the 'Start Index' to 0 and the 'Count' to 1000 to 'stack' feature requests per 1000.

 

2.

Yes, it might be possible to combine both an attribute query and a spatial query. This depends on the XML filter expressions that are supported by the WFS server (again check the 'GetCapabilities' of the WFS server). The following XML filter combines a bounding box and an attribute query. Of cource the coordinates still need to be changed to suit your specific demands.

<Filter>
   <And>
      <BBOX>
         <ValueReference>Geometry</ValueReference>
         <Envelope srsName="urn:ogc:def:crs:EPSG::4326">
            <lowerCorner>10 30</lowerCorner>
            <upperCorner>35 45</upperCorner>
         </Envelope>
      </BBOX>
      <PropertyIsEqualTo>
         <ValueReference>durum</ValueReference>
         <Literal>3</Literal>
      </PropertyIsEqualTo>
   </And>
</Filter>

 

Hope this can be of any help.

Badge +1

Hi @ssisman06,

Not sure if you already found a proper solution to your problem. I seems to me that there are two items you liked answered:

  1. Is there a work around for the WFS limitation of querying 1000 features at a time?
  2. Can two queries be combined?

A useful link to both items can be found from the question:

https://knowledge.safe.com/questions/39574/wfs-reader-filtering-a-non-spatial-class-by-attrib.html

 

1.

As is discussed there, if the WFS has support for version 2.0.0 you might be able to use WFS paging. You can check this from a 'GetCapabilities' request, i.e.: http://cbsservis.tkgm.gov.tr/tkgm.ows/wfs?request=GetCapabilities&service=WFS.

Unfortunately I noticed that the WFS requires a login, so I can't do this for you. Anyway, you should check for some XML fragment similar to the following:

0684Q00000ArLqvQAF.png

When supported by the WFS server, within the WFS parameters you can set the 'Start Index' to 0 and the 'Count' to 1000 to 'stack' feature requests per 1000.

 

2.

Yes, it might be possible to combine both an attribute query and a spatial query. This depends on the XML filter expressions that are supported by the WFS server (again check the 'GetCapabilities' of the WFS server). The following XML filter combines a bounding box and an attribute query. Of cource the coordinates still need to be changed to suit your specific demands.

<Filter>
   <And>
      <BBOX>
         <ValueReference>Geometry</ValueReference>
         <Envelope srsName="urn:ogc:def:crs:EPSG::4326">
            <lowerCorner>10 30</lowerCorner>
            <upperCorner>35 45</upperCorner>
         </Envelope>
      </BBOX>
      <PropertyIsEqualTo>
         <ValueReference>durum</ValueReference>
         <Literal>3</Literal>
      </PropertyIsEqualTo>
   </And>
</Filter>

 

Hope this can be of any help.

h? @thijsknapen ;

 

thank you, I solved the problem
  • <Filter>
    <And>
    <PropertyIsEqualTo>
    <PropertyName>durum</PropertyName>
    <Literal>3</Literal>
    </PropertyIsEqualTo>
      <Intersects>
        <PropertyName>geom</PropertyName>
        <gml:Polygon>
            <gml:outerBoundaryIs>
                <gml:LinearRing>
                    <gml:coordinates>@Value(_indices{0}.x),@Value(_indices{0}.y) @Value(_indices{1}.x),@Value(_indices{1}.y) @Value(_indices{2}.x),@Value(_indices{2}.y) @Value(_indices{3}.x),@Value(_indices{3}.y) @Value(_indices{4}.x),@Value(_indices{4}.y)</gml:coordinates>
                </gml:LinearRing>
            </gml:outerBoundaryIs>
        </gml:Polygon>
    </Intersects>
    </And>
    </Filter>

Reply