Added GPS
This commit is contained in:
@@ -15,6 +15,7 @@ public class MapRenderer : MonoBehaviour
|
||||
public float queryRadiusMeters = 200f; // radius around lat/lon to query
|
||||
|
||||
[Header("Location (lat, lon)")]
|
||||
public GPSManager gpsManager;
|
||||
private double latitude = 50.7727878;
|
||||
private double longitude = 15.0718625;
|
||||
|
||||
@@ -26,30 +27,31 @@ public class MapRenderer : MonoBehaviour
|
||||
[Header("Road settings")]
|
||||
public Material roadMaterial;
|
||||
public float defaultRoadWidth = 4.0f; // meters
|
||||
public float motorwayWidth = 10.0f;
|
||||
public float primaryWidth = 8.0f;
|
||||
public float secondaryWidth = 6.0f;
|
||||
public float tertiaryWidth = 5.0f;
|
||||
|
||||
|
||||
[Header("Misc")]
|
||||
public float metersPerUnit = 1f; // scale: 1 unit = 1 meter
|
||||
public bool autoStart = true;
|
||||
|
||||
|
||||
[Header("Storage")]
|
||||
Dictionary<long, Vector2> nodes = new Dictionary<long, Vector2>(); // id -> latlon
|
||||
List<Way> parsedWays = new List<Way>();
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (autoStart) { StartCoroutine(RenderMap()); }
|
||||
}
|
||||
|
||||
public void StartGenerating()
|
||||
{
|
||||
StartCoroutine(RenderMap());
|
||||
}
|
||||
|
||||
IEnumerator RenderMap()
|
||||
{
|
||||
ClearChildren();
|
||||
|
||||
//TODO: GPS update
|
||||
double[] GPS = gpsManager.GetLastCoords();
|
||||
latitude = GPS[0];
|
||||
longitude = GPS[1];
|
||||
|
||||
string q = $"[out:xml][timeout:90];(way[\"building\"](around:{queryRadiusMeters.ToString().Replace(",", ".")},{latitude.ToString().Replace(",", ".")},{longitude.ToString().Replace(",", ".")});way[\"highway\"](around:{queryRadiusMeters.ToString().Replace(",", ".")},{latitude.ToString().Replace(",", ".")},{longitude.ToString().Replace(",", ".")}););(._;>;);out body;";
|
||||
|
||||
@@ -337,10 +339,10 @@ public class MapRenderer : MonoBehaviour
|
||||
{
|
||||
// simple heuristic
|
||||
string h = w.tags["highway"];
|
||||
if (h == "motorway") width = 10f;
|
||||
else if (h == "primary") width = 8f;
|
||||
else if (h == "secondary") width = 6f;
|
||||
else if (h == "tertiary") width = 5f;
|
||||
if (h == "motorway") width = motorwayWidth;
|
||||
else if (h == "primary") width = primaryWidth;
|
||||
else if (h == "secondary") width = secondaryWidth;
|
||||
else if (h == "tertiary") width = tertiaryWidth;
|
||||
else width = defaultRoadWidth;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user