Beispiel #1
0
    // Use this for initialization

    void Start()
    {
        nodes = new Dictionary <ulong, OsmNode> ();
        ways  = new List <OsmWay> ();


        var txtAsset = Resources.Load <TextAsset> (resourceFile);

        XmlDocument doc = new XmlDocument();

        doc.LoadXml(txtAsset.text);


        SetBounds(doc.SelectSingleNode("/osm/bounds"));
        GetNodes(doc.SelectNodes("/osm/node"));
        GetWays(doc.SelectNodes("/osm/way"));

        float minx = (float)MercatorProjection.lonToX(bounds.MinLon);
        float maxx = (float)MercatorProjection.lonToX(bounds.MaxLon);
        float miny = (float)MercatorProjection.latToY(bounds.MinLat);
        float maxy = (float)MercatorProjection.latToY(bounds.MaxLat);

        groundPlane.transform.localScale = new Vector3((maxx - minx) / 2, 1, (maxy - miny) / 2);

        IsReady = true;
    }
Beispiel #2
0
    /// <summary>
    /// Updates the models position using GPS coordinates.
    /// Also creates smooth walking animation between the old model
    /// position and new model position.
    /// </summary>
    void Update()
    {
        x = (float)MercatorProjection.lonToX(Gps.instance.longitude);
        y = (float)MercatorProjection.latToY(Gps.instance.latitude);

        newPos = new Vector3(x, 0f, y);
        newPos = newPos - map.bounds.centre;

        float t = Mathf.SmoothStep(0f, 1f, Mathf.PingPong(1 / 25f, 1f));

        //Linearly adjusts rotation and position.
        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(newPos), 0.15f);
        transform.position = Vector3.Lerp(transform.position, newPos, t);

        float distance = Vector3.Distance(transform.position, newPos);

        if (distance < 2)
        {
            anim.SetFloat("MoveSpeed", Mathf.SmoothStep(v, 0f, time));
        }
        else
        {
            v = Mathf.SmoothStep(0f, 1f, time);
            anim.SetFloat("MoveSpeed", v);
        }

        time += 0.5f * Time.deltaTime;

        if (time > 1.0f)
        {
            time = 1.0f;
        }
    }
Beispiel #3
0
    /// <summary>
    /// Spawns new enemies when they are sent from the server.
    /// </summary>
    /// <param name="enemies">List of type Enemy of all the enemies to be spawned.</param>
    void Spawn(List <Enemy> enemies)
    {
        //Only execute in the Map scene.
        if (SceneManager.GetActiveScene().name == "Map Reader Test")
        {
            //Destroy any current spawned enemies
            for (int i = enemyParent.transform.childCount; i > 0; i--)
            {
                Destroy(enemyParent.transform.GetChild(i - 1).gameObject);
            }

            //Instantiate each new enemy.
            foreach (Enemy e in enemies)
            {
                float   x        = (float)MercatorProjection.lonToX(e.lon);
                float   y        = (float)MercatorProjection.latToY(e.lat);
                Vector3 position = new Vector3(x, 0, y);
                position = position - map.bounds.centre;

                if (e.name == "wizard")
                {
                    var newWizard = Instantiate(wizard, position, transform.rotation);
                    newWizard.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
                    newWizard.transform.SetParent(enemyParent.transform);
                }
                else if (e.name == "skeleton")
                {
                    var newSkeleton = Instantiate(skeleton, position, transform.rotation);
                    newSkeleton.transform.SetParent(enemyParent.transform);
                }
            }
        }
    }
