Function suggestion

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Function suggestion

Martin Schäfer
Message
Hi,
 
I'd like to suggest two functions to be added to postgis, which I would find really useful. Hopefully others would too.
 
extent_estimated(<schema>, <relation>, <column>)
 
returns the extent of the specified spatial column as calculated when update_geometry_stats() was executed the last time (histogram2d contains the information). Obviously the result will not always be up-to-date, but often it will, and even if it isn't then it is quite likely within the ballpark. This function would allow a viewer application to zoom in quickly to where the data lies. Calculating the exact extent takes way too long if the table has, say, a couple of 100,000 rows. An outdated value of the extent is good enough in this case, as long as it can be found within O(1) time.
Alternatively, the geometry_columns schema could be modified by adding an 'extent' column which gets updated whenever update_geometry_stats() is executed.
 
is_spatially_indexed(<schema>, <relation>, <column>)
 
returns true or false depending on whether a spatial index exists on this column in the table or view. Again a viewer application would benefit from knowing in advance that a spatial query on this column will take a very long time, in which case it would be better to refuse to display the geometries altogether, rather than present the user with an unresponsive or seemingly 'hanging' user interface for zooming and panning.
 
Does this make sense?
 
Martin