deegree 2.3 (2010/04/09 10:10 build-4-official)

org.deegree.io.shpapi
Class ShapeFile

java.lang.Object
  extended by org.deegree.io.shpapi.ShapeFile

public class ShapeFile
extends Object

Class representing an ESRI Shape File.

Version:
$Revision: 20366 $, $Date: 2009-10-26 11:25:12 +0100 (Mo, 26. Okt 2009) $
Author:
Andreas Poth, last edited by: $Author: apoth $

Constructor Summary
ShapeFile(String fileName)
          constructor:
Construct a ShapeFile from a file name.
ShapeFile(String url, String rwflag)
          constructor:
Construct a ShapeFile from a file name.
 
Method Summary
 void close()
           
 int[] getDataLengths()
           
 String[] getDataTypes()
          returns the datatype of each column of the database file
associated to the shape-file
 String[] getDataTypes(String[] fields)
          returns the datatype of each column of the dBase associated
to the shape-file specified by fields
 Feature getFeatureByRecNo(int RecNo)
          Returns the given entry of the shape file as a Feature instance.
 FeatureProperty[] getFeatureProperties(FeatureCollection fc, int n)
          Copies the feature properties of a feature.
 Envelope getFileMBR()
          returns the minimum bounding rectangle of all geometries
within the shape-file
 Geometry getGeometryByRecNo(int recNo)
          returns RecNo'th Geometrie
 int[] getGeoNumbersByAttribute(String column, Comparable<?> value)
          returns a int array that containts all the record numbers that matches the search operation
 int[] getGeoNumbersByRect(Envelope r)
          returns a ArrayList that contains all geomeries of the shape file
which mbr's are completly or partly within the rectangle r
only Points, MultiPoints, PolyLines and Polygons are handled
 Envelope getMBRByRecNo(int recNo)
          returns the minimum bound rectangle of RecNo'th Geometrie
 String[] getProperties()
          returns the properties (column headers) of the dBase-file
associated to the shape-file
 int getRecordNum()
          returns the number of records within a shape-file
 int getShapeTypeByRecNo(int RecNo)
          returns the type of the RecNo'th Geometrie
per definition a shape file contains onlay one shape type
but null shapes are possible too!
 boolean hasDBaseFile()
          returns true if a dBase-file is associated to the shape-file
 boolean hasDBaseIndex(String column)
          returns true if a column is indexed
 boolean hasRTreeIndex()
          returns true if an R-tree index is associated to the shape-file
 boolean isUnique(String property)
          is a property unique?
 void setFeatureType(FeatureType ft, Map<PropertyType,String> ftMapping)
          Overrides the default feature type (which is generated from all columns in the dbase file) to allow customized naming and ordering of properties.
 void writeShape(FeatureCollection fc)
          writes a OGC FeatureCollection to a ESRI shape file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShapeFile

public ShapeFile(String fileName)
          throws IOException
constructor:
Construct a ShapeFile from a file name.

Parameters:
fileName -
Throws:
IOException

ShapeFile

public ShapeFile(String url,
                 String rwflag)
          throws IOException
constructor:
Construct a ShapeFile from a file name.

Parameters:
url -
rwflag -
Throws:
IOException
Method Detail

close

public void close()

setFeatureType

public void setFeatureType(FeatureType ft,
                           Map<PropertyType,String> ftMapping)
Overrides the default feature type (which is generated from all columns in the dbase file) to allow customized naming and ordering of properties.

Parameters:
ft -
ftMapping -

hasDBaseIndex

public boolean hasDBaseIndex(String column)
returns true if a column is indexed

Parameters:
column -
Returns:
true if a column is indexed

hasDBaseFile

public boolean hasDBaseFile()
returns true if a dBase-file is associated to the shape-file

Returns:
true if a dBase-file is associated to the shape-file

hasRTreeIndex

public boolean hasRTreeIndex()
returns true if an R-tree index is associated to the shape-file

Returns:
true if an R-tree index is associated to the shape-file

getRecordNum

public int getRecordNum()
returns the number of records within a shape-file

Returns:
the number of records within a shape-file

getFileMBR

public Envelope getFileMBR()
returns the minimum bounding rectangle of all geometries
within the shape-file

