/**
 * Creator: ASNDT (http://www.asnlab.org)
 * Author: WANGYizhi
 * Created: Tue Sep 06 17:32:36 CST 2016
 */
Map DEFINITIONS AUTOMATIC TAGS ::= BEGIN

-- imports and exports

EXPORTS MapData, NodeID, NodeReferenceID, MovementList, LaneID, DescriptiveName, LaneWidth, PointList, SpeedLimitList, LaneAttributes, AllowedManeuvers, ConnectsToList, MovementEx;
IMPORTS MinuteOfTheYear FROM DefTime
		MsgCount FROM MsgFrame
		Speed FROM DefMotion
		Position3D FROM DefPosition
		PositionOffsetLLV FROM DefPositionOffset
		PhaseID FROM SignalPhaseAndTiming
		Polygon FROM SensorSharing;
	
	MapData ::=	SEQUENCE {
		msgCnt MsgCount,
		timeStamp MinuteOfTheYear OPTIONAL,
		nodes NodeList,
		-- intersections or road endpoints
		...
	}
	
	NodeList ::= SEQUENCE (SIZE(1..32)) OF Node
	
	Node ::= SEQUENCE {
		-- intersection or road endpoint
		name DescriptiveName OPTIONAL,
		-- Node name
		id NodeReferenceID,
		-- A globally unique value set,
		-- consisting of a regionID and
		-- node ID assignment
		refPos Position3D, 
		-- 3D position of the center of this Node.
		-- This position is also the reference position for the elements inside
		
		-- Link list using Day I format --------------------------------------
		inLinks LinkList OPTIONAL,
		-- all the links enter this Node
		
		...,
		
		-- Day II Extension--------------------------------------
		inLinks-ex LinkExList OPTIONAL,
		-- all the links enter this Node
		prohibitedzone ProhibitedZone OPTIONAL,
		...
	}
	
	DescriptiveName ::= IA5String (SIZE(1..63))
	
	NodeReferenceID ::= SEQUENCE {
		region RoadRegulatorID OPTIONAL,
		-- a globally unique regional assignment value
		-- typical assigned to a regional DOT authority
		-- the value zero shall be used for testing needs
		id NodeID
		-- a unique mapping to the node
		-- in question within the above region of use		
		}
	
	RoadRegulatorID ::= INTEGER (0..65535)
	-- The value zero shall be used for testing only
	
	NodeID ::= INTEGER (0..65535)
	-- The values zero through 255 are allocated for testing purposes 
	-- Note that the value assigned to a node will be 
	-- unique within a given regional ID only
	
	LinkList ::= SEQUENCE (SIZE(1..32)) OF Link
	
	Link ::= SEQUENCE {
		name DescriptiveName OPTIONAL,
		-- Link name
		
		upstreamNodeId NodeReferenceID,
		-- this link is from upstreamNode to the Node it belongs to
		
		speedLimits SpeedLimitList OPTIONAL,
		-- List all the speed limits
		
		linkWidth LaneWidth,
		-- Width of this link
		
		points PointList OPTIONAL,
		-- Define road points along the center of this link
		
		movements MovementList OPTIONAL,
		-- Define movements at intersection
		
		lanes LaneList,
		-- Lanes belong to this link
		...
	}
	
	MovementList ::= SEQUENCE (SIZE(1..32)) OF Movement
	
	Movement ::= SEQUENCE {
		remoteIntersection NodeReferenceID,
		-- This entry indicates the downstream intersection of the link this lane connects to. 
		-- This provides a means to create meshes of lanes
		
		phaseId PhaseID OPTIONAL
		-- The matching signal group send by
		-- the SPAT message for this lane/maneuver.
		-- Shall be present unless the connectingLane
		-- has no signal group (is un-signalized)
	}
	
	LaneList ::= SEQUENCE (SIZE(1..32)) OF Lane
	
	Lane ::= SEQUENCE {
		laneID LaneID,
		-- The unique ID number assigned
		-- to this lane object
		laneWidth LaneWidth OPTIONAL,
		laneAttributes LaneAttributes OPTIONAL,
		-- Define basic attribute of lane
		maneuvers AllowedManeuvers OPTIONAL,
		-- the permitted maneuvers for this lane
		connectsTo ConnectsToList OPTIONAL,	
		-- connection to downsteam lanes
		speedLimits SpeedLimitList OPTIONAL,
		-- List all the speed limits
		points PointList OPTIONAL,
		-- Define road points and segments
		...
	}
	
	LaneID ::= INTEGER (0..255) 
	-- the value 0 shall be used when the lane ID is 
	-- not available or not known 
	-- the value 255 is reserved for future use
	
	LaneWidth ::= INTEGER (0..32767) 
	-- units of 1 cm
	
	ConnectsToList ::= SEQUENCE (SIZE(1..8)) OF Connection
	
	Connection::= SEQUENCE {
		remoteIntersection NodeReferenceID,
		-- This entry indicates the downstream intersection of the link this lane connects to. 
		-- This provides a means to create meshes of lanes
		connectingLane ConnectingLane OPTIONAL,
		-- The index of the connecting lane and also
		-- the maneuver from the current lane to it
		-- When we want to list the allowed lanes of the next link
		-- this lane can lead to, we use this entry
		phaseId PhaseID OPTIONAL
		-- The matching signal group send by
		-- the SPAT message for this lane/maneuver.
		-- Shall be present unless the connectingLane
		-- has no signal group (is un-signalized)
	}
	
	ConnectingLane ::= SEQUENCE {
		lane LaneID, 
		-- Index of the connecting lane
		maneuver AllowedManeuvers OPTIONAL
		-- The Maneuver between
		-- the enclosing lane and this lane
		-- at the stop line to connect them
		}
	
	AllowedManeuvers ::= BIT STRING {
		-- With bits as defined:
		-- Allowed maneuvers at path end (stop line)
		-- All maneuvers with bits not set are therefore prohibited
		-- A value of zero shall be used for unknown, indicating no Maneuver
		maneuverStraightAllowed (0),
		-- a Straight movement is allowed in this lane
		maneuverLeftAllowed (1),
		-- a Left Turn movement is allowed in this lane
		maneuverRightAllowed (2),
		-- a Right Turn movement is allowed in this lane
		maneuverUTurnAllowed (3),
		-- a U turn movement is allowed in this lane
		maneuverLeftTurnOnRedAllowed (4),
		-- a Stop, and then proceed when safe movement
		-- is allowed in this lane
		maneuverRightTurnOnRedAllowed (5),
		-- a Stop, and then proceed when safe movement
		-- is allowed in this lane
		maneuverLaneChangeAllowed (6),
		-- a movement which changes to an outer lane
		-- on the egress side is allowed in this lane
		-- (example: left into either outbound lane)
		maneuverNoStoppingAllowed (7),
		-- the vehicle should not stop at the stop line
		-- (example: a flashing green arrow)
		yieldAllwaysRequired (8),
		-- the allowed movements above are not protected
		-- (example: an permanent yellow condition)
		goWithHalt (9),
		-- after making a full stop, may proceed
		caution (10),
		-- proceed past stop line with caution
		reserved1 (11)
		-- used to align to 12 Bit Field
		} (SIZE(12))
	
	LaneAttributes ::= SEQUENCE {
		shareWith LaneSharing OPTIONAL,
		laneType LaneTypeAttributes
	}
	
	LaneSharing ::= BIT STRING {
		-- With bits as defined:
		overlappingLaneDescriptionProvided (0),
		-- Assert when another lane object is present to describe the
		-- path of the overlapping shared lane
		-- this construct is not used for lane objects which simply cross
		multipleLanesTreatedAsOneLane (1),
		-- Assert if the lane object path and width details represents
		-- multiple lanes within it that are not further described
		-- Various modes and type of traffic that may share this lane:
		otherNonMotorizedTrafficTypes (2), -- horse drawn etc.
		individualMotorizedVehicleTraffic (3),
		busVehicleTraffic (4),
		taxiVehicleTraffic (5),
		pedestriansTraffic (6),
		cyclistVehicleTraffic (7),
		trackedVehicleTraffic (8),
		pedestrianTraffic (9)
	} (SIZE (10))
		-- All zeros would indicate 'not shared' and 'not overlapping'
		
	LaneTypeAttributes ::= CHOICE {
		vehicle LaneAttributes-Vehicle, -- motor vehicle lanes
		crosswalk LaneAttributes-Crosswalk, -- pedestrian crosswalks
		bikeLane LaneAttributes-Bike, -- bike lanes
		sidewalk LaneAttributes-Sidewalk, -- pedestrian sidewalk paths
		median LaneAttributes-Barrier, -- medians & channelization
		striping LaneAttributes-Striping, -- roadway markings
		trackedVehicle LaneAttributes-TrackedVehicle, -- trains and trolleys
		parking LaneAttributes-Parking, -- parking and stopping lanes
		...
	}
		
	LaneAttributes-Vehicle ::= BIT STRING { 
		-- With bits as defined:
		isVehicleRevocableLane (0),
		-- this lane may be activated or not based
		-- on the current SPAT message contents
		-- if not asserted, the lane is ALWAYS present
		isRampLane (1),
		-- Redefined in Day II Standard
		hovLaneUseOnly (2),
		restrictedToBusUse (3),
		restrictedToTaxiUse (4),
		restrictedFromPublicUse (5),
		emergencyLane (6),
		-- Redefined in Day II Standard
		permissionOnRequest (7)
		-- e.g. to inform about a lane for e-cars
	} (SIZE (8,...))
		
	LaneAttributes-Crosswalk ::= BIT STRING { 
		-- With bits as defined: 
		-- MUTCD provides no suitable "types" to use here
		crosswalkRevocableLane (0),
		-- this lane may be activated or not based
		-- on the current SPAT message contents
		-- if not asserted, the lane is ALWAYS present
		bicyleUseAllowed (1),
		-- The path allows bicycle traffic,
		-- if not set, this mode is prohibited
		isXwalkFlyOverLane (2),
		-- path of lane is not at grade
		fixedCycleTime (3),
		-- ped walk phases use preset times
		-- i.e. there is not a 'push to cross' button
		biDirectionalCycleTimes (4),
		-- ped walk phases use different SignalGroupID
		-- for each direction. The first SignalGroupID
		-- in the first Connection represents 'inbound'
		-- flow (the direction of travel towards the first
		-- node point) while second SignalGroupID in the
		-- next Connection entry represents the 'outbound'
		-- flow. And use of RestrictionClassID entries
		-- in the Connect follow this same pattern in pairs.
		hasPushToWalkButton (5),
		-- Has a demand input
		audioSupport (6),
		-- audio crossing cues present
		rfSignalRequestPresent (7),
		-- Supports RF push to walk technologies
		unsignalizedSegmentsPresent (8)
		-- The lane path consists of one of more segments
		-- which are not part of a signal group ID
		-- Bits 9~15 reserved and set to zero
	} (SIZE (16))
	
	LaneAttributes-Bike ::= BIT STRING { 
		-- With bits as defined:
		bikeRevocableLane (0),
		-- this lane may be activated or not based
		-- on the current SPAT message contents
		-- if not asserted, the lane is ALWAYS present
		pedestrianUseAllowed (1),
		-- The path allows pedestrian traffic,
		-- if not set, this mode is prohibited
		isBikeFlyOverLane (2),
		-- path of lane is not at grade
		fixedCycleTime (3),
		-- the phases use preset times
		-- i.e. there is not a 'push to cross' button
		biDirectionalCycleTimes (4),
		-- ped walk phases use different SignalGroupID
		-- for each direction. The first SignalGroupID
		-- in the first Connection represents 'inbound'
		-- flow (the direction of travel towards the first
		-- node point) while second SignalGroupID in the
		-- next Connection entry represents the 'outbound'
		-- flow. And use of RestrictionClassID entries
		-- in the Connect follow this same pattern in pairs.
		isolatedByBarrier (5),
		unsignalizedSegmentsPresent (6)
		-- The lane path consists of one of more segments
		-- which are not part of a signal group ID
		-- Bits 7~15 reserved and set to zero
	} (SIZE (16))
		
	LaneAttributes-Sidewalk ::= BIT STRING { 
		-- With bits as defined:
		sidewalk-RevocableLane (0),
		-- this lane may be activated or not based
		-- on the current SPAT message contents
		-- if not asserted, the lane is ALWAYS present
		bicyleUseAllowed (1),
		-- The path allows bicycle traffic,
		-- if not set, this mode is prohibited
		isSidewalkFlyOverLane (2),
		-- path of lane is not at grade
		walkBikes (3)
		-- bike traffic must dismount and walk 
		-- Bits 4~15 reserved and set to zero
	} (SIZE (16))
		
	LaneAttributes-Barrier ::= BIT STRING { 
		-- With bits as defined:
		median-RevocableLane (0),
		-- this lane may be activated or not based
		-- on the current SPAT message contents
		-- if not asserted, the lane is ALWAYS present
		median (1),
		whiteLineHashing (2),
		stripedLines (3),
		doubleStripedLines (4),
		trafficCones (5),
		constructionBarrier (6),
		trafficChannels (7),
		lowCurbs (8),
		highCurbs (9) -- Bits 10~15 reserved and set to zero
	} (SIZE (16))
		
	LaneAttributes-Striping ::= BIT STRING { 
		-- With bits as defined:
		stripeToConnectingLanesRevocableLane (0),
		-- this lane may be activated or not activated based
		-- on the current SPAT message contents
		-- if not asserted, the lane is ALWAYS present
		stripeDrawOnLeft (1),
		stripeDrawOnRight (2),
		-- which side of lane to mark
		stripeToConnectingLanesLeft (3),
		stripeToConnectingLanesRight (4),
		stripeToConnectingLanesAhead (5)
		-- the stripe type should be
		-- presented to the user visually
		-- to reflect stripes in the
		-- intersection for the type of
		-- movement indicated 
		-- Bits 6~15 reserved and set to zero
	} (SIZE (16))
		
	LaneAttributes-TrackedVehicle ::= BIT STRING { 
		-- With bits as defined:
		spec-RevocableLane (0),
		-- this lane may be activated or not based
		-- on the current SPAT message contents
		-- if not asserted, the lane is ALWAYS present
		spec-commuterRailRoadTrack (1),
		spec-lightRailRoadTrack (2),
		spec-heavyRailRoadTrack (3),
		spec-otherRailType (4) -- Bits 5~15 reserved and set to zero
	} (SIZE (16))
		
	LaneAttributes-Parking ::= BIT STRING {
		-- With bits as defined:
		-- Parking use details, note that detailed restrictions such as
		-- allowed hours are sent by way of ITIS codes in the TIM message
		parkingRevocableLane (0),
		-- this lane may be activated or not based
		-- on the current SPAT message contents
		-- if not asserted, the lane is ALWAYS present
		parallelParkingInUse (1),
		headInParkingInUse (2),
		doNotParkZone (3),
		-- used to denote fire hydrants as well as
		-- short disruptions in a parking zone
		parkingForBusUse (4),
		parkingForTaxiUse (5),
		noPublicParkingUse (6)
		-- private parking, as in front of
		-- private property 
		-- Bits 7~15 reserved and set to zero
	} (SIZE (16))
	
	SpeedLimitList ::= SEQUENCE (SIZE(1..9)) OF RegulatorySpeedLimit
	
	RegulatorySpeedLimit ::= SEQUENCE {
		type SpeedLimitType,
		-- The type of regulatory speed which follows
		speed Speed
		-- The speed in units of 0.02 m/s
		-- See Section 11 for converting and translating
		-- speed expressed in mph into units of m/s
		}
	
	SpeedLimitType ::= ENUMERATED {
		unknown, -- Speed limit type not available
		maxSpeedInSchoolZone, -- Only sent when the limit is active
		maxSpeedInSchoolZoneWhenChildrenArePresent, -- Sent at any time
		maxSpeedInConstructionZone, -- Used for work zones, incident zones, etc.
		-- where a reduced speed is present
		vehicleMinSpeed,
		vehicleMaxSpeed, -- Regulatory speed limit for general traffic
		vehicleNightMaxSpeed,
		truckMinSpeed,
		truckMaxSpeed,
		truckNightMaxSpeed,
		vehiclesWithTrailersMinSpeed,
		vehiclesWithTrailersMaxSpeed,
		vehiclesWithTrailersNightMaxSpeed,
		...
	}
	
	PointList ::= SEQUENCE (SIZE(2..31)) OF RoadPoint
	-- At least 2 points of 1 lane
	-- entry line and exit line
	-- points need to be listed sequentially
	-- from upstream to downstream
	
	RoadPoint ::= SEQUENCE {
		posOffset PositionOffsetLLV,
		-- Position offset to the reference position
		...
	}
	
	-- Day II Extension--------------------------------
	LinkExList ::= SEQUENCE (SIZE(1..32)) OF LinkEx
	
	LinkEx ::= SEQUENCE {
		name DescriptiveName OPTIONAL,
		-- Link name
		
		upstreamNodeId NodeReferenceID,
		-- this link is from upstreamNode to the Node it belongs to
		
		speedLimits SpeedLimitList OPTIONAL,
		-- List all the speed limits
		
		linkWidth LaneWidth OPTIONAL,
		-- Width of this link
		
		refLine PointList OPTIONAL,
		-- Define reference line of this link
		-- Using the points list from upstream to downstream
		-- along the center of lane 0 of this link
		-- Ref. line must cover the whole link, from the link entrance to the stop line
		
		movements-ex MovementExList OPTIONAL,
		-- Define movements at intersection
		
		sections SectionList,
		-- Link sections belong to this link
		-- listed from upstream to downstream
		-- Different sections are generally seperated according to lane increase or decrease
		...
	}
	
	MovementExList ::= SEQUENCE (SIZE(1..32)) OF MovementEx
	
	MovementEx ::= SEQUENCE {
		remoteIntersection NodeReferenceID,
		-- This entry indicates the downstream intersection of the link this lane connects to. 
		-- This provides a means to create meshes of lanes
		
		phaseId PhaseID OPTIONAL,
		-- The matching signal group send by
		-- the SPAT message for this lane/maneuver.
		-- Shall be present unless the connectingLane
		-- has no signal group (is un-signalized)
		
		turn-direction Maneuver OPTIONAL,
		-- Indicating the turn direction corresponding to this movement
		
		...
	}
	
	Maneuver ::= ENUMERATED {
		maneuverStraight (0),
		maneuverLeftTurn (1),
		maneuverRightTurn (2),
		maneuverUTurn (3),
		...
	}
	
	SectionList ::= SEQUENCE (SIZE(1..16)) OF Section
	
	Section ::= SEQUENCE {
		secId SectionId,
		-- Section id is distributed from upstream to downstream
		-- with 1, 2, 3, ..., sequentially
		lanes LaneExList,
		-- Lanes belong to this link
		...
	}
	
	SectionId ::= INTEGER (1..63) 
	
	LaneExList ::= SEQUENCE (SIZE(1..32)) OF LaneEx
	
	LaneEx ::= SEQUENCE {
		laneRefID LaneRefID,
		-- Lane reference id related to reference line of this link
		-- Ref. line belongs to lane ref. id 0
		-- Lane ref. ids on the left side of ref. line should be 1, 2, 3... in sequence
		-- Ref. ids on the right side should be -1, -2, -3... in sequence
		laneWidth LaneWidth OPTIONAL,
		laneAttributes LaneAttributes OPTIONAL,
		-- Define basic attribute of lane
		maneuvers AllowedManeuvers OPTIONAL,
		-- the permitted maneuvers for this lane
		connectsTo-ex ConnectsToExList OPTIONAL,
		-- connection to downsteam lanes
		speedLimits SpeedLimitList OPTIONAL,
		-- List all the speed limits
		st-points STPointList OPTIONAL,
		-- Points list of the center of this lane
		-- using ST coordinates
		laneLineType LaneLineType OPTIONAL,
		...
	}
	
	LaneLineType ::= SEQUENCE{
		leftLaneLine Dotted-SolidMarkingLineType,
		rightLaneLine Dotted-SolidMarkingLineType
	}
	
	Dotted-SolidMarkingLineType::= ENUMERATED {
		whiteDottedLine(0),
		whiteSolidLine(1),
		yellowDottedLine(2),
		yellowSolidLine(3),
		whiteDotted-solidLine(4),
		-- 白色虚实线（内侧为虚线） ，可临时跨越同向车道
		whiteSotted-dottedLine(5),
		-- 白色实虚线 （内侧为实线），同向车道可临时跨越至本车道，本车道禁止跨越到同向车道
		yellowDotted-solidLine(6),
		--黄色虚实线（内侧为虚线），可临时跨越对向车道
		yellowSotted-dottedLine(7),
		--黄色虚实线（内侧为实线），对向车道可临时跨越至本车道，本车道禁止跨越到对向车道
		...
	}
	
	LaneRefID ::= INTEGER (-31..31) 
	
	ConnectsToExList ::= SEQUENCE (SIZE(1..32)) OF ConnectionEx
	
	ConnectionEx::= SEQUENCE {
		remoteIntersection NodeReferenceID,
		-- This entry indicates the downstream intersection of the link this lane connects to. 
		-- This provides a means to create meshes of lanes
		
		swl SignalWaitingLane OPTIONAL,
		-- waiting area for certain signal phase
		-- usually set for left turn
		
		connectingLane SEQUENCE (SIZE(1..16)) OF ConnectingLaneEx OPTIONAL,
		-- The index of the connecting lane and also
		-- the maneuver from the current lane to it
		-- When we want to list the allowed lanes of the next link
		-- this lane can lead to, we use this entry
		
		phaseId PhaseID OPTIONAL,
		-- The matching signal group send by
		-- the SPAT message for this lane/maneuver.
		-- Shall be present unless the connectingLane
		-- has no signal group (is un-signalized)
		
		turn-direction Maneuver OPTIONAL,
		-- Indicating the turn direction corresponding to this movement
		...
	}
	
	SignalWaitingLane ::= SEQUENCE {
		laneWidth LaneWidth,
		points PointList,
		allowedPhaseIds SEQUENCE (SIZE(1..7)) OF PhaseID OPTIONAL
		-- e.g. for a typiccal left turn waiting area, both left turn phase and go straight phase are allowed
	}
	
	ConnectingLaneEx ::= SEQUENCE {
		target-section SectionId,
		target-lane LaneRefID, 
		-- Index of the connecting lane
		
		connectingLaneWidth LaneWidth OPTIONAL,
		-- Indicating the width of the real or virtual connecting lane
		connectingLanePoints PointList OPTIONAL,
		-- Indicating the position of the real or virtual connecting lane
		isolatedConnectingLane BOOLEAN OPTIONAL
		-- A real isolated connecting lane is seperated from any other lanes
		-- Usually exists in right turning
	}
	
	STPointList ::= SEQUENCE (SIZE(2..63)) OF ST-Point
	
	ST-Point ::= SEQUENCE {
		s-axis INTEGER (-1024..65535),
		-- Unit 0.1m
		-- Longitudinal length related to the ref. line
		t-axis INTEGER (-32768..32767),
		-- Unit 0.01m
		-- Latitudinal distance in st coordinates
		-- Positive in the left of ref. line
		-- Negative in the right of ref. line
		...
	}
	
	ProhibitedZone ::= SEQUENCE {
		centralCircleProhibitedZone Polygon OPTIONAL,
		non-motorVehicleProhibitedZones SEQUENCE (SIZE(1..16)) OF Polygon OPTIONAL,
		gridLineMarkingProhibitedZones SEQUENCE (SIZE(2..16)) OF Polygon OPTIONAL,
		-- Gird line marking prohibited zones 
		-- inside the node(intersection) or at the in-links of this node
		...
	}

	
END
