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

java.lang.Object
  extended byes.prodevelop.gvsig.mobile.fmap.driver.vect.shp.ShpReader

public class ShpReader
extends java.lang.Object

This class accesses the SHP/DBF file via static JNI functions.

Author:
jldominguez

Constructor Summary
ShpReader()
           
 
Method Summary
static boolean closeDbfFile(long fileHandler)
          Closes the file
static boolean closeShpFile(long ptr)
          Closes a SHP file
static boolean getDbfBooleanFieldValue(long handler, int row, int fieldindex)
          Gets a boolean value from a row and field
static int getDbfFileFieldCount(long fileHandler)
          Gets the field count of a DBF file
static java.lang.String getDbfFileFieldNames(long fileHandler, int size)
          Gets the field names of a DBF file
static char[] getDbfFileFieldTypes(long fileHandler, int size)
          Gets the field types of a DBF file
static int[] getDbfFileFieldWidths(long fileHandler, int size)
          Gets the field widths of a DBF file
static int getDbfFileRowCount(long fileHandler)
          Gets row count
static double getDbfNumberFieldValue(long handler, int row, int fieldindex)
          Gets a numeric value from a row and field
static java.lang.String getDbfStringFieldValue(long handler, int row, int fieldindex)
          Gets a string value from a row and field
static int[] getPixelTransformedShape(double[] data, int size, double m00, double m11, double m02, double m12, int dim)
          Utility method to transform a geometry with a given affine transform.
static double[] getShapeBounds(long ptr, int index)
          Gets the shapebounds of a geometry
static double[] getShapeWithBox(long ptr, int index)
          Gets the shape as an array of coordinates
static double[] getShpMetadata(long ptr)
          Gets SHP metadata
static long openDbfFile(java.lang.String canonicalPath, boolean write_access)
          Opens a DBF file.
static long openShpFile(java.lang.String full_file_path, boolean write_access)
          Opens a SHP file
static void touch()
          Utility method to force the load of the DLL library
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShpReader

public ShpReader()
Method Detail

openShpFile

public static long openShpFile(java.lang.String full_file_path,
                               boolean write_access)
Opens a SHP file

Parameters:
full_file_path - file path
write_access - whether a write access is needed
Returns:
the handler to the opened file

closeShpFile

public static boolean closeShpFile(long ptr)
Closes a SHP file

Parameters:
ptr - the handler of the file to be closed
Returns:
whether the file was successfully closed

getShpMetadata

public static double[] getShpMetadata(long ptr)
Gets SHP metadata

Parameters:
ptr - handler to the SHP file
Returns:
an array containing metadata: [0] = shape type, [1] = extent min x, [2] = extent min y, [3] = extent width, [4] = extent height, [5] = row count,

getShapeWithBox

public static double[] getShapeWithBox(long ptr,
                                       int index)
Gets the shape as an array of coordinates

Parameters:
ptr - handler of the SHP file
index - index of the geometry of interest
Returns:
the shape as an array of coordinates: [minx, miny, w, h, type, n_parts, n_parts_start_index, nvertices, vertices]

getShapeBounds

public static double[] getShapeBounds(long ptr,
                                      int index)
Gets the shapebounds of a geometry

Parameters:
ptr - handler of the SHP file
index - index of the geometry of interest
Returns:
bounding box [x, y, w, h]

getPixelTransformedShape

public static int[] getPixelTransformedShape(double[] data,
                                             int size,
                                             double m00,
                                             double m11,
                                             double m02,
                                             double m12,
                                             int dim)
Utility method to transform a geometry with a given affine transform. This method is incomplete and should not be used.

Parameters:
data - the corrdinates to be transformed
size - the number of vertices
m00 - component of the affine transform matrix
m11 - component of the affine transform matrix
m02 - component of the affine transform matrix
m12 - component of the affine transform matrix
dim - the dimension of the geometry
Returns:

openDbfFile

public static long openDbfFile(java.lang.String canonicalPath,
                               boolean write_access)
Opens a DBF file.

Parameters:
canonicalPath - file path
write_access - whether write access is needed
Returns:
the handler to the file

getDbfFileFieldCount

public static int getDbfFileFieldCount(long fileHandler)
Gets the field count of a DBF file

Parameters:
fileHandler - teh handler of the file of interest
Returns:
the field count

getDbfFileFieldTypes

public static char[] getDbfFileFieldTypes(long fileHandler,
                                          int size)
Gets the field types of a DBF file

Parameters:
fileHandler - the handler of the file of interest
size - field count
Returns:
the field types as an array of chars (treated as integers)

getDbfFileFieldNames

public static java.lang.String getDbfFileFieldNames(long fileHandler,
                                                    int size)
Gets the field names of a DBF file

Parameters:
fileHandler - the handler of the file of interest
size - field count
Returns:
the field types as a comma separated list

closeDbfFile

public static boolean closeDbfFile(long fileHandler)
Closes the file

Parameters:
fileHandler - the handler of the DBF file to be closed
Returns:
whether the file was successfully closed

getDbfFileRowCount

public static int getDbfFileRowCount(long fileHandler)
Gets row count

Parameters:
fileHandler - the handler of the file of interest
Returns:
the row count

getDbfFileFieldWidths

public static int[] getDbfFileFieldWidths(long fileHandler,
                                          int size)
Gets the field widths of a DBF file

Parameters:
fileHandler - the handler of the file of interest
size - field count
Returns:
the field types as a comma separated list

getDbfNumberFieldValue

public static double getDbfNumberFieldValue(long handler,
                                            int row,
                                            int fieldindex)
Gets a numeric value from a row and field

Parameters:
handler - the handler of the file of interest
row - the row index
fieldindex - the field index
Returns:
the numeric value of that cell (row, field)

getDbfStringFieldValue

public static java.lang.String getDbfStringFieldValue(long handler,
                                                      int row,
                                                      int fieldindex)
Gets a string value from a row and field

Parameters:
handler - the handler of the file of interest
row - the row index
fieldindex - the field index
Returns:
the string value of that cell (row, field)

getDbfBooleanFieldValue

public static boolean getDbfBooleanFieldValue(long handler,
                                              int row,
                                              int fieldindex)
Gets a boolean value from a row and field

Parameters:
handler - the handler of the file of interest
row - the row index
fieldindex - the field index
Returns:
the boolean value of that cell (row, field)

touch

public static void touch()
Utility method to force the load of the DLL library