Class ShapefileWriter

java.lang.Object
nz.org.riskscape.engine.output.RiskscapeWriter
nz.org.riskscape.engine.output.AbstractDataStoreWriter
nz.org.riskscape.engine.output.ShapefileWriter
All Implemented Interfaces:
Closeable, AutoCloseable

public class ShapefileWriter extends AbstractDataStoreWriter

Writes typed riskscape Values out to a new shapefile.

Due to restrictions in the shapefile format and geotools' own hacks to work with them, the ShapefileWriter writes out the geometry to the the_geom magic feature attribute. If geometry also appears in the value, the writer either ignores it (if it was also passed as the special geometry parameter) or writes it out as text in WKT

  • Field Details

    • FACTORY

      public static final org.geotools.data.shapefile.ShapefileDataStoreFactory FACTORY

      Needed for constructing shapefile data stores NB unsure of thread safety

    • MAX_FIELD_LENGTH

      public static final int MAX_FIELD_LENGTH
      See Also:
  • Constructor Details

    • ShapefileWriter

      public ShapefileWriter(File outfile, nz.org.riskscape.engine.SRIDSet sridSet, nz.org.riskscape.problem.ProblemSink problemSink) throws IOException
      Throws:
      IOException
  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class AbstractDataStoreWriter
      Throws:
      IOException
    • getAttrNameMaxLength

      protected int getAttrNameMaxLength()
      Description copied from class: AbstractDataStoreWriter

      Sub classes should override and return a positive value to force attribute names to be truncated if they exceed the max length.

      Overrides:
      getAttrNameMaxLength in class AbstractDataStoreWriter
      Returns:
      desired max length of attribute names
    • outputCrs

      protected org.geotools.api.referencing.crs.CoordinateReferenceSystem outputCrs(org.geotools.api.referencing.crs.CoordinateReferenceSystem crs)
      Description copied from class: AbstractDataStoreWriter

      Get a crs that will be "correct" for the produced file. This is to allow implementions to modify output where this may be expected by other software. Such as EPSG:4326 in shapefiles other software ignores axis defintion in projection file and instead uses Long/Lat.

      Implementations that override this method should set the targetSrid to match the returned CRS.

      Overrides:
      outputCrs in class AbstractDataStoreWriter
      Returns:
      crs correct crs for the produced file
    • setupCrsAndGeoType

      protected void setupCrsAndGeoType(nz.org.riskscape.engine.Tuple value) throws IOException
      Overrides:
      setupCrsAndGeoType in class AbstractDataStoreWriter
      Throws:
      IOException
    • mapValueIfNecessary

      protected Object mapValueIfNecessary(Object value, nz.org.riskscape.engine.types.Type type)
      Description copied from class: AbstractDataStoreWriter

      Allows implementations to perform any value mapping should this be required.

      Overrides:
      mapValueIfNecessary in class AbstractDataStoreWriter
      Parameters:
      value - to map
      type - Riskscape type that values is
      Returns:
      value, or a mapped version of value.