public void DisplayCantProceedBecauseOfGeocode(AddressUploadBatch latestBatch)
 {
     GeocodingProxy geoProxy = new GeocodingProxy();
     LabelNumberAvailableGeocodes.Text = geoProxy.AvailableToday.ToString();
     LabelNumberOfDesiredGeocodes.Text = latestBatch.GetDistinctAddressesInBatch().Count().ToString();
     Panel1CantContinue.Visible = true;
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        GeocodingProxy geoProxy = new GeocodingProxy();

        int dailyQuota = geoProxy.DailyLimit;
        int remainingToday = geoProxy.AvailableToday;
        int geocodedToday = geoProxy.GeocodedLast24Hours;

        LabelGeocodedToday.Text = geocodedToday.ToString();
        LabelGeocodingLeftToday.Text = remainingToday.ToString();
        LabelGeocodingLeftToday2.Text = LabelGeocodingLeftToday.Text;
        LabelDailyLimit.Text = dailyQuota.ToString();
    }
    private bool Geocode(ref  string lng, ref string lat)
    {
        bool ret = false;
        // PAOLO WAS HERE
        throw new NotImplementedException("Must revisit");
        City thisCity = new City(int.Parse(DropDownListCities.SelectedValue));
        string address = this.TextBoxHouseNumber.Text + " " + TextBoxStreet.Text + ", " + DropDownListCities.SelectedItem.Text + " " + thisCity.StateProvince.Description;

        try
        {
            var geocoder = new GeocodingProxy();
            Coordinate coords = geocoder.Geocode(address);
            lat = coords.Latitude.ToString();
            lng = coords.Longitude.ToString();
            ret = true;
        }
        catch (Exception ex)
        {

        }
        return ret;
    }
Ejemplo n.º 4
0
 public bool CanGeoCode()
 {
     GeocodingProxy geoProxy = new GeocodingProxy();
     return geoProxy.AvailableToday > GetDistinctAddressesInBatch().Count;
 }
Ejemplo n.º 5
0
        public void GeoCode()
        {
            // in order to reduce the number of geocodes that we send, let's group all uploaded entries by address
            // so that all those living in an apartment of the same address might be geocoded with one call
            if (CanGeoCode())
            {
                List<string> distinctAddresses = GetDistinctAddressesInBatch();
                var geocoder = new GeocodingProxy();
                Dictionary<string, Coordinate> geocodedAddresses = new Dictionary<string, Coordinate>();
                foreach (string distinctAddress in distinctAddresses)
                {
                    try
                    {
                        var matchingIAddress = UploadedAddresses.Where(x => x.FullAddressWithCity == distinctAddress).First();
                        var coordinates = geocoder.Geocode(matchingIAddress);
                        geocodedAddresses.Add(distinctAddress, coordinates);
                    }
                    catch (Exception ex)
                    {

                    }
                }

                // save coordinates in the database
                foreach (var geocodedAddress in geocodedAddresses)
                {
                    string addressString = geocodedAddress.Key;
                    var coordinates = geocodedAddress.Value;
                    // find all entries with same address
                    var recordsWithSameAddress = (from a in this.UploadedAddresses
                                                  where a.FullAddressWithCity == addressString
                                                  select a).ToList();

                    // update each record with associated coordinates
                    foreach (var address in recordsWithSameAddress)
                    {
                        address.UpdateCoordinates(coordinates);
                    }
                }
            }
            else
            {
                throw new Exception("Cannot geocode batch (not enought geocoding available).");
            }
        }
Ejemplo n.º 6
0
        public bool Geocode()
        {
            bool ret = false;
            CMS.City city = CMS.City.FetchByID(CityId);
            string address = FullAddress;

            try
            {
                var geocoder = new GeocodingProxy();
                var coords = geocoder.Geocode(this);
                this.Lat = coords.Latitude.ToString();
                this.Long = coords.Longitude.ToString();
                var db = new TerritoryDBDataContext();
                db.sp_Address_Update_Coordinates(AddressId, Long, Lat);
                ret = true;
            }
            catch (Exception ex)
            {

            }
            return ret;
        }