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

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

public class DiskShpDriver
extends MemoryShpDriver

SHP driver via JNI when the file does not have to be loaded into memory.

Author:
jldominguez
See Also:
ShpReader

Field Summary
 
Fields inherited from class es.prodevelop.gvsig.mobile.fmap.driver.vect.shp.MemoryShpDriver
POINT_TOL
 
Constructor Summary
DiskShpDriver()
           
 
Method Summary
 boolean accept(java.io.File f)
          Says whether a file is a SHP file.
 boolean canAlterTable()
           
 void close()
          Closes the file
 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.awt.geom.Rectangle2D getFullExtent()
          Gets the extent of the geometries of this driver
 long getHandler()
           
 int[] getIntersectingIndices(java.awt.geom.Rectangle2D rect, int max)
          Gets the indices of the geometries intersecting the given rectangle
 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 SHX associated with the given SHP file
 void initialize()
          Initializes the driver
 void initialize(ITableDefinition layerDef)
          Initializes the driver with the given table definition.
 boolean isWritable()
           
 boolean isWriteAll()
          Currently unused.
 void open(java.io.File f)
          Opens the file with through JNI functions
 void reload()
          Reloads this driver (reopens and initializes)
 void setHandler(long h)
          Sets the main file handler
 
Methods inherited from class es.prodevelop.gvsig.mobile.fmap.driver.vect.shp.MemoryShpDriver
getDataDriverName, getFilePath, getName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiskShpDriver

public DiskShpDriver()
Method Detail

close

public void close()
           throws java.io.IOException
Closes the file

Specified by:
close in interface VectorialFileDriver
Overrides:
close in class MemoryShpDriver
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 through JNI functions

Specified by:
open in interface VectorialFileDriver
Overrides:
open in class MemoryShpDriver
Parameters:
f - the file to be opened
Throws:
java.io.IOException
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
Overrides:
getShape in class MemoryShpDriver
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
Overrides:
getShapeCount in class MemoryShpDriver
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
Overrides:
getShapeType in class MemoryShpDriver
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
Overrides:
initialize in class MemoryShpDriver
Throws:
java.io.IOException
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
Overrides:
getFullExtent in class MemoryShpDriver
Throws:
java.io.IOException
See Also:
com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#getFullExtent()

accept

public boolean accept(java.io.File f)
Description copied from class: MemoryShpDriver
Says whether a file is a SHP file.

Specified by:
accept in interface VectorialFileDriver
Overrides:
accept in class MemoryShpDriver
Parameters:
f - the file of interest
Returns:
whether it is a valid SHP file
See Also:
com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#accept(java.io.File)

getDataFile

public java.io.File getDataFile(java.io.File f)
Description copied from class: MemoryShpDriver
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
Overrides:
getDataFile in class MemoryShpDriver
See Also:
com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#getDataFile(java.io.File)

getShxFile

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

Overrides:
getShxFile in class MemoryShpDriver
Parameters:
f - a file objects that points to a SHP file
Returns:
the associated SHX file

getShapeType

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

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

getFile

public java.io.File getFile()
Description copied from class: MemoryShpDriver
Gets the main SHP file object.

Specified by:
getFile in interface VectorialFileDriver
Overrides:
getFile in class MemoryShpDriver
Returns:
the main SHP file

reload

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

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

initialize

public void initialize(ITableDefinition layerDef)
Initializes the driver with the given table definition. Currently unused.

Overrides:
initialize in class MemoryShpDriver
Parameters:
layerDef - the table definitiion to be used

isWritable

public boolean isWritable()
Specified by:
isWritable in interface VectorialDriver
Overrides:
isWritable in class MemoryShpDriver
Returns:
Whether the driver is writable. Currently unused.

canAlterTable

public boolean canAlterTable()
Overrides:
canAlterTable in class MemoryShpDriver
Returns:
whether the associated table can be altered. Returns false. Currently unused.

isWriteAll

public boolean isWriteAll()
Currently unused.

Overrides:
isWriteAll in class MemoryShpDriver

getHandler

public long getHandler()
Returns:
the main SHP file handler

setHandler

public void setHandler(long h)
Sets the main file handler

Parameters:
h - the new handler

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
Overrides:
getShapeBounds in class MemoryShpDriver
Parameters:
index - the index of the geometry of interest
Returns:
the bounding box of the geometry
Throws:
java.io.IOException

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
Overrides:
getIntersectingIndices in class MemoryShpDriver
Parameters:
rect - the rectangle of interest
max - the maximum number of indices to be returned
Throws:
java.io.IOException