|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.data.AbstractDataStore
org.geotools.data.AbstractFileDataStore
org.geotools.data.shapefile.ShapefileDataStore
public class ShapefileDataStore
A DataStore implementation which allows reading and writing from Shapefiles.
Field Summary | |
---|---|
protected java.nio.charset.Charset |
dbfCharset
|
static java.nio.charset.Charset |
DEFAULT_STRING_CHARSET
|
protected java.net.URI |
namespace
|
protected org.opengis.feature.simple.SimpleFeatureType |
schema
|
protected ShpFiles |
shpFiles
|
protected boolean |
useMemoryMappedBuffer
|
Fields inherited from class org.geotools.data.AbstractDataStore |
---|
isWriteable, listenerManager, LOGGER |
Constructor Summary | |
---|---|
ShapefileDataStore(java.net.URL url)
Creates a new instance of ShapefileDataStore. |
|
ShapefileDataStore(java.net.URL url,
boolean useMemoryMappedBuffer)
|
|
ShapefileDataStore(java.net.URL url,
boolean useMemoryMappedBuffer,
java.nio.charset.Charset dbfCharset)
|
|
ShapefileDataStore(java.net.URL url,
java.net.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(java.net.URL url,
java.net.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(java.net.URL url,
java.net.URI namespace,
boolean useMemoryMapped,
java.nio.charset.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(org.opengis.feature.simple.SimpleFeatureType featureType)
Attempt to create a DbaseFileHeader for the FeatureType. |
protected FIDFeatureReader |
createFeatureReader(java.lang.String typeName,
ShapefileAttributeReader reader,
org.opengis.feature.simple.SimpleFeatureType readerSchema)
|
protected java.lang.String |
createFeatureTypeName()
Create the type name of the single FeatureType this DataStore represents. For example, if the urls path is file:///home/billy/mytheme.shp, the type name will be mytheme. |
protected FeatureWriter<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> |
createFeatureWriter(java.lang.String typeName,
Transaction transaction)
Create a FeatureWriter for the given type name. |
protected java.util.Map |
createMetadata(java.lang.String typeName)
Latch onto xmlURL if it is there, we may be able to get out of calculating the bounding box! |
void |
createSchema(org.opengis.feature.simple.SimpleFeatureType featureType)
Set the FeatureType of this DataStore. |
void |
dispose()
Dummy implementation, it's a no-op. |
void |
forceSchemaCRS(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
This method is used to force the creation of a .prj file. |
protected ShapefileAttributeReader |
getAttributesReader(boolean readDbf,
com.vividsolutions.jts.geom.GeometryFactory gf)
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 java.lang.String |
getCurrentTypeName()
|
FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> |
getFeatureReader()
Singular version, which must be implemented to represent a Reader for the url being read. |
protected FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> |
getFeatureReader(java.lang.String typeName)
Create a FeatureReader |
protected FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> |
getFeatureReader(java.lang.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<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> |
getFeatureSource(java.lang.String typeName)
Default implementation based on getFeatureReader and getFeatureWriter. |
protected com.vividsolutions.jts.geom.GeometryFactory |
getGeometryFactory(Hints hints)
Builds the most appropriate geometry factory depending on the available query hints |
ServiceInfo |
getInfo()
Access a ServiceInfo object for this shapefile. |
org.opengis.feature.simple.SimpleFeatureType |
getSchema()
Singular version, returns the FeatureType for the url being read. |
org.opengis.feature.simple.SimpleFeatureType |
getSchema(java.lang.String typeName)
Obtain the FeatureType of the given name. |
java.nio.charset.Charset |
getStringCharset()
Returns the Charset used to decode strings in the DBF file |
protected java.util.Set |
getSupportedHints()
If you are using the automated FeatureSource/Store/Locking creation, this method allows for the specification of the supported hints. |
java.lang.String[] |
getTypeNames()
Get an array of type names this DataStore holds. ShapefileDataStore will always return a single name. |
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(com.vividsolutions.jts.geom.GeometryFactory gf)
Convenience method for opening a ShapefileReader. |
protected java.util.List<org.opengis.feature.type.AttributeDescriptor> |
readAttributes()
Create the AttributeDescriptor contained within this DataStore. |
void |
setStringCharset(java.nio.charset.Charset stringCharset)
Set this if you need BDF strings to be decoded in a Charset other
than ISO-8859-1 |
java.lang.String |
toString()
|
protected void |
typeCheck(java.lang.String requested)
A convenience method to check if a type name is correct. |
Methods inherited from class org.geotools.data.AbstractFileDataStore |
---|
getFeatureSource, getFeatureWriter, getFeatureWriter, getFeatureWriterAppend, updateSchema |
Methods inherited from class org.geotools.data.AbstractDataStore |
---|
createLockingManager, getFeatureReader, getFeatureSource, getFeatureWriter, getFeatureWriter, getFeatureWriter, getFeatureWriterAppend, getLockingManager, getNames, getSchema, getUnsupportedFilter, getView, state, updateSchema, updateSchema |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.geotools.data.DataStore |
---|
getFeatureReader, getFeatureWriter, getFeatureWriter, getFeatureWriterAppend, getLockingManager, getView, updateSchema |
Methods inherited from interface org.geotools.data.DataAccess |
---|
getFeatureSource, getNames, getSchema, updateSchema |
Field Detail |
---|
public static final java.nio.charset.Charset DEFAULT_STRING_CHARSET
protected final ShpFiles shpFiles
protected java.net.URI namespace
protected org.opengis.feature.simple.SimpleFeatureType schema
protected boolean useMemoryMappedBuffer
protected java.nio.charset.Charset dbfCharset
Constructor Detail |
---|
public ShapefileDataStore(java.net.URL url) throws java.net.MalformedURLException
url
- The URL of the shp file to use for this DataSource.
java.lang.NullPointerException
- DOCUMENT ME!
.
- If computation of related URLs (dbf,shx) fails.
java.net.MalformedURLException
public ShapefileDataStore(java.net.URL url, boolean useMemoryMappedBuffer) throws java.net.MalformedURLException
java.net.MalformedURLException
public ShapefileDataStore(java.net.URL url, boolean useMemoryMappedBuffer, java.nio.charset.Charset dbfCharset) throws java.net.MalformedURLException
java.net.MalformedURLException
public ShapefileDataStore(java.net.URL url, java.net.URI namespace) throws java.net.MalformedURLException
url
- namespace
-
java.net.MalformedURLException
public ShapefileDataStore(java.net.URL url, java.net.URI namespace, boolean useMemoryMapped, java.nio.charset.Charset dbfCharset) throws java.net.MalformedURLException
url
- namespace
- useMemoryMapped
- dbfCharset
-
java.net.MalformedURLException
public ShapefileDataStore(java.net.URL url, java.net.URI namespace, boolean useMemoryMapped) throws java.net.MalformedURLException
url
- namespace
- useMemoryMapped
-
java.net.MalformedURLException
Method Detail |
---|
public ServiceInfo getInfo()
getInfo
in interface DataAccess<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
getInfo
in class AbstractDataStore
public void setStringCharset(java.nio.charset.Charset stringCharset)
Charset
other
than ISO-8859-1
stringCharset
- public java.nio.charset.Charset getStringCharset()
Charset
used to decode strings in the DBF file
protected java.util.Map createMetadata(java.lang.String typeName)
This method is called by the createTypeEntry anonymous inner class DefaultTypeEntry.
createMetadata
in class AbstractDataStore
typeName
- DOCUMENT ME!
public boolean isLocal()
protected FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatureReader(java.lang.String typeName) throws java.io.IOException
getFeatureReader
in class AbstractDataStore
typeName
- The name of the FeatureType to create a reader for.
java.io.IOException
- If an error occurs during creationpublic FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatureReader() throws java.io.IOException
AbstractFileDataStore
getFeatureReader
in interface FileDataStore
getFeatureReader
in class AbstractFileDataStore
java.io.IOException
org.geotools.data.DataStore#getFeatureReader(java.lang.String)
protected FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatureReader(java.lang.String typeName, Query query) throws java.io.IOException
getFeatureReader
in class AbstractDataStore
java.io.IOException
AbstractDataStore.getFeatureReader(java.lang.String,
org.geotools.data.Query)
protected com.vividsolutions.jts.geom.GeometryFactory getGeometryFactory(Hints hints)
query
-
protected FIDFeatureReader createFeatureReader(java.lang.String typeName, ShapefileAttributeReader reader, org.opengis.feature.simple.SimpleFeatureType readerSchema) throws SchemaException
SchemaException
protected ShapefileAttributeReader getAttributesReader(boolean readDbf, com.vividsolutions.jts.geom.GeometryFactory gf) throws java.io.IOException
readDbf
- -
if true, the dbf fill will be opened and read
java.io.IOException
protected ShapefileReader openShapeReader(com.vividsolutions.jts.geom.GeometryFactory gf) throws java.io.IOException
java.io.IOException
- If an error occurs during creation.protected DbaseFileReader openDbfReader() throws java.io.IOException
java.io.IOException
- If an error occurs during creation.protected IndexFile openIndexFile() throws java.io.IOException
java.io.IOException
protected PrjFileReader openPrjReader() throws java.io.IOException, org.opengis.referencing.FactoryException
java.io.IOException
- If an error occurs during creation.
org.opengis.referencing.FactoryException
- DOCUMENT ME!public java.lang.String[] getTypeNames()
getTypeNames
in interface DataStore
getTypeNames
in class AbstractDataStore
protected java.lang.String createFeatureTypeName()
protected java.lang.String getCurrentTypeName()
protected void typeCheck(java.lang.String requested) throws java.io.IOException
requested
- The type name requested.
java.io.IOException
- If the type name is not availableprotected FeatureWriter<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> createFeatureWriter(java.lang.String typeName, Transaction transaction) throws java.io.IOException
createFeatureWriter
in class AbstractDataStore
typeName
- The typeName of the FeatureType to writetransaction
- DOCUMENT ME!
java.io.IOException
- If the typeName is not available or some other error
occurs.public org.opengis.feature.simple.SimpleFeatureType getSchema(java.lang.String typeName) throws java.io.IOException
getSchema
in interface DataStore
getSchema
in class AbstractDataStore
typeName
- The name of the FeatureType.
java.io.IOException
- If a type by the requested name is not present.public org.opengis.feature.simple.SimpleFeatureType getSchema() throws java.io.IOException
AbstractFileDataStore
getSchema
in interface FileDataStore
getSchema
in class AbstractFileDataStore
java.io.IOException
DataStore.getSchema(java.lang.String)
protected java.util.List<org.opengis.feature.type.AttributeDescriptor> readAttributes() throws java.io.IOException
java.io.IOException
- If AttributeType reading failspublic void forceSchemaCRS(org.opengis.referencing.crs.CoordinateReferenceSystem crs) throws java.io.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
-
java.io.IOException
public void createSchema(org.opengis.feature.simple.SimpleFeatureType featureType) throws java.io.IOException
createSchema
in interface DataAccess<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
createSchema
in class AbstractDataStore
featureType
- The desired FeatureType.
java.io.IOException
- If the DataStore is remote.protected ReferencedEnvelope getBounds() throws DataSourceException
DataSourceException
- DOCUMENT ME!protected ReferencedEnvelope getBounds(Query query) throws java.io.IOException
AbstractDataStore
Will 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 AbstractDataStore
SchemaNotFoundException
java.io.IOException
public FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatureSource(java.lang.String typeName) throws java.io.IOException
AbstractDataStore
We should be able to optimize this to only get the RowSet once
getFeatureSource
in interface DataStore
getFeatureSource
in class AbstractDataStore
java.io.IOException
DataStore.getFeatureSource(java.lang.String)
public int getCount(Query query) throws java.io.IOException
AbstractDataStore
If getBounds(Query) returns -1
due to expense consider
using getFeatures(Query).getCount()
as a an alternative.
getCount
in class AbstractDataStore
query
- Contains the Filter and MaxFeatures to find the bounds for.
-1
if count is too expensive to calculate or any errors or occur.
java.io.IOException
AbstractDataStore.getCount(org.geotools.data.Query)
protected static DbaseFileHeader createDbaseHeader(org.opengis.feature.simple.SimpleFeatureType featureType) throws java.io.IOException, DbaseFileException
featureType
- DOCUMENT ME!
java.io.IOException
- DOCUMENT ME!
DbaseFileException
- DOCUMENT ME!public java.lang.String toString()
toString
in class java.lang.Object
public void dispose()
AbstractDataStore
dispose
in interface DataAccess<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
dispose
in class AbstractDataStore
protected java.util.Set getSupportedHints()
AbstractDataStore
getSupportedHints
in class AbstractDataStore
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |