Package com.vividsolutions.jump.io
Class ShapefileReader
- java.lang.Object
-
- com.vividsolutions.jump.io.AbstractJUMPReader
-
- com.vividsolutions.jump.io.ShapefileReader
-
- All Implemented Interfaces:
JUMPReader,TaskMonitorSupport
public class ShapefileReader extends AbstractJUMPReader
ShapefileReader is aJUMPReaderspecialized to read Shapefiles.DataProperties for the JUMPReader load(DataProperties) interface:
Parameter Meaning InputFile or DefaultValue File name for the input .shp file NOTE: The input .dbf is assumed to be 'beside' (in the same directory) as the .shp file. CompressedFile File name (.zip or .tgz NOT a .gz) with .shp and .dbf file inside Uses a modified version of geotools to do the .dbf and .shp file reading. If you are reading from a .zip file, the dbf file will be copied to your temp directory and deleted after being read.
-
-
Constructor Summary
Constructors Constructor Description ShapefileReader()Creates new ShapeReader
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetCharset(String shpFileName, DriverProperties dp)protected InputStreamgetCpgInputStream(String srcFileName, String compressedFname)protected DbfFilegetDbfFile(String srcFileName, String compressedFname, Charset charset)Get's a DbfFile.protected ShapefilegetShapefile(String shpfileName, String compressedFname)protected InputStreamgetShx(String srcFileName, String compressedFname)FeatureCollectionread(DriverProperties dp)Main method to read a shapefile.-
Methods inherited from class com.vividsolutions.jump.io.AbstractJUMPReader
addException, getExceptions, getTaskMonitor, setTaskMonitor
-
-
-
-
Method Detail
-
read
public FeatureCollection read(DriverProperties dp) throws Exception
Main method to read a shapefile. Most of the work is done in the org.geotools.* package.- Specified by:
readin interfaceJUMPReader- Specified by:
readin classAbstractJUMPReader- Parameters:
dp- 'InputFile' or 'DefaultValue' to specify output .shp file.- Returns:
- a FeatureCollection created from .shp and .dbf (dbf is optional)
- Throws:
Exception
-
getShapefile
protected Shapefile getShapefile(String shpfileName, String compressedFname) throws Exception
- Throws:
Exception
-
getShx
protected InputStream getShx(String srcFileName, String compressedFname) throws Exception
- Throws:
Exception
-
getCharset
protected String getCharset(String shpFileName, DriverProperties dp) throws Exception
- Throws:
Exception
-
getCpgInputStream
protected InputStream getCpgInputStream(String srcFileName, String compressedFname) throws Exception
- Throws:
Exception
-
getDbfFile
protected DbfFile getDbfFile(String srcFileName, String compressedFname, Charset charset) throws IOException
Get's a DbfFile. Kept, for compatibilty. Use the method with charset parameter.- Parameters:
srcFileName- either a pass to a dbf or an archive file (*.zip etc.) accompanied by the compressedFname it containscompressedFname- the name of the compressed entry in the compressed file or nullcharset- the charset to use to read this dbf file- Returns:
- a DbfFile object for the dbf file named FileName
- Throws:
IOException- if an I/O error occurs during dbf file reading
-
-