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 a JUMPReader specialized 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 Details

    • ShapefileReader

      public ShapefileReader()
      Creates new ShapeReader
  • Method Details

    • 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:
      read in interface JUMPReader
      Specified by:
      read in class AbstractJUMPReader
      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 contains
      compressedFname - the name of the compressed entry in the compressed file or null
      charset - 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