Package org.goplanit.io.converter
Class PlanitWriterImpl<T>
- java.lang.Object
-
- org.goplanit.converter.BaseWriterImpl<T>
-
- org.goplanit.io.converter.PlanitWriterImpl<T>
-
- Type Parameters:
T- type to generate with this writer
- All Implemented Interfaces:
ConverterEntity,ConverterWriter<T>
- Direct Known Subclasses:
PlanitNetworkWriter,PlanitZoningWriter
public abstract class PlanitWriterImpl<T> extends BaseWriterImpl<T>
Common functionality for writing in the native PLANit format across different writers- Author:
- markr
-
-
Field Summary
-
Fields inherited from class org.goplanit.converter.BaseWriterImpl
idMapper
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPlanitWriterImpl(IdMapperType idMapperType)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected net.opengis.gml.CoordTypecreateGmlCoordType(org.locationtech.jts.geom.Coordinate coordinate)Create a GML coord type from the provided coordinateprotected net.opengis.gml.DirectPositionTypecreateGmlDirectPositionType(org.locationtech.jts.geom.Point position)Create a position type based on point locationprotected net.opengis.gml.LineStringTypecreateGmlLineStringType(org.locationtech.jts.geom.LineString lineString)Create a GML LineStringType from a JTS LineStringand account for any crs transformation if neededprotected net.opengis.gml.PointTypecreateGmlPointType(org.locationtech.jts.geom.Point position)Create a GML PointType from a JTS Point and account for any crs transformation if neededprotected net.opengis.gml.PolygonTypecreateGmlPolygonType(org.locationtech.jts.geom.Polygon polygon)create a GML PolygonType from a JTS Polygon and account for any crs transformation if neededprotected static StringextractSrsName(PlanitXmlWriterSettings xmlSettings)Extract the src name to use based on the available crs information on network and settingsprotected Function<Connectoid,String>getConnectoidIdMapper()get id mapper for connectoidsprotected org.opengis.referencing.operation.MathTransformgetDestinationCrsTransformer()get the destination crs transformer.protected PlanitJtsCrsUtilsgetGeoUtils()geo util class based on source Crs (if any)protected Function<Link,String>getLinkIdMapper()get id mapper for linksprotected Function<MacroscopicLinkSegment,String>getLinkSegmentIdMapper()get id mapper for link segmentsprotected Function<MacroscopicLinkSegmentType,String>getLinkSegmentTypeIdMapper()get id mapper for link segment typesprotected Function<Mode,String>getModeIdMapper()get id mapper for modesprotected Function<TransferZoneGroup,String>getTransferZoneGroupIdMapper()get id mapper for transfer zone groupsprotected Function<Vertex,String>getVertexIdMapper()get id mapper for nodesprotected Function<Zone,String>getZoneIdMapper()get id mapper for zonesprotected voidinitialiseIdMappingFunctions()depending on the chosen id mapping, create the mapping functions for all id carrying entities that are persistedprotected voidpersist(Object xmlRootElement, Class<?> rootElementClazz, String planitSchemaName)Persist the populated XML memory model to disk using JAXbprotected voidprepareCoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem sourceCrs)prepare the Crs transformer (if any) based on the user configuration settings-
Methods inherited from class org.goplanit.converter.BaseWriterImpl
getIdMapperType, identifyDestinationCoordinateReferenceSystem, setIdMapperType
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.converter.ConverterEntity
getTypeDescription, reset
-
Methods inherited from interface org.goplanit.converter.ConverterWriter
getSettings, write
-
-
-
-
Constructor Detail
-
PlanitWriterImpl
protected PlanitWriterImpl(IdMapperType idMapperType)
Constructor- Parameters:
idMapperType- to use
-
-
Method Detail
-
extractSrsName
protected static String extractSrsName(PlanitXmlWriterSettings xmlSettings) throws PlanItException
Extract the src name to use based on the available crs information on network and settings- Parameters:
xmlSettings- to use- Returns:
- srsName to use
- Throws:
PlanItException- thrown if error
-
createGmlDirectPositionType
protected net.opengis.gml.DirectPositionType createGmlDirectPositionType(org.locationtech.jts.geom.Point position)
Create a position type based on point location- Parameters:
position- to convert to GML and transform if needed- Returns:
- created GML pos
-
createGmlCoordType
protected net.opengis.gml.CoordType createGmlCoordType(org.locationtech.jts.geom.Coordinate coordinate)
Create a GML coord type from the provided coordinate- Parameters:
coordinate- to convert to GML and transform if needed- Returns:
- created GML coordinate
-
createGmlPointType
protected net.opengis.gml.PointType createGmlPointType(org.locationtech.jts.geom.Point position)
Create a GML PointType from a JTS Point and account for any crs transformation if needed- Parameters:
position- to extract from- Returns:
- created PointType
-
createGmlPolygonType
protected net.opengis.gml.PolygonType createGmlPolygonType(org.locationtech.jts.geom.Polygon polygon)
create a GML PolygonType from a JTS Polygon and account for any crs transformation if needed- Parameters:
polygon- to extract from- Returns:
- created PolygonType
-
createGmlLineStringType
protected net.opengis.gml.LineStringType createGmlLineStringType(org.locationtech.jts.geom.LineString lineString)
Create a GML LineStringType from a JTS LineStringand account for any crs transformation if needed- Parameters:
lineString- to extract from- Returns:
- created LineStringType
-
prepareCoordinateReferenceSystem
protected void prepareCoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem sourceCrs) throws PlanItExceptionprepare the Crs transformer (if any) based on the user configuration settings- Parameters:
sourceCrs- the crs used for the source material of this writer- Throws:
PlanItException- thrown if error
-
initialiseIdMappingFunctions
protected void initialiseIdMappingFunctions() throws PlanItExceptiondepending on the chosen id mapping, create the mapping functions for all id carrying entities that are persisted- Throws:
PlanItException- thrown if error
-
getVertexIdMapper
protected Function<Vertex,String> getVertexIdMapper()
get id mapper for nodes- Returns:
- id mapper
-
getLinkIdMapper
protected Function<Link,String> getLinkIdMapper()
get id mapper for links- Returns:
- id mapper
-
getLinkSegmentIdMapper
protected Function<MacroscopicLinkSegment,String> getLinkSegmentIdMapper()
get id mapper for link segments- Returns:
- id mapper
-
getLinkSegmentTypeIdMapper
protected Function<MacroscopicLinkSegmentType,String> getLinkSegmentTypeIdMapper()
get id mapper for link segment types- Returns:
- id mapper
-
getModeIdMapper
protected Function<Mode,String> getModeIdMapper()
get id mapper for modes- Returns:
- id mapper
-
getZoneIdMapper
protected Function<Zone,String> getZoneIdMapper()
get id mapper for zones- Returns:
- id mapper
-
getConnectoidIdMapper
protected Function<Connectoid,String> getConnectoidIdMapper()
get id mapper for connectoids- Returns:
- id mapper
-
getTransferZoneGroupIdMapper
protected Function<TransferZoneGroup,String> getTransferZoneGroupIdMapper()
get id mapper for transfer zone groups- Returns:
- id mapper
-
getDestinationCrsTransformer
protected org.opengis.referencing.operation.MathTransform getDestinationCrsTransformer()
get the destination crs transformer. Note it might be null and should only be collected afterprepareCoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)has been invoked which determines if and which transformer should be applied- Returns:
- destination crs transformer
-
getGeoUtils
protected PlanitJtsCrsUtils getGeoUtils()
geo util class based on source Crs (if any)- Returns:
- geoUtils
-
persist
protected void persist(Object xmlRootElement, Class<?> rootElementClazz, String planitSchemaName) throws PlanItException
Persist the populated XML memory model to disk using JAXb- Parameters:
xmlRootElement- to persist fromrootElementClazz- the type of the root element objectplanitSchemaName- schema the XML complies with- Throws:
PlanItException- thrown if error
-
-