Class MatsimWriter<T>

    • Field Detail

      • indentLevel

        protected int indentLevel
        track indentation level
      • destinationCrsTransformer

        protected org.opengis.referencing.operation.MathTransform destinationCrsTransformer
        when the destination CRS differs from the network CRS all geometries require transforming, for which this transformer will be initialised
      • 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​(TransportLayerNetwork<?,​?> 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
      • prepareCoordinateReferenceSystem

        protected org.opengis.referencing.crs.CoordinateReferenceSystem prepareCoordinateReferenceSystem​(MacroscopicNetwork network,
                                                                                                         String destinationCountry,
                                                                                                         org.opengis.referencing.crs.CoordinateReferenceSystem destinationCrs)
                                                                                                  throws PlanItException
        Prepare the Crs transformer (if any) based on the user configuration settings. If no destinationCrs is provided than we use the country to try and infer the most appropriate desintation crs. In case the identified destination crs differs from the network one, we also creata destination transformer which is registered on the instance of the class
        Parameters:
        network - the network extract current Crs if no user specific settings can be found
        destinationCountry - of the network
        destinationCrs - that we would like to use, maybe null
        Returns:
        identified destinationCrs to use
        Throws:
        PlanItException - thrown if error
      • extractDestinationCrsCompatibleCoordinate

        protected org.locationtech.jts.geom.Coordinate extractDestinationCrsCompatibleCoordinate​(org.locationtech.jts.geom.Point location)
                                                                                          throws org.opengis.geometry.MismatchedDimensionException,
                                                                                                 org.opengis.referencing.operation.TransformException
        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
        Throws:
        org.opengis.referencing.operation.TransformException - thrown if error
        org.opengis.geometry.MismatchedDimensionException - 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 use
        xmlElementName - 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 use
        decreaseIndentation - when true decrease indentation level before this element has been written
        Throws:
        XMLStreamException - thrown if error