Beispiel #4
0
    public Vector2 GetUnityMapCenter()
    {
        Vector2 gpsMapCenter = GetGPSMapCenter();
        double  x            = MercatorProjection.lonToX(gpsMapCenter.x);
        double  y            = MercatorProjection.latToY(gpsMapCenter.y);

        return(new Vector2((float)x, (float)y));
    }
 public OsmNode(XmlNode node)
 {
     ID        = GetAttribute <ulong>("id", node.Attributes);
     Latitude  = GetAttribute <float>("lat", node.Attributes);
     Longitude = GetAttribute <float>("lon", node.Attributes);
     X         = (float)MercatorProjection.lonToX(Longitude);
     Y         = (float)MercatorProjection.latToY(Latitude);
 }
Beispiel #6
0
        private static Vector3[] ParseCoords(Model model, MultiResidenceInputs input)
        {
            var    rows     = ParseCSV(System.IO.File.ReadAllText(input.Site.LocalFilePath));
            var    points   = new List <Vector3>();
            double x        = 0.0;
            var    xCorrect = 0.0;
            var    yCorrect = 0.0;

            for (int i = 0; i < rows[0].Count(); i++)
            {
                if (i == 0 &&
                    double.TryParse(rows[0][0].ToString(), out double lon) &&
                    double.TryParse(rows[0][1].ToString(), out double lat))
                {
                    xCorrect     = MercatorProjection.lonToX(lon);
                    yCorrect     = MercatorProjection.lonToX(lat);
                    model.Origin = new Position(lon, lat);
                }
                if (i % 2 == 0 && double.TryParse(rows[0][i].ToString(), out lon))
                {
                    x = MercatorProjection.lonToX(lon) - xCorrect;
                }
                else if (double.TryParse(rows[0][i].ToString(), out lat))
                {
                    points.Add(new Vector3(x, MercatorProjection.lonToX(lat) - yCorrect));
                }
            }
            //double.TryParse(rows[1][0].ToString(), out double parkX);
            //double.TryParse(rows[1][1].ToString(), out double parkY);
            //parkX = (MercatorProjection.lonToX(parkX) - xCorrect) * 0.001;
            //parkY = (MercatorProjection.latToY(parkY) - yCorrect) * 0.001;

            //double.TryParse(rows[2][0].ToString(), out double busX);
            //double.TryParse(rows[2][1].ToString(), out double busY);
            //busX = (MercatorProjection.lonToX(busX) - xCorrect) * 0.001;
            //busY = (MercatorProjection.latToY(busY) - yCorrect) * 0.001;

            //double.TryParse(rows[3][0].ToString(), out double schoolX);
            //double.TryParse(rows[3][1].ToString(), out double schoolY);
            //schoolX = (MercatorProjection.lonToX(schoolX) - xCorrect) * 0.001;
            //schoolY = (MercatorProjection.latToY(schoolY) - yCorrect) * 0.001;

            //model.AddElement(new Mass(new Profile(Elements.Geometry.Polygon.Circle(20.0, 50)),
            //                          0.1,
            //                          new Material("park", Palette.Green),
            //                          new Transform(parkX, parkY, 0.5)));

            //model.AddElement(new Mass(new Profile(Elements.Geometry.Polygon.Circle(1.0)),
            //                  5.0,
            //                  new Material("bus", Palette.Cobalt),
            //                  new Transform(busX, busY, 0.0)));

            //model.AddElement(new Mass(new Profile(Elements.Geometry.Polygon.Rectangle(30.0, 30.0)),
            //                  5.0,
            //                  new Material("school", Palette.Lavender),
            //                  new Transform(schoolX, schoolY, 0.0)));
            return(points.Distinct().ToArray());
        }
Beispiel #7
0
    public OsmNode(XmlNode node) // 读每个node 的id, lat and lon;
    {
        ID        = GetAttribute <ulong>("id", node.Attributes);
        Latitude  = GetAttribute <float>("lat", node.Attributes);// lat 和 lon 是在球面的,现在要转换成平面
        Longitude = GetAttribute <float>("lon", node.Attributes);

        X = (float)MercatorProjection.lonToX(Longitude);
        Y = (float)MercatorProjection.latToY(Latitude);
    }
