示例#1
0
        public async static Task <List <string> > GetSuggestionsAsync(string query, BasicGeoposition?location)
        {
            List <string> suggestions = new List <string>();

            HttpClient client = new HttpClient();

            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", Common.CoreConstants.AutosuggestApiSubscriptionKey);

            if (location != null)
            {
                client.DefaultRequestHeaders.Add("X-Search-Location", $"lat:{((BasicGeoposition)location).Latitude.ToString(CultureInfo.InvariantCulture)};long:{((BasicGeoposition)location).Longitude.ToString(CultureInfo.InvariantCulture)};re:100");
            }

            var response = await client.GetAsync(new Uri($"{CogsExplorer.Common.CoreConstants.SearchServicesBaseUrl}/bing/v7.0/Suggestions?q={query}&mkt={CultureInfo.CurrentCulture.Name}"));

            try
            {
                var results = await response.Content.ReadAsStringAsync();

                var suggestionResults = JsonConvert.DeserializeObject <Suggestion.SuggestionResult>(results);
                var suggestionGroups  = suggestionResults.suggestionGroups.Select(s => s.searchSuggestions).FirstOrDefault();

                suggestions = suggestionGroups.Select(s => s.displayText).Distinct().ToList();
            }
            catch (Exception ex)
            {
            }

            return(suggestions);
        }
示例#2
0
        private async void GetWeather(BasicGeoposition?position)
        {
            if (!position.HasValue)
            {
                Weather.Messages = "Can't find your location";
                return;
            }

            var hasApiContract = ApiInformation
                                 .IsApiContractPresent("Windows.Phone.PhoneContract", 1);

            Weather.Messages = hasApiContract
                                ? $"{Battery.GetDefault().RemainingDischargeTime.TotalHours:0.0} hours remaining"
                                : "";

            var client  = new OpenWeatherMapClient();
            var weather = await client.GetCurrentWeatherAsync(position.Value.Latitude, position.Value.Longitude);

            Weather.Current = new CurrentWeatherViewModel(weather);

            var forecast = await client.GetSevenDayForecastAsync(position.Value.Latitude, position.Value.Longitude);

            Weather.Forecast = forecast.List
                               .Select(f => new ForecastViewModel(f))
                               .ToList();
        }
示例#3
0
 public ColoredGeocircle(IEnumerable <Geopoint> circlePoints, Color fillColor, Color strokeColor, double strokeThickness = 2, BasicGeoposition?center = null)
 {
     CirclePoints    = circlePoints;
     FillColor       = fillColor;
     StrokeColor     = strokeColor;
     StrokeThickness = strokeThickness;
     Center          = center;
 }
示例#4
0
 public ColoredGeocircle(IEnumerable <Geopoint> circlePoints, BasicGeoposition?center = null)
 {
     CirclePoints    = circlePoints;
     FillColor       = DefaultColor;
     StrokeColor     = DefaultColor;
     StrokeThickness = 2;
     Center          = center;
 }
示例#5
0
 public Shop(string id, string name, string address, double radius, BasicGeoposition?location)
 {
     ID       = id;
     Name     = name;
     Address  = address;
     Radius   = radius;
     Location = location;
 }
示例#6
0
        private async Task RefreshRideDetails()
        {
            while (RideState == RideStates.Ride)
            {
                rideDetails = await AppConstants.ShyftClient.RetrieveRideDetails(currentRideId);

                rideStatusBackground.Visibility = Visibility.Visible;
                rideStatusTextBlock.Text        = rideDetails.Status.Humanize(LetterCasing.Title);
                if (rideDetails.Status == LyftConstants.RideStatus.Pending)
                {
                    // Orange
                    rideStatusBackground.Background = new SolidColorBrush(AppConstants.GetColor("#FF8C00"));
                    SetCancelButtonVisibility(rideDetails);
                }
                else if (rideDetails.Status == LyftConstants.RideStatus.Accepted)
                {
                    // Yellow
                    rideStatusBackground.Background = new SolidColorBrush(AppConstants.GetColor("#FFB900"));
                    SetCancelButtonVisibility(rideDetails);
                    SetVehicleInfo(rideDetails);
                }
                else if (rideDetails.Status == LyftConstants.RideStatus.Arrived)
                {
                    // Light Green
                    rideStatusBackground.Background = new SolidColorBrush(AppConstants.GetColor("#00CC6A"));
                    SetCancelButtonVisibility(rideDetails);
                    SetVehicleInfo(rideDetails);
                    UpdateDriverLocation(rideDetails.Location);
                    UpdateRideEtaInfo(rideDetails.Origin);
                }
                else if (rideDetails.Status == LyftConstants.RideStatus.PickedUp)
                {
                    // Pink
                    rideStatusBackground.Background = new SolidColorBrush(AppConstants.LyftPink);
                    SetCancelButtonVisibility(rideDetails);
                    SetVehicleInfo(rideDetails);
                    UpdateDriverLocation(rideDetails.Location);
                    UpdateRideEtaInfo(rideDetails.Destination);
                }
                else if (rideDetails.Status == LyftConstants.RideStatus.DroppedOff)
                {
                    // Blue
                    rideStatusBackground.Background = new SolidColorBrush(AppConstants.LyftMulberry);
                    await SetRideState(RideStates.Complete);
                }
                else if (rideDetails.Status == LyftConstants.RideStatus.Canceled)
                {
                    await SetupPin(RideStates.Pickup, null, rideDetails.Origin);

                    pickupLocation = startLocation.Location.Position;
                    await SetupPin(RideStates.Dropoff, null, rideDetails.Destination);

                    dropoffLocation = endLocation.Location.Position;
                    await SetRideState(RideStates.RideStaging);
                }
                await Task.Delay(TimeSpan.FromMilliseconds(500));
            }
        }
        protected override async Task AjouterDonneesExif(BitmapEncoder encodeur)
        {
            BasicGeoposition?positionGPS = GetDernierePositionGPSValide();

            if (positionGPS.HasValue)
            {
                await encodeur.BitmapProperties.SetPropertiesAsync(CreerDonneesExifGps(positionGPS.Value));
            }
        }
示例#8
0
        public void Draw(BasicGeoposition?geoposition, double circleRadius)
        {
            if (geoposition == null)
            {
                return;
            }

            var mapElements = Map.Children;

            mapElements.Where(element => element is Ellipse).Cast <Ellipse>().ForEach(ellipse =>
            {
                double metersPerPixel = (Math.Cos(ToRadian(geoposition.Value.Latitude)) * (2 * Math.PI * _earthRadiusInMeters)) / (256 * Math.Pow(2, Map.ZoomLevel));
                ellipse.Height        = circleRadius / metersPerPixel * 2;
                ellipse.Width         = circleRadius / metersPerPixel * 2;
            });
        }
        public override void OnNewParams(object args) {
            base.OnNewParams(args);
            node = args as Model.Node;
            if (node != null) {
                position = new BasicGeoposition {
                    Latitude = node.lat,
                    Longitude = node.lon
                };
                positionTextBox.Text = String.Format("POSITION".t(R.File.NODE), position?.Latitude, position?.Longitude);
            }
            titleTextBlock.Text = Title;
            initCategoryComboBox();
            initStatus(node);
            nameTextBox.Text = node?.name ?? "";

            streetTextBox.Text = node?.street ?? "";
            houseNumberTextBox.Text = node?.housenumber ?? "";
            phoneNumberTextBox.Text = node?.phone ?? "";
            plzTextBox.Text = node?.postcode ?? "";
            cityTextBox.Text = node?.city ?? "";
            websiteTextBox.Text = node?.website ?? "";
            commentTextBox.Text = node?.wheelchairDescription ?? "";

        }
