|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.bbn.openmap.layer.shape.ShapeUtils
com.bbn.openmap.layer.shape.SpatialIndex
A Spatial Index is a variation on a Shape Index, adding the bounding box of the shape to the index.
The file has a 100 byte header identical to a Shape Index followed by n records.
The record layout of the spatial index is as follows:
Position | Field | Value | Type | Byte Order |
Byte 0 | Offset | Offset | Integer | Big |
Byte 4 | Content Length | Content Length | Integer | Big |
Byte 8 | Bounding Box | Xmin | Double | Little |
Byte 16 | Bounding Box | Ymin | Double | Little |
Byte 24 | Bounding Box | Xmax | Double | Little |
Byte 32 | Bounding Box | Ymax | Double | Little |
file.ssx
from shape file
file.shp
.
ShapeIndex
Nested Class Summary | |
static class |
SpatialIndex.Entry
|
Field Summary | |
protected ESRIBoundingBox |
bounds
The bounds of all the shapes in the shape file. |
protected DbfHandler |
dbf
The handler for dbf file information. |
static int |
DEFAULT_SHAPE_RECORD_SIZE
Default size for shape record buffer. |
protected java.util.List |
entries
A cached list of the SpatialIndex file entries, for repeated reference. |
protected javax.swing.ImageIcon |
pointIcon
The icon to use for point objects. |
static int |
SHAPE_FILE_HEADER_LENGTH
Size of a shape file header in bytes. |
static int |
SHAPE_RECORD_HEADER_LENGTH
Size of a shape file record header in bytes. |
protected BinaryBufferedFile |
shp
The shape file. |
protected java.lang.String |
shpFileName
The file name for the shape file, for opening/reopening. |
static int |
SPATIAL_INDEX_HEADER_LENGTH
Size of the spatial index header in bytes. |
static int |
SPATIAL_INDEX_RECORD_LENGTH
Size of the spatial index record in bytes. |
protected BinaryBufferedFile |
ssx
The spatial index file. |
protected java.lang.String |
ssxFileName
The file name for the spatial index file, for opening/reopening. |
Constructor Summary | |
SpatialIndex(java.lang.String ssxFilename)
Opens a spatial index file for reading. |
|
SpatialIndex(java.lang.String ssxFilename,
java.lang.String shpFilename)
Opens a spatial index file and it's associated shape file. |
Method Summary | |
boolean |
close(boolean done)
|
static void |
createIndex(java.lang.String inFile,
java.lang.String outFile)
Creates a spatial index for a shape file. |
void |
dumpIndex(boolean showBounds)
Displays the contents of this index. |
java.util.Iterator |
entryIterator()
Provides an iterator over the SpatialIndex entries. |
java.util.Iterator |
entryIterator(GeoCoordTransformation dataTransform)
Provides an iterator over the SpatialIndex entries. |
ESRIBoundingBox |
getBounds()
Get the box boundary containing all the shapes. |
DbfHandler |
getDbf()
|
EsriGraphicFactory |
getFactory()
The factory is used to filter and create OMGraphics from a shape file. |
OMGraphic |
getOMGraphicAtOffset(int byteOffset,
DrawingAttributes drawingAttributes)
Skips the BinaryFile for the shp data to the offset and reads the record data there, creating an OMGraphic from that data. |
OMGraphicList |
getOMGraphics(double xmin,
double ymin,
double xmax,
double ymax,
OMGraphicList list,
DrawingAttributes drawingAttributes,
Projection mapProj,
GeoCoordTransformation dataProj)
Locates OMGraphics in the shape file that intersect with the given rectangle. |
javax.swing.ImageIcon |
getPointIcon()
Get the icon used for general point objects. |
protected static void |
indexNulls(java.io.InputStream is,
long ptr,
java.io.OutputStream os)
Writes the spatial index for a null shape file. |
protected static void |
indexPoints(java.io.InputStream is,
long ptr,
java.io.OutputStream os)
Writes the spatial index for a point shape file. |
protected static void |
indexPolygons(java.io.InputStream is,
long ptr,
java.io.OutputStream os)
Writes the spatial index for a polygon shape file. |
protected static boolean |
intersects(double xmin1,
double ymin1,
double xmax1,
double ymax1,
double xmin2,
double ymin2,
double xmax2,
double ymax2)
Determines if two rectangles intersect. |
static SpatialIndex |
locateAndSetShapeData(java.lang.String shapeFileName)
Create a SpatialIndex object with just a shape file name. |
static SpatialIndex |
locateAndSetShapeData(java.lang.String shapeFileName,
java.lang.String spatialIndexFileName)
|
static java.lang.String |
locateFile(java.lang.String name)
Locate file 'fileName' in classpath, if it is not an absolute file name. |
ESRIRecord[] |
locateRecords(double xmin,
double ymin,
double xmax,
double ymax)
Locates records in the shape file that intersect with the given rectangle. |
static void |
main(java.lang.String[] argv)
The driver for the command line interface. |
ESRIRecord |
makeESRIRecord(int shapeType,
byte[] b,
int off)
Creates a record instance from the shape file data. |
static void |
printUsage(java.io.PrintStream out)
Prints a usage statement describing how to use this class from the command line. |
protected java.util.List |
readIndexFile(ESRIBoundingBox bounds)
|
protected java.util.List |
readIndexFile(ESRIBoundingBox bounds,
GeoCoordTransformation dataTransform)
|
void |
resetBounds()
Reset the bounds so they will be recalculated the next time a file is read. |
void |
setDbf(DbfHandler dbf)
|
void |
setFactory(EsriGraphicFactory factory)
|
void |
setPointIcon(javax.swing.ImageIcon ii)
Set the icon to use for point objects, in general. |
Methods inherited from class com.bbn.openmap.layer.shape.ShapeUtils |
readBEInt, readBox, readLEDouble, readLEInt, readLEInt, readLELong, readPoint, writeBEInt, writeBox, writeLEDouble, writeLEInt, writeLELong, writePoint |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int SHAPE_FILE_HEADER_LENGTH
public static final int SHAPE_RECORD_HEADER_LENGTH
public static final int SPATIAL_INDEX_HEADER_LENGTH
public static final int SPATIAL_INDEX_RECORD_LENGTH
public static final int DEFAULT_SHAPE_RECORD_SIZE
protected BinaryBufferedFile ssx
protected BinaryBufferedFile shp
protected DbfHandler dbf
protected javax.swing.ImageIcon pointIcon
protected ESRIBoundingBox bounds
protected java.lang.String shpFileName
protected java.lang.String ssxFileName
protected java.util.List entries
Constructor Detail |
public SpatialIndex(java.lang.String ssxFilename) throws java.io.IOException
ssxFilename
- the name of the spatial index file
java.io.IOException
- if something goes wrong opening the filepublic SpatialIndex(java.lang.String ssxFilename, java.lang.String shpFilename) throws java.io.IOException
ssxFilename
- the name of the spatial index fileshpFilename
- the name of the shape file
java.io.IOException
- if something goes wrong opening the filesMethod Detail |
public ESRIBoundingBox getBounds()
public void resetBounds()
public ESRIRecord makeESRIRecord(int shapeType, byte[] b, int off) throws java.io.IOException
shapeType
- the shape file's shape type, enumerated in
ShapeUtils
b
- the buffer pointing to the raw record dataoff
- the offset of the data starting point in the buffer
java.io.IOException
- if something goes wrong reading the fileShapeUtils
public ESRIRecord[] locateRecords(double xmin, double ymin, double xmax, double ymax) throws java.io.IOException, FormatException
xmin
- the smaller of the x coordinatesymin
- the smaller of the y coordinatesxmax
- the larger of the x coordinatesymax
- the larger of the y coordinates
java.io.IOException
- if something goes wrong reading the files
FormatException
public EsriGraphicFactory getFactory()
public void setFactory(EsriGraphicFactory factory)
public OMGraphicList getOMGraphics(double xmin, double ymin, double xmax, double ymax, OMGraphicList list, DrawingAttributes drawingAttributes, Projection mapProj, GeoCoordTransformation dataProj) throws java.io.IOException, FormatException
xmin
- the smaller of the x coordinatesymin
- the smaller of the y coordinatesxmax
- the larger of the x coordinatesymax
- the larger of the y coordinateslist
- OMGraphicList to add OMGraphics to and return, if null one
will be created.drawingAttributes
- DrawingAttributes to set on the OMGraphics.mapProj
- the Map Projection for the OMGraphics so they can be
generated right after creation.dataProj
- for preprojected data, a coordinate translator for the
data's projection to use to translate the coordinates to decimal
degree lat/lon. Can be null to leave the coordinates untouched.
java.io.IOException
- if something goes wrong reading the files
FormatException
public OMGraphic getOMGraphicAtOffset(int byteOffset, DrawingAttributes drawingAttributes) throws java.io.IOException, FormatException
drawingAttributes
-
java.io.IOException
FormatException
public java.util.Iterator entryIterator() throws java.io.IOException, FormatException
java.io.IOException
FormatException
public java.util.Iterator entryIterator(GeoCoordTransformation dataTransform) throws java.io.IOException, FormatException
dataTransform
- GeoCoordTransform for pre-projected data.
java.io.IOException
FormatException
protected java.util.List readIndexFile(ESRIBoundingBox bounds) throws java.io.IOException, FormatException
bounds
- if not null, add min/max values to them.
java.io.IOException
FormatException
protected java.util.List readIndexFile(ESRIBoundingBox bounds, GeoCoordTransformation dataTransform) throws java.io.IOException, FormatException
bounds
- if not null, add min/max values to them.dataTransform
- GeoCoordTransform for pre-projected data.
java.io.IOException
FormatException
protected static final boolean intersects(double xmin1, double ymin1, double xmax1, double ymax1, double xmin2, double ymin2, double xmax2, double ymax2)
xmin1
- the small x of rectangle 1ymin1
- the small y of rectangle 1xmax1
- the big x of rectangle 1ymax1
- the big y of rectangle 1xmin2
- the small x of rectangle 2ymin2
- the small y of rectangle 2xmax2
- the big x of rectangle 2ymax2
- the big y of rectangle 2
true
if the rectangles intersect,
false
if they do notpublic void dumpIndex(boolean showBounds) throws java.io.IOException
showBounds
- true to show bounding box, false to skip it
java.io.IOException
- if something goes wrong reading the fileprotected static void indexPolygons(java.io.InputStream is, long ptr, java.io.OutputStream os)
is
- the shape file input streamptr
- the current position in the fileos
- the spatial index file output streamprotected static void indexPoints(java.io.InputStream is, long ptr, java.io.OutputStream os)
is
- the shape file input streamptr
- the current position in the fileos
- the spatial index file output streamprotected static void indexNulls(java.io.InputStream is, long ptr, java.io.OutputStream os)
is
- the shape file input streamptr
- the current position in the fileos
- the spatial index file output streampublic static void createIndex(java.lang.String inFile, java.lang.String outFile)
inFile
- the shape fileoutFile
- the spatial index filepublic static void printUsage(java.io.PrintStream out)
out
- The output stream to use for outputpublic static java.lang.String locateFile(java.lang.String name)
public static SpatialIndex locateAndSetShapeData(java.lang.String shapeFileName)
public static SpatialIndex locateAndSetShapeData(java.lang.String shapeFileName, java.lang.String spatialIndexFileName)
public static void main(java.lang.String[] argv) throws java.io.IOException
See the file documentation for usage.
argv
- the command line arguments
java.io.IOException
- if something goes wrong reading or writing the
filepublic void setPointIcon(javax.swing.ImageIcon ii)
ii
- ImageIcon to use for icon.public javax.swing.ImageIcon getPointIcon()
public boolean close(boolean done)
public DbfHandler getDbf()
public void setDbf(DbfHandler dbf)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |