Example #1
0
        void picMap_Click(object sender, EventArgs e)
        {
            double?latSel = View.latitudeSelected;
            double?lngSel = View.longitudeSelected;

            Thread t = new Thread(new ThreadStart(delegate()
            {
                try
                {
                    if (latSel.HasValue && lngSel.HasValue)
                    {
                        Geolocation geo = Geolocation.Get(latSel.Value, lngSel.Value);
                        if (geo != null)
                        {
                            Service_GeocodeResult(geo);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.RegisterLog("geolocation", ex);
                }
            }));

            t.StartThread();
        }
Example #2
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            Geolocation geo = Geolocation.Get(pictureBox1.SelectedPoint);

            if (geo != null)
            {
                label1.Text = geo.ToString();
            }
            else
            {
                label1.Text = " - ";
            }
            Clipboard.SetText(pictureBox1.SelectedPoint.ToString());
        }
Example #3
0
        //[TestMethod]
        public void Geocoding()
        {
#if PROXY
            WebProxy proxy = new WebProxy("10.2.108.25", 8080);
            proxy.Credentials = new NetworkCredential("y3tr", "htc9377J");
            System.Net.WebRequest.DefaultWebProxy = proxy;
#endif

            List <PointF> latlngList = new List <PointF>();
            latlngList.Add(new PointF(28.404931F, -131.850588F)); //Water


            latlngList.Add(new PointF(-22.909667F, -43.179656F)); //Rio de Janeiro
            latlngList.Add(new PointF(-22.857696F, -43.373414F)); //Rio de Janeiro
            latlngList.Add(new PointF(-9.967379F, -67.819979F));  //Acre
            latlngList.Add(new PointF(-1.295547F, -47.923565F));  //Roraima
            latlngList.Add(new PointF(42.983202F, -108.627434F)); //Wyoming
            latlngList.Add(new PointF(19.404819F, -72.367172F));  //Haiti, unknown address
            latlngList.Add(new PointF(18.555136F, -72.319565F));  //Haiti, port-au-prince
            latlngList.Add(new PointF(31.248382F, 121.243515F));  //Shanghai, China
            latlngList.Add(new PointF(43.665674F, -79.40938F));   //Toronto, Canada
            latlngList.Add(new PointF(45.577742F, -73.739641F));  //Montreal, Canada
            latlngList.Add(new PointF(45.543064F, -73.640699F));  //Montreal, Canada
            latlngList.Add(new PointF(45.501098F, -73.565912F));  //Montreal, Canada
            latlngList.Add(new PointF(45.501745F, -73.567414F));  //Montreal, Canada

            List <Geolocation> list = new List <Geolocation>();
            foreach (PointF latlng in latlngList)
            {
                var loc = Geolocation.Get(latlng.X, latlng.Y);
                if (latlngList.IndexOf(latlng) == 0)
                {
                    Assert.IsNull(loc);
                }
                else
                {
                    Assert.IsNotNull(loc);
                }
                if (loc != null)
                {
                    System.Diagnostics.Debug.WriteLine(loc.ToString());
                    list.Add(loc);
                }
            }
        }