-
-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WFS maxFeatures support broken in many cases. #4011
Comments
|
Author: myOpenLayersUName I was able to successfully perform the queries with filters and maxFeatures. Yay!!!! You can't see it, but I'm doing a 'very' 'happy dance' in my cubicle! |
|
Author: adube |
|
Author: assefa Pagination support with WFS: the wfs request can send a startindex and a maxfeatures. The startindex is an integer value the allows users to paginate through a set of results. Current support is done at 2 levels:
With the patch proposed in this bug, we also need to take into account the startindex and apply the logic in the query and draw functions. |
|
Author: sdlime If no pagination is necessary then the drivers wouldn't limit things on their side and would let MapServer do it (as in the patch). Steve |
|
Author: aboudreault |
|
Author: sdlime
Which driver? I may have been a bit overzealous in my gutting of the Oracle and/or PostGIS code. My thinking now is that we'd only use maxfeatures IF start index is set as well. Steve |
|
Author: aboudreault |
|
Author: rouault |
|
Author: sdlime
Try backing out the patch for mappostgis.c and test again. It rally shouldn't matter if the driver tries to honor maxfeatures. Steve |
|
Author: aboudreault |
|
Author: aboudreault |
|
Author: aboudreault |
|
Author: sdlime Steve |
|
Author: aboudreault |
|
Author: aboudreault |
|
Author: aboudreault |
|
attachment http://trac.osgeo.org/mapserver/attachment/ticket/4011/4011.patch : |
|
Been thinking about this more. I'm not convinced at this point we can do this on the driver side unless the driver fully supports common expressions (used for attribute and shape queries). The reason is that we don't know that a feature is in the result set unless is passes filtering in the query functions. The exception might be bounding box queries where the bbox is applied solely on the driver side. I'm not sure the performance will be that bad. Ok, it will be with paging as you reach the latter pages but that's unavoidable unless everything can be done on the driver side. Setting max features is the far more useful use case and there is really no penalty doing that check on the query function side since you don't have to send extra features over the wire. Personally I'd like to drop paging support in 6.2. It flat out doesn't work except for the most basic (bbox) query type. If we can limit paging to that case then that would be ideal- don't know if that's possible. I had envisioned that drivers would be able to examine filters to decide if they could support them, there's a layer API function for that purpose. If a driver supported a filter and supported paging then we could things on the driver side, otherwise it should be purely on the MapServer side. Steve |
|
cc @sdlime , I begin to check this ticket |
|
@sdlime, do you have a test case I could use to be sure I understand the isse and the desired result. Something that use shapefile and/or postgis with FILTERS and good examples of the issue with the expressions? |
|
Here's the issue, let's say a user issues a query (either straight MapServer or via WFS) to intersect a geometry and apply an attribute filter against a PostGIS-based layer. The problem is that the full query isn't executed in PostGIS. All we do in PostGIS is a bbox query to get candidate shapes and the other tests are done within MapServer. In a case like this you can't do the maxresults or paging computations on the database side since you have no idea if geometry met the filter criteria. See what I mean? It's always been this way except for a couple of simple cases (Assefa would be able to detail). Complex filters are really quite expensive in this regard because we basically have to process every feature on the MapServer side. Using something like a shapefile or other local data this isn't that big a deal, sucks for network-based resources. Really need to work on a Common Filters => SQL capability to push everything to the database whenever possible. I think we need to develop an RFC. I'm of the opinion that we should keep this out of the 6.2 release. The patches would still be available for users not using PostgreSQL/Oracle. Steve |
|
I think I understand. The issue cannot be fixed easily. The only easy solution would be to do what you wanted initially... handling the maxfeature/pagination in mapserver. However, this will highly affect the performance of database backends. I agree that we should keep this out of 6.2 and write a RFC. |
|
I think it only highly affects performance w/pagination. With maxfeatures the database server is delivering no more data than it would normally would. |
|
We have a few featuretypes with more than million rows and we would still be able use WFS for delivering the whole dataset for users. Paging with plain GetFeature would suit that use case perfectly. Could it be possible to support paging already in 6.2 if GetFeature is sent without a filter? Even better if BBOX could be supported. Paging is not officially supported by WFS 1.0.0. and 1.1.0 so we can consider it as a vendor option and then it would not be critical to omit it with filters. |
|
@sdlime, could we do that for WFS Getfeature requests: 1- If the layer does not have FILTER set, do the maxfeature + pagination in drivers (mostly for DB backends). This should be well documented in the migration guide. Would be nice to get this for 6.2. What do you think? |
|
@aboudreault This would work for our purposes as we try not to set the filters at the WFS level but move them to the sql level so they get processed by the database driver (oracle) |
|
Ok, looking at this now. I think in general this is the right approach. I understand that layer->paginate means supporting both paging and maxfeatures, correct? In regards on when to enable: DrawVectorLayer() (mapscript draw calls?) - Actually layer->maxfeatures has long been supported for drawing from the CGI or MapScript. In fact that's what it was added for originally. It's an easy to deal with high resolution data. For example, you might sort lakes by area and draw only the 50 largest in a single map draw. My guess is that this use should go away to avoid conflict w/query use. It's not a giant deal since you generally don't query these types of layers. Drawing uses a bbox so this is probably ok. msQueryByPoint - ok to enable msQueryByAttribute - ok to enable (I think) since the filter must be native to the RDBMS WFS GetFeature (if not complex filter set) - doesn't this just call the msQueryBy... functions? Regarding multiple layer types. It seems like we can just do paging/maxfeatures within each layer. I guess there's no harm in doing so although it makes little sense since there's no way to control paging/maxfeatures on a by/layer basis. Steve |
|
Alan, can we do this without adding the paging parameter to a layer? nice to avoid more complications there and most drivers won't ever support this. Could store in driver layer info... Not a giant deal but I thought I'd bring it up. |
|
@sdlime , I've made a new patch at: http://download.osgeo.org/mapserver/tickets/b4011-150612.patch The paging flag is not at driver level. Since there is a reset in all msQueryBy* function, (layer close/open), you'll see that I've been force to get the paging to be able to restore it, so I've also added a msLayerGetPaging function. Otherwise, thing was just reseted. Basically, the queries behavior: msQueryByPoint: Driver pagination enabled. In mapwfs.c, I set the paging to MS_FALSE if it's a complex query and/or if the request is made on more than 1 layer. |
|
Does the WFS code actually try to execute queries independently of the msQueryBy... functions? Was the maxfeatures check yanked from the shapefile driver (should be)... Steve Sent from my iPad On Jun 15, 2012, at 11:04 AM, Alan Boudreaultreply@reply.github.com wrote:
|
|
@sdlime , No, well not that I am aware. WFS getfeature call msQueryBy*. Yes the maxfeatures check has been removed from the mapshape.c driver. |
|
I've just committed my changes in master in 0d4eef8. |
|
Saw you committed, woot! Sent from my iPad On Jun 20, 2012, at 6:35 AM, Alan Boudreaultreply@reply.github.com wrote:
|
|
Compiling master without postgis support enabled seems broken: mappostgis.c: In function 'msPostGISEnablePaging': Steve |
|
is there any need for documenting this one, or can it be closed now ? |
|
wfs_filter_startindex2.xml autotest is failing.
wfs_filter_startindex.xml is also failing, but that is only a question of ordering compared to what is expected. For wfs_filter_startindex2.xml it seems more serious. |
|
The startindex was badly handled. There was a maxfeature check in all msQuery functions but the startindex was handle in mapgml.c. So, most of the time there was not enough features in the resultcache when the startindex was set. ie. maxfeature=3 with startindex=10: FAILS... there was only 3 features in the cache.
@sdlime - Questions:
|
|
"Should I remove totally the maxfeature parameter in msGMLWriteWFSQuery ? I don't think we need it anymore" Yes... Maxfeatures should be applied at query time. The template code allows some limiting through the tags themselves but that's a different mechanism. "There are some code in mapwfs.c, line 2416 which I'm not sure..." My understanding is that all WFS queries are handled through the msQueryBy... functions so you are correct. There's also code around L2383 (branch-6-2) that also takes maxfeatures into account. Offhand I'd say that isn't needed because maxfeatures is applied before hand. However, looking at that code it looks like maxfeatures is applied across layers and we're doing it within layers (which I think is more reasonable). I don't know the WFS specification well though. Do you? Steve |
|
"However, looking at that code it looks like maxfeatures is applied across layers and we're doing it within layers (which I think is more reasonable)" If you mean a case where request is having a list of layers and maxfeatures |
|
Couple of questions:
If we do have to make it query-wide then we may have to do some things differently:
Likewise, paging becomes a global operation (startindex also exists in the queryObj). Steve |
|
Hi, MaxFeatures can be used for protecting WFS server because it can be set on the server side too and clients cannot override (hopefully) the setting. Mapserver, Geoserver and TinyOWS all support setting MaxFeatures on server side. My TinyOWS does not seem to advertise it but Mapserver does DefaultMaxFeatures is on page 86, table 7b in the WFS 1.1.0 standard. -Jukka- |
|
Will have to let Alan react. I think it's still very manageable. Just need the global values to alter layer values (down, not up if they are already set). Steve |
|
I've modified WFSGetFeature to support maxfeatures across layers. Here's the current behavior of MS: WFSGetFeature:
MapScript:
I'm a little bit concerned about my change in a beta release...... haven't been able to test all queryBy* functions. |
|
"maxfeature+startindex/1 layer: driver pagination disabled", should that be enabled? Seems like with only one layer in play many drivers can support both. Where is global maxfeatures stored? We could add a means in MapScript of setting global maxfeatures/startindex values I suppose but really I think the within layer behavior makes the most sense anyway. |
|
sorry, was a typo: maxfeature+startindex/1 layer: driver pagination enabled. global maxfeatures/startindex are stored in the queryObj. But I also think we should let things are they are now using mapscript. The maxfeatures server protection is more a standard of WFSGetFeature. |
|
considering this one closed now |
Reporter: sdlime
Date: 2011/09/06 - 14:48
Trac URL: http://trac.osgeo.org/mapserver/ticket/4011
Passing a value for maxFeatures in a WFS request doesn't work in some cases. This is because of how that filtering is done relative to FILTER processing. Since FILTERs are used increasingly for both attribute and some spatial filters (e.g. intersect) this becomes a problem. The layerObj maxfeatures property is used...
Presently it's up to a driver to apply maxfeatures, for example, PostGIS sets a limit on the SQL statement. Not all drivers implement this so it's impossible to use maxFeatures in some cases. A better solution would be apply feature counting in the query and drawing functions that request geometries from drivers. This allows for all drivers to be supported and makes it possible to count results after all requisite filters have been applied.
Steve
The text was updated successfully, but these errors were encountered: