Example #1
0
        /// <summary>
        /// Geocodes the given input and returns a response.
        /// </summary>
        /// <param name="request">The request to geocode.</param>
        /// <returns>The response to the request, will not be null even if there are no
        ///          matches.</returns>
        protected override GeocodeResponse InternalGeocode(GeocodeRequest request)
        {
            GeocodeResponse gRes = null;

            foreach (GeocoderSource gs in _geocoderSources)
            {
                gRes = gs.Geocode(request);
                if (gRes.Candidates.Count > 0)
                {
                    // If a specific coordinate system was requested,
                    // reproject from the goeocoder coordinate system to the
                    // requested coordinate system.  We also need to identify
                    // what CS we are returning in as well.
                    _coordinateSystem = gs.CoordinateSystem;
                    if (request.CoordinateSystem != null)
                    {
                        foreach (GeocodeCandidate candidate in gRes.Candidates)
                        {
                            IPoint p = Reprojector.Reproject(gs.CoordinateSystem, request.CoordinateSystem,
                                                             candidate.Longitude,
                                                             candidate.Latitude);

                            candidate.Longitude = p.X;
                            candidate.Latitude  = p.Y;
                        }
                    }
                    break;
                }
            }
            if (gRes == null)
            {
                throw new LoggingException(
                          "Internal state error, should never have a null object at this point. Num sources: " +
                          _geocoderSources.Count);
            }
            return(gRes);
        }
Example #2
0
 /// <summary>
 /// Takes a geocoding response, and runs it through all of the ResponseProcessors.
 /// </summary>
 /// <param name="geocodeResponse"></param>
 private void ProcessResponse(GeocodeResponse geocodeResponse)
 {
     foreach (IResponseProcessor rp in _processors[typeof(IResponseProcessor)])
     {
         rp.ProcessResponse(geocodeResponse);
     }
 }