Exemplo n.º 1
0
        public void Initialise(String geometry)
        {
            edges      = new List <Edge>();
            map        = new CustomMap();
            map.planes = planes;
            lastDist   = -1;

            polyline = geometry;
            List <Vector2d> meterPoints = ConvertLatLongToMeters(polyline);

            Vector2[] vectors = new Vector2[meterPoints.Count];

            int index = 0;

            foreach (Vector2d v in meterPoints)
            {
                vectors[index] = new Vector2((float)v.x, (float)v.y);
                index++;
            }

            Node[] nodes = nodes = generateNodes(vectors, PolylineUtils.Decode(polyline));

            generateEdges(nodes);

            map.GetTextures(nodes, mapZoom);

            map.placeLocationPin(polyline, pin, mapZoom);
            pin.GetComponent <ZoomMovement>().calcScale(PolylineUtils.Decode(polyline).First(), mapZoom);
            pin.GetComponent <ZoomMovement>().loc     = pin.transform.localPosition;
            pin.GetComponent <ZoomMovement>().enabled = true;

            initialised = true;
        }
Exemplo n.º 2
0
        List <Vector2d> ConvertLatLongToMeters(string polyline)
        {
            /*
             * GetTileScaleInMeters(Single, Int32)
             *
             * GeoToWorldPosition(Double, Double, Vector2d, Single)
             *
             * Converts WGS84 lat/lon to x/y meters in reference to a center point
             *  Declaration
             *
             *   public static Vector2d GeoToWorldPosition(double lat, double lon, Vector2d refPoint, float scale = 1F)
             */

            List <Vector2d> array = PolylineUtils.Decode(polyline);

            Vector2d reference = Conversions.LatLonToMeters(array[0]);

            for (int i = 0; i < array.Count; i++)
            {
                Vector2d temp = Conversions.LatLonToMeters(array[i]);
                array[i] = new Vector2d(temp.x - reference.x, temp.y - reference.y);
            }

            return(array);
        }
Exemplo n.º 3
0
        public void placeLocationPin(String polyline, GameObject pin, float zoom)
        {
            //Place astronaut at start and keep updated location with InvokeRepeating
            Vector2d startCoords = GetWorldSpaceOfLatLong(PolylineUtils.Decode(polyline)[0], zoom);

            pin.transform.SetParent(planes.transform);
            pin.transform.localPosition = new Vector3((float)startCoords.x, 0, (float)startCoords.y);
        }
Exemplo n.º 4
0
        private static void profile_mop_onclick(object sender, EventArgs ars)
        {
            if (!PolylineUtils.ConfirmSelected(CamBamUI.MainUI.ActiveView))
            {
                return;
            }

            MOPTrochoprof mop = new MOPTrochoprof(CamBamUI.MainUI.ActiveView.CADFile, CamBamUI.MainUI.ActiveView.Selection);

            CamBamUI.MainUI.InsertMOP(mop);
        }
        public void TestEncode()
        {
            // (38.5, -120.2), (40.7, -120.95), (43.252, -126.453)
            var path = new List <Vector2d>();

            path.Add(new Vector2d(38.5, -120.2));
            path.Add(new Vector2d(40.7, -120.95));
            path.Add(new Vector2d(43.252, -126.453));

            // _p~iF~ps|U_ulLnnqC_mqNvxq`@
            Assert.AreEqual("_p~iF~ps|U_ulLnnqC_mqNvxq`@", PolylineUtils.Encode(path));
        }
        public void TestDecode()
        {
            // _p~iF~ps|U_ulLnnqC_mqNvxq`@
            List <Vector2d> path = PolylineUtils.Decode(
                "_p~iF~ps|U_ulLnnqC_mqNvxq`@");

            // (38.5, -120.2), (40.7, -120.95), (43.252, -126.453)
            Assert.AreEqual(-120.2, path[0].y);
            Assert.AreEqual(38.5, path[0].x);
            Assert.AreEqual(-120.95, path[1].y);
            Assert.AreEqual(40.7, path[1].x);
            Assert.AreEqual(-126.453, path[2].y);
            Assert.AreEqual(43.252, path[2].x);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Writes the JSON as an encoded polyline.
        /// </summary>
        /// <param name="writer">A <see cref="JsonWriter"/>.</param>
        /// <param name="value">The original value.</param>
        /// <param name="serializer">A <see cref="JsonSerializer"/>.</param>
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var val = (List <Vector2d>)value;

            serializer.Serialize(writer, PolylineUtils.Encode(val));
        }
Exemplo n.º 8
0
 /// <summary>
 /// Create the specified objectType and jArray.
 /// </summary>
 /// <param name="objectType">Object type.</param>
 /// <param name="polyLine">string representation of a polyLine.</param>
 /// <returns>A List of <see cref="Vector2d"/>.</returns>
 public List <Vector2d> Create(Type objectType, string polyLine)
 {
     return(PolylineUtils.Decode(polyLine));
 }