shptreetst

Purpose

Executes a spatial query on an existing spatial index (.qix), that was created by the shptree utility. This utility is useful to understand how a search of a Shape data set and its qix index works.

Syntax

shptreetst shapefile {minx miny maxx maxy}

Example

shptreetst esp 879827.480246 4317203.699447 884286.289767 4321662.508967

  This new LSB index supports a shapefile with 48 shapes, 4 depth
  shapes 6, node 4, -13702.315770,3973784.599548,1127752.921471,4859616.714055
  shapes 5, node 3, -13702.315770,3973784.599548,614098.064712,4460992.262527
  shapes 1, node 1, -13702.315770,3973784.599548,331587.893495,4241748.814186
  shapes 1, node 0, 141678.278400,3973784.599548,331587.893495,4121164.917599
  shapes 1, node 0, 268807.855447,4193028.047889,614098.064712,4460992.262527
  shapes 1, node 0, 268807.855447,3973784.599548,614098.064712,4241748.814186
  shapes 7, node 4, -13702.315770,4372409.051076,614098.064712,4859616.714055
  shapes 1, node 0, -13702.315770,4372409.051076,331587.893495,4640373.265714
  shapes 3, node 1, -13702.315770,4591652.499417,331587.893495,4859616.714055
  shapes 1, node 0, -13702.315770,4712236.396004,176207.299326,4859616.714055
  shapes 2, node 0, 268807.855447,4372409.051076,614098.064712,4640373.265714
  shapes 3, node 2, 268807.855447,4591652.499417,614098.064712,4859616.714055
  shapes 2, node 0, 424188.449617,4712236.396004,614098.064712,4859616.714055
  shapes 1, node 0, 424188.449617,4591652.499417,614098.064712,4739032.817468
  shapes 2, node 1, 499952.540988,3973784.599548,1127752.921471,4460992.262527
  shapes 2, node 0, 499952.540988,4193028.047889,845242.750254,4460992.262527
  shapes 5, node 3, 499952.540988,4372409.051076,1127752.921471,4859616.714055
  shapes 1, node 1, 499952.540988,4372409.051076,845242.750254,4640373.265714
  shapes 1, node 0, 655333.135158,4372409.051076,845242.750254,4519789.369127
  shapes 1, node 0, 499952.540988,4591652.499417,845242.750254,4859616.714055
  read entire file now at quad box rec 20 file pos 1084
  result of rectangle search was
  8, 10, 36, 37, 38, 39, 42, 46,
Result

The above output from the shptreetst command tells us that the existing .qix index is for a Shape data set that contains 48 shapes; indeed the Shape data set used in this example, esp.shp, contains 48 polygons of Spain. The command also tells us that qix file has a quadtree depth of 4.

Most importantly, the resulting shape IDs (or feature IDs) that were contained in the bounding box that we passed in our example were returned at the bottom of the output: “8, 10, 36, 37, 38, 39, 42, 46”. You can use a tool such as QGIS to view those feature IDs and check what shapes MapServer is querying when a user clicks within that bounding box.