Class PlanitNetworkReader
- java.lang.Object
-
- org.goplanit.converter.BaseReaderImpl<LayeredNetwork<?,?>>
-
- org.goplanit.converter.network.NetworkReaderImpl
-
- org.goplanit.io.converter.network.PlanitNetworkReader
-
- All Implemented Interfaces:
ConverterEntity
,ConverterReader<LayeredNetwork<?,?>>
,NetworkReader
public class PlanitNetworkReader extends NetworkReaderImpl
Implementation of the network reader for the PLANit XML native format- Author:
- gman, markr
-
-
Field Summary
Fields Modifier and Type Field Description static String
NETWORK_XSD_FILE
Default XSD files used to validate input XML files against, TODO: move to properties file-
Fields inherited from class org.goplanit.converter.BaseReaderImpl
sourceIdTracker
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PlanitNetworkReader(String networkPathDirectory, String xmlFileExtension, LayeredNetwork<?,?> network)
Constructorprotected
PlanitNetworkReader(PlanitNetworkReaderSettings settings, LayeredNetwork<?,?> network)
Constructor where settings are directly provided such that input information can be exracted from itprotected
PlanitNetworkReader(PlanitNetworkReaderSettings settings, IdGroupingToken idToken)
Constructor where settings are directly provided such that input information can be exracted from itprotected
PlanitNetworkReader(org.goplanit.xml.generated.XMLElementMacroscopicNetwork externalXmlRawNetwork, PlanitNetworkReaderSettings settings, LayeredNetwork<?,?> network)
Constructor where file has already been parsed and we only need to convert from raw XML objects to PLANit memory modelprotected
PlanitNetworkReader(org.goplanit.xml.generated.XMLElementMacroscopicNetwork externalXmlRawNetwork, LayeredNetwork<?,?> network)
Constructor where file has already been parsed and we only need to convert from raw XML objects to PLANit memory model
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MacroscopicLinkSegment
getLinkSegmentByExternalId(MacroscopicNetwork network, String externalId)
returns the first link segment for which the given external id matches.PlanitNetworkReaderSettings
getSettings()
any settings to configure the reader can be configured by collecting these settingsvoid
parseLinkAndLinkSegments(org.goplanit.xml.generated.XMLElementInfrastructureLayer xmlLayer, MacroscopicNetworkLayer networkLayer, PlanitJtsCrsUtils jtsUtils)
parse link and link segmentsvoid
parseLinkSegmentTypeAccessProperties(org.goplanit.xml.generated.XMLElementAccessGroup xmlAccessGroupProperties, MacroscopicLinkSegmentType linkSegmentType, Collection<Mode> defaultModes)
parse the mode properties for given link segment type and populate the helper with themvoid
parseLinkSegmentTypes(org.goplanit.xml.generated.XMLElementLayerConfiguration xmlLayerconfiguration, MacroscopicNetworkLayer networkLayer)
Parse the link segment typesvoid
parseNodes(org.goplanit.xml.generated.XMLElementInfrastructureLayer xmlLayer, MacroscopicNetworkLayer networkLayer)
Create and register nodes on the networkMacroscopicNetwork
read()
parse the network based on the configuration of the implementing class to yield a PLANit networkvoid
reset()
reset the reader to allow for marking unnecessary resources for garbage collectionprotected void
setNetwork(LayeredNetwork<?,?> network)
Place network to populate-
Methods inherited from class org.goplanit.converter.BaseReaderImpl
getBySourceId, getSourceIdContainer, initialiseSourceIdMap, initialiseSourceIdMap, registerBySourceId, registerBySourceId
-
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.network.NetworkReader
getTypeDescription
-
-
-
-
Field Detail
-
NETWORK_XSD_FILE
public static final String NETWORK_XSD_FILE
Default XSD files used to validate input XML files against, TODO: move to properties file- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PlanitNetworkReader
protected PlanitNetworkReader(PlanitNetworkReaderSettings settings, IdGroupingToken idToken) throws PlanItException
Constructor where settings are directly provided such that input information can be exracted from it- Parameters:
settings
- to useidToken
- to use for the network to populate- Throws:
PlanItException
- thrown if error
-
PlanitNetworkReader
protected PlanitNetworkReader(PlanitNetworkReaderSettings settings, LayeredNetwork<?,?> network) throws PlanItException
Constructor where settings are directly provided such that input information can be exracted from it- Parameters:
settings
- to usenetwork
- to populate- Throws:
PlanItException
- thrown if error
-
PlanitNetworkReader
protected PlanitNetworkReader(org.goplanit.xml.generated.XMLElementMacroscopicNetwork externalXmlRawNetwork, LayeredNetwork<?,?> network) throws PlanItException
Constructor where file has already been parsed and we only need to convert from raw XML objects to PLANit memory model- Parameters:
externalXmlRawNetwork
- to extract fromnetwork
- to populate- Throws:
PlanItException
- thrown if error
-
PlanitNetworkReader
protected PlanitNetworkReader(org.goplanit.xml.generated.XMLElementMacroscopicNetwork externalXmlRawNetwork, PlanitNetworkReaderSettings settings, LayeredNetwork<?,?> network) throws PlanItException
Constructor where file has already been parsed and we only need to convert from raw XML objects to PLANit memory model- Parameters:
externalXmlRawNetwork
- to extract fromnetwork
- to populatesettings
- to use- Throws:
PlanItException
- thrown if error
-
PlanitNetworkReader
protected PlanitNetworkReader(String networkPathDirectory, String xmlFileExtension, LayeredNetwork<?,?> network) throws PlanItException
Constructor- Parameters:
networkPathDirectory
- to usexmlFileExtension
- to usenetwork
- to populate- Throws:
PlanItException
- thrown if error
-
-
Method Detail
-
parseLinkSegmentTypes
public void parseLinkSegmentTypes(org.goplanit.xml.generated.XMLElementLayerConfiguration xmlLayerconfiguration, MacroscopicNetworkLayer networkLayer) throws PlanItException
Parse the link segment types- Parameters:
xmlLayerconfiguration
- to extract them fromnetworkLayer
- to register them on- Throws:
PlanItException
- thrown if error
-
parseLinkSegmentTypeAccessProperties
public void parseLinkSegmentTypeAccessProperties(org.goplanit.xml.generated.XMLElementAccessGroup xmlAccessGroupProperties, MacroscopicLinkSegmentType linkSegmentType, Collection<Mode> defaultModes) throws PlanItException
parse the mode properties for given link segment type and populate the helper with them- Parameters:
xmlAccessGroupProperties
- to extract information from on (TODO:ugly, helper should be removed)linkSegmentType
- to register mode properties ondefaultModes
- to allow when no modes are specified- Throws:
PlanItException
- thrown if error
-
parseNodes
public void parseNodes(org.goplanit.xml.generated.XMLElementInfrastructureLayer xmlLayer, MacroscopicNetworkLayer networkLayer) throws PlanItException
Create and register nodes on the network- Parameters:
xmlLayer
- to extract fromnetworkLayer
- to populate- Throws:
PlanItException
- thrown if there is an error in storing the GML Point definition
-
parseLinkAndLinkSegments
public void parseLinkAndLinkSegments(org.goplanit.xml.generated.XMLElementInfrastructureLayer xmlLayer, MacroscopicNetworkLayer networkLayer, PlanitJtsCrsUtils jtsUtils) throws PlanItException
parse link and link segments- Parameters:
xmlLayer
- layer to extract them fromnetworkLayer
- to register them onjtsUtils
- for length calculations based on crs- Throws:
PlanItException
- thrown if error
-
setNetwork
protected void setNetwork(LayeredNetwork<?,?> network) throws PlanItException
Place network to populate- Parameters:
network
- to populate- Throws:
PlanItException
- thrown if error
-
read
public MacroscopicNetwork read()
parse the network based on the configuration of the implementing class to yield a PLANit network- Returns:
- parsed network
-
getSettings
public PlanitNetworkReaderSettings getSettings()
any settings to configure the reader can be configured by collecting these settings- Returns:
- the settings to configrue the reader
-
getLinkSegmentByExternalId
public MacroscopicLinkSegment getLinkSegmentByExternalId(MacroscopicNetwork network, String externalId)
returns the first link segment for which the given external id matches. Extremely slow, because it is not indexed at the moment. Also external ids are not guaranteed to be unique so if multiple matches exist problems may arise- Parameters:
network
- to look inexternalId
- to look for- Returns:
- link segment
-
reset
public void reset()
reset the reader to allow for marking unnecessary resources for garbage collection- Specified by:
reset
in interfaceConverterEntity
- Overrides:
reset
in classBaseReaderImpl<LayeredNetwork<?,?>>
-
-