Class AbstractDataStoreWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
ShapefileWriter
Writes typed riskscape Value
s 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
Modifier and TypeFieldDescriptionprotected AxisSwapper
some formats require mandate x-y ordering, regardless of what the prj says - this is here to apply that.static final String
The name of the geometry output in the written feature - by convention with shapefiles this must be the_geomprotected List<StructFlattener.StructMapping>
protected boolean
protected int
SRID to write geometries as.static final String
When writing out aSimpleType
value, the feature's only attribute is named this -
Constructor Summary
ConstructorDescriptionAbstractDataStoreWriter
(File outfile, nz.org.riskscape.engine.SRIDSet sridSet, org.geotools.api.data.DataStore dataStore) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected org.geotools.api.feature.simple.SimpleFeatureType
featureTypeFromMappings
(org.geotools.feature.simple.SimpleFeatureTypeBuilder builder) protected int
Sub 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.Struct
TheType
we are writing out to file.protected Class<?>
mapJavaType
(Class<?> toMap) 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
(@NonNull org.geotools.api.referencing.crs.CoordinateReferenceSystem crs) Get a crs that will be "correct" for the produced file.protected void
setAttr
(org.geotools.api.feature.simple.SimpleFeature toWrite, String key, Object value, nz.org.riskscape.engine.types.Type type) protected void
setupCrsAndGeoType
(nz.org.riskscape.engine.Tuple value) void
write
(nz.org.riskscape.engine.Tuple value)
-
Field Details
-
VALUE_ATTRIBUTE
When writing out a
SimpleType
value, 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
outputCrs
method
-
-
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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
write
- Specified by:
write
in 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
Type
we are writing out to file. All calls towrite(Tuple)
must match this type. -
getStoredAt
- Specified by:
getStoredAt
in classnz.org.riskscape.engine.output.RiskscapeWriter
-