Function Repository Resource:

WorldTravellerSignpostSolve

Source Notebook

Find the location of a signpost with given distances to a set of cities

Contributed by: Sander Huisman

ResourceFunction["WorldTravellerSignpostSolve"][{{loc1, dist1},{loc2, dist2},}]

given the locations loci and distances disti find the location of the signpost.

Details

The algorithm finds the location p for which the sum of distance errors (distance from p to loci minus disti) squared is minimized: ∑i=1n(||p-loci||-disti)2 All locations loci are included in the calculation. The error between the distance from p to loci and disti can be anything such that even crude values will give a satisfactory answer. In general the crudeness/precision of the distances given gives the precision of the found location.

Examples

Basic Examples (1) 

Given a set of cities and their distance, what is the location of the signpost:

In[1]:=
locs = {
   {Entity["City", {"LosAngeles", "California", "UnitedStates"}], Quantity[9060, "Kilometers"]},
   {Entity["City", {"NewYork", "NewYork", "UnitedStates"}], Quantity[6013, "Kilometers"]},
   {Entity["City", {"Berlin", "Berlin", "Germany"}], Quantity[431, "Kilometers"]},
   {Entity["City", {"Oslo", "Oslo", "Norway"}], Quantity[901, "Kilometers"]}
   };
ResourceFunction["WorldTravellerSignpostSolve"][locs]
Out[2]=

Scope (1) 

Numbers are interpreted as kilometers:

In[3]:=
locs = {
   {Entity["City", {"LosAngeles", "California", "UnitedStates"}], 9000},
   {Entity["City", {"NewYork", "NewYork", "UnitedStates"}], 6000},
   {Entity["City", {"Berlin", "Berlin", "Germany"}], Quantity[431, "Kilometers"]},
   {Entity["City", {"Oslo", "Oslo", "Norway"}], Quantity[901, "Kilometers"]}
   };
ResourceFunction["WorldTravellerSignpostSolve"][locs]
Out[4]=

Neat Examples (2) 

Given the signpost, find the location:

In[5]:=
locs = {
   {Entity["Neighborhood", "Waikiki::Honolulu::Hawaii::UnitedStates"],
     Quantity[9920, "Miles"]},
   {Entity["Country", "SouthAfrica"], Quantity[2774, "Miles"]},
   {Entity["City", {"HongKong", "HongKong", "HongKong"}], Quantity[4373, "Miles"]},
   {Entity["Country", "Jamaica"], Quantity[9113, "Miles"]},
   {Entity["City", {"Prague", "Prague", "CzechRepublic"}], Quantity[4542, "Miles"]},
   {Entity["Country", "Barbados"], Quantity[7970, "Miles"]},
   {Entity["City", {"NewYork", "NewYork", "UnitedStates"}], Quantity[8442, "Miles"]},
   {Entity["AdministrativeDivision", {"California", "UnitedStates"}], Quantity[10189, "Miles"]},
   {Entity["City", {"Prague", "Prague", "CzechRepublic"}], Quantity[4542, "Miles"]},
   {Entity["City", {"Barcelona", "Barcelona", "Spain"}], Quantity[4626, "Miles"]}
   };
loc = ResourceFunction["WorldTravellerSignpostSolve"][locs]
Out[6]=

Find the country:

In[7]:=
GeoNearest["Country", loc]
Out[7]=

Visualize the lines and the found minimum:

In[8]:=
GeoGraphics[{GeoCircle @@@ locs, GeoMarker[loc]}, GeoCenter -> loc, GeoRange -> "World", ImageSize -> 600]
Out[8]=

Investigate the effect of the precision of the distances on the final location. Given a location, and some random cities, find the estimates for 'rounded' distances:

In[9]:=
SeedRandom[1234];
p = GeoPosition[{16.78`, -3.01`}];
places = Table[RandomGeoPosition[], {15}];
dists = GeoDistance[p, #] & /@ places;
dists = QuantityMagnitude[#, "Kilometers"] & /@ dists;
poss = Table[{a, ResourceFunction[
    "WorldTravellerSignpostSolve"][{places, Round[dists, a]} // Transpose]}, {a, {0.1, 0.3, 1, 3, 10, 30, 100, 300, 1000}}]
Out[10]=

Plot the error in the location as a function of the rounding:

In[11]:=
ListLogLogPlot[{poss[[All, 1]], QuantityMagnitude[GeoDistance[p, #], "Kilometers"] & /@ poss[[All, 2]]} // Transpose, FrameLabel -> {"Rounding in distances [m]", "Error in location [m]"},
 Frame -> True
 ]
Out[11]=

We see that the error in the location is much better than the errors introduced by rounding.

Publisher

SHuisman

Version History

  • 1.0.0 – 19 May 2023

Related Resources

License Information