|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectAbstractDataStore
AbstractFileDataStore
ShapefileDataStore
public class ShapefileDataStore
A DataStore implementation which allows reading and writing from Shapefiles.
trunk/gt/modules (gt-modules.jar) (Maven report) (SVN head)| Field Summary | |
|---|---|
protected Charset |
dbfCharset
|
static Charset |
DEFAULT_STRING_CHARSET
|
protected URI |
namespace
|
protected SimpleFeatureType |
schema
|
protected ShpFiles |
shpFiles
|
protected boolean |
useMemoryMappedBuffer
|
| Fields inherited from class AbstractDataStore |
|---|
isWriteable, listenerManager, LOGGER |
| Constructor Summary | |
|---|---|
ShapefileDataStore(URL url)
Creates a new instance of ShapefileDataStore. |
|
ShapefileDataStore(URL url,
boolean useMemoryMappedBuffer)
|
|
ShapefileDataStore(URL url,
boolean useMemoryMappedBuffer,
Charset dbfCharset)
|
|
ShapefileDataStore(URL url,
URI namespace)
this sets the datastore's namespace during construction (so the schema - FeatureType - will have the correct value) You can call this with namespace = null, but I suggest you give it an actual namespace. |
|
ShapefileDataStore(URL url,
URI namespace,
boolean useMemoryMapped)
this sets the datastore's namespace during construction (so the schema - FeatureType - will have the correct value) You can call this with namespace = null, but I suggest you give it an actual namespace. |
|
ShapefileDataStore(URL url,
URI namespace,
boolean useMemoryMapped,
Charset dbfCharset)
this sets the datastore's namespace during construction (so the schema - FeatureType - will have the correct value) You can call this with namespace = null, but I suggest you give it an actual namespace. |
|
| Method Summary | |
|---|---|
protected static DbaseFileHeader |
createDbaseHeader(SimpleFeatureType featureType)
Attempt to create a DbaseFileHeader for the FeatureType. |
protected FIDFeatureReader |
createFeatureReader(String typeName,
ShapefileAttributeReader reader,
SimpleFeatureType readerSchema)
|
protected String |
createFeatureTypeName()
Create the type name of the single FeatureType this DataStore represents. |
protected FeatureWriter<SimpleFeatureType,SimpleFeature> |
createFeatureWriter(String typeName,
Transaction transaction)
Create a FeatureWriter for the given type name. |
protected Map |
createMetadata(String typeName)
Latch onto xmlURL if it is there, we may be able to get out of calculating the bounding box! |
void |
createSchema(SimpleFeatureType featureType)
Set the FeatureType of this DataStore. |
void |
dispose()
Dummy implementation, it's a no-op. |
void |
forceSchemaCRS(CoordinateReferenceSystem crs)
This method is used to force the creation of a .prj file. |
protected ShapefileAttributeReader |
getAttributesReader(boolean readDbf)
Returns the attribute reader, allowing for a pure shapefile reader, or a combined dbf/shp reader. |
protected ReferencedEnvelope |
getBounds()
Gets the bounding box of the file represented by this data store as a whole (that is, off all of the features in the shapefile) |
protected ReferencedEnvelope |
getBounds(Query query)
Computes the bounds of the features for the specified feature type that satisfy the query provided that there is a fast way to get that result. |
int |
getCount(Query query)
Gets the number of the features that would be returned by this query for the specified feature type. |
protected String |
getCurrentTypeName()
|
protected FeatureReader<SimpleFeatureType,SimpleFeature> |
getFeatureReader()
Singular version, which must be implemented to represent a Reader for the url being read. |
protected FeatureReader<SimpleFeatureType,SimpleFeature> |
getFeatureReader(String typeName)
Create a FeatureReader |
protected FeatureReader<SimpleFeatureType,SimpleFeature> |
getFeatureReader(String typeName,
Query query)
Just like the basic version, but adds a small optimization: if no attributes are going to be read, don't uselessly open and read the dbf file. |
FeatureSource<SimpleFeatureType,SimpleFeature> |
getFeatureSource(String typeName)
Default implementation based on getFeatureReader and getFeatureWriter. |
ServiceInfo |
getInfo()
Access a ServiceInfo object for this shapefile. |
SimpleFeatureType |
getSchema()
Singular version, returns the FeatureType for the url being read. |
SimpleFeatureType |
getSchema(String typeName)
Obtain the FeatureType of the given name. |
Charset |
getStringCharset()
Returns the Charset used to decode strings in the DBF file |
String[] |
getTypeNames()
Get an array of type names this DataStore holds. |
boolean |
isLocal()
Determine if the location of this shapefile is local or remote. |
protected DbaseFileReader |
openDbfReader()
Convenience method for opening a DbaseFileReader. |
protected IndexFile |
openIndexFile()
Convenience method for opening an index file. |
protected PrjFileReader |
openPrjReader()
Convenience method for opening a DbaseFileReader. |
protected ShapefileReader |
openShapeReader()
Convenience method for opening a ShapefileReader. |
protected List<AttributeDescriptor> |
readAttributes()
Create the AttributeDescriptor contained within this DataStore. |
void |
setStringCharset(Charset stringCharset)
Set this if you need BDF strings to be decoded in a Charset other
than ISO-8859-1 |
String |
toString()
|
protected void |
typeCheck(String requested)
A convenience method to check if a type name is correct. |
| Methods inherited from class AbstractFileDataStore |
|---|
getFeatureSource, getFeatureWriter, getFeatureWriter, getFeatureWriterAppend, updateSchema |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Charset DEFAULT_STRING_CHARSET
protected final ShpFiles shpFiles
protected URI namespace
protected SimpleFeatureType schema
protected boolean useMemoryMappedBuffer
protected Charset dbfCharset
| Constructor Detail |
|---|
public ShapefileDataStore(URL url)
throws MalformedURLException
url - The URL of the shp file to use for this DataSource.
NullPointerException - DOCUMENT ME!
. - If computation of related URLs (dbf,shx) fails.
MalformedURLException
public ShapefileDataStore(URL url,
boolean useMemoryMappedBuffer)
throws MalformedURLException
MalformedURLException
public ShapefileDataStore(URL url,
boolean useMemoryMappedBuffer,
Charset dbfCharset)
throws MalformedURLException
MalformedURLException
public ShapefileDataStore(URL url,
URI namespace)
throws MalformedURLException
url - namespace -
MalformedURLException
public ShapefileDataStore(URL url,
URI namespace,
boolean useMemoryMapped,
Charset dbfCharset)
throws MalformedURLException
url - namespace - useMemoryMapped - dbfCharset -
MalformedURLException
public ShapefileDataStore(URL url,
URI namespace,
boolean useMemoryMapped)
throws MalformedURLException
url - namespace - useMemoryMapped -
MalformedURLException| Method Detail |
|---|
public ServiceInfo getInfo()
getInfo in interface DataAccess<SimpleFeatureType,SimpleFeature>getInfo in class AbstractDataStorepublic void setStringCharset(Charset stringCharset)
Charset other
than ISO-8859-1
stringCharset - public Charset getStringCharset()
Charset used to decode strings in the DBF file
protected Map createMetadata(String typeName)
This method is called by the createTypeEntry anonymous inner class DefaultTypeEntry.
createMetadata in class AbstractDataStoretypeName - DOCUMENT ME!
public boolean isLocal()
protected FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(String typeName)
throws IOException
getFeatureReader in class AbstractDataStoretypeName - The name of the FeatureType to create a reader for.
IOException - If an error occurs during creation
protected FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader()
throws IOException
AbstractFileDataStore
getFeatureReader in class AbstractFileDataStoreIOExceptionorg.geotools.data.DataStore#getFeatureReader(java.lang.String)
protected FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(String typeName,
Query query)
throws IOException
getFeatureReader in class AbstractDataStoreIOExceptionAbstractDataStore.getFeatureReader(java.lang.String,
org.geotools.data.Query)
protected FIDFeatureReader createFeatureReader(String typeName,
ShapefileAttributeReader reader,
SimpleFeatureType readerSchema)
throws SchemaException
SchemaException
protected ShapefileAttributeReader getAttributesReader(boolean readDbf)
throws IOException
readDbf - -
if true, the dbf fill will be opened and read
IOException
protected ShapefileReader openShapeReader()
throws IOException
IOException - If an error occurs during creation.
protected DbaseFileReader openDbfReader()
throws IOException
IOException - If an error occurs during creation.
protected IndexFile openIndexFile()
throws IOException
IOException
protected PrjFileReader openPrjReader()
throws IOException,
FactoryException
IOException - If an error occurs during creation.
FactoryException - DOCUMENT ME!public String[] getTypeNames()
getTypeNames in interface DataStoregetTypeNames in class AbstractDataStoreprotected String createFeatureTypeName()
protected String getCurrentTypeName()
protected void typeCheck(String requested)
throws IOException
requested - The type name requested.
IOException - If the type name is not available
protected FeatureWriter<SimpleFeatureType,SimpleFeature> createFeatureWriter(String typeName,
Transaction transaction)
throws IOException
createFeatureWriter in class AbstractDataStoretypeName - The typeName of the FeatureType to writetransaction - DOCUMENT ME!
IOException - If the typeName is not available or some other error
occurs.
public SimpleFeatureType getSchema(String typeName)
throws IOException
getSchema in interface DataStoregetSchema in class AbstractDataStoretypeName - The name of the FeatureType.
IOException - If a type by the requested name is not present.
public SimpleFeatureType getSchema()
throws IOException
AbstractFileDataStore
getSchema in class AbstractFileDataStoreIOExceptionDataStore.getSchema(java.lang.String)
protected List<AttributeDescriptor> readAttributes()
throws IOException
IOException - If AttributeType reading fails
public void forceSchemaCRS(CoordinateReferenceSystem crs)
throws IOException
The internally cached FeatureType will be removed, so the next call to getSchema() will read in the created file. This method is not thread safe and will have dire consequences for any other thread making use of the shapefile.
crs -
IOException
public void createSchema(SimpleFeatureType featureType)
throws IOException
createSchema in interface DataAccess<SimpleFeatureType,SimpleFeature>createSchema in class AbstractDataStorefeatureType - The desired FeatureType.
IOException - If the DataStore is remote.
protected ReferencedEnvelope getBounds()
throws DataSourceException
DataSourceException - DOCUMENT ME!
protected ReferencedEnvelope getBounds(Query query)
throws IOException
AbstractDataStoreWill return null if there is not fast way to compute the bounds. Since it's based on some kind of header/cached information, it's not guaranteed to be real bound of the features
getBounds in class AbstractDataStoreSchemaNotFoundException
IOException
public FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource(String typeName)
throws IOException
AbstractDataStoreWe should be able to optimize this to only get the RowSet once
getFeatureSource in interface DataStoregetFeatureSource in class AbstractDataStoreIOExceptionDataStore.getFeatureSource(java.lang.String)
public int getCount(Query query)
throws IOException
AbstractDataStore
If getBounds(Query) returns -1 due to expense consider
using getFeatures(Query).getCount() as a an alternative.
getCount in class AbstractDataStorequery - Contains the Filter and MaxFeatures to find the bounds for.
-1
if count is too expensive to calculate or any errors or occur.
IOExceptionAbstractDataStore.getCount(org.geotools.data.Query)
protected static DbaseFileHeader createDbaseHeader(SimpleFeatureType featureType)
throws IOException,
DbaseFileException
featureType - DOCUMENT ME!
IOException - DOCUMENT ME!
DbaseFileException - DOCUMENT ME!public String toString()
toString in class Objectpublic void dispose()
AbstractDataStore
dispose in interface DataAccess<SimpleFeatureType,SimpleFeature>dispose in class AbstractDataStore
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||