Can't get a dynamic URL to work properly in the OGC WFS FeatureReader
Hi,
I’m trying to use the OGC WFS FeatureReader to read in features based on a dynamic URL stored as an attribute. This is because in the URL link, I want to have a bounding box parameter that changes based on the extent of another dataset. I.e., I only want to read in the features that are within the bounding box of another dataset.
I’ve set up an attribute “URL” that contains the bounding box parameter.
When I hard-code in the URL with the bounding box parameter into the FeatureReader, it works as expected and reads in only the features within the bounding box.
If I replace the URL with the dynamic “URL” attribute, it ignores the bbox parameter and reads in everything. I
And yes, I’ve confirmed that the dynamic URL attribute is exactly the same as what I’ve hard-coded into the FeatureReader that works. Does anyone have any idea how I can fix this? Or any other ways I can read OGC WFS features with a dynamic bounding box?
I’ve tried the Spatial Filter parameter in the FeatureReader too and I can’t get it working. Would prefer dynamic URL requests in case I want to add more parameters though.
UPDATE:
I haven’t changed anything between the two FeatureReaders but now I can’t get either of them to filter by the bounding box parameter. On the other hand, hard-coding the URL into a normal Reader works perfectly every time.
Page 1 / 1
If I needed this, I simply would feed a geometry with the boundingbox to the FeatureReader and use the FeatureReader’s Spatial Filter.
But if you want to have more control, in the FeatureReader under Parameters, you are able to enter a XML Filter Expression. I think this is the place where Safe expects to put the boundingbox parameters.
First of all, a few preliminary remarks. 1) The part “&request=GetCapabilities” in your WFS-URL should be superfluous in my opinion. The URL should also work without it.
2) Please open the GetCapabilities document of your WFS service and check the default coordinate system <wfs:DefaultCRS>. Your BBOX-coordinates must be in DefaultCRS, if you don’t specify a different CRS for the BBOX.
3) I have no idea about the Common Query Language (CQL) you’re using, but I’ll try to give you some other hints.
My firstapproach would be the same as the one suggested by @nielsgerrits. Take your BBOX-coordinate values and create a BBOX-geometry by using the 2DBoxReplacer-Transformer. If you already have a geometry, please replace it by the BBOX.
Then send the BBOX-geometry to the FeatureReader. In FeatureReader Constraints please set Spatial Filter to “Bounding Boxes OGC-Intersect”.
Spatial Filter: BBOX
FeatureReader fetches the BBOX-coordinates and integrates them into the WFS request.
You may verify this by having a look into the Translation Log, please search for <WFS> GetFeature URL.
My third approach would be a dynamic URL, similar to the one you tried, but without CQL-syntax. According to OGC Web Services Common Standard and the WFS Standard, the BBOX can be passed KVP (Key Value Pair) encoded as part of the service URL like this:
Please replace xmin etc. by your coordinate values.
OGC Web Services Common Standard
Hope, this helps?
PS:
@nielsgerrits - Many thanks for the flowers!
Thanks both @nielsgerrits and @oliver for the help!
I tried the first approach of using the Spatial Filter with the bounding box geometry again. For some reason I just can’t get it to work, I’m not sure why
What did work was the third approach suggested by @oliver - works perfectly now in the FeatureReader so thanks for those tips. However, I will take a look into the XML filtering options as well when I’ve got some more time on my hands
Thanks for taking the time to help and providing all that info!
@scottpool , fine!
If the WFS is public available without credentials, please let me know the WFS-URL.
I can have a look…
Best regards
Oliver
sorry for the delay @oliver , it’s available on this New Zealand government agency website called LINZ here: NZ 1:500 Tile Index | LINZ Data Service. However, you do need to make a free account to create the API key, so yeah not really available without credentials sorry
You can also build valid WFS urls and use a httpCaller to get feature
Hi @scottpool!
This has left me no peace.
So I got an account and an API-key from LINZ and tried it out.
First conspicuous feature: 5458856.7335033035,1762303.2917200956,5460668.162203304,1764145.6364200956
It seems to me that your coordinates shown above (in your screenshot) have the wrong range sequence (YMIN,XMIN,YMAX,XMAX), if they are in EPSG:2193?
When I display it, the BBOX looks like this:
Wrong order of coords?
If I reverse the order of the coordinates, I get this BBOX.
X and Y swappedMaybe the BBOX you wanted?
I assume this was your intention?
If this is the case, then Bounding Boxes OGC-Intersect] also works as expected in FeatureReader.