示例#10
0
        public async static Task <EntityCollection> SearchEntitiesAsync(string query, BasicGeoposition?location)
        {
            EntityCollection entities = new EntityCollection();

            HttpClient client = new HttpClient();

            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", Common.CoreConstants.EntitiesApiSubscriptionKey);

            if (location != null)
            {
                client.DefaultRequestHeaders.Add("X-Search-Location", $"lat:{((BasicGeoposition)location).Latitude.ToString(CultureInfo.InvariantCulture)};long:{((BasicGeoposition)location).Longitude.ToString(CultureInfo.InvariantCulture)};re:100");
            }

            var response = await client.GetAsync(new Uri($"{CogsExplorer.Common.CoreConstants.SearchServicesBaseUrl}/bing/v7.0/Entities?q={query}&mkt={CultureInfo.CurrentCulture.Name}"));

            try
            {
                var results = await response.Content.ReadAsStringAsync();

                var entityResults = JsonConvert.DeserializeObject <Entities.EntityResult>(results);
                var entityValues  = (entityResults.entities == null) ? new List <Entities.Value>() : entityResults.entities.value.ToList();
                var placeValues   = (entityResults.places == null) ? new List <Entities.Value1>() : entityResults.places.value.ToList();

                entities.Entities = (from result in entityValues
                                     select new EntityInformation()
                {
                    Description = result.description,
                    DisplayType = result.entityPresentationInfo.entityTypeDisplayHint,
                    Id = result.bingId,
                    Name = result.name,
                    Scenario = result.entityPresentationInfo.entityScenario,
                    SearchUrl = result.webSearchUrl,
                    ItemUrl = result.image?.hostPageUrl,
                    ThumbnailUrl = result.image?.thumbnailUrl,
                }).ToList();

                entities.Places = (from result in placeValues
                                   select new PlaceInformation()
                {
                    AddressLine = $"{result.address.addressLocality}, {result.address.addressRegion} {result.address.addressCountry} {result.address.postalCode}",
                    PhoneNumber = result.telephone,
                    DisplayType = result.entityPresentationInfo.entityTypeHints.LastOrDefault() + "",
                    Scenario = result.entityPresentationInfo.entityScenario,
                    Name = result.name,
                    Url = result.url,
                    SearchUrl = result.webSearchUrl,
                }).ToList();
            }
            catch (Exception ex)
            {
            }

            return((entities == null) ? new EntityCollection() : entities);
        }
        private void positionTextBox_Tapped(object sender, TappedRoutedEventArgs e) {

            PositionChooserDialogPageArgs args = null;
            if (position != null) {
                args = new PositionChooserDialogPageArgs {
                    lat = position.Value.Latitude,
                    lon = position.Value.Longitude
                };
            }

            PositionChooserDialogPage.ShowInDialog(args, (position) => {
                this.position = position;
                positionTextBox.Text = String.Format("POSITION".t(R.File.NODE), position.Latitude, position.Longitude);
            });
        }