Beispiel #8
0
    /// <summary>
    /// Creates an OsmNode with id, latitude and longitude from the given node.
    /// </summary>
    /// <param name="node">The from which the values are extracted.</param>
    public OsmNode(XmlNode node)
    {
        id        = GetAttribute <ulong>("id", node.Attributes);
        latitude  = GetAttribute <float>("lat", node.Attributes);
        longitude = GetAttribute <float>("lon", node.Attributes);

        x = (float)MercatorProjection.lonToX(longitude);
        y = (float)MercatorProjection.latToY(latitude);
    }
Beispiel #9
0
    /// <summary>
    /// Constructor
    /// </summary>
    public NodeFactory(XmlNode node)
    {
        id = GetAttributes <ulong>("id", node.Attributes);
        // visible = GetAttributes<bool>("visible", node.Attributes);
        lat = GetAttributes <float>("lat", node.Attributes);
        lon = GetAttributes <float>("lon", node.Attributes);

        // Calculate x and y coordinates
        x = (float)MercatorProjection.lonToX(lon);
        y = (float)MercatorProjection.latToY(lat);
    }
    /// <summary>
    /// Constructor.
    /// </summary>
    /// <param name="node">Xml node</param>
    public OsmNode(XmlNode node)
    {
        // Get the attribute values
        ID        = GetAttribute <ulong>("id", node.Attributes);
        Latitude  = GetAttribute <float>("lat", node.Attributes);
        Longitude = GetAttribute <float>("lon", node.Attributes);

        // Calculate the position in Unity units
        X = (float)MercatorProjection.lonToX(Longitude);
        Y = (float)MercatorProjection.latToY(Latitude);
    }
Beispiel #11
0
 public void CalculateVertices(BoundingBox box)
 {
     LeftBottom = new Vector3((float)(MercatorProjection.lonToX(box.West)), 0,
                              (float)(MercatorProjection.latToY(box.South)));
     LeftTop = new Vector3((float)(MercatorProjection.lonToX(box.West)), 0,
                           (float)(MercatorProjection.latToY(box.North)));
     RightBottom = new Vector3((float)(MercatorProjection.lonToX(box.East)), 0,
                               (float)(MercatorProjection.latToY(box.South)));
     RightTop = new Vector3((float)(MercatorProjection.lonToX(box.East)), 0,
                            (float)(MercatorProjection.latToY(box.North)));
 }
    public OsmBounds(XmlNode node)
    {
        MinLat = GetAttribute <float>("minlat", node.Attributes);
        MaxLat = GetAttribute <float>("maxlat", node.Attributes);
        MinLon = GetAttribute <float>("minlon", node.Attributes);
        MaxLon = GetAttribute <float>("maxlon", node.Attributes);

        float x = (float)(MercatorProjection.lonToX(MaxLon) + MercatorProjection.lonToX(MinLon)) / 2;
        float y = (float)(MercatorProjection.latToY(MaxLat) + MercatorProjection.latToY(MinLat)) / 2;

        Centre = new Vector3(x, 0, y);
    }
Beispiel #13
0
    /// <summary>
    /// Sets the model to the clients GPS location.
    /// </summary>
    private void Start()
    {
        anim = gameObject.transform.GetChild(0).GetComponent <Animator>();
        anim.SetBool("Grounded", true);

        map = GameObject.Find("Map").GetComponent <MapReader>();

        x = (float)MercatorProjection.lonToX(Gps.instance.longitude);
        y = (float)MercatorProjection.latToY(Gps.instance.latitude);

        newPos             = new Vector3(x, 0f, y);
        transform.position = newPos - map.bounds.centre;
    }
