Sort a shape data set
sortshp \kx [ infile outfile item [ascending | descending] | -v]
sortshp sorts a Shape data set based on a single column in ascending or descending order. Supports INTEGER, DOUBLE and STRING column types. Useful for prioritizing shapes for rendering and/or labeling.
The idea here is that if you know that you need to display a certain attribute classed by a certain value, it will be faster for MapServer to access that value if it is at the beginning of the attribute file.
infile
The name of the .shp file
outfile
The name of the .shp/.shx and .dbf files to create
item
Name of the field to sort on
ascending, descending
Sort order (default: ascending)
\*(T<-v\*(T>
Display mapserver version and build options.
This example uses a roads file ('roads_ugl') that has a field with road classes in integer format ('class1').
\*(T< sortshp roads_ugl roads-sort class1 ascending \*(T>
Result:
A new Shape data set named 'roads-sort.shp' is created with shapes sorted in ascending order, according to the values in the 'class1' field.
Figure 1: Attributes Before sortshp \$2 \(la\$1\(ra\$3
Figure 2: Attributes After sortshp