Returns:
the minimum bounding rectangle of all geometries
within the shape-file

getMBRByRecNo

public Envelope getMBRByRecNo(int recNo)
                       throws IOException
returns the minimum bound rectangle of RecNo'th Geometrie

Parameters:
recNo -
Returns:
the minimum bound rectangle of RecNo'th Geometrie
Throws:
IOException

getFeatureByRecNo

public Feature getFeatureByRecNo(int RecNo)
                          throws IOException,
                                 HasNoDBaseFileException,
                                 DBaseException
Returns the given entry of the shape file as a Feature instance.

This contains the geometry as well as the attributes stored into the dbase file. The geometry property will use a default name (app:GEOM).

Parameters:
RecNo -
Returns:
the given entry of the shape file as a Feature instance
Throws:
IOException
HasNoDBaseFileException
DBaseException

getGeometryByRecNo

public Geometry getGeometryByRecNo(int recNo)
                            throws IOException
returns RecNo'th Geometrie

Parameters:
recNo -
Returns:
RecNo'th Geometrie
Throws:
IOException

getShapeTypeByRecNo

public int getShapeTypeByRecNo(int RecNo)
                        throws IOException
returns the type of the RecNo'th Geometrie
per definition a shape file contains onlay one shape type
but null shapes are possible too!

Parameters:
RecNo -
Returns:
the type of the RecNo'th Geometrie
per definition a shape file contains onlay one shape type
but null shapes are possible too!
Throws:
IOException

getGeoNumbersByAttribute

public int[] getGeoNumbersByAttribute(String column,
                                      Comparable<?> value)
                               throws IOException,
                                      DBaseIndexException
returns a int array that containts all the record numbers that matches the search operation

Parameters:
column -
value -
Returns:
a int array that containts all the record numbers that matches the search operation
Throws:
IOException
DBaseIndexException

getGeoNumbersByRect

public int[] getGeoNumbersByRect(Envelope r)
                          throws IOException
returns a ArrayList that contains all geomeries of the shape file
which mbr's are completly or partly within the rectangle r
only Points, MultiPoints, PolyLines and Polygons are handled

Parameters:
r -
Returns:
a ArrayList that contains all geomeries of the shape file
which mbr's are completly or partly within the rectangle r
only Points, MultiPoints, PolyLines and Polygons are handled
Throws:
IOException

isUnique

public boolean isUnique(String property)
is a property unique?

Parameters:
property -
Returns:
if it is unique

getProperties

public String[] getProperties()
                       throws HasNoDBaseFileException,
                              DBaseException
returns the properties (column headers) of the dBase-file
associated to the shape-file

Returns:
the properties (column headers) of the dBase-file
associated to the shape-file
Throws:
HasNoDBaseFileException
DBaseException

getDataTypes

public String[] getDataTypes()
                      throws HasNoDBaseFileException,
                             DBaseException
returns the datatype of each column of the database file
associated to the shape-file

Returns:
the datatype of each column of the database file
associated to the shape-file
Throws:
HasNoDBaseFileException
DBaseException

getDataLengths

public int[] getDataLengths()
                     throws HasNoDBaseFileException,
                            DBaseException
Returns:
the lengths
Throws:
HasNoDBaseFileException
DBaseException

getDataTypes

public String[] getDataTypes(String[] fields)
                      throws HasNoDBaseFileException,
                             DBaseException
returns the datatype of each column of the dBase associated
to the shape-file specified by fields

Parameters:
fields -
Returns:
the datatype of each column of the dBase associated
to the shape-file specified by fields
Throws:
HasNoDBaseFileException
DBaseException

getFeatureProperties

public FeatureProperty[] getFeatureProperties(FeatureCollection fc,
                                              int n)
Copies the feature properties of a feature.

Parameters:
fc -
n - the number of the feature to get the properties for
Returns:
the properties

writeShape

public void writeShape(FeatureCollection fc)
                throws Exception
writes a OGC FeatureCollection to a ESRI shape file.
all features in the collection must have the same properties.

Parameters:
fc - FeatureCollection. must not be null or empty.
Throws:
Exception

deegree 2.3 (2010/04/09 10:10 build-4-official)

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org