Beispiel #14
0
    /// <summary>
    /// Constructs the OSMNode based on the attributes in the given XmlNode
    /// </summary>
    /// <param name="xmlNode">XmlNode with construction attributes</param>
    public OSMNode(XmlNode xmlNode, Vector3 mapCenter)
    {
        // OSM attributes
        ID        = GetAttribute <ulong>("id", xmlNode.Attributes);
        Latitude  = GetAttribute <float>("lat", xmlNode.Attributes);
        Longitude = GetAttribute <float>("lon", xmlNode.Attributes);

        // Convertion of OSM position attributes to unity positions
        XCoord = (float)MercatorProjection.lonToX(Longitude);
        YCoord = (float)MercatorProjection.latToY(Latitude);

        WorldCoord = new Vector3(XCoord - mapCenter.x, -mapCenter.y, YCoord - mapCenter.z);
    }
Beispiel #15
0
    public Vector2 GetGPSAsUnityPosition(Vector2 gpsLocation)
    {
        double posX = MercatorProjection.lonToX(gpsLocation.x);
        double posY = MercatorProjection.latToY(gpsLocation.y);

        Vector2 mapCenter = GetUnityMapCenter();

        posX -= mapCenter.x;
        posX /= GetZoom();
        posY -= mapCenter.y;
        posY /= GetZoom();

        return(new Vector2((float)posY, (float)posX));
    }
    //<bounds minlat="59.3356100" minlon="18.0864400" maxlat="59.3394800" maxlon="18.0984100"/>

    public OsmBounds(XmlNode node)
    {
        MinLat = GetAttribute <float>("minlat", node.Attributes);
        MaxLat = GetAttribute <float>("maxlat", node.Attributes);
        MinLon = GetAttribute <float>("minlon", node.Attributes);
        MaxLon = GetAttribute <float>("maxlon", node.Attributes);

        //calculate the center
        float x = (float)((MercatorProjection.lonToX(MaxLon) + MercatorProjection.lonToX(MinLon)) / 2);
        float y = (float)((MercatorProjection.latToY(MaxLat) + MercatorProjection.latToY(MinLat)) / 2);

        Centre = new Vector3(x, 0, y);
        //这个center point 可以设到(0,0,0),让我们所有的点都与之相关联
    }
Beispiel #17
0
    /// <summary>
    /// Constructor.
    /// </summary>
    /// <param name="node">Xml node</param>
    public OsmBounds(XmlNode node)
    {
        // Get the values from the node
        MinLat = GetAttribute <float>("minlat", node.Attributes);
        MaxLat = GetAttribute <float>("maxlat", node.Attributes);
        MinLon = GetAttribute <float>("minlon", node.Attributes);
        MaxLon = GetAttribute <float>("maxlon", node.Attributes);

        // Create the centre location
        float x = (float)((MercatorProjection.lonToX(MaxLon) + MercatorProjection.lonToX(MinLon)) / 2);
        float y = (float)((MercatorProjection.latToY(MaxLat) + MercatorProjection.latToY(MinLat)) / 2);

        Centre = new Vector3(x, 0, y);
    }
Beispiel #18
0
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="xmlNode">XML node</param>
    public BoundsFactory(XmlNode xmlNode)
    {
        // Get the values from the node
        minlat = GetAttributes <float>("minlat", xmlNode.Attributes);
        minlon = GetAttributes <float>("minlon", xmlNode.Attributes);
        maxlat = GetAttributes <float>("maxlat", xmlNode.Attributes);
        maxlon = GetAttributes <float>("maxlon", xmlNode.Attributes);

        // Calculate x and y coordinates
        y = (float)((MercatorProjection.latToY(minlat) + MercatorProjection.latToY(maxlat)) / 2);
        x = (float)((MercatorProjection.lonToX(minlon) + MercatorProjection.lonToX(maxlon)) / 2);

        CalculateCenter(x, y);
    }
