--
-- a road segment
--

function roadseg_ctor (self, Lanes, RLanes, Median)

   -- this defines one section of road; they are linked together; we are generally interested
   -- in how many lanes, etc.

   self.lanes = Lanes -- how many lanes in our direction
   self.rlanes = RLanes -- how many lanes in the opposite direction
   self.median = Median -- how many lanes wide is the median

   -- off/on ramps; these take up the rightmost lane
   self.exit_flag = nil
   self.exit_radius = 0
   self.exit_spinout_kph = 0 -- how many kph or less to avoid spinout

   -- terrain swatch seed
   self.terrain_seed = RN_get_seed ()

   -- on ramp
   self.entrance_flag = nil
   self.entrance_radius = 0

   -- is this an overpass?
   self.overpass_flag = nil
   self.overpass_lanes = 0
   self.overpass_rlanes = 0
   self.overpass_median = 0

   -- message and message range associated with this road segment
   self.message_flag = nil
   self.message_range_m = 0 -- how many meters before does this message appear
   self.message_string = nil

   -- lane speeds; this can be used to set a lower speed limit for an outer lane, e.g., for
   -- the lane before an exit ramp)
   self.lane_speeds = {}
end

roadseg = class (roadseg_ctor)

function roadseg:init_exit (Radius, SpinoutKPH, Node)

   self.exit_flag = true
   self.exit_radius = Radius
   self.exit_spinout_kph = SpinoutKPH
   self.exit_node = Node
end

function roadseg:init_entrance (Radius)

   self.entrance_flag = true
   self.entrance_radius = Radius
end

function roadseg:init_overpass (Lanes, RLanes, Median)

   self.overpass_flag = true
   self.overpass_lanes = Lanes
   self.overpass_rlanes = RLanes
   self.overpass_median = Median
end

function roadseg:init_message (RangeM, Text)

   self.message_flag = true
   self.message_range_m = RangeM
   self.message_text = Text
end

function roadseg:set_lane_speed (LaneID, Speed)

   self.lane_speeds[LaneID] = Speed
end
