Package org.goplanit.matsim.converter
Class MatsimWriter<T>
- java.lang.Object
-
- org.goplanit.converter.BaseWriterImpl<T>
-
- org.goplanit.converter.CrsWriterImpl<T>
-
- org.goplanit.matsim.converter.MatsimWriter<T>
-
- All Implemented Interfaces:
ConverterEntity
,ConverterWriter<T>
- Direct Known Subclasses:
MatsimNetworkWriter
,MatsimRoutedServicesWriter
public abstract class MatsimWriter<T> extends CrsWriterImpl<T>
Base class from which all matsim writers derive- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_FILE_NAME_EXTENSION
default extension for xml files generatedstatic String
NETWORK_DOCTYPE
the doc type of MATSIM public transport schedule.static String
TRANSIT_SCHEDULE_DOCTYPE
the doc type of MATSIM public transport schedule.-
Fields inherited from class org.goplanit.converter.BaseWriterImpl
idMapper
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MatsimWriter(IdMapperType idMapperType)
Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected int
decreaseIndentation()
Decrease indentation levelprotected org.locationtech.jts.geom.Coordinate
extractDestinationCrsCompatibleCoordinate(org.locationtech.jts.geom.Point location)
Using the destination crs and its transformer extract the coordinate from the position in the desired crsabstract PlanitMatsimWriterSettings
getSettings()
any settings to configure the writer can be configured by collecting these settingsprotected int
increaseIndentation()
Increase indentation levelprotected boolean
validateNetwork(LayeredNetwork<?,?> referenceNetwork)
Validate the network instance available, throw or log when issues are foundprotected void
writeEndElementNewLine(XMLStreamWriter xmlWriter, boolean decreaseIndentation)
write an end element and add newline afterwardsprotected void
writeIndentation(XMLStreamWriter xmlWriter)
Add indentation to stream at current indentation levelprotected void
writeStartElement(XMLStreamWriter xmlWriter, String xmlElementName, boolean increaseIndentation)
write a start element and add newline afterwardsprotected void
writeStartElementNewLine(XMLStreamWriter xmlWriter, String xmlElementName, boolean increaseIndentation)
write a start element and add newline afterwards-
Methods inherited from class org.goplanit.converter.CrsWriterImpl
createTransformedCoordinate, extractSrsName, getDestinationCoordinateReferenceSystem, getDestinationCrsTransformer, getGeoUtils, getTransformedCoordinates, prepareCoordinateReferenceSystem
-
Methods inherited from class org.goplanit.converter.BaseWriterImpl
getComponentIdMappers, getIdMapperType, getPrimaryIdMapper, setIdMapperType, setParentIdMappers
-
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
write
-
-
-
-
Field Detail
-
TRANSIT_SCHEDULE_DOCTYPE
public static final String TRANSIT_SCHEDULE_DOCTYPE
the doc type of MATSIM public transport schedule.- See Also:
- Constant Field Values
-
NETWORK_DOCTYPE
public static final String NETWORK_DOCTYPE
the doc type of MATSIM public transport schedule.- See Also:
- Constant Field Values
-
DEFAULT_FILE_NAME_EXTENSION
public static final String DEFAULT_FILE_NAME_EXTENSION
default extension for xml files generated- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MatsimWriter
protected MatsimWriter(IdMapperType idMapperType)
Constructor- Parameters:
idMapperType
- to use
-
-
Method Detail
-
validateNetwork
protected boolean validateNetwork(LayeredNetwork<?,?> referenceNetwork) throws PlanItException
Validate the network instance available, throw or log when issues are found- Parameters:
referenceNetwork
- to use for persisting- Returns:
- true when valid, false otherwise
- Throws:
PlanItException
- thrown if invalid
-
extractDestinationCrsCompatibleCoordinate
protected org.locationtech.jts.geom.Coordinate extractDestinationCrsCompatibleCoordinate(org.locationtech.jts.geom.Point location)
Using the destination crs and its transformer extract the coordinate from the position in the desired crs- Parameters:
location
- to extract destination crs compatible coordinate for- Returns:
- coordinate created
-
writeIndentation
protected void writeIndentation(XMLStreamWriter xmlWriter) throws XMLStreamException
Add indentation to stream at current indentation level- Parameters:
xmlWriter
- to use- Throws:
XMLStreamException
- thrown if error
-
increaseIndentation
protected int increaseIndentation()
Increase indentation level- Returns:
- updated indentation level
-
decreaseIndentation
protected int decreaseIndentation()
Decrease indentation level- Returns:
- updated indentation level
-
writeStartElement
protected void writeStartElement(XMLStreamWriter xmlWriter, String xmlElementName, boolean increaseIndentation) throws XMLStreamException
write a start element and add newline afterwards- Parameters:
xmlWriter
- to usexmlElementName
- element to start tag, e.g.<xmlElementName>
increaseIndentation
- when true, increase indentation after this element has been written- Throws:
XMLStreamException
- thrown if error
-
writeStartElementNewLine
protected void writeStartElementNewLine(XMLStreamWriter xmlWriter, String xmlElementName, boolean increaseIndentation) throws XMLStreamException
write a start element and add newline afterwards- Parameters:
xmlWriter
- to usexmlElementName
- element to start tag, e.g.<xmlElementName>
increaseIndentation
- when true, increase indentation after this element has been written- Throws:
XMLStreamException
- thrown if error
-
writeEndElementNewLine
protected void writeEndElementNewLine(XMLStreamWriter xmlWriter, boolean decreaseIndentation) throws XMLStreamException
write an end element and add newline afterwards- Parameters:
xmlWriter
- to usedecreaseIndentation
- when true decrease indentation level before this element has been written- Throws:
XMLStreamException
- thrown if error
-
getSettings
public abstract PlanitMatsimWriterSettings getSettings()
any settings to configure the writer can be configured by collecting these settings- Returns:
- the settings to configure the writer
-
-