Beispiel #19
0
    /// <summary>
    /// Construct the Bounds based on the attributes given in the XmlNode
    /// </summary>
    /// <param name="xmlNode">XmlNode with construction attributes</param>
    public OSMBounds(XmlNode xmlNode)
    {
        // Read the OSM position attributes
        MinLatitude  = GetAttribute <float>("minlat", xmlNode.Attributes);
        MaxLatitude  = GetAttribute <float>("maxlat", xmlNode.Attributes);
        MinLongitude = GetAttribute <float>("minlon", xmlNode.Attributes);
        MaxLongitude = GetAttribute <float>("maxlon", xmlNode.Attributes);

        // Convert OSM position attributes to Unity positions
        float latitudeAsY  = (float)((MercatorProjection.latToY(MinLatitude) + MercatorProjection.latToY(MaxLatitude)) / 2);
        float longitudeAsX = (float)((MercatorProjection.lonToX(MinLongitude) + MercatorProjection.lonToX(MaxLongitude)) / 2);

        Center = new Vector3(longitudeAsX, 0, latitudeAsY);
    }
Beispiel #20
0
    public HighwayNode(XmlNode xmlNode, Vector3 MapCenter)
    {
        // OSM attributes
        ID = XMLHelper.GetAttribute <ulong>("id", xmlNode.Attributes);
        float Latitude  = XMLHelper.GetAttribute <float>("lat", xmlNode.Attributes);
        float Longitude = XMLHelper.GetAttribute <float>("lon", xmlNode.Attributes);

        // Convertion of OSM position attributes to unity positions
        float XCoord = (float)MercatorProjection.lonToX(Longitude);
        float YCoord = (float)MercatorProjection.latToY(Latitude);

        Position          = new Vector3(XCoord, 0.0f, YCoord) - MapCenter;
        IsParkingLotEntry = false;
        Neighbours        = new List <HighwayNode>();
    }
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="node">XML node</param>
    public OsmNode(XmlNode node)
    {
        TransportLines = new List <string>();

        ID = GetAttribute <ulong>("id", node.Attributes);

        Latitude  = GetFloat("lat", node.Attributes);
        Longitude = GetFloat("lon", node.Attributes);

        // Longitude and Latitude are being converted to Unity coordinates using the
        // Mercator projection.
        X = (float)MercatorProjection.lonToX(Longitude);
        Y = (float)MercatorProjection.latToY(Latitude);

        findName(node);
    }
    void Update()
    {
        if (Input.location.status == LocationServiceStatus.Running)
        {
            LocationInfo li;
            li = Input.location.lastData;

            double delta = MercatorProjection.latToY(li.latitude) - MercatorProjection.latToY(lat);
            transform.position += transform.forward * (float)delta * Time.deltaTime;
            delta = MercatorProjection.lonToX(li.longitude) - MercatorProjection.lonToX(lon);
            transform.position += transform.right * (float)delta * Time.deltaTime;

            lat = li.latitude;
            lon = li.longitude;
        }
    }
Beispiel #23
0
    public OsmBound(XmlNode node)
    {
        minlat = GetAttribute <float>("minlat", node.Attributes);
        minlon = GetAttribute <float>("minlon", node.Attributes);
        maxlat = GetAttribute <float>("maxlat", node.Attributes);
        maxlon = GetAttribute <float>("maxlon", node.Attributes);

        float x = (float)((MercatorProjection.lonToX(maxlon) + MercatorProjection.lonToX(minlon))) / 2;
        float y = (float)((MercatorProjection.latToY(maxlat) + MercatorProjection.latToY(minlat))) / 2;

        float width  = (float)((MercatorProjection.lonToX(maxlon) - MercatorProjection.lonToX(minlon)));
        float length = (float)((MercatorProjection.latToY(maxlat) - MercatorProjection.latToY(minlat)));

        size   = new Vector3(width * 2, 600, length * 2);
        centre = new Vector3(x, 0, y);
    }
