Example #1
0
 public void InsertSampleAddressResult(SAMPLEADDRESSRESULT model)
 {
     geocoderEntities.SAMPLEADDRESSRESULT.Add(model);
     geocoderEntities.SaveChanges();
 }
Example #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;
                }
            }
        }
Example #3
0
 public void InsertSampleAddressResult(SAMPLEADDRESSRESULT model)
 {
     geocoderEntities.SAMPLEADDRESSRESULT.Add(model);
     geocoderEntities.SaveChanges();
 }