Esempio n. 1
0
        /// <summary>
        /// Gets the number of addresses left to geocode
        /// </summary>
        /// <returns>the number of addresses left to geocode</returns>
        public int GetNumAddressesToProcess()
        {
            GeoDatabaser geoDatabaser = new GeoDatabaser();

            NumAddresses = geoDatabaser.GetNumAddressesLeftToProcess();
            return(NumAddresses);
        }
Esempio n. 2
0
        /// <summary>
        /// Geocodes all addresses in Dimension.Location table
        /// </summary>
        public static void GeocodeAllAddresses()
        {
            GeoDatabaser       geoDatabaser = new GeoDatabaser();
            RootResponseObject root         = new RootResponseObject();
            List <Location>    locations    = new List <Location>();

            root.locations = locations;
            int locationCount = 0;

            // Get a new token every x batches based on appConfig key.
            // Token expires every 60 minutes according to ArcGIS Server settings
            geoCodeAddresses.GetToken(BatchesProcessed);

            RootRequestObject  rootRequestObject  = new RootRequestObject();
            RootResponseObject rootResponseObject = new RootResponseObject();

            rootRequestObject = geoDatabaser.GetBatchOfNonGeocodedAddressesFromDatabase(rootRequestObject);

            if (rootRequestObject.records.Count != 0)
            {
                rootResponseObject = RestServices.GeocodeABatchOfAddresses(rootRequestObject, Token);

                if (rootResponseObject.locations != null)
                {
                    Log.Info(
                        String.Format("rootResponseObject.locations.count = {0}",
                                      rootResponseObject.locations.Count));
                    AddressesProcessed += rootResponseObject.locations.Count;
                    foreach (Location location in rootResponseObject.locations)
                    {
                        Log.Debug(String.Format("Location Info: x: {0} y: {1} score: {2} address: {3}",
                                                location.location.x, location.location.y, location.score, location.address));
                        if (!(location.location.x > 0 || location.location.x < 0) &&
                            !(location.location.y > 0 || location.location.y < 0))
                        {
                            location.location.x = null;
                            location.location.y = null;
                        }
                        root.locations.Add(new Location());
                        locations[locationCount] = location;
                        locationCount++;
                    }
                    geoDatabaser.InsertBatchOfGeocodedAddressesToDatabase(root);
                    root.locations.Clear();
                }
                else
                {
                    Log.Debug(
                        String.Format("rootResponseObject is null"));
                }
            }
        }