Beispiel #24
0
    // Use this for initialization
    void Start()
    {
        //TextAsset mapFileAsset = Resources.Load<TextAsset>(mapFile.name);

        // init data structures
        MapInfo.Nodes      = new Dictionary <ulong, OSMNode>();
        MapInfo.Unknown    = new List <OSMWay>();
        MapInfo.Roads      = new List <OSMWay>();
        MapInfo.Buildings  = new List <OSMWay>();
        MapInfo.ParkSpaces = new List <OSMWay>();

        NavInfo.Nodes = new Dictionary <ulong, HighwayNode>();

        // load xml map file
        XmlDocument xmlMap = new XmlDocument();

        xmlMap.LoadXml(MapFile.text);

        // load different xmlNode types
        SetBounds(xmlMap.SelectSingleNode("/osm/bounds"));
        GetNodes(xmlMap.SelectNodes("/osm/node"));
        GetWays(xmlMap.SelectNodes("/osm/way"));

        // Connect and spawn Debug Displays
        ConnectHighwayNodes();
        MarkParkingEntries();
        NavDebugDisplay.SpawnNavigationNodes(NavInfo);
        NavDebugDisplay.SpawnParkingLotMarkers(MapInfo);
        NavDebugDisplay.SpawnRoads(MapInfo);
        NavDebugDisplay.SpawnBuildings(MapInfo);

        // read and convert map boundaries
        float minx = (float)MercatorProjection.lonToX(MapInfo.Bounds.MinLongitude);
        float maxx = (float)MercatorProjection.lonToX(MapInfo.Bounds.MaxLongitude);
        float miny = (float)MercatorProjection.latToY(MapInfo.Bounds.MinLatitude);
        float maxy = (float)MercatorProjection.latToY(MapInfo.Bounds.MaxLatitude);

        // scale the groundplane to cover the whole map area
        GroundPlane.transform.localScale = new Vector3((maxx - minx) / 2, 1, (maxy - miny) / 2);

        // signalize that the reading of the map file is done
        IsReady = true;
    }
Beispiel #25
0
        private void GetOsmBoundsCentre(XmlNode node)
        {
            var MaxLat = XmlAttributeParser
                         .GetAttribute <float>("maxlat", node.Attributes);
            var MinLat = XmlAttributeParser
                         .GetAttribute <float>("minlat", node.Attributes);
            var MinLon = XmlAttributeParser
                         .GetAttribute <float>("minlon", node.Attributes);
            var MaxLon = XmlAttributeParser
                         .GetAttribute <float>("maxlon", node.Attributes);

            // Create the centre location of OSM data
            float x = (float)((MercatorProjection
                               .lonToX(MaxLon) + MercatorProjection.lonToX(MinLon)) / 2);
            float z = (float)((MercatorProjection
                               .latToY(MaxLat) + MercatorProjection.latToY(MinLat)) / 2);

            BoundsCentre = new Vector3(x, 0, z);
        }
    IEnumerator MapAPICall()
    {
        float latHeight = 0.010f;
        float lonWidth = 0.025f;
        float lonMin = currentLon - lonWidth / 2, lonMax = currentLon + lonWidth / 2, latMin = currentLat - latHeight / 2, latMax = currentLat + latHeight / 2;

        // setting class variables for future use
        minX = (float)(MercatorProjection.lonToX(lonMin) - MercatorProjection.lonToX(currentLon));
        maxX = (float)(MercatorProjection.lonToX(lonMax) - MercatorProjection.lonToX(currentLon));
        minY = (float)(MercatorProjection.latToY(latMin) - MercatorProjection.latToY(currentLat));
        maxY = (float)(MercatorProjection.latToY(latMax) - MercatorProjection.latToY(currentLat));

        // longitude is "x", latitude is "y"
        // url bounds in form: longitude min, latitude min, longitude max, latitude max
        string URL = "https://overpass-api.de/api/map?bbox=" + lonMin.ToString() + "," + latMin.ToString() + ","
                     + lonMax.ToString() + "," + latMax.ToString();

        UnityWebRequest uwr      = UnityWebRequest.Get(URL);
        String          filePath = Application.persistentDataPath + "/data1.txt"; // this needs to change

        if (File.Exists(filePath))
        {
            Debug.Log("File already exists! Deleting it now.");
            File.Delete(filePath);
            //map.ReadInput(filePath);
            //yield break;
        }

        uwr.downloadHandler = new DownloadHandlerFile(filePath);
        yield return(uwr.SendWebRequest());

        if (uwr.isHttpError || uwr.isNetworkError)
        {
            Debug.Log(uwr.error);
            yield break;
        }
        else
        {
            Debug.Log("Saved data to: " + filePath);
            map.ReadInput(filePath);
            yield break;
        }
    }
