Zsort ?

Attila Csipa plists at PROMETHEUS.ORG.YU
Thu May 17 11:16:23 EDT 2007


On Thursday 17 May 2007 16:10, Daniel Morissette wrote:
> Doesn't the sortshp command-line program allow you to do this already?
> http://mapserver.gis.umn.edu/docs/reference/utilityreference/sortshp

That is for static datasets and a (small number of) predefined criteria. If 
you have new values being added to the end of the shapefile, it is also very 
costly to invoke sortshp after each shape being added. Also, if you have 
several columns that might be used as sort criteria (example: we have a dbf 
with multiple timestamps, or different keys (like total weight, number of 
container items, etc) it becomes cumbersome to keep all of these as separate 
data sets, especially if they are large.

> I am also worried that an ORDERITEM keyword/mechanism would be awfully
> slow on large shapefiles since the primary index used to fetch shapes on
> large files is the spatial index (.qix). There is currently no attribute
> index support on shapefile DBF's in MapServer and even if we added that,
> the primary index would remain the spatial index so I can't see how we
> could easily implement dynamic ordering of shapes without hurting
> performance.

If you are really strapped for speed, nothing will beat a pregenerated data 
set, like the one generated with sortshp above, but I feel that is an 
optimization question (like having qix-es in the first place). I don't think 
the sort itself would take too much time (if you are drawing a million+ 
shapes after the spatial filtering you're in trouble anyway), and you _could_ 
use the attribute indexes - the spatial index is more of a filter in this 
case, you just need one extra pass to leave out the items not picked up by 
the qix, but since the order inside the attribute index is preserved it 
should be fairly quick (even for large datasets). This is basically a B+ tree 
pruning problem IINM.



More information about the mapserver-dev mailing list