Package org.goplanit.zoning
Class ConnectoidImpl
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.utils.id.ExternalIdAbleImpl
-
- org.goplanit.zoning.ConnectoidImpl
-
- All Implemented Interfaces:
Cloneable
,Comparable<IdAble>
,Iterable<Zone>
,ExternalIdAble
,IdAble
,ManagedId
,Connectoid
- Direct Known Subclasses:
DirectedConnectoidImpl
,UndirectedConnectoidImpl
public abstract class ConnectoidImpl extends ExternalIdAbleImpl implements Connectoid
connectoid connecting one or more (transfer/OD) zone(s) to the physical road network, the type of connectoid depends on the implementing class- Author:
- markr
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
ConnectoidImpl.AccessZoneProperties
Stores access properties for each zone
-
Field Summary
Fields Modifier and Type Field Description protected TreeMap<Long,ConnectoidImpl.AccessZoneProperties>
accessZones
the zones and their properties accessible from this connectoidprotected String
name
name of the connectoid if anyprotected ConnectoidType
type
the type of connectoid to identify its purpose more easily-
Fields inherited from interface org.goplanit.utils.zoning.Connectoid
CONNECTOID_ID_CLASS, DEFAULT_CONNECTOID_TYPE, DEFAULT_LENGTH_KM
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ConnectoidImpl(IdGroupingToken idToken)
Constructorprotected
ConnectoidImpl(IdGroupingToken idToken, Zone accessZone)
Constructorprotected
ConnectoidImpl(IdGroupingToken idToken, Zone accessZone, double length)
Constructorprotected
ConnectoidImpl(ConnectoidImpl connectoidImpl)
Copy constructor
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Zone
addAccessZone(Zone accessZone)
Add an access zone with default propertiesvoid
addAllowedMode(Zone accessZone, Mode allowedMode)
Add an allowed mode.abstract ConnectoidImpl
clone()
Create a shallow copy of this entityprotected static long
generateId(IdGroupingToken groupId)
Generate connectoid idCollection<Zone>
getAccessZones()
The zones that can be accessed by this connectoidCollection<Mode>
getExplicitlyAllowedModes(Zone accessZone)
collect modes that are explicitly allowed for this zone (unmodifiable).Zone
getFirstAccessZone()
first available zone that is accessible based on the first entry the iterator returnsOptional<Double>
getLengthKm(Zone accessZone)
length can be used to virtually assign a length to the connectoid/zone combinationString
getName()
The name of the connectoidlong
getNumberOfAccessZones()
the number of accessible zones registeredConnectoidType
getType()
The type of the connectoidboolean
hasAccessZone(Zone accessZone)
Check if zone is registered as access zoneboolean
isModeAllowed(Zone accessZone, Mode mode)
Verify if a mode is allowed access to the zone via this connectoidIterator<Zone>
iterator()
void
recreateAccessZoneIdMapping()
recreate the id mapping for the registered access zoneslong
recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable idprotected void
setId(long id)
set the connectoid idvoid
setLength(Zone accessZone, double length)
Add an access zone and provide length to this connectoidvoid
setName(String name)
Set the name of the connectoidvoid
setType(ConnectoidType type)
Set the type of the connectoid-
Methods inherited from class org.goplanit.utils.id.ExternalIdAbleImpl
getExternalId, getXmlId, setExternalId, setXmlId
-
Methods inherited from class org.goplanit.utils.id.IdAbleImpl
equals, generateAndSetId, generateId, getId, hashCode
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.zoning.Connectoid
addAllowedModes, addAllowedModes, getAccessVertex, getIdClass, hasAccessZones, hasExplicitlyAllowedModes, hasLength, hasName, isAllModesAllowed
-
Methods inherited from interface org.goplanit.utils.id.ExternalIdAble
getExternalId, getXmlId, hasExternalId, hasXmlId, setExternalId, setXmlId
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, getId, idEquals, idHashCode
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.goplanit.utils.id.ManagedId
resetChildManagedIdEntities
-
-
-
-
Field Detail
-
name
protected String name
name of the connectoid if any
-
type
protected ConnectoidType type
the type of connectoid to identify its purpose more easily
-
accessZones
protected TreeMap<Long,ConnectoidImpl.AccessZoneProperties> accessZones
the zones and their properties accessible from this connectoid
-
-
Constructor Detail
-
ConnectoidImpl
protected ConnectoidImpl(IdGroupingToken idToken)
Constructor- Parameters:
idToken
- contiguous id generation within this group for instances of this class
-
ConnectoidImpl
protected ConnectoidImpl(IdGroupingToken idToken, Zone accessZone, double length)
Constructor- Parameters:
idToken
- contiguous id generation within this group for instances of this classaccessZone
- for the connectoidlength
- for the connection
-
ConnectoidImpl
protected ConnectoidImpl(IdGroupingToken idToken, Zone accessZone)
Constructor- Parameters:
idToken
- contiguous id generation within this group for instances of this classaccessZone
- for the connectoid
-
ConnectoidImpl
protected ConnectoidImpl(ConnectoidImpl connectoidImpl)
Copy constructor- Parameters:
connectoidImpl
- to copy
-
-
Method Detail
-
generateId
protected static long generateId(IdGroupingToken groupId)
Generate connectoid id- Parameters:
groupId
- contiguous id generation within this group for instances of this class- Returns:
- id of connectoid
-
recreateAccessZoneIdMapping
public void recreateAccessZoneIdMapping()
recreate the id mapping for the registered access zones
-
setId
protected void setId(long id)
set the connectoid id- Overrides:
setId
in classIdAbleImpl
- Parameters:
id
- to set as unique internal id across all connectoids
-
setType
public void setType(ConnectoidType type)
Set the type of the connectoid- Specified by:
setType
in interfaceConnectoid
- Parameters:
type
- its type
-
getType
public ConnectoidType getType()
The type of the connectoid- Specified by:
getType
in interfaceConnectoid
- Returns:
- its type
-
setName
public void setName(String name)
Set the name of the connectoid- Specified by:
setName
in interfaceConnectoid
- Parameters:
name
- its name
-
getName
public String getName()
The name of the connectoid- Specified by:
getName
in interfaceConnectoid
- Returns:
- its name
-
getAccessZones
public Collection<Zone> getAccessZones()
The zones that can be accessed by this connectoid- Specified by:
getAccessZones
in interfaceConnectoid
- Returns:
- accessible zones
-
getFirstAccessZone
public Zone getFirstAccessZone()
first available zone that is accessible based on the first entry the iterator returns- Specified by:
getFirstAccessZone
in interfaceConnectoid
- Returns:
- first available zone
-
getNumberOfAccessZones
public long getNumberOfAccessZones()
the number of accessible zones registered- Specified by:
getNumberOfAccessZones
in interfaceConnectoid
- Returns:
- number of accessible zones
-
getLengthKm
public Optional<Double> getLengthKm(Zone accessZone)
length can be used to virtually assign a length to the connectoid/zone combination- Specified by:
getLengthKm
in interfaceConnectoid
- Parameters:
accessZone
- to collect length for- Returns:
- length in km(null if zone is not registered)
-
addAccessZone
public Zone addAccessZone(Zone accessZone)
Add an access zone with default properties- Specified by:
addAccessZone
in interfaceConnectoid
- Parameters:
accessZone
- to register as accessible- Returns:
- overwritten zone if any
-
isModeAllowed
public boolean isModeAllowed(Zone accessZone, Mode mode) throws PlanItException
Verify if a mode is allowed access to the zone via this connectoid- Specified by:
isModeAllowed
in interfaceConnectoid
- Parameters:
accessZone
- to verifymode
- to verify if allowed- Returns:
- true when allowed, false otherwise
- Throws:
PlanItException
- thrown if provided zone is not valid
-
hasAccessZone
public boolean hasAccessZone(Zone accessZone)
Check if zone is registered as access zone- Specified by:
hasAccessZone
in interfaceConnectoid
- Parameters:
accessZone
- to verify- Returns:
- true when registered, false otherwise
-
setLength
public void setLength(Zone accessZone, double length)
Add an access zone and provide length to this connectoid- Specified by:
setLength
in interfaceConnectoid
- Parameters:
accessZone
- to set length forlength
- to traverse between connectoid and zone
-
addAllowedMode
public void addAllowedMode(Zone accessZone, Mode allowedMode)
Add an allowed mode. We assume the zone is already registered as an access zone for this connectoid- Specified by:
addAllowedMode
in interfaceConnectoid
- Parameters:
accessZone
- to add allowed mode toallowedMode
- to add
-
getExplicitlyAllowedModes
public Collection<Mode> getExplicitlyAllowedModes(Zone accessZone)
collect modes that are explicitly allowed for this zone (unmodifiable). Note that if no explicit allowed modes are present, all modes are implicitly allowed. When there exist explicitly allowed modes, any mdoes in the network not included in the explicitly allowed modes are regarded to not be allowed.- Specified by:
getExplicitlyAllowedModes
in interfaceConnectoid
- Parameters:
accessZone
- to check- Returns:
- the modes explicitly allowed for this zone, null if none
-
recreateManagedIds
public long recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable id- Specified by:
recreateManagedIds
in interfaceManagedId
- Parameters:
tokenId
- to use- Returns:
- the updated internal id
-
clone
public abstract ConnectoidImpl clone()
Create a shallow copy of this entity- Specified by:
clone
in interfaceIdAble
- Overrides:
clone
in classExternalIdAbleImpl
- Returns:
- shallow copy of entity
-
-