Beispiel #27
0
        public void buildNodePositionWithOffset(Vector3 offset)
        {
            float Latitude = XmlAttributeParser
                             .GetAttribute <float>("lat", nodeData.Attributes);
            float Longitude = XmlAttributeParser
                              .GetAttribute <float>("lon", nodeData.Attributes);

            // Debug.Log(Latitude + " " + Longitude);

            float X = (float)MercatorProjection
                      .lonToX(Longitude) - offset.x;
            float Z = (float)MercatorProjection
                      .latToY(Latitude) - offset.z;
            float Y = 0;

            node.setNodePosition(new Vector3(X, Y, Z));

            // Debug.Log(new Vector3(X, Y, Z));
        }
Beispiel #28
0
    /// <summary>
    /// Load the OpenMap data resource file.
    /// </summary>
    /// <param name="resourceFile">Path to the resource file. The file must exist.</param>
    public void Read(string resourceFile)
    {
        nodes = new Dictionary <ulong, OsmNode>();
        ways  = new List <OsmWay>();

        var xmlText = File.ReadAllText(resourceFile);

        XmlDocument doc = new XmlDocument();

        doc.LoadXml(xmlText);

        SetBounds(doc.SelectSingleNode("/osm/bounds"));
        GetNodes(doc.SelectNodes("/osm/node"));
        GetWays(doc.SelectNodes("/osm/way"));

        float minx = (float)MercatorProjection.lonToX(bounds.MinLon);
        float maxx = (float)MercatorProjection.lonToX(bounds.MaxLon);
        float miny = (float)MercatorProjection.latToY(bounds.MinLat);
        float maxy = (float)MercatorProjection.latToY(bounds.MaxLat);
    }
Beispiel #29
0
    public MapNode(XmlNode node, OSMBounds bounds)
    {
        latitude  = GetAttribute <float>("lat", node.Attributes);
        id        = GetAttribute <long>("id", node.Attributes);
        longitude = GetAttribute <float>("lon", node.Attributes);

        X = MercatorProjection.lonToX(longitude);
        Y = MercatorProjection.latToY(latitude);

        XmlNodeList tags = node.SelectNodes("tag");

        foreach (XmlNode tag in tags)
        {
            string key = GetAttribute <string>("k", tag.Attributes);
            if (key == "natural")
            {
                isTree = true;
            }
        }
    }
Beispiel #30
0
    public OSMNode(XmlNode node)
    {
        ID        = GetAttribute <ulong>("id", node.Attributes);
        Latitude  = GetAttribute <float>("lat", node.Attributes);
        Longitude = GetAttribute <float>("lon", node.Attributes);
        //string Val = GetAttribute<string>("v", node.Attributes);

        // Transfer this for waypoints?
        X = (float)MercatorProjection.lonToX(Longitude);
        Y = (float)MercatorProjection.latToY(Latitude);

        XmlNodeList tags = node.SelectNodes("tag");

        foreach (XmlNode t in tags)
        {
            string val = GetAttribute <string>("v", t.Attributes);
            //Debug.Log(val);
            if (val == "traffic_signals")
            {
                IsStreetLight = true;
            }
        }
    }