Class ShapefileWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
Writes typed riskscape Value
s 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 Summary
Modifier and TypeFieldDescriptionstatic final org.geotools.data.shapefile.ShapefileDataStoreFactory
Needed for constructing shapefile data stores NB unsure of thread safetystatic final int
Fields inherited from class nz.org.riskscape.engine.output.AbstractDataStoreWriter
axisSwapper, GEOMETRY_ATTRIBUTE, mappings, setup, targetSrid, VALUE_ATTRIBUTE
-
Constructor Summary
ConstructorDescriptionShapefileWriter
(File outfile, nz.org.riskscape.engine.SRIDSet sridSet, nz.org.riskscape.problem.ProblemSink problemSink) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected int
Sub classes should override and return a positive value to force attribute names to be truncated if they exceed the max length.protected Object
mapValueIfNecessary
(Object value, nz.org.riskscape.engine.types.Type type) Allows implementations to perform any value mapping should this be required.protected org.geotools.api.referencing.crs.CoordinateReferenceSystem
outputCrs
(org.geotools.api.referencing.crs.CoordinateReferenceSystem crs) Get a crs that will be "correct" for the produced file.protected void
setupCrsAndGeoType
(nz.org.riskscape.engine.Tuple value) Methods inherited from class nz.org.riskscape.engine.output.AbstractDataStoreWriter
featureTypeFromMappings, getRiskscapeType, getStoredAt, mapJavaType, setAttr, write
-
Field Details
-
FACTORY
public static final org.geotools.data.shapefile.ShapefileDataStoreFactory FACTORYNeeded 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
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classAbstractDataStoreWriter
- 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 classAbstractDataStoreWriter
- 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 classAbstractDataStoreWriter
- Returns:
- crs correct crs for the produced file
-
setupCrsAndGeoType
- Overrides:
setupCrsAndGeoType
in classAbstractDataStoreWriter
- Throws:
IOException
-
mapValueIfNecessary
Description copied from class:AbstractDataStoreWriter
Allows implementations to perform any value mapping should this be required.
- Overrides:
mapValueIfNecessary
in classAbstractDataStoreWriter
- Parameters:
value
- to maptype
- Riskscape type that values is- Returns:
- value, or a mapped version of value.
-