Package ca.spatial.table
Class ShapeSpatialIndex
java.lang.Object
ca.spatial.table.ShapeSpatialIndex
- All Implemented Interfaces:
SpatialIndex
Encapsulate access to a shapefile spatial index. This class
performs optimistic indexing. The set of records that are returned
will include at least the selection. The records will be tested
using a fast but approximate criteria, and some boundary records
may be included. Routines that use this class should perform
additional refinement on this list.
-
Constructor Summary
ConstructorsConstructorDescriptionShapeSpatialIndex(ShapeStore grs, boolean universe)
Create a spatial index from the features in an existing data setShapeSpatialIndex(String fileName, String indexName, Extent2D parentExtent)
Read an existing spatial index -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
dump(PrintStream out)
Print the index to the output streamvoid
exportToShapefile(String name)
Export the indexing structure to a shapefile.int
getDepth()
The depth of partitions in this indexThe extent of the index.int
Get the number of feature in this indexgetSelection(Extent2D e)
Retrieve a spatial selection.getSelection(Extent2D e, int offset)
Retrieve a spatial selection.void
Save this index to permanent files.toString()
-
Constructor Details
-
ShapeSpatialIndex
Create a spatial index from the features in an existing data set- Parameters:
grs
- The reference to the spatial data setuniverse
- Indicates if an additional universe polygon index record should be added. This is required for building indexes on polygon coverage data sets. It is never required for shapefiles.
-
ShapeSpatialIndex
public ShapeSpatialIndex(String fileName, String indexName, Extent2D parentExtent) throws IOExceptionRead an existing spatial index- Parameters:
fileName
- The name of the file containing the spatial index records. For shapefiles this is the sbn file.indexName
- The name of the file that indexes the spatial index records. For shapefiles this is the sbx file.- Throws:
IOException
-
-
Method Details
-
close
public void close() -
exportToShapefile
Export the indexing structure to a shapefile. This is diagnostic aid to help troubleshoot problems with spatial index encoding and decoding.- Parameters:
name
- The nameof the shapefile to create. The file will contain polygons for each indexed feature showing their coverage in the index.- Throws:
IOException
- Will throw a IOException if there is trouble while creating the shapefile.
-
getExtent
The extent of the index. Note that this is the bounding box of all features in single precision floating point- Specified by:
getExtent
in interfaceSpatialIndex
-
getDepth
public int getDepth()The depth of partitions in this index -
getRecordCount
public int getRecordCount()Get the number of feature in this index -
getSelection
Retrieve a spatial selection. The selection is fast and optimistic, including records that are likely to be in the selection. The returned set may include additional boudary records and so should be checked using a more refined test to see if the records actually match.This method is equivalent to
getselection(e, 0);
- Specified by:
getSelection
in interfaceSpatialIndex
- Parameters:
e
- The rectangle that represents the spatial query
-
getSelection
Retrieve a spatial selection. The selection is fast and optimistic, including records that are likely to be in the selection. The returned set may include additional boudary records and so should be checked using a more refined test to see if the records actually match.- Specified by:
getSelection
in interfaceSpatialIndex
- Parameters:
e
- The rectangle that represents the spatial queryoffset
- This parameter indicates how records in the index relate to records in the data set. Most data sets have a one-to-one relationship and this parameter should be zero. Polygon coverages have a universe polygon which is ignored, so in this case specify an offset of 1.
-
dump
Print the index to the output stream- Specified by:
dump
in interfaceSpatialIndex
-
toString
-
saveIndex
Save this index to permanent files. The index is saved in two parts:- The index data, containing the search tree
- The index to the index, containing direct access record pointers.
Spatial file magic numbers Data set type Data name Index name Magic1 Magic2 Any shapefile filename.sbn filename.sbx 9994 -400 Point coverage coverage/xbn.adf coverage/xbx.adf 9994 -46 Line coverage coverage/abn.adf coverage/abx.adf 9994 -47 Polygon coverage coverage/pbn.adf coverage/pbx.adf 9994 -48 - Parameters:
dataName
- The name of the file to store the index data in toindexName
- The name of the file to store the direct access pointers in to.magic1
- The first magic numbermagic2
- The second magic number- Throws:
Exception
-