示例#12
0
        private void ShowTripDetails(TripItinerary model)
        {
            List <Guid> legIds = new List <Guid>();

            for (int i = 0; i <= model.ItineraryLegs.Count - 1; i++)
            {
                legIds.Add(Guid.NewGuid());
            }

            SelectedDetailLegs = model.ItineraryLegs
                                 .Zip(legIds, (x, id) => { x.TemporaryId = id; return(x); })
                                 .ToList();

            ColoredMapLines.Clear();
            int legIndex = 0;

            foreach (TripLeg leg in model.ItineraryLegs)
            {
                List <ColoredMapLinePoint> coloredPoints = GooglePolineDecoder.Decode(leg.LegGeometryString)
                                                           .Select(x =>
                {
                    if (leg.Mode == ApiEnums.ApiMode.Walk)
                    {
                        return(new ColoredMapLinePoint(x, HslColors.GetModeColor(leg.Mode), true));
                    }
                    else
                    {
                        return(new ColoredMapLinePoint(x, HslColors.GetModeColor(leg.Mode)));
                    }
                })
                                                           .ToList();

                // Add one extra point at the beginning if this is a walk leg to account for legs starting too far away
                if (leg.Mode == ApiEnums.ApiMode.Walk && legIndex > 0)
                {
                    BasicGeoposition?previousLegLastPoint = ColoredMapLines.LastOrDefault()?.LastOrDefault()?.Coordinates;
                    if (previousLegLastPoint != null)
                    {
                        coloredPoints.Insert(0, new ColoredMapLinePoint(previousLegLastPoint.Value, HslColors.GetModeColor(ApiEnums.ApiMode.Walk), true));
                    }
                }

                // Add one extra point at the end to account for legs ending too early
                coloredPoints.Add(new ColoredMapLinePoint(leg.EndCoords, HslColors.GetModeColor(leg.Mode), leg.Mode == ApiEnums.ApiMode.Walk));
                var mapLine = new ColoredMapLine(coloredPoints, legIds[legIndex]);
                ColoredMapLines.Add(mapLine);
                legIndex++;
            }

            var stops = new List <IMapPoi>();

            stops.AddRange(model.ItineraryLegs.Zip(legIds, (x, id) => {
                IMapPoi poi = x.StartPlaceToPoi();
                poi.Id      = id;
                return(poi);
            }));
            IMapPoi endPoi = model.ItineraryLegs.Last().EndPlaceToPoi();

            endPoi.Id = legIds.Last();
            stops.Add(endPoi);

            MapStops = stops;

            _messengerService.Send(new MessageTypes.ViewPlanDetails(model));
            IsInDetailedState = true;
        }
示例#13
0
        private async Task SetRideState(RideStates state)
        {
            if (RideState == RideStates.RideStaging && state == RideStates.Dropoff)
            {
                dropoffSearchBox.Visibility = Visibility.Collapsed;
                searchBox.Visibility        = Visibility.Visible;
                costTextBlock.Visibility    = Visibility.Collapsed;
                map.Routes.Clear();
            }
            RideState = state;
            if (state == RideStates.Pickup)
            {
                SetPickupView();
                await SetupPin(RideStates.Pickup);
                await GetAvailableTypes(map.Center.Position);

                var preferredRideType = GetPreferredType(availableRideTypes);
                if (preferredRideType.HasValue)
                {
                    SelectPreferredType(preferredRideType.Value);
                    await DisplayDrivers(map.Center.Position, preferredRideType.Value);
                    await GetEta(map.Center.Position, preferredRideType.Value);
                }
                else
                {
                    button.IsEnabled = false;
                    button.Content   = "No rides available";
                }
            }
            else if (state == RideStates.Dropoff)
            {
                SetDropoffView();
                pickupSearchBox.Text = searchBox.Text;
                await SetupPin(RideStates.Dropoff);

                pickupLocation = startLocation.Location.Position;
                button.Content = "Set destination";
            }
            else if (state == RideStates.RideStaging)
            {
                SetRideStagingView();
                dropoffSearchBox.Text = searchBox.Text;
                dropoffLocation       = endLocation.Location.Position;
                selectedRideType      = GetSelectedRideType();
                if (selectedRideType.HasValue)
                {
                    await GetCostEstimate(pickupLocation.Value, dropoffLocation.Value, selectedRideType.Value);

                    button.Content = $"Request {GetDisplayName(selectedRideType.Value)}";
                    await ShowRoute(pickupLocation.Value, dropoffLocation.Value);
                }
            }
            else if (state == RideStates.Ride)
            {
                selectedRideType = GetSelectedRideType();
                if (selectedRideType.HasValue)
                {
                    await RequestRide();
                }
            }
            else if (state == RideStates.Complete)
            {
                ratingGrid.Visibility = Visibility.Visible;
            }
        }