public GeoLocation.BusinessEntities.Location GeoLocate(GeoLocation.BusinessEntities.Address address) { GeoLocation.BusinessEntities.Location result = new GeoLocation.BusinessEntities.Location(); GeocodeRequest innerRequest = new GeocodeRequest(); innerRequest.Address = new Address() { AddressLine = address.AddressLine, AdminDistrict = address.AdminDistrict, CountryRegion = address.CountryRegion, District = address.District, FormattedAddress = address.FormattedAddress, Locality = address.Locality, PostalCode = address.PostalCode, PostalTown = address.PostalTown }; GeocodeRequest1 request = new GeocodeRequest1(innerRequest); GeocodeResponse1 response = this.proxy.Geocode(request); GeocodeResponse innerResponse = response.GeocodeResult; if (innerResponse.Results != null && innerResponse.Results.Count > 0 && innerResponse.Results[0].Locations != null && innerResponse.Results[0].Locations.Count > 0) { result.Latitude = (decimal)innerResponse.Results[0].Locations[0].Latitude; result.Longitude = (decimal)innerResponse.Results[0].Locations[0].Longitude; } return result; }
public static string GetLocationUrl(GeoLocation l, int mapEngine) { switch (mapEngine) { //bing case 0: // Bing Maps how-to make your URL http://help.live.com/help.aspx?project=wl_local&market=en-us&querytype=topic&query=wl_local_proc_buildurl.htm return String.Format("http://www.bing.com/maps/default.aspx?v=2&cp={0}~{1}&v=2&lvl=12", l.Latitude, l.Longitude); //break; //Google case 1: return String.Format("http://maps.google.com/?ie=UTF8&ll={0},{1}&saddr={0},{1}&z=14", l.Latitude, l.Longitude); //break; //Yahoo case 2: return String.Format("http://maps.yahoo.com/#mvt=m&lat={0}&lon={1}&q1={0}%2C{1}&zoom=14", l.Latitude, l.Longitude); //break; } return null; }
public CarWashesMapPage (GeoLocation location) { //Todo : inject the service _viewModel = new CarWashesMapViewModel (new GooglePlacesService (new HttpClient ()), location); Init (location); }
public async Task<List<Place>> GetCarWashesAsync (GeoLocation location) { var uri = string.Format (GooglePlacesUrl, location.Latitude, location.Longitude, API_KEY); var result = await _httpClient.GetAsync<PlacesRootObject> (uri); return result.Places; }
private void Watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e) { Debug.WriteLine("Watcher_PositionChanged ({0}, {1})", e.Position.Location.Latitude, e.Position.Location.Longitude); _currentLocation = new GeoLocation() { Latitude = e.Position.Location.Latitude, Longitude = e.Position.Location.Longitude }; }
public GeoLocation execute(GeoLocation request) { Guard.IsNotNull(request, "request"); var result = geolocation_repository.Entities.FirstOrDefault(g => g.Geoposition.Latitude == request.Geoposition.Latitude && g.Geoposition.Longitude == request.Geoposition.Longitude && g.AccuracyInMetres == request.AccuracyInMetres); var returned_result = result ?? request; Guard.IsNotNull(returned_result, "returned_result"); return returned_result; }
public Member() { // JoinDate = DateTime.UtcNow; LastVisitDate = DateTime.UtcNow; FacebookAccesstokenExpiration = DateTime.UtcNow; GeoLocation=new GeoLocation(); // ActivationGuid = Guid.NewGuid(); DateCreated = DateTime.UtcNow; DateModified = DateTime.UtcNow; }
public async void GetCarWashesAsync_ShouldReturnCarWashes () { var googlePlacesService = new GooglePlacesService (new System.Net.Http.HttpClient ()); var location = new GeoLocation { Latitude = 41.890969, Longitude = -87.676392 }; var resultTask = googlePlacesService.GetCarWashesAsync (location).Result; var places = resultTask as List<Place>; Assert.IsNotNull (places); }
private async Task Init (GeoLocation geoLocation) { var location = new Position (geoLocation.Latitude, geoLocation.Longitude); var map = new CustomMap (MapSpan.FromCenterAndRadius (location, Distance.FromMiles (5))) { IsShowingUser = true }; //Show current location for Win Phone if (Device.OS == TargetPlatform.WinPhone) { map.CustomPins.Add (new CustomPin { Position = location, Label = "Current Location" }); } //Add the car wash pins Task.Run (async () => { var carWashPins = await _viewModel.GetMapPinsAsync (); Device.BeginInvokeOnMainThread (() => { foreach (var carWashPin in carWashPins) { map.CustomPins.Add (carWashPin); } }); }); var selectedPinLabel = new LargeLabel { HorizontalOptions = LayoutOptions.Center, TextColor = Color.Black }; selectedPinLabel.BindingContext = map; selectedPinLabel.SetBinding<CustomMap> (Label.TextProperty, vm => vm.SelectedPin.Label); var selectedPinAddress = new Label { HorizontalOptions = LayoutOptions.Center, TextColor = Color.Black }; selectedPinAddress.BindingContext = map; selectedPinAddress.SetBinding<CustomMap> (Label.TextProperty, vm => vm.SelectedPin.Address); var stack = new StackLayout { Spacing = 0, BackgroundColor = Color.FromHex ("#ecf0f1") }; map.VerticalOptions = LayoutOptions.FillAndExpand; stack.Children.Add (map); stack.Children.Add (selectedPinLabel); stack.Children.Add (selectedPinAddress); Content = stack; }
private void Watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e) { Debug.WriteLine("Watcher_StatusChanged ({0})", e.Status); switch (e.Status) { case GeoPositionStatus.Disabled: _currentLocation = null; break; case GeoPositionStatus.NoData: _currentLocation = null; break; } }
public static Distance CalculateDistance(GeoLocation pos1, GeoLocation pos2, DistanceUnit unit) // returns KMs between two Geopoints { double r = unit == DistanceUnit.Kilometres ? RKilometres : RMiles; double lat = (pos2.Latitude - pos1.Latitude).ToRadians(); var lng = (pos2.Longitude - pos1.Longitude).ToRadians(); double h1 = Math.Sin(lat/2)*Math.Sin(lat/2) + Math.Cos(ToRadians(pos1.Latitude))*Math.Cos(ToRadians(pos2.Latitude))* Math.Sin(lng/2)*Math.Sin(lng/2); double h2 = 2*Math.Asin(Math.Min(1, Math.Sqrt(h1))); return new Distance(r*h2, unit); }
public static bool intersects(this GeoLocation locationA, GeoLocation locationB) { Guard.IsNotNull(locationA, "locationA"); Guard.IsNotNull(locationB, "locationB"); var point_a = locationA.Geoposition; var radius_a = Resources.determine_radius(locationA.AccuracyInMetres); var point_b = locationB.Geoposition; var radius_b = Resources.determine_radius(locationB.AccuracyInMetres); var circleA = point_a.Buffer(radius_a + 0.0); var circleB = point_b.Buffer(radius_b + 0.0); return circleA.Intersects(circleB); }
public void GetAddressByGeoLocation(GeoLocation geoLocation, Action<string> addressByGeoLocationCallback) { _onAddressByGeoLocationCallback = addressByGeoLocationCallback; string formattedGeoLocation = Uri.EscapeUriString(string.Format("{0},{1}", geoLocation.Latitude, geoLocation.Longitude)); string requestUri = string.Format("https://maps.googleapis.com/maps/api/geocode/xml?address={0}&sensor=true", formattedGeoLocation); DownloadString(requestUri, (data) => { string address = ExtractAddressFromGeocodeData(data); //GeoLocation geoLocation = new GeoLocation(42.642364f, 23.337971f);//some test data if (_onAddressByGeoLocationCallback != null) { _onAddressByGeoLocationCallback(address); _onAddressByGeoLocationCallback = null; } }); }
public static GeoLocation GetLocation() { var _applicationSettings = CompositionManager.Get<IApplicationSettingsProvider>(); if (_applicationSettings.UseLocation) { if (Loc == null) { var l = new GeoLocation(); //Try grabbing the Win7 location try { if (_loadproviderthrowsexception) return null; if (_provider == null) _provider = new LatLongLocationProvider(DefaultReportInterval); var position = _provider.GetReport() as LatLongLocationReport; if (position == null) return null; l.Latitude = position.Latitude; l.Longitude = position.Longitude; return l; } catch (Exception ex) { CompositionManager.Get<IExceptionReporter>().ReportHandledException(ex); _loadproviderthrowsexception = true; return null; } } } return null; }
public static IdentifiableEntity Create(GeoLocation geoLocation) { return geoLocation; }
public GeoLocationSearchItem(GeoLocation location) { Location = location; DisplayText = string.Format("{0:F2}, {1:F2}", location.Latitude, location.Longitude); }
public async Task <IEnumerable <Station> > GetNearestStationsTo(GeoLocation location) { await Task.Delay(200); return(stations); }
public static Task <Distance> GetDistance(this IGoogleDirectionsRepository repository, GeoLocation origin, AddressLocation destination) => repository.GetDistance(GetParameter(origin), GetParameter(destination));
public static GeoLocation Create(double geoLat, double geoLong) { GeoLocation geo = new GeoLocation(); geo.Update(geoLat, geoLong); return geo; }
/// <summary> /// Initializes a new instance of the <see cref="LocationUpdatedEvent"/> class. /// </summary> /// <param name="previous">The previous.</param> /// <param name="current">The current.</param> public LocationUpdatedEvent(GeoLocation previous, GeoLocation current) { Previous = previous; Current = current; }
public static TimeSpan CalculateSunsetTime(GeoLocation location, DateTimeOffset instant) => CalculateSunriseSunsetTime(location, instant, false);
private static TimeSpan CalculateSunriseSunsetTime(GeoLocation location, DateTimeOffset instant, bool isSunrise) { // Based on https://edwilliams.org/sunrise_sunset_algorithm.htm // Convert longitude to hour value and calculate an approximate time var lngHours = location.Longitude / 15; var timeApproxHours = isSunrise ? 6 : 18; var timeApproxDays = instant.DayOfYear + (timeApproxHours - lngHours) / 24; // Calculate Sun's mean anomaly var sunMeanAnomaly = 0.9856 * timeApproxDays - 3.289; // Calculate Sun's true longitude var sunLng = sunMeanAnomaly + 282.634 + 1.916 * Math.Sin(DegreesToRadians(sunMeanAnomaly)) + 0.020 * Math.Sin(2 * DegreesToRadians(sunMeanAnomaly)); sunLng = Wrap(sunLng, 0, 360); // Calculate Sun's right ascension var sunRightAsc = RadiansToDegrees(Math.Atan(0.91764 * Math.Tan(DegreesToRadians(sunLng)))); sunRightAsc = Wrap(sunRightAsc, 0, 360); // Right ascension value needs to be in the same quadrant as true longitude var sunLngQuad = Math.Floor(sunLng / 90) * 90; var sunRightAscQuad = Math.Floor(sunRightAsc / 90) * 90; var sunRightAscHours = sunRightAsc + (sunLngQuad - sunRightAscQuad); sunRightAscHours /= 15; // Calculate Sun's declination var sinDec = 0.39782 * Math.Sin(DegreesToRadians(sunLng)); var cosDec = Math.Cos(Math.Asin(sinDec)); // Calculate Sun's zenith local hour const double zenith = 90.83; // official sunrise/sunset var sunLocalHoursCos = (Math.Cos(DegreesToRadians(zenith)) - sinDec * Math.Sin(DegreesToRadians(location.Latitude))) / (cosDec * Math.Cos(DegreesToRadians(location.Latitude))); // This value may be invalid in case the Sun never reaches zenith // so we clamp to get the closest highest point instead sunLocalHoursCos = sunLocalHoursCos.Clamp(-1, 1); // Calculate local time of Sun's highest point var sunLocalHours = isSunrise ? 360 - RadiansToDegrees(Math.Acos(sunLocalHoursCos)) : RadiansToDegrees(Math.Acos(sunLocalHoursCos)); sunLocalHours /= 15; // Calculate mean time of the event var meanHours = sunLocalHours + sunRightAscHours - 0.06571 * timeApproxDays - 6.622; // Adjust mean time to UTC var utcHours = meanHours - lngHours; utcHours = Wrap(utcHours, 0, 24); // Adjust UTC time to local time // (we use the offset provided because we can't accurately calculate local timezone from coordinates) var localHours = utcHours + instant.Offset.TotalHours; localHours = Wrap(localHours, 0, 24); return(TimeSpan.FromHours(localHours)); }
public async Task <Station> GetNearestStationTo(GeoLocation location) { IEnumerable <Station> stations = await GetNearestStationsTo(location); return(stations.FirstOrDefault()); }
public override void OnActionExecuting(HttpActionContext actionContext) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); var request = actionContext.ActionArguments[RequestArgumentName]; bool enableValidation = false; if (Utils.Configuration.HasSetting(Constants.ValidateWSDLocation)) { enableValidation = Utils.Configuration[Constants.ValidateWSDLocation].ToBool(); } if (request == null || !enableValidation) { return; } HttpRequestMessage httpRequest = (HttpRequestMessage)request; Request requestparam = new Request(); this.PawsAuditor.UserId = this.PawsLogger.UserId; this.PawsAuditor.TransactionId = this.PawsLogger.TransactionId; this.PawsAuditor.RegionCode = Utils.Configuration.CurrentRegionId; try { requestparam = JsonSerialization.DeserializeString <Request>(httpRequest.Content.ReadAsStringAsync().Result); GeoLocation geolocation = requestparam.Params.Location; GeoLocation[] geolocations = requestparam.Params.Locations; List <RegionPolygonsCache> subregions = (List <RegionPolygonsCache>)DatabaseCache.ServiceCacheHelper.GetServiceCacheObjects(ServiceCacheObjectType.RegionPolygons, null); bool isValidRequest = false; bool isBatchRequest = false; if (geolocation != null) { isValidRequest = ValidateRequestedLocation(geolocation, subregions); } else if (geolocations != null && geolocations.Length > 0) { isBatchRequest = true; isValidRequest = ValidateBatchRequestLocations(geolocations, subregions); } stopWatch.Stop(); if (!isValidRequest) { PawsResponse errorResponse = null; if (isBatchRequest) { errorResponse = ErrorHelper.CreateErrorResponse(requestparam.Method, geolocations, Constants.ErrorMessageOutsideCoverage); } else { errorResponse = ErrorHelper.CreateErrorResponse(requestparam.Method, geolocation, Constants.ErrorMessageOutsideCoverage); } this.PawsLogger.Log(TraceEventType.Error, LoggingMessageId.PAWSGenericMessage, errorResponse.Error.Message); string auditMethod; AuditId auditId = PawsUtil.GetAuditId(requestparam.Method, out auditMethod); this.PawsAuditor.Audit(auditId, AuditStatus.Failure, stopWatch.ElapsedMilliseconds, auditMethod + " failed"); actionContext.Response = actionContext.Request.CreateResponse <PawsResponse>(errorResponse); } } catch (Exception ex) { stopWatch.Stop(); this.PawsLogger.Log(TraceEventType.Error, LoggingMessageId.PAWSGenericMessage, ex.ToString()); string auditMethod; AuditId auditId = PawsUtil.GetAuditId(requestparam.Method, out auditMethod); this.PawsAuditor.Audit(auditId, AuditStatus.Failure, stopWatch.ElapsedMilliseconds, auditMethod + " failed"); PawsResponse errorResponse = ErrorHelper.CreateExceptionResponse(requestparam.Method, ex.Message); actionContext.Response = actionContext.Request.CreateResponse <PawsResponse>(errorResponse); } }
public static string ToLongitudeString(this double tag) { if (tag == 0) { return(GeoLocation.DecimalToDegreesMinutesSecondsString(tag)); } return((tag > 0 ? GUILocalizeStrings.Get(9095) : GUILocalizeStrings.Get(9096)) + GeoLocation.DecimalToDegreesMinutesSecondsString(tag)); }
internal Communication(long?contentLength, string contentType, string destination, int?destinationPort, string headers, string host, string html, string httpPacket, long?id, string informationType, bool outgoing, string payload, string referer, bool request, string requestMethod, string requestUrl, bool response, string server, string source, int?sourcePort, GeoLocation location) { ContentLength = contentLength; ContentType = contentType; Destination = destination; DestinationPort = destinationPort; Headers = headers; Host = host; Html = html; HttpPacket = httpPacket; ID = id; InformationType = informationType; Outgoing = outgoing; Payload = payload; Referer = referer; Request = request; RequestMethod = requestMethod; RequestUrl = requestUrl; Response = response; Server = server; Source = source; SourcePort = sourcePort; }
/// <summary> /// /// </summary> /// <param name="locations"></param> /// <param name="locationType"></param> /// <param name="geoLocation"></param> /// <returns></returns> private ElasticsearchLocation GetParentLocationOfCity(List <ElasticsearchLocation> locations, LocationType locationType, GeoLocation geoLocation) { var parent = locations.SingleOrDefault(x => x.Division3Code == geoLocation.Admin3Code && x.TypeID == (int)LocationType.ThirdOrderDivision); if (parent != null) { return(parent); } parent = locations.SingleOrDefault(x => x.Division2Code == geoLocation.Admin2Code && x.TypeID == (int)LocationType.SecondOrderDivision); if (parent != null) { return(parent); } parent = locations.SingleOrDefault(x => x.Division1Code == geoLocation.Admin1Code && x.TypeID == (int)LocationType.FirstOrderDivision); if (parent != null) { return(parent); } parent = locations.SingleOrDefault(x => x.CountryCode == geoLocation.CountryCode && x.TypeID == (int)LocationType.Country); if (parent != null) { return(parent); } return(null); }
public static ITwitterStatusUpdate Update(this ITwitterStatuses instance, string text, GeoLocation location) { instance.Root.Parameters.Action = "update"; instance.Root.Parameters.Text = text; instance.Root.Parameters.GeoLocation = location; return new TwitterStatusUpdate(instance.Root); }
partial void OnGeoLocationChanging(GeoLocation value);
public async Task <InvokeResult> UpdateGeoLocationAsync(DeviceRepository deviceRepo, string id, GeoLocation geoLocation, EntityHeader org, EntityHeader user) { if (geoLocation == null) { return(InvokeResult.FromError("Geolocation must not be null.")); } var device = await GetDeviceByIdAsync(deviceRepo, id, org, user); if (device == null) { return(InvokeResult.FromErrors(Resources.ErrorCodes.CouldNotFindDeviceWithId.ToErrorMessage())); } await AuthorizeAsync(device, AuthorizeActions.Update, user, org); device.GeoLocation = geoLocation; device.LastUpdatedBy = user; device.LastUpdatedDate = DateTime.UtcNow.ToJSONString(); var repo = GetRepo(deviceRepo); await repo.UpdateDeviceAsync(deviceRepo, device); return(InvokeResult.Success); }
public List<string> GetHotels(FormCollection collection) { //TempData["col"] = collection; // return RedirectToAction("SearchTourico", "BookTourico", collection); //musanka comment GeoLocation gloc = new GeoLocation(); gloc.Latitude = Convert.ToDecimal(collection["lat"]); gloc.Longitude = Convert.ToDecimal(collection["lan"]); //HotelSearchRequestDto searchCriteria = new HotelSearchRequestDto(); //// searchCriteria.Address = collection["add"]; //searchCriteria.Location = gloc; //searchCriteria.CheckInDate = Convert.ToDateTime(collection["checkIn"]); //searchCriteria.CheckOutDate = Convert.ToDateTime(collection["checkOut"]); //searchCriteria.NumberOfAdults = Convert.ToInt16(collection["ddlTotalGuest"]); //searchCriteria.NumberOfRooms = Convert.ToInt16(collection["ddlNoOfRooms"]); ////Check in cache //var key = gloc.Latitude.ToString() + gloc.Longitude.ToString() + searchCriteria.CheckInDate.ToString() + searchCriteria.CheckInDate.ToString(); //var result = GetFromCache(key); //holds list of hotel ids to search var hotelIds = new List<string>(); //if (result == null) //{ //check here which provider is selected in UI //ProviderType = "Tourico"; //Retrieve from catalog the list of hotel ids, that will be passed to the provider, if the coordinates are specified in the request var catalogRequest = new HotelCatalogRequest { GeoLocation = gloc, //request.Location, MinRating = 1, //request.MinRating, MaxRating = 5 //request.MaxRating }; //HotelSearhManager call to get the provider and search //If "Skip Local Cache" is false, then call the catalog manager for local search -- (!request.SkipLocalCache) if (true) { var hotelCatalogManager = new HotelCatalogManager(); //TODO: //hotelIds = hotelCatalogManager.RrieveHotelsByLatLongCatalog(catalogRequest); } // var provider = HotelProviderBroker.GetHotelSearchProvider(HotelSearchProviderTypes.Tourico); // var providerRes = provider.Search(ConvertToHotelSearchReq(searchCriteria, hotelIds)); // result = providerRes; // ConvertFromHotelSearchResp(providerRes); // AddToCache(result, key); //} //ViewBag.StartDate = searchCriteria.CheckInDate; //ViewBag.EndDate = searchCriteria.CheckOutDate; //ViewBag.TotalTravellers = searchCriteria.NumberOfAdults; //ViewBag.Lat = gloc.Latitude; //ViewBag.Lan = gloc.Longitude; //return View("SearchHotelTourico", result); return hotelIds; }
public IEnumerable <Place> Find(GeoLocation location, Guid userId) { return(Find(new GeoLocation[] { location }, userId)); }
private void DoCallback(GeoLocation g) { if(pendingCallback != null) { pendingCallback(g); pendingCallback = null; } }
public ClosestLocationVisitor(GeoLocation location) { _location = location; }
public void Init(GeoLocation location) { if(location.Latitude+location.Longitude>0) { GeoLocationSearchItem searchItem = new GeoLocationSearchItem(location); InitSearchBase(searchItem); } }
public void Update(GeoLocation loc) { GeoLocation = loc; adapter = new MainRecyclerAdapter(ExhibitSet, GeoLocation, Application.Context); recyclerView.SetAdapter(adapter); }
public Task <Station> GetNearestStationTo(GeoLocation location) { var station = stations[StationsCounter++ % stations.Count()]; return(Task.FromResult(station)); }
public IEnumerable <ComplexZmanimCalendar> GetDaysInHebrewMonth(DateTime yearAndMonth, GeoLocation location) { Calendar calendar = new HebrewCalendar(); var daysInMonth = calendar.GetDaysInMonth(calendar.GetYear(yearAndMonth), calendar.GetMonth(yearAndMonth)); for (int i = 0; i < daysInMonth; i++) { var zmanimCalendar = new ComplexZmanimCalendar(location); zmanimCalendar.DateWithLocation.Date = new DateTime(yearAndMonth.Year, yearAndMonth.Month, i + 1); yield return(zmanimCalendar); } }
public Task <Station> GetInfoForNearestStationTo(GeoLocation toGeoLocation) { return(GetNearestStationTo(toGeoLocation)); }
public IEnumerable <ComplexZmanimCalendar> GetDaysInHebrewYear(DateTime year, GeoLocation location) { Calendar calendar = new HebrewCalendar(); var currentYear = calendar.GetYear(year); var amountOfMonths = calendar.GetMonthsInYear(currentYear); for (int i = 0; i < amountOfMonths; i++) { var currentMonth = i + 1; var daysInMonth = calendar.GetDaysInMonth(currentYear, currentMonth); for (int dayOfMonth = 0; dayOfMonth < daysInMonth; dayOfMonth++) { var zmanimCalendar = new ComplexZmanimCalendar(location); zmanimCalendar.DateWithLocation.Date = new DateTime(currentYear, currentMonth, dayOfMonth + 1, calendar); yield return(zmanimCalendar); } } }
protected GeoLocationParameter(GeoLocation location) : this(location.Latitude, location.Longitude) { }
public async Task <GeoLocation> GetPositionAsync() { await Task.Delay(500); return(GeoLocation.Parse(AppSettings.DefaultFallbackMapsLocation)); }
public static ITwitterStatusUpdate Update(this ITwitterStatuses instance, string text, double latitude, double longitude) { var location = new GeoLocation {Latitude = latitude, Longitude = longitude}; return instance.Update(text, location); }
/// <summary> /// /// </summary> /// <param name="dronesGeoLocation"></param> /// <param name="storesGeoLocation"></param> /// <param name="destGeoLocation"></param> /// <returns></returns> private DeliveryInfo CalacuteShortPath(List <GeoLocation> dronesGeoLocation, List <GeoLocation> storesGeoLocation, GeoLocation destGeoLocation) { //define max value double shortDistance = Double.MaxValue; // define delivery info object DeliveryInfo deliveryInfo = new DeliveryInfo(); // go through drones location for (int i = 0; i < dronesGeoLocation.Count; i++) { for (int j = 0; j < storesGeoLocation.Count; j++) { // define Geo Coordinate for drone var droneCoord = new GeoCoordinate(dronesGeoLocation[i].Latitude, dronesGeoLocation[i].Longitude); // define Geo Coordinate for store var storeCoord = new GeoCoordinate(storesGeoLocation[j].Latitude, storesGeoLocation[j].Longitude); // define Geo Coordinate for destination var destCoord = new GeoCoordinate(destGeoLocation.Latitude, destGeoLocation.Longitude); // get distance btw drone and store in km double distance1 = droneCoord.GetDistanceTo(storeCoord) / 1000; // get distance btw store and destination in km double distance2 = storeCoord.GetDistanceTo(destCoord) / 1000; // get total distance double totaldistance = distance1 + distance2; // determine short distance if (totaldistance < shortDistance) { shortDistance = totaldistance; deliveryInfo.DroneLocation = dronesGeoLocation[i].Address; deliveryInfo.StoreLocation = storesGeoLocation[j].Address; } } } //get delivery time deliveryInfo.DeliveryTime = this.CalacuteDeliveryTime(shortDistance); return(deliveryInfo); }
public static Product CreateProduct(string ID, decimal priceMin, decimal priceMax, decimal priceRetail, Label label, GeoLocation geoLocation) { Product product = new Product(); product.Id = ID; product.PriceMin = priceMin; product.PriceMax = priceMax; product.PriceRetail = priceRetail; if ((label == null)) { throw new global::System.ArgumentNullException("label"); } product.Label = label; if ((geoLocation == null)) { throw new global::System.ArgumentNullException("geoLocation"); } product.GeoLocation = geoLocation; return product; }
public GarageBuilder WithGeoLocation(GeoLocation geoLocation) { PropertyBag.GeoLocation = geoLocation; return(this); }
public ZmanimService(ZmanimModel model) { String locationName = "Random"; double latitude = model.latitude; double longitude = model.longitude; double elevation = model.elevation; ITimeZone timeZone = new WindowsTimeZone(model.timezone); GeoLocation location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone); ComplexZmanimCalendar czc; //if the models date is null then set the models date to today if (!model.date.HasValue) { model.date = DateTime.Now; } Console.WriteLine("Date was submitted so using the date of" + model.date.ToString()); czc = new ComplexZmanimCalendar(model.date.GetValueOrDefault(), location); //If the request wanted basic mode then use basic zmanim, else print everything if (model.mode == "basic") { //insert the zmanim into the model so the controller can create a view from it model.zmanimList.Add("Alos 16point 1Degrees", czc.GetAlos16Point1Degrees()); model.zmanimList.Add("Sunrise", czc.GetSunrise()); model.zmanimList.Add("Sof Zman Shema MGA", czc.GetSofZmanShmaMGA()); model.zmanimList.Add("Sof Zman Shema Gra", czc.GetSofZmanShmaGRA()); model.zmanimList.Add("Sof Zman Tefilah Gra", czc.GetSofZmanTfilaGRA()); model.zmanimList.Add("Sof Zman Tefilah MGA", czc.GetSofZmanTfilaMGA72Minutes()); model.zmanimList.Add("Chatzos", czc.GetChatzos()); model.zmanimList.Add("Mincha Gedolah", czc.GetMinchaGedola()); model.zmanimList.Add("PlagHamincha", czc.GetPlagHamincha()); model.zmanimList.Add("Shkia", czc.GetSunset()); model.zmanimList.Add("Tzais", czc.GetTzais()); model.zmanimList.Add("Candle Lighting", czc.GetCandleLighting()); } else { //insert the zmanim into the model so the controller can create a view from it model.zmanimList.Add("Alos", czc.GetAlos16Point1Degrees()); model.zmanimList.Add("Alos16point1Degrees", czc.GetAlos16Point1Degrees()); model.zmanimList.Add("Alos18Degrees", czc.GetAlos18Degrees()); model.zmanimList.Add("Alos19Point8Degrees", czc.GetAlos19Point8Degrees()); model.zmanimList.Add("Alos26Degrees", czc.GetAlos26Degrees()); model.zmanimList.Add("Alos60", czc.GetAlos60()); model.zmanimList.Add("Alos72", czc.GetAlos72Zmanis()); model.zmanimList.Add("Alos90", czc.GetAlos90()); model.zmanimList.Add("Alos90Zmanim", czc.GetAlos90Zmanis()); model.zmanimList.Add("Alos96", czc.GetAlos96()); model.zmanimList.Add("Alos96Zmanim", czc.GetAlos96Zmanis()); model.zmanimList.Add("Alos120", czc.GetAlos120()); model.zmanimList.Add("Alos120Zmanim", czc.GetAlos120Zmanis()); model.zmanimList.Add("Misheyakir10.2Degrees", czc.GetMisheyakir10Point2Degrees()); model.zmanimList.Add("Misheyakir11Degrees", czc.GetMisheyakir11Degrees()); model.zmanimList.Add("Misheyakir11.5Degrees", czc.GetMisheyakir11Point5Degrees()); model.zmanimList.Add("Sunrise", czc.GetSunrise()); model.zmanimList.Add("SofZmanShemaMGA", czc.GetSofZmanShmaMGA()); model.zmanimList.Add("SofZmanShmaGra", czc.GetSofZmanShmaGRA()); model.zmanimList.Add("SofZmanShema3HoursBeforeChatzos", czc.GetSofZmanShma3HoursBeforeChatzos()); model.zmanimList.Add("SofZmanShemaAlos16Point1ToSunset", czc.GetSofZmanShmaAlos16Point1ToSunset()); model.zmanimList.Add("SofZmanShemaAlos16Point1ToTzaisGeonim7Point083Degrees", czc.GetSofZmanShmaAlos16Point1ToTzaisGeonim7Point083Degrees()); model.zmanimList.Add("SofZmanShemaAteretTorah", czc.GetSofZmanShmaAteretTorah()); model.zmanimList.Add("SofZmanShemaMGA18Degrees", czc.GetSofZmanShmaMGA18Degrees()); model.zmanimList.Add("SofZmanShemaMGA16Point1Degrees", czc.GetSofZmanShmaMGA16Point1Degrees()); model.zmanimList.Add("SofZmanShemaMGA19point8Degrees", czc.GetSofZmanShmaMGA19Point8Degrees()); model.zmanimList.Add("SofZmanShemaMGA72", czc.GetSofZmanShmaMGA72Minutes()); model.zmanimList.Add("SofZmanShemaMGA72Zmanis", czc.GetSofZmanShmaMGA72MinutesZmanis()); model.zmanimList.Add("SofZmanShemaMGA90", czc.GetSofZmanShmaMGA90Minutes()); model.zmanimList.Add("SofZmanShemaMGA90Zmanis", czc.GetSofZmanShmaMGA90MinutesZmanis()); model.zmanimList.Add("SofZmanShemaMGA96", czc.GetSofZmanShmaMGA96Minutes()); model.zmanimList.Add("SofZmanShemaMGA96Zmanis", czc.GetSofZmanShmaMGA96MinutesZmanis()); model.zmanimList.Add("SofZmanShemaMGA120", czc.GetSofZmanShmaMGA120Minutes()); model.zmanimList.Add("SofZmanTefilahGra", czc.GetSofZmanTfilaGRA()); model.zmanimList.Add("SofZmanTefilahGra2HoursBeforeChatzos", czc.GetSofZmanTfila2HoursBeforeChatzos()); model.zmanimList.Add("SofZmanTefilahAteretTorah", czc.GetSofZmanTfilahAteretTorah()); model.zmanimList.Add("SofZmanTefilahMGA72", czc.GetSofZmanTfilaMGA72Minutes()); model.zmanimList.Add("SofZmanTefilahMGA72Zmanis", czc.GetSofZmanTfilaMGA72MinutesZmanis()); model.zmanimList.Add("SofZmanTefilahMGA90", czc.GetSofZmanTfilaMGA90Minutes()); model.zmanimList.Add("SofZmanTefilahMGA90Zmanis", czc.GetSofZmanTfilaMGA90MinutesZmanis()); model.zmanimList.Add("SofZmanTefilahMGA96", czc.GetSofZmanTfilaMGA96Minutes()); model.zmanimList.Add("SofZmanTefilahMGA96Zmanis", czc.GetSofZmanTfilaMGA96MinutesZmanis()); model.zmanimList.Add("SofZmanTefilahMGA120", czc.GetSofZmanTfilaMGA120Minutes()); model.zmanimList.Add("SolarMidnight", czc.GetSolarMidnight()); model.zmanimList.Add("Chatzos", czc.GetChatzos()); model.zmanimList.Add("MinchaGedolah", czc.GetMinchaGedola()); model.zmanimList.Add("MinchaGedolah16.1Degrees", czc.GetMinchaGedola16Point1Degrees()); model.zmanimList.Add("MinchaGedolah30MinutesAfterChatzos", czc.GetMinchaGedola30Minutes()); model.zmanimList.Add("MinchaGedolah72MinutesAfterChatzos", czc.GetMinchaGedola72Minutes()); model.zmanimList.Add("MinchaGedolahAteretTorah", czc.GetMinchaGedolaAteretTorah()); model.zmanimList.Add("MinchaKetana", czc.GetMinchaKetana()); model.zmanimList.Add("MinchaKetanaMGA72Minutes", czc.GetMinchaKetana72Minutes()); model.zmanimList.Add("MinchaKetanaMGA16.1Degrees", czc.GetMinchaKetana16Point1Degrees()); model.zmanimList.Add("MinchaKetanaAteretTorah", czc.GetMinchaKetanaAteretTorah()); model.zmanimList.Add("PlagHamincha", czc.GetPlagHamincha()); model.zmanimList.Add("PlagHaminchaAteretTorah", czc.GetPlagHaminchaAteretTorah()); model.zmanimList.Add("PlagHaminchaDayStartAlosEndSunset", czc.GetPlagAlosToSunset()); model.zmanimList.Add("PlagHaminchaAlos16Point1ToTzaisGeonim7Point083Degrees", czc.GetPlagAlos16Point1ToTzaisGeonim7Point083Degrees()); model.zmanimList.Add("PlagHamincha18Degrees", czc.GetPlagHamincha18Degrees()); model.zmanimList.Add("PlagHamincha19.8Degrees", czc.GetPlagHamincha19Point8Degrees()); model.zmanimList.Add("PlagHamincha26Degrees", czc.GetPlagHamincha26Degrees()); model.zmanimList.Add("PlagHamincha60", czc.GetPlagHamincha60Minutes()); model.zmanimList.Add("PlagHamincha72", czc.GetPlagHamincha72Minutes()); model.zmanimList.Add("PlagHamincha72Zmanis", czc.GetPlagHamincha72MinutesZmanis()); model.zmanimList.Add("PlagHamincha90", czc.GetPlagHamincha90Minutes()); model.zmanimList.Add("PlagHamincha90Zmanis", czc.GetPlagHamincha90MinutesZmanis()); model.zmanimList.Add("PlagHamincha96", czc.GetPlagHamincha96Minutes()); model.zmanimList.Add("PlagHamincha96Zmanis", czc.GetPlagHamincha96MinutesZmanis()); model.zmanimList.Add("Shkia", czc.GetSunset()); model.zmanimList.Add("BainHashmashosRabeinuTam2Stars", czc.GetBainHasmashosRT2Stars()); model.zmanimList.Add("BainHashmashosRabeinuTam58.5Minutes", czc.GetBainHasmashosRT58Point5Minutes()); model.zmanimList.Add("BainHashmashosRabeinuTam13.24Degrees", czc.GetBainHasmashosRT13Point24Degrees()); model.zmanimList.Add("BainHashmashosRabeinuTam13Point5MinutesBefore7Point083Degrees", czc.GetBainHasmashosRT13Point5MinutesBefore7Point083Degrees()); model.zmanimList.Add("Tzais", czc.GetTzais()); model.zmanimList.Add("Tzais16.1Degrees", czc.GetTzais16Point1Degrees()); model.zmanimList.Add("Tzais18Degrees", czc.GetTzais18Degrees()); model.zmanimList.Add("Tzais26Degrees", czc.GetTzais26Degrees()); model.zmanimList.Add("Tzais19.8Degrees", czc.GetTzais19Point8Degrees()); model.zmanimList.Add("Tzais60", czc.GetTzais60()); model.zmanimList.Add("Tzais90", czc.GetTzais90()); model.zmanimList.Add("Tzais96", czc.GetTzais96()); model.zmanimList.Add("Tzais120", czc.GetTzais120()); model.zmanimList.Add("Tzais72Zmanis", czc.GetTzais72Zmanis()); model.zmanimList.Add("Tzais90Zmanis", czc.GetTzais90Zmanis()); model.zmanimList.Add("Tzais96Zmanis", czc.GetTzais96Zmanis()); model.zmanimList.Add("Tzais120Zmanis", czc.GetTzais120Zmanis()); model.zmanimList.Add("TzaisAteretTorah", czc.GetTzaisAteretTorah()); model.zmanimList.Add("CandleLighting", czc.GetCandleLighting()); } }
/// <summary> /// Get the address from a latitude and longitude /// </summary> /// <param name="location"><see cref="GeoLocation"/></param> /// <returns>Null if no address is resolved</returns> public static GeoAddress GetAddressFromLatLong(GeoLocation location) { var requestUri = GetAddressConversionUrl(location); using (var wc = new WebClient()) { try { var result = wc.DownloadString(new Uri(requestUri)); var xmlElm = XElement.Parse(result); var status = (from elm in xmlElm.Descendants() where elm.Name == "status" select elm).FirstOrDefault(); Console.WriteLine("Google Status {0}", status); if (status != null && status.Value.ToLower() == "ok") { var address = new GeoAddress(); var street = string.Empty; var country = string.Empty; var city = string.Empty; var zip = string.Empty; var region1 = string.Empty; var region2 = string.Empty; var region3 = string.Empty; foreach (var descendant in xmlElm.Descendants("address_component")) { var type = descendant.Descendants("type").FirstOrDefault(); if (type != null && type.Value == "street_number") { address.Number = descendant.Descendants("long_name").First().Value; } if (type != null && type.Value == "route") { street = descendant.Descendants("long_name").First().Value; } if (type != null && type.Value == "locality") { city = descendant.Descendants("long_name").First().Value; } if (type != null && type.Value == "administrative_area_level_3") { region3 = descendant.Descendants("long_name").First().Value; } if (type != null && type.Value == "administrative_area_level_2") { region2 = descendant.Descendants("long_name").First().Value; } if (type != null && type.Value == "administrative_area_level_1") { region1 = descendant.Descendants("long_name").First().Value; } if (type != null && type.Value == "country") { country = descendant.Descendants("long_name").First().Value; } if (type != null && type.Value == "postal_code") { zip = descendant.Descendants("long_name").First().Value; } //Console.WriteLine(descendant.Name); } address.City = city; address.Zip = zip; address.Country = country; address.Region1 = region1; address.Region2 = region2; address.Region3 = region3; address.Street = street; return(address); } return(null); } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } } }
//private GeoLocation Parse(JObject jobject) //{ // GeoLocation location = new GeoLocation // { // DateCreated = DateTime.Now, // LastSeen = DateTime.Now // }; // location.Country = (string)jobject.SelectToken("country"); // location.Address = (string)jobject.SelectToken("query"); // location.CountryCode = (string)jobject.SelectToken("countryCode"); // location.Region = (string)jobject.SelectToken("region"); // location.RegionName = (string)jobject.SelectToken("country"); // location.City = (string)jobject.SelectToken("city"); // location.Zip = (string)jobject.SelectToken("zip"); // location.Latitude = (string)jobject.SelectToken("lat"); // location.Longitude = (string)jobject.SelectToken("lon"); // location.TimeZone = (string)jobject.SelectToken("timezone"); // location.Isp = (string)jobject.SelectToken("isp"); // location.Organization = (string)jobject.SelectToken("org"); // location.As = (string)jobject.SelectToken("as"); // return location; //} private GeoLocation ParseFreeGeoIp(JObject jobject) { GeoLocation location = new GeoLocation { DateCreated = DateTime.Now, LastSeen = DateTime.Now }; location.Country = (string)jobject.SelectToken("country_name"); location.Address = (string)jobject.SelectToken("ip"); location.CountryCode = (string)jobject.SelectToken("country_code"); location.Region = (string)jobject.SelectToken("region_code"); location.RegionName = (string)jobject.SelectToken("region_name"); location.City = (string)jobject.SelectToken("city"); location.Zip = (string)jobject.SelectToken("zipcode"); location.Latitude = (string)jobject.SelectToken("latitude"); location.Longitude = (string)jobject.SelectToken("longitude"); //location.TimeZone = (string)jobject.SelectToken("timezone"); location.Isp = (string)jobject.SelectToken("isp"); location.Organization = (string)jobject.SelectToken("metro_code"); location.As = (string)jobject.SelectToken("areacode"); return location; }
/// <summary> /// Compares two AdditionalGeoLocations for equality. /// </summary> /// <param name="AdditionalGeoLocation">A AdditionalGeoLocation to compare with.</param> /// <returns>True if both match; False otherwise.</returns> public Boolean Equals(AdditionalGeoLocation AdditionalGeoLocation) => GeoLocation.Equals(AdditionalGeoLocation.GeoLocation) && ((!Name.HasValue && !AdditionalGeoLocation.Name.HasValue) || (Name.HasValue && AdditionalGeoLocation.Name.HasValue && Name.Value.Equals(AdditionalGeoLocation.Name.Value)));
public CarWashesMapViewModel (IGooglePlacesService googlePlacesService, GeoLocation currentPosition) { _googlePlacesService = googlePlacesService; _currentPosition = currentPosition; }
private void getData(GeoLocation location) { weatherPinFound(location); }
public void SetGeoLocation(GeoLocation location) { GeoPoint = location; }
/// <summary> /// 根据距离排序 /// </summary> public static SortDescriptor <T> SortByDistance <T>(this SortDescriptor <T> sort, Expression <Func <T, object> > field, GeoLocation point, bool desc = false) where T : class, IElasticSearchIndex { var geo_sort = new SortGeoDistanceDescriptor <T>().PinTo(point); if (desc) { geo_sort = geo_sort.Descending(); } else { geo_sort = geo_sort.Ascending(); } return(sort.GeoDistance(x => geo_sort)); /* * if (desc) * { * return sort.GeoDistance(x => x.Field(field).PinTo(new GeoLocation(lat, lng)).Descending()); * } * else * { * return sort.GeoDistance(x => x.Field(field).PinTo(new GeoLocation(lat, lng)).Ascending()); * }*/ }
private GeoLocation InvalidLocation(string ipaddress) { GeoLocation location = new GeoLocation { DateCreated = DateTime.Now, LastSeen = DateTime.Now }; location.Address = ipaddress; return location; }
public static ITwitterStreamingFilter Within(this ITwitterStreamingFilter instance, GeoLocation southWest, GeoLocation northEast) { return instance.Within(new[] {southWest, northEast}); }
public static Distance CalculateDistance(GeoLocation pos1, GeoLocation pos2) // returns KMs between two Geopoints { return CalculateDistance(pos1, pos2, DistanceUnit.Kilometres); }
/// <summary> /// Called when an <see cref="iLayer"/> instance is ready to be outputted. Override this method in a subclass /// in order to handle layer types that cannot be handled by the available abstract objects. /// </summary> /// <param name="layer">The layer to be outputted.</param> /// <returns><c>true</c> if layer output was handled and the factory should not attempt to output it as a controller; otherwise <c>false</c>.</returns> protected virtual bool OnOutputLayer(iLayer layer) { var browser = layer as Browser; if (browser != null && browser.Url != null) { int index = browser.Url.IndexOf(':'); if (index < 0) { return(false); } switch (browser.Url.Substring(0, index)) { case "accel": var parameters = HttpUtility.ParseQueryString(browser.Url.Substring(browser.Url.IndexOf('?'))); string callback = parameters == null ? null : parameters.GetValueOrDefault("callback"); if (callback == null) { throw new ArgumentException("Accelerometer requires a callback URI."); } var accel = new Accelerometer(); accel.ValuesUpdated += (o, e) => { lock (accel) { if (accel.IsActive) { accel.Stop(); iApp.Navigate(callback, new Dictionary <string, string>() { { "X", e.Data.X.ToString() }, { "Y", e.Data.Y.ToString() }, { "Z", e.Data.Z.ToString() }, }); } } }; accel.Start(); return(true); case "compass": parameters = HttpUtility.ParseQueryString(browser.Url.Substring(browser.Url.IndexOf('?'))); callback = parameters == null ? null : parameters.GetValueOrDefault("callback"); if (callback == null) { throw new ArgumentException("Compass requires a callback URI."); } var compass = new Compass(); compass.HeadingUpdated += (o, e) => { lock (compass) { if (compass.IsActive) { compass.Stop(); iApp.Navigate(callback, new Dictionary <string, string>() { { "Bearing", e.Data.TrueHeading.ToString() }, }); } } }; compass.Start(); return(true); case "geoloc": parameters = HttpUtility.ParseQueryString(browser.Url.Substring(browser.Url.IndexOf('?'))); callback = parameters == null ? null : parameters.GetValueOrDefault("callback"); if (callback == null) { throw new ArgumentException("Geolocation requires a callback URI."); } var geoloc = new GeoLocation(); geoloc.LocationUpdated += (o, e) => { lock (geoloc) { if (geoloc.IsActive) { geoloc.Stop(); iApp.Navigate(callback, new Dictionary <string, string>() { { "Lat", e.Data.Latitude.ToString() }, { "Lon", e.Data.Longitude.ToString() } }); } } }; geoloc.Start(); return(true); } } return(false); }
/// <summary> /// Get the Full url for location to address conversion /// </summary> /// <param name="location"></param> /// <returns></returns> public static string GetAddressConversionUrl(GeoLocation location) { return(string.Format(BaseUri, location.Latitude, location.Longitude)); }
private static string GetParameter(GeoLocation location) { return(location.Latitude.ToString(CultureInfo.InvariantCulture) + "," + location.Longitude.ToString(CultureInfo.InvariantCulture)); }