예제 #1
0
 public Node(XmlNode node)
 {
     ID        = XmlGetter.GetAttribute <ulong>("id", node.Attributes);
     Latitude  = XmlGetter.GetAttribute <float>("lat", node.Attributes);
     Longitude = XmlGetter.GetAttribute <float>("lon", node.Attributes);
     X         = (float)MercatorProjection.lonToX(Longitude);
     Y         = (float)MercatorProjection.latToY(Latitude);
 }
예제 #2
0
        public Bounds(XmlNode node)
        {
            MinLat = XmlGetter.GetAttribute <float>("minlat", node.Attributes);
            MaxLat = XmlGetter.GetAttribute <float>("maxlat", node.Attributes);
            MinLon = XmlGetter.GetAttribute <float>("minlon", node.Attributes);
            MaxLon = XmlGetter.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);

            Center = new Vector3(x, 0, y);
        }
예제 #3
0
        public Vector3 MapPositionAt(float lon, float lat)
        {
            bool inLat = lat >= MinLat && lat <= MaxLat;
            bool inLon = lon >= MinLon && lon <= MaxLon;

            if (inLat && inLon)
            {
                return(mapObjects.TransformPoint(new Vector3(
                                                     (float)MercatorProjection.lonToX(lon),
                                                     transform.position.y,
                                                     (float)MercatorProjection.latToY(lat)
                                                     ) - Center));
            }
            else
            {
                throw new Exception("Position not inside bounds!");
            }
        }