Skip to main content
Solved

Can't get a dynamic URL to work properly in the OGC WFS FeatureReader

  • February 25, 2025
  • 7 replies
  • 112 views

scottpool
Contributor
Forum|alt.badge.img+2

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.

Best answer by oliver

Hi ​@scottpool!


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 first approach 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 second approach would of course be an XML filter expression.
Please consult my wiki:
https://olivers-expression-lab.gitbook.io/filter-expressions-in-fme/spatial-operators#bbox

 

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:


/wfs/layer-106965/?service=WFS&BBOX=xmin,ymin,xmax,ymax

Please replace xmin etc. by your coordinate values.

 

OGC Web Services Common Standard

Hope, this helps?

 

PS:

@nielsgerrits - Many thanks for the flowers! 👍

 

 

View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

nielsgerrits
VIP
Forum|alt.badge.img+54

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.

Please also see this excellent piece of documentation / article / tutorial https://olivers-expression-lab.gitbook.io/filter-expressions-in-fme/spatial-operators by ​@oliver which will save you a lot of time.


oliver
Contributor
Forum|alt.badge.img+6
  • Contributor
  • Best Answer
  • February 26, 2025

Hi ​@scottpool!


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 first approach 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 second approach would of course be an XML filter expression.
Please consult my wiki:
https://olivers-expression-lab.gitbook.io/filter-expressions-in-fme/spatial-operators#bbox

 

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:


/wfs/layer-106965/?service=WFS&BBOX=xmin,ymin,xmax,ymax

Please replace xmin etc. by your coordinate values.

 

OGC Web Services Common Standard

Hope, this helps?

 

PS:

@nielsgerrits - Many thanks for the flowers! 👍

 

 


scottpool
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • February 27, 2025

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!


oliver
Contributor
Forum|alt.badge.img+6
  • Contributor
  • February 27, 2025

@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


scottpool
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • March 3, 2025

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


bjarne
Contributor
Forum|alt.badge.img+5
  • Contributor
  • March 4, 2025

You can also build valid WFS urls and use a httpCaller to get feature


oliver
Contributor
Forum|alt.badge.img+6
  • Contributor
  • March 5, 2025

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 swapped
Maybe 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.

I get 48 tiles.

Built-in BBOX filter
Result: 48 tiles

Kind regards from Germany to New Zealand

Oliver


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings