-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
No Possibility of Effectively Limiting Data Query Results When Using Time Dimensions #6952
Comments
I think that creating new class called LIMIT within Layer would be a good idea. Then users will be able to define maximal number of rendered features within layer based on data after filtrations. |
Does setting MAXFEATURES to 10 give you the result you want? |
No, I believe that MAXFEATURES defines the number of images to be drawn, so if I will have my data i descending cloud cover order then on top of my service I will have the Tenth worst image. If I will have my data i ascending cloud cover order then the one on top would be the Tenth best image. t. In my case, as you can see: DATA 'geometry from (select * from mrc order by maxcc desc) as subquery using unique unique_id' I'm selecting all of the images, but I only need to render the top ten, meaning the last ten images in the order, with the one on top being the best. |
As I wrote, the "order by" in its current form returns the column in the following order: maxcc Let's assume I need the last 5, which are: 75% And they must be in the order so that the image with 0% cloud cover is at the top. In the example you mentioned, the column is sorted by the column name. Let's assume that my column will be ordered in the following way:
90%
0% So in both situations, the best image will not be returned at the very top. |
Is your use case somewhat similar than the one in #5899? Would that serve also your needs? Start filling pixels of the output image starting from the best source image within the time window until all the pixels are filled. Then stop. |
You currently have your ORDER BY within the subquery. The SQL Server driver allows this to be moved to the outer query, so records are ordered after the time filter has been applied and not before. In this case you'd have filtered out the 90% values and then records would be ordered as follows: 75% |
@geographika I guess for now this is how it should be done? #5008 (comment) |
@jratike80 |
It is a feature request, not implemented. If it was implemented it would work with any sorted tileindex features. User decides what is the best just like you want to do by sorting the images with ORDER BY maxcc DESC. The difference would be that there would be no need to use LIMIT for shortening the list. Mapserver would take all pixels which are not nodata from 0% and then automatically try to fill the holes from 10%, 50% and so on. Because this is not implemented we are not using the native TIME support of Mapserver. We have additional time attributes in the tile index. The WMS GetMaps from standard WMS-T clients contain the
Order by is still needed because there may be several images from the same time and then we want to render the one with smallest pixel size last. Isn't that the same use case that you have? We just prefer small pixels but you would like to prefer low cloud coverage. |
This is practically the same situation. Okay, now I fully understand the process of selecting images for rendering. You work around the lack of implementation of this functionality by using a time parameter that is not the TIME dimension. But from my experience with MapServer, the last rendered image is the one on top. I understand how to make MapServer recognize the best image, but how do you make it recognize NoData and use the second best image to fill in the gaps and also do not overlap actual data from the first/best image? Or Is it also an unimplemented feature, and just an idea? |
Correct - the ORDER BY isn't as yet implemented in the PostGIS driver, It would need similar changes to e653b9b added. |
My experience since this https://lists.osgeo.org/pipermail/mapserver-users/2008-April/055317.html is the opposite. Mapserver takes the first image that it gets from the tileindex (the one on top) renders it, takes the next image, renders that above the previous etc. What remain on the top of the final rendered image is the one that was on the bottom of the image list from the tileindex. You can see Mapserver in action here https://kartta.paikkatietoikkuna.fi/?zoomLevel=8&coord=433861.1118164062_6947879.803305684&mapLayers=801+100+default,3400+100+ortokuva:indeksi×eries=1950&uuid=90246d84-3958-fd8c-cb2c-2510cccca1d3&noSavedState=true&showIntro=false I can see from your debug info above that when time dimension is used with WMS-T Mapserver generates a query like this However, Mapserver does not sort the selected tileindex rows. I think it should do |
There are two separate things: how Mapserver behave now and how it could behave for being more efficient. The current way is to use the painters algorithm.
The pixels from this raster should go to the top of the resulting raster which means that by the painters method it must be rendered last, and that means that the image must appear last in the list that is returned by the "select" from the tileindex.
It is not possible now. Painters algorithm keeps on rendering till the end of the image list. What Mapserver does is
The painters algorithm is making a good end result: every pixel comes from the most valuable source image but it is heavy and slow if there are many overlapping images in the source image list that is selected from the tileindex. |
For comparison, Geoserver has an option named ExcessGranuleRemoval for avoiding unnecessary rendering. I found documentation from https://docs.geoserver.geo-solutions.it/edu/en/raster_data/mosaic_pyramid.html. The system filters out images (granules in Geoserver language) based on their footprints. Documentation about how Geoserver handles the footprints in https://docs.geoserver.geo-solutions.it/edu/en/raster_data/imagemosaic_footprint.html#geoserver-imagemosaic-footprint. |
@geographika Is there any possibility of implementing the LIMIT class in the near future? |
The possibility of stopping rendering data when every pixel is covered seems like an amazing performance improvement opportunity. I'm rooting for this to happen someday! |
@MathewNWSH - I'm not currently a user of the PostGIS drive so no plans on implementing this in the near future. You could try making the modifications and submitting a pull request, or sponsoring adding this feature to MapServer. |
Is the algorithm associated with the solution well known? |
Would it be possible to add MAXFEATURES_FIRST MAXFEATURES_LAST along with the MAXFEATURES keyword in order to select first/last N features? This would resolve the problem mentioned by @MathewNWSH |
Expected behavior and actual behavior.
This ticket is based on my experience described in the mailing archive: https://marc.info/?t=169770835500001&r=1&w=2
To summarize, I've discovered that it's not possible to limit the DATA query result when the TIME dimension is enabled. The layer data source is constrained when opening the data source, and by using the LIMIT clause as described here: https://mapserver.org/input/vector/postgis.html#data-access-connection-method, it limits the source data at the beginning. Subsequent filtration based on dimensions only operates on this already limited dataset.
I can think of two potential solutions:
However, this approach might limit the types of requests you can use, as mentioned here:
Attach simple test case (drag/drop it here)
Mapfile example:
example request:
And mapserver LOG which I get after receiving NoData layer:
Operating system
Ubuntu 20.04 LTS
MapServer version and installation method
Mapserver 7.6.4 and Mapserver 8
The text was updated successfully, but these errors were encountered: