mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Update Towns.lua
This commit is contained in:
parent
17f672dad4
commit
629925e2d8
@ -83,7 +83,7 @@ TOWNS = {
|
|||||||
|
|
||||||
--- TOWNS class version.
|
--- TOWNS class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
TOWNS.version="0.0.0"
|
TOWNS.version="0.0.1"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- ToDo list
|
-- ToDo list
|
||||||
@ -92,6 +92,7 @@ TOWNS.version="0.0.0"
|
|||||||
-- TODO: A lot...
|
-- TODO: A lot...
|
||||||
-- TODO: Road connection
|
-- TODO: Road connection
|
||||||
-- TODO: Rail connection
|
-- TODO: Rail connection
|
||||||
|
-- TODO: Connection between towns
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Constructor(s)
|
-- Constructor(s)
|
||||||
@ -114,6 +115,12 @@ function TOWNS:NewFromTable(TownTable)
|
|||||||
-- Get coordinate
|
-- Get coordinate
|
||||||
town.coordinate=COORDINATE:NewFromLLDD(town.latitude, town.longitude)
|
town.coordinate=COORDINATE:NewFromLLDD(town.latitude, town.longitude)
|
||||||
|
|
||||||
|
-- Get coordinate of closest road
|
||||||
|
town.coordRoad=town.coordinate:GetClosestPointToRoad()
|
||||||
|
|
||||||
|
-- Get coordinate of closest rail
|
||||||
|
town.coordRail=town.coordinate:GetClosestPointToRoad(true)
|
||||||
|
|
||||||
-- Add to table
|
-- Add to table
|
||||||
table.insert(self.towns, town)
|
table.insert(self.towns, town)
|
||||||
end
|
end
|
||||||
@ -170,6 +177,34 @@ function TOWNS:GetCoordinate(town)
|
|||||||
return town.coordinate
|
return town.coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get closest road coordinate of a town.
|
||||||
|
-- @param #TOWNS self
|
||||||
|
-- @param #TOWNS.Town town The town data structure.
|
||||||
|
-- @return Core.Point#COORDINATE The closest road coordinate.
|
||||||
|
function TOWNS:GetCoordRoad(town)
|
||||||
|
return town.coordRoad
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get closest rail coordinate of a town.
|
||||||
|
-- @param #TOWNS self
|
||||||
|
-- @param #TOWNS.Town town The town data structure.
|
||||||
|
-- @return Core.Point#COORDINATE The closest rail coordinate.
|
||||||
|
function TOWNS:GetCoordRail(town)
|
||||||
|
return town.coordRail
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get road connection between two towns.
|
||||||
|
-- @param #TOWNS self
|
||||||
|
-- @param #TOWNS.Town townA The town data structure.
|
||||||
|
-- @param #TOWNS.Town townB The town data structure.
|
||||||
|
-- @return #table Table containing path coordinates.
|
||||||
|
function TOWNS:GetConnectionRoad(townA, townB)
|
||||||
|
|
||||||
|
local path=townA.coordRoad:GetPathOnRoad(townB.coordRoad)
|
||||||
|
|
||||||
|
return path
|
||||||
|
end
|
||||||
|
|
||||||
--- Find closest town to a given coordinate.
|
--- Find closest town to a given coordinate.
|
||||||
-- @param #TOWNS self
|
-- @param #TOWNS self
|
||||||
-- @param Core.Point#COORDINATE Coordinate The reference coordinate.
|
-- @param Core.Point#COORDINATE Coordinate The reference coordinate.
|
||||||
@ -182,7 +217,7 @@ function TOWNS:GetClosestTown(Coordinate)
|
|||||||
for _,_town in pairs(self.towns) do
|
for _,_town in pairs(self.towns) do
|
||||||
local town=_town --#TOWNS.Town
|
local town=_town --#TOWNS.Town
|
||||||
|
|
||||||
local dist=Coordinate:Get2DDistance(bc.coordinate)
|
local dist=Coordinate:Get2DDistance(town.coordinate)
|
||||||
|
|
||||||
if dist<distmin then
|
if dist<distmin then
|
||||||
distmin=dist
|
distmin=dist
|
||||||
@ -208,8 +243,8 @@ function TOWNS:MarkerShow(Town)
|
|||||||
|
|
||||||
for _,_town in pairs(self.towns) do
|
for _,_town in pairs(self.towns) do
|
||||||
local town=_town --#TOWNS.Town
|
local town=_town --#TOWNS.Town
|
||||||
if Town==nil or Town.name==Town.name then
|
if Town==nil or Town.name==town.name then
|
||||||
local text=self:_GetMarkerText(Town)
|
local text=self:_GetMarkerText(town)
|
||||||
local coord=town.coordinate
|
local coord=town.coordinate
|
||||||
if town.markerID then
|
if town.markerID then
|
||||||
UTILS.RemoveMark(town.markerID)
|
UTILS.RemoveMark(town.markerID)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user