Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            GoogleGeocoder googleGeocoder = new GoogleGeocoder();
            YandexGeocoder yandexGeocoder = new YandexGeocoder();

            RequestData request = new RequestData()
            {
                Address = "inönü mahallesi atatürk caddesi birlik apt. no:55 daire 7 istanbul ataşehir türkiye"
            };

            ResponseData googleResult = googleGeocoder.Geocode(request);

            List <GoogleResult> googleGeocodeResultList = googleGeocoder.GeocodeAndParse(request);

            ResponseData yandexResult = yandexGeocoder.Geocode(request);

            List <YandexResult> yandexGeocodeResultList = yandexGeocoder.GeocodeAndParse(request);
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            List <SAMPLEADDRESS> samples = geocoderService.GetSampleaddresss();

            Stopwatch timer = new Stopwatch();

            foreach (var item in samples)
            {
                bool checkIfExist = geocoderService.CheckIfExist(item);

                if (checkIfExist)
                {
                    continue;
                }


                SAMPLEADDRESSRESULT result = new SAMPLEADDRESSRESULT();

                RequestData request = new RequestData();
                request.Address = item.ADDRESS + " " + item.CITY + " " + item.TOWN;
                timer.Reset();
                timer.Start();
                List <YandexResult> yandexResults = yandexGeocoder.GeocodeAndParse(request);
                timer.Stop();

                if (yandexResults.Count == 1)
                {
                    string[] coordinates = yandexResults[0].Position.Split(' ');
                    string   xCoor       = coordinates[0];
                    string   yCoor       = coordinates[1];

                    result.XCOORYANDEX = xCoor;
                    result.YCOORYANDEX = yCoor;
                    result.YANDEXTIME  = timer.Elapsed.ToString();
                }
                timer.Reset();

                timer.Start();
                List <GoogleResult> googleResults = googleGeocoder.GeocodeAndParse(request);
                timer.Stop();

                if (googleResults.Count == 1)
                {
                    string xCoor = googleResults[0].Longtitute;
                    string yCoor = googleResults[0].Latitute;

                    result.XCOORGOOGLE = xCoor;
                    result.YCOORGOOGLE = yCoor;
                    result.GOOGLETIME  = timer.Elapsed.ToString();
                }

                timer.Reset();

                timer.Start();
                AddressLevel addressLevel = Geocode(request.Address);
                timer.Stop();

                if (addressLevel.XCoor != string.Empty || addressLevel.XCoor != "0")
                {
                    string xCoor = addressLevel.XCoor;
                    string yCoor = addressLevel.YCoor;

                    result.XCOORMY = xCoor;
                    result.YCOORMY = yCoor;
                    result.MYTIME  = timer.Elapsed.ToString();
                }

                result.ID = item.ID;
                try
                {
                    geocoderService.InsertSampleAddressResult(result);
                }
                catch
                {
                    continue;
                }
            }
        }