es.prodevelop.gvsig.mobile.fmap.driver.vect.shp
Class MemoryShpDriver

java.lang.Object
  extended byes.prodevelop.gvsig.mobile.fmap.driver.vect.shp.MemoryShpDriver
All Implemented Interfaces:
BoundedShapes, Driver, ExternalData, VectorialDriver, VectorialFileDriver
Direct Known Subclasses:
DiskShpDriver

public class MemoryShpDriver
extends java.lang.Object
implements VectorialFileDriver, BoundedShapes, ExternalData

SHP driver for a file that is completely loaded into memory.

Author:
jldominguez
See Also:
FalseByteBuffer

Field Summary
static double POINT_TOL
           
 
Constructor Summary
MemoryShpDriver()
           
 
Method Summary
 boolean accept(java.io.File f)
          Says whether a file is a SHP file.
 boolean canAlterTable()
           
 void close()
          Closes the file an dtries to preven memory leaks
 java.lang.String getDataDriverName()
          Obtiene el nombre del driver que leerá la tabla de datos de la capa
 java.io.File getDataFile(java.io.File f)
          Gets the data file (attributes file, in this case a DBF file) that corresponds to the given SHP file
 java.io.File getFile()
          Gets the main SHP file object.
 java.lang.String getFilePath()
           
 java.awt.geom.Rectangle2D getFullExtent()
          Gets the extent of the geometries of this driver
 int[] getIntersectingIndices(java.awt.geom.Rectangle2D rect, int max)
          Gets the indices of the geometries intersecting the given rectangle
 java.lang.String getName()
          Gets the driver name
 IGeometry getShape(int index)
          Gets the geometry for an index
 java.awt.geom.Rectangle2D getShapeBounds(int index)
          Gets the extent of one geometry of this driver.
 int getShapeCount()
          Obtiene el número de geometrías que contiene la capa
 int getShapeType()
          Devuelve el tipo de los shapes que hay en el fichero.
 int getShapeType(int index)
          Gets the shape type of the geometry of interest.
 java.io.File getShxFile(java.io.File f)
          Gets the associated SHX file
 void initialize()
          Initializes the driver
 void initialize(ITableDefinition layerDef)
          Initializes the driver
 boolean isWritable()
           
 boolean isWriteAll()
          Unused.
 void open(java.io.File f)
          Opens the file with using standard Java I/O system and loads it completely into memory
 void reload()
          Reloads the driver (reopens file and initializes)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POINT_TOL

public static final double POINT_TOL
See Also:
Constant Field Values
Constructor Detail

MemoryShpDriver

public MemoryShpDriver()
Method Detail

getFilePath

public java.lang.String getFilePath()
Specified by:
getFilePath in interface VectorialFileDriver
Returns:
gets the fiel path

close

public void close()
           throws java.io.IOException
Closes the file an dtries to preven memory leaks

Specified by:
close in interface VectorialFileDriver
Throws:
java.io.IOException
See Also:
com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#close()

open

public void open(java.io.File f)
          throws java.io.IOException
Opens the file with using standard Java I/O system and loads it completely into memory

Specified by:
open in interface VectorialFileDriver
Parameters:
f - the file to be opened
Throws:
java.io.IOException - Si se produce algún error
See Also:
com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#open(java.io.File)

getShape

public IGeometry getShape(int index)
                   throws java.io.IOException
Gets the geometry for an index

Specified by:
getShape in interface VectorialDriver
Parameters:
index - index of the geometry of interest
Returns:
the geometry
Throws:
java.io.IOException

getShapeCount

public int getShapeCount()
Description copied from interface: VectorialDriver
Obtiene el número de geometrías que contiene la capa

Specified by:
getShapeCount in interface VectorialDriver
Returns:
the number of geometries in this driver
See Also:
com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#getShapeCount()

getShapeType

public int getShapeType()
Description copied from interface: VectorialDriver
Devuelve el tipo de los shapes que hay en el fichero. Pueden haber varios tipos de shapes y para indicar esto se devuelve un bitoring de los tipos que contiene el fichero. Por ejemplo un fichero que contenga textos y lineas devolverá la expresión (FShape.LINE | FShape.TEXT)

Specified by:
getShapeType in interface VectorialDriver
Returns:
the shape type of the geometries of this driver
See Also:
com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getShapeType()

initialize

public void initialize()
                throws java.io.IOException
Initializes the driver

Specified by:
initialize in interface VectorialFileDriver
Throws:
java.io.IOException - Si se produce algún error
See Also:
com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#initialize()

getFullExtent

public java.awt.geom.Rectangle2D getFullExtent()
                                        throws java.io.IOException
Gets the extent of the geometries of this driver

Specified by:
getFullExtent in interface VectorialDriver
Returns:
Rectangle2D
Throws:
java.io.IOException - Si se produce algún error
See Also:
com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#getFullExtent()

getShapeBounds

public java.awt.geom.Rectangle2D getShapeBounds(int index)
                                         throws java.io.IOException
Gets the extent of one geometry of this driver.

Specified by:
getShapeBounds in interface VectorialDriver
Parameters:
index - the index of the geometry of interest
Returns:
the bounding box of the geometry
Throws:
java.io.IOException

accept

public boolean accept(java.io.File f)
Says whether a file is a SHP file.

Specified by:
accept in interface VectorialFileDriver
Parameters:
f - the file of interest
Returns:
whether it is a valid SHP file

getName

public java.lang.String getName()
Gets the driver name

Specified by:
getName in interface Driver
Returns:
Objeto asociado al driver. Se recomienda que sea un String

getDataDriverName

public java.lang.String getDataDriverName()
Description copied from interface: ExternalData
Obtiene el nombre del driver que leerá la tabla de datos de la capa

Specified by:
getDataDriverName in interface ExternalData
Returns:
the name of the associated data driver (DBF in this case)

getDataFile

public java.io.File getDataFile(java.io.File f)
Gets the data file (attributes file, in this case a DBF file) that corresponds to the given SHP file

Specified by:
getDataFile in interface VectorialFileDriver

getShxFile

public java.io.File getShxFile(java.io.File f)
Gets the associated SHX file

Parameters:
f - a certain SHP file
Returns:
the associated SHX file

getShapeType

public int getShapeType(int index)
Gets the shape type of the geometry of interest. Redirects to getShapeType()

Specified by:
getShapeType in interface BoundedShapes
Parameters:
index - the index of the geometry of interest
Returns:
the type of the geometry of interest.

getFile

public java.io.File getFile()
Gets the main SHP file object.

Specified by:
getFile in interface VectorialFileDriver
Returns:
the main file object

reload

public void reload()
            throws java.io.IOException
Reloads the driver (reopens file and initializes)

Specified by:
reload in interface VectorialDriver
Throws:
java.io.IOException

initialize

public void initialize(ITableDefinition layerDef)
Initializes the driver

Parameters:
layerDef - the table definition to initialize the driver

isWritable

public boolean isWritable()
Specified by:
isWritable in interface VectorialDriver
Returns:
whether this driver is writable.

canAlterTable

public boolean canAlterTable()
Returns:
whether this driver's table can be altered

isWriteAll

public boolean isWriteAll()
Unused.


getIntersectingIndices

public int[] getIntersectingIndices(java.awt.geom.Rectangle2D rect,
                                    int max)
                             throws java.io.IOException
Gets the indices of the geometries intersecting the given rectangle

Specified by:
getIntersectingIndices in interface BoundedShapes
Parameters:
rect - the rectangle of interest
max - the maximum number of indices to be returned
Throws:
java.io.IOException