Class ShapefileWriter
- All Implemented Interfaces:
Closeable,AutoCloseable
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final org.geotools.data.shapefile.ShapefileDataStoreFactoryNeeded for constructing shapefile data stores NB unsure of thread safetystatic final intFields inherited from class nz.org.riskscape.engine.output.AbstractDataStoreWriter
axisSwapper, GEOMETRY_ATTRIBUTE, mappings, setup, targetSrid, VALUE_ATTRIBUTE -
Constructor Summary
ConstructorsConstructorDescriptionShapefileWriter(File outfile, nz.org.riskscape.engine.SRIDSet sridSet, nz.org.riskscape.problem.ProblemSink problemSink) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected intSub classes should override and return a positive value to force attribute names to be truncated if they exceed the max length.protected ObjectmapValueIfNecessary(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.CoordinateReferenceSystemoutputCrs(org.geotools.api.referencing.crs.CoordinateReferenceSystem crs) Get a crs that will be "correct" for the produced file.protected voidsetupCrsAndGeoType(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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classAbstractDataStoreWriter- Throws:
IOException
-
getAttrNameMaxLength
protected int getAttrNameMaxLength()Description copied from class:AbstractDataStoreWriterSub classes should override and return a positive value to force attribute names to be truncated if they exceed the max length.
- Overrides:
getAttrNameMaxLengthin 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:AbstractDataStoreWriterGet 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:
outputCrsin classAbstractDataStoreWriter- Returns:
- crs correct crs for the produced file
-
setupCrsAndGeoType
- Overrides:
setupCrsAndGeoTypein classAbstractDataStoreWriter- Throws:
IOException
-
mapValueIfNecessary
Description copied from class:AbstractDataStoreWriterAllows implementations to perform any value mapping should this be required.
- Overrides:
mapValueIfNecessaryin classAbstractDataStoreWriter- Parameters:
value- to maptype- Riskscape type that values is- Returns:
- value, or a mapped version of value.
-