/// <summary> /// Constructor. /// </summary> /// <param name="geocoder">Application server geocoder.</param> /// <param name="nameAddressStorage">Local storage for name/address geocoding.</param> public LocalGeocoder(IGeocoder geocoder, NameAddressStorage nameAddressStorage) { Debug.Assert(geocoder != null); Debug.Assert(nameAddressStorage != null); _geocoder = geocoder; _nameAddressStorage = nameAddressStorage; }
public MembersController(IDivineRepositories repositories, IDivineLogger logger, IGeocoder geocoder, IHttpContextAccessor _httpContextAccessor) : base(repositories,logger, _httpContextAccessor) { membersRepo = repositories.MemberRepo; lookupRepo = repositories.LookupRepo; this.geocoder = geocoder; }
public void Setup() { container = new Container(); container.Configure(c => { c.For<MarketingCampaign>().Add<MarketingCampaign>(); _MockGeocoder = MockRepository.GenerateMock<IGeocoder>(); c.For<IGeocoder>().Add(_MockGeocoder); }); }
public static void Log(string address, double latitude, double longitude, IGeocoder provider, string error) { var db = new TerritoryDBDataContext(); GeocodingLog newEntry = new GeocodingLog(); newEntry.AccountId = CurrentUser.CurrentAccount.AccountId; newEntry.Lat = latitude; newEntry.Address= address; newEntry.Long = longitude; newEntry.Provider = provider.GetType().Name; newEntry.RequestDateTime = DateTime.Now; db.GeocodingLogs.InsertOnSubmit(newEntry); db.SubmitChanges(); }
public int GetBurnForLast24Hour(DateTime when, IGeocoder provider) { var db = new TerritoryDBDataContext(); DateTime minDate = when.AddDays(-1); DateTime maxDate = when; string providerString = provider.GetType().Name; var count = (from h in db.GeocodingLogs where h.RequestDateTime >= minDate && h.RequestDateTime <= when && h.Provider == providerString select h).Count(); return count; }
public ServiceOfflineException(IGeocoder p, Exception ex) : base("ServiceOffline", ex) { provider = p.GetType().Name; ; }
/// <summary> /// Export route to GRF file. /// </summary> /// <param name="writer">XMLWriter.</param> /// <param name="route">Route to export.</param> /// <param name="stops">Route's stops.</param> /// <param name="project">Project, which contains this route.</param> /// <param name="geocoder">Geocoder.</param> /// <param name="solver">Solver.</param> /// <param name="orderPropertiesToExport">Collection of order properties, which must be /// exported.</param> /// <param name="compress">Flag, shows compress result file or not.</param> /// <returns>GrfExportResult which contains messages about exporting.</returns> public static GrfExportResult ExportToGRF(XmlWriter writer, Route route, ICollection<Stop> stops, Project project, IGeocoder geocoder, IVrpSolver solver, ICollection<string> orderPropertiesToExport, bool compress) { GrfExportResult result = new GrfExportResult(); writer.WriteStartElement(GRF_DOC_NODE_NAME); writer.WriteAttributeString(VERSION_ATTR_NAME, VERSION_VALUE); writer.WriteStartElement(ROUTEINFO_NODE_NAME); if (stops.Count > 0) { _SaveStops( writer, route, stops, orderPropertiesToExport, project, geocoder.AddressFields); } IDataObjectCollection<Barrier> barriers = (IDataObjectCollection<Barrier>)project.Barriers.Search(route.StartTime.Value.Date, true); _SaveBarriers(writer, barriers, result); _SaveRouteResults(writer, route, stops); writer.WriteEndElement(); _SaveRouteSettings(writer, route, solver, result); writer.WriteEndElement(); return result; }
public Conversation(IGeocoder geocoder) { _geocoder = geocoder; }
/// <summary> /// Initializes a new instance of the MarketingCampaign class. /// </summary> /// <param name="geocoder"></param> public MarketingCampaign(IGeocoder geocoder) { _geocoder = geocoder; }
/// <summary> /// Export route to GRF file. /// </summary> /// <param name="filePath">Path to grf file.</param> /// <param name="route">Route to export.</param> /// <param name="project">Project, which contains this route.</param> /// <param name="geocoder">Geocoder.</param> /// <param name="solver">Solver.</param> /// <param name="orderPropertiesToExport">Collection of order properties, which must be /// exported.</param> /// <param name="compress">Flag, shows compress result file or not.</param> /// <returns>GrfExportResult which contains messages about exporting.</returns> public static GrfExportResult ExportToGRF(string filePath, Route route, Project project, IGeocoder geocoder, IVrpSolver solver, ICollection<string> orderPropertiesToExport, bool compress) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = CommonHelpers.XML_SETTINGS_INDENT_CHARS; using (XmlWriter writer = XmlWriter.Create(filePath, settings)) { var result = ExportToGRF(writer, route, route.Stops, project, geocoder, solver, orderPropertiesToExport, compress); writer.Flush(); return result; } }
/// <summary> /// Initializes a new instance of the <see cref="Tracker"/> class. /// </summary> /// <param name="settings">Settings to be used by the tracker.</param> /// <param name="trackingService">The tracking service client to be used to communicate /// with the tracking server.</param> /// <param name="synchronizationService">The synchronization service to be used for /// synchronizing data in the project and at the tracking service.</param> /// <param name="solver">The VRP solver to be used by the tracker.</param> /// <param name="geocoder">The geocoder to be used by the tracker.</param> /// <param name="messageReporter">The message reporter to be used for reporting /// tracking errors.</param> /// <exception cref="ArgumentNullException"><paramref name="settings"/>, /// <paramref name="trackingService"/>, <paramref name="synchronizationService"/>, /// <paramref name="solver"/>, <paramref name="geocoder"/> or /// <paramref name="messageReporter"/> is a null reference.</exception> internal Tracker( TrackingSettings settings, ITrackingService trackingService, ISynchronizationService synchronizationService, IVrpSolver solver, IGeocoder geocoder, IMessageReporter messageReporter) { CodeContract.RequiresNotNull("settings", settings); CodeContract.RequiresNotNull("trackingService", trackingService); CodeContract.RequiresNotNull("synchronizationService", synchronizationService); CodeContract.RequiresNotNull("solver", solver); CodeContract.RequiresNotNull("geocoder", geocoder); CodeContract.RequiresNotNull("messageReporter", messageReporter); _settings = settings; _trackingService = trackingService; _synchronizationService = synchronizationService; _solver = solver; _geocoder = geocoder; _messageReporter = messageReporter; }
public MessageManager(IGeocoder geocoder) { _geocoder = geocoder; Conversations = new List<Conversation>(); }
public HomeController(IGeocoder geoCoder) { this.geoCoder = geoCoder; }
public GeocodeCommand(IGeocoder geoCoder) { _geoCoder = geoCoder; }
/// <summary> /// Get candidates from not primary sublocators. City, Zip, Street candidates. /// </summary> /// <param name="geocodable">Geocodable object to validation</param> /// <param name="candidatesIncludedDisabledLocators">Candidates from all locators.</param> /// <returns>City, Zip, Street candidates.</returns> public static IEnumerable<AddressCandidate> GetBestCandidatesFromNotPrimaryLocators(IGeocoder geocoder, IGeocodable geocodable, IEnumerable<AddressCandidate> candidatesIncludedDisabledLocators) { Debug.Assert(geocodable != null); Debug.Assert(candidatesIncludedDisabledLocators != null); List<AddressCandidate> candidatesFromNotPrimaryLocators = new List<AddressCandidate>(); // If current geocoder is ArcGiscomGeocoder. var arcgisgeocoder = geocoder as ArcGiscomGeocoder; if (arcgisgeocoder != null) { // If we have candidates - return first of them as a result. if (candidatesIncludedDisabledLocators.Any()) candidatesFromNotPrimaryLocators.Add(candidatesIncludedDisabledLocators.First()); return candidatesFromNotPrimaryLocators; } if (App.Current.Geocoder.IsCompositeLocator) { List<LocatorInfo> sublocators = new List<LocatorInfo>(); sublocators.AddRange(App.Current.Geocoder.Locators); // Get best street candidate. List<LocatorInfo> streetLocators = _ExtractLocators(AddressPart.AddressLine, sublocators); List<AddressCandidate> streetCandidates = _GetStreetCandidates(geocodable, streetLocators, candidatesIncludedDisabledLocators); if (streetCandidates != null) candidatesFromNotPrimaryLocators.AddRange(streetCandidates); if (candidatesFromNotPrimaryLocators.Count == 0) { // Get best zip candidate. List<LocatorInfo> zipLocators = _ExtractLocators(AddressPart.PostalCode1, sublocators); AddressCandidate bestCandidate = _GetBestCandidateFromLocators(zipLocators, candidatesIncludedDisabledLocators); if (bestCandidate == null) { // Get best cityState candidate. List<LocatorInfo> cityStateLocators = _ExtractLocators(AddressPart.StateProvince, sublocators); bestCandidate = _GetBestCandidateFromLocators(cityStateLocators, candidatesIncludedDisabledLocators); } if (bestCandidate != null) { candidatesFromNotPrimaryLocators.Add(bestCandidate); } } } return candidatesFromNotPrimaryLocators; }
public GeocoderService() { geocoder = new GoogleGeocoder(); }
public GeocoderTest() { Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-us"); geocoder = CreateGeocoder(); }
public Locationer(IGeocoder geocoder) { _geocoder = geocoder; }
public UnknownAddressException(string message, IGeocoder geocoder) : base(message) { provider = geocoder.GetType().Name; }
/// <summary> /// Finish geocoding and try to zoom near. /// </summary> /// <param name="geocoder">Geocoder which found candidates.</param> /// <param name="geocodable">Item to geocode.</param> /// <param name="allCandidates">All candidates, returned for current geocoded item.</param> private void _ProcessCandidatesNotFound(IGeocoder geocoder, IGeocodable geocodable, IEnumerable<AddressCandidate> allCandidates) { // Set candidates to zoom. var candidatesFromNotPrimaryLocators = GeocodeHelpers.GetBestCandidatesFromNotPrimaryLocators(geocoder, geocodable, allCandidates); CandidatesToZoom = candidatesFromNotPrimaryLocators.ToArray(); if (CandidatesNotFound != null) CandidatesNotFound(this, EventArgs.Empty); AddressCandidate zoomedCandidate = null; // Zoom to candidates from not primary locators. if (CandidatesToZoom != null && CandidatesToZoom.Length > 0) { MapExtentHelpers.ZoomToCandidates(_mapCtrl, CandidatesToZoom); zoomedCandidate = CandidatesToZoom[0]; } // Show popup on map if not in fleet wizard. if (!ParentIsFleetWisard) _mapCtrl.ShowZoomToCandidatePopup(geocodable, CandidatesToZoom); IsGeocodingInProcess = false; }
public ProcessApiRequests(AllReadyContext context, IMediator mediator, IGeocoder geocoder) { this.context = context; this.mediator = mediator; this.geocoder = geocoder; }
/// <summary> /// Sorts candidates collection by index of corresponding primary locator filtering /// out candidates without one. /// </summary> /// <param name="geocoder">The reference to the geocoder object containing locators /// to be used.</param> /// <param name="candidates">Candidates from all locators.</param> /// <returns>Candidates from primary locators sorted by index of their primary locator. /// </returns> public static IEnumerable<AddressCandidate> SortCandidatesByPrimaryLocators( IGeocoder geocoder, IEnumerable<AddressCandidate> candidates) { Debug.Assert(geocoder != null); Debug.Assert(candidates != null); Debug.Assert(candidates.All(candidate => candidate != null)); // If geocoder is ArcGiscomGeocoder. var arcgisgeocoder = geocoder as ArcGiscomGeocoder; if (arcgisgeocoder != null) { var bestCandidates = _SelectBestCandidates(candidates); // Check that best candidates locator type is in exact locators names collection. if (bestCandidates.Any() && arcgisgeocoder.ExactLocatorsTypesNames.Contains(bestCandidates.First().AddressType)) return bestCandidates; // If not - return empty collection. else return new List<AddressCandidate>(); } // If sublocators is absent - use all candidates. if (!geocoder.IsCompositeLocator) { return candidates.ToList(); } var primarySublocators = geocoder.Locators .Where(locator => locator.Primary) .ToList(); // Candidate from local geocoder will have empty locator. var manuallyEditedXY = Application.Current.FindString(MANUALLY_EDITED_MATCH_METHOD_KEY); var result = from candidate in candidates let locatorIndex = primarySublocators.IndexOf(candidate.Locator) where locatorIndex >= 0 || candidate.Address.MatchMethod.Equals(manuallyEditedXY) orderby locatorIndex select candidate; return result; }
//public static int GetAccountBurnForDay(DateTime day, int accountId) //{ // var db = new TerritoryDBDataContext(); // var count = (from h in db.GeocodingHistories // where h.GeocodingDay.Date == day.Date // & h.AccountId == accountId // select h.Count).Sum(); // return count; //} public int GetAvailableForDay(DateTime when, IGeocoder provider) { // this thing needs some work as it is hardcoded for google var burn = GetBurnForLast24Hour(when, provider); return provider.DailyLimit - burn; }
public OverQueryLimitException(IGeocoder p) { Provider = p.GetType().ToString(); }
/// <summary> /// Returns a reference to the <see cref="Tracker"/> class object. /// </summary> /// <param name="solver">The solver to be used by the returned tracker.</param> /// <param name="geocoder">The geocoder to be used by the returned tracker.</param> /// <param name="messageReporter">The messageReporter to be used by the returned /// tracker.</param> /// <returns>A new <see cref="Tracker"/> class instance.</returns> /// <exception cref="ArgumentNullException"><paramref name="solver"/>, /// <paramref name="geocoder"/> or <paramref name="messageReporter"/> is a null /// reference.</exception> public Tracker GetTracker( IVrpSolver solver, IGeocoder geocoder, IMessageReporter messageReporter) { CodeContract.RequiresNotNull("solver", solver); CodeContract.RequiresNotNull("geocoder", geocoder); CodeContract.RequiresNotNull("messageReporter", messageReporter); _CheckSettings(_settings); var settings = new TrackingSettings { BreakTolerance = _settings.TrackingSettings.BreakTolerance ?? 0, }; var uri = new Uri(_settings.TrackingServiceInfo.RestUrl); var service = FeatureService.Create(uri, Server); var trackingServiceClient = new TrackingServiceClient(service); var trackingService = new TrackingServiceClient(service); var synchronizationService = new SynchronizationService(trackingServiceClient); return new Tracker( settings, trackingService, synchronizationService, solver, geocoder, messageReporter); }