-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathObserver.cs
56 lines (49 loc) · 1.59 KB
/
Observer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System.Collections.Generic;
using StereoKit;
using SimpleJSON;
namespace DutchSkies
{
public class Observer
{
public string id;
public float lat, lon;
public float floor_altitude; // meters
public Vec3 map_position;
public bool on_map; // XXX
public Observer(string id, float lat, float lon, float floor_altitude)
{
this.id = id;
this.lat = lat;
this.lon = lon;
this.floor_altitude = floor_altitude;
on_map = false;
}
public void update_map_position(OSMMap map)
{
on_map = lat >= map.min_lat && lat <= map.max_lat && lon >= map.min_lon && lon <= map.max_lon;
float x = 0f, y = 0f;
map.Project(out x, out y, lon, lat);
map_position = new Vec3(x, y, floor_altitude / 1000f);
Log.Info($"Observer: lat {lat:F6}, lon {lon:F6}, alt {floor_altitude} m (map pos = {x:F6}, {y:F6})");
}
}
public class ObserverSet
{
public string id;
public Dictionary<string, Observer> observers;
public string default_observer;
public ObserverSet(string id)
{
this.id = id;
observers = new Dictionary<string, Observer>();
default_observer = "";
}
public void Add(string ob_id, Observer observer)
{
Log.Info($"ObserverSet.Add '{ob_id}'");
observers[ob_id] = observer;
if (observers.Count == 1)
default_observer = ob_id;
}
}
}