Subscribe to this thread
Home - General / All posts - M9 filtering a WFS connection using the BBOX filter
danb


1,935 post(s)
#15-Jun-22 20:57

I have been trying to connect to a Land Information New Zealand (LINZ) WFS service and filter the data to a given extent and use the LINZ supported BBOX spatial filter (WFS spatial filtering | Toitū Te Whenua Land Information New Zealand (linz.govt.nz)).

If I paste the example for Geodetic marks into a browser, I get a bunch of XML returned defining the filtered points for this layer as expected. I had assumed that I could simply take this string and paste it into the ‘Source’ box in the ‘New Data Source’ dialogue for a WFS connection. This appears to work and the ‘Edit Query’ button gives the following query text:

--SQL9 

CREATE DATASOURCE [WFS DATASOURCE] (

  PROPERTY 'Source' '{ "Source": "https:\\/\\/data.linz.govt.nz\\/services;key=YOUR_API_KEY\\/wfs?service=WFS&version=2.0.0&request=GetFeature&typeNames=layer-50787&cql_filter=bbox(shape,-36.764156,174.975230,-36.817467,175.023120)", "SourceAgent": "Mozilla\\/5.0 Manifold\\/9.0", "SourceCache": true, "SourceCacheTemp": true, "SourceUuid": "6b0ab626-ea7f-4fd3-a63b-630da9a5d467" }',

  PROPERTY 'Type' 'wfs'

);

If however I run this query to build the WFS datasource, Manifold returns all LINZ WFS layers at the full extent. Does anyone know what is going on? Is the BBOX filter part not supported by Manifold? I had assumed that the filtering would occur on the server and just the filtered results be returned.

It would be great to get to the bottom of this as connecting to a whole of country WFS layer and then filtering on the Manifold side is like pulling teeth. A method to expedite or mitigate this would therefore be very useful.

Thanks in advance

Note where it says YOUR_API_KEY in the query string, this must be replaced with a free API key. To get this go to LINZ Data Service, click on sign in and make an account.


Landsystems Ltd ... Know your land | www.landsystems.co.nz

danb


1,935 post(s)
#15-Jun-22 21:51

Oops. Just notice that my link to the spatial filtering examples hasn't come through.

WFS spatial filtering | Toitū Te Whenua Land Information New Zealand (linz.govt.nz)

or my link for the LINZ data service

LINZ Data Service


Landsystems Ltd ... Know your land | www.landsystems.co.nz

oeaulong

408 post(s)
#16-Jun-22 00:19

That site is the motherload of data. I am amazed.

There are so many layers I don't know which could test the bbox() function.

Trying one at random, and will let you know.

What connected:

in the New Data Source dialog for the Source field: I posted the WFS spatial filtering link with the bbox() and it was truncating along the soft returns. checking in a comments, yes there were some return characters that was causing the problems. pulling out that white space allowed the connection....<going to check> not looking pretty with Manifold unresponsive.

double check your created Source url and I think you may have better luck.

cheers.

oeaulong

408 post(s)
#16-Jun-22 01:03

It didn't return the bbox() exclusively for the "NZ Geodetic Marks". sorry.

danb


1,935 post(s)
#16-Jun-22 01:54

Thanks for having a look. I have subsequently got it to return just the one layer but I can't get the filter to work despite getting it to work in FME.


Landsystems Ltd ... Know your land | www.landsystems.co.nz

Dimitri

7,025 post(s)
#16-Jun-22 06:11

Could it be you are using a malformed URL? One way to find out is to take your URL, eliminate the \\ escapes, and try it out in a browser. That results in error messages. If a browser cannot connect using the URL, Manifold will not be able to do so either.

adamw

10,011 post(s)
#16-Jun-22 08:27

The link is a request to a WFS server. You can create a WFS data source based on that link (I tried doing this by copy-pasting the link from the text above, unescaping the escapes, replacing YOUR_API_KEY with a real API key, etc, it worked the first time), but the result will be a WFS data source, not a single WFS request. The WFS data source issues its own requests, eg, it starts with request=GetCapabilities (if I remember the verb correctly), and it will be issuing request=GetFeature for the specific layers as you work with them. It will also do its own rect filtering, cql_filter=bbox(...) and other parameters that appear in your string that the data source won't deem as needed (or won't understand the meaning of) will just be stripped out.

It sounds like you want a function that would take a URL for a WFS request, run it, then return the result as a table. We'll consider adding something like this in the future.

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.