Class AbstractDataStoreWriter
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
ShapefileWriter
Writes typed riskscape Values out to a new file.
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 TypeFieldDescriptionprotected AxisSwappersome formats require mandate x-y ordering, regardless of what the prj says - this is here to apply that.static final StringThe name of the geometry output in the written feature - by convention with shapefiles this must be the_geomprotected List<StructFlattener.StructMapping>protected booleanprotected intSRID to write geometries as.static final StringWhen writing out aSimpleTypevalue, the feature's only attribute is named this -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDataStoreWriter(File outfile, nz.org.riskscape.engine.SRIDSet sridSet, org.geotools.api.data.DataStore dataStore) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected org.geotools.api.feature.simple.SimpleFeatureTypefeatureTypeFromMappings(org.geotools.feature.simple.SimpleFeatureTypeBuilder builder) protected intSub classes should override and return a positive value to force attribute names to be truncated if they exceed the max length.nz.org.riskscape.engine.types.StructTheTypewe are writing out to file.protected Class<?>mapJavaType(Class<?> toMap) 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(@NonNull org.geotools.api.referencing.crs.CoordinateReferenceSystem crs) Get a crs that will be "correct" for the produced file.protected voidsetAttr(org.geotools.api.feature.simple.SimpleFeature toWrite, String key, Object value, nz.org.riskscape.engine.types.Type type) protected voidsetupCrsAndGeoType(nz.org.riskscape.engine.Tuple value) voidwrite(nz.org.riskscape.engine.Tuple value)
-
Field Details
-
VALUE_ATTRIBUTE
When writing out a
SimpleTypevalue, the feature's only attribute is named this- See Also:
-
GEOMETRY_ATTRIBUTE
The name of the geometry output in the written feature - by convention with shapefiles this must be the_geom
- See Also:
-
mappings
-
setup
protected boolean setup -
targetSrid
protected int targetSridSRID to write geometries as.
-
axisSwapper
some formats require mandate x-y ordering, regardless of what the prj says - this is here to apply that. Implementations should set the axisSwapper if required by overriding the
outputCrsmethod
-
-
Constructor Details
-
AbstractDataStoreWriter
public AbstractDataStoreWriter(File outfile, nz.org.riskscape.engine.SRIDSet sridSet, org.geotools.api.data.DataStore dataStore) throws IOException - Throws:
IOException
-
-
Method Details
-
outputCrs
protected org.geotools.api.referencing.crs.CoordinateReferenceSystem outputCrs(@NonNull @NonNull org.geotools.api.referencing.crs.CoordinateReferenceSystem crs) 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.
- Parameters:
crs-- Returns:
- crs correct crs for the produced file
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
write
- Specified by:
writein classnz.org.riskscape.engine.output.RiskscapeWriter- Throws:
WriteException
-
setupCrsAndGeoType
- Throws:
IOException
-
getAttrNameMaxLength
protected int getAttrNameMaxLength()Sub classes should override and return a positive value to force attribute names to be truncated if they exceed the max length.
- Returns:
- desired max length of attribute names
-
setAttr
-
mapValueIfNecessary
Allows implementations to perform any value mapping should this be required.
- Parameters:
value- to maptype- Riskscape type that values is- Returns:
- value, or a mapped version of value.
-
featureTypeFromMappings
protected org.geotools.api.feature.simple.SimpleFeatureType featureTypeFromMappings(org.geotools.feature.simple.SimpleFeatureTypeBuilder builder) -
mapJavaType
-
getRiskscapeType
public nz.org.riskscape.engine.types.Struct getRiskscapeType()The
Typewe are writing out to file. All calls towrite(Tuple)must match this type. -
getStoredAt
- Specified by:
getStoredAtin classnz.org.riskscape.engine.output.RiskscapeWriter
-