示例#1
0
        public async Task <HereExploreResponseResult> GetPlaces(Coordinate coordinate, IEnumerable <string> categories, int radius)
        {
            var url = new StringBuilder()
                      .Append("https://places.demo.api.here.com/places/v1/discover/explore")
                      .Append($"?app_id={appId}")
                      .Append($"&app_code={appCode}")
                      .Append(categories == null || !categories.Any() ? string.Empty : $"&cat={string.Join(",", categories)}")
                      .Append($"&in={coordinate.Latitude.ToString(NFI)},{coordinate.Longitude.ToString(NFI)};r={radius.ToString()}")
                      .Append("&Accept-Language=ru-RU")
                      .ToString();

            return(await HttpHepler.GetResult <HereExploreResponseResult>(url));
        }
示例#2
0
        public async Task <HereSuggestions> GetHereSuggestions(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            var url = new StringBuilder()
                      .Append("http://autocomplete.geocoder.api.here.com/6.2/suggest.json")
                      .Append($"?app_id={_hereSettings.AppId}")
                      .Append($"&app_code={_hereSettings.AppCode}")
                      .Append($"&query={text}")
                      .ToString();

            return(await HttpHepler.GetResult <HereSuggestions>(url));
        }
示例#3
0
        public async Task <HereRouteResponse> GetRoutes(DateTime time, Coordinate from, Coordinate to, string mode = "publicTransport")
        {
            var url = new StringBuilder()
                      .Append("https://route.api.here.com/routing/7.2/calculateroute.json")
                      .Append($"?app_id={_hereSettings.AppId}")
                      .Append($"&app_code={_hereSettings.AppCode}")
                      .Append($"&language=ru-ru")
                      .Append($"&mode=fastest;{mode}")
                      .Append($"&maneuverattributes=po,ti,pt,ac,di,fj,ix")
                      .Append($"&avoidtransporttypes=railLight,railRegional,busPublic,busTouristic,busIntercity,busExpress,monoRail,aerial,inclined,water,privateService,railMetro,railMetroRegional")
                      .Append($"&routeattributes=sh,gr")
                      .Append($"&waypoint0=geo!stopOver!{from.Latitude.ToString(NFI)},{from.Longitude.ToString(NFI)}")
                      .Append($"&waypoint1=geo!stopOver!{to.Latitude.ToString(NFI)},{to.Longitude.ToString(NFI)}")
                      .ToString();

            return(await HttpHepler.GetResult <HereRouteResponse>(url));
        }
示例#4
0
        public async Task <HereRouteResponse> GetRoutes(DateTime time, Coordinate from, Coordinate to, string mode = "publicTransport")
        {
            var url = new StringBuilder()
                      .Append("https://route.api.here.com/routing/7.2/calculateroute.json")
                      .Append($"?app_id={appId}")
                      .Append($"&app_code={appCode}")
                      .Append($"&language=ru-ru")
                      .Append($"&mode=fastest;{mode}")
                      .Append($"&maneuverattributes=po,ti,pt,ac,di,fj,ix")
                      .Append($"&routeattributes=sh,gr")
                      .Append($"&waypoint0=geo!stopOver!{from.Latitude.ToString(NFI)},{from.Longitude.ToString(NFI)}")
                      .Append($"&waypoint1=geo!stopOver!{to.Latitude.ToString(NFI)},{to.Longitude.ToString(NFI)}")
                      .Append($"&departure={time.ToString("yyyy-MM-ddTHH:mm:ss")}")
                      .ToString();

            return(await HttpHepler.GetResult <HereRouteResponse>(url));
        }
示例#5
0
        public async Task <Coordinate> GetCoordinate(string locationId)
        {
            if (string.IsNullOrEmpty(locationId))
            {
                return(null);
            }

            var url = new StringBuilder()
                      .Append("http://geocoder.api.here.com/6.2/geocode.json")
                      .Append($"?locationid={locationId}")
                      .Append($"&jsonattributes=1")
                      .Append($"&gen=9")
                      .Append($"&app_id={_hereSettings.AppId}")
                      .Append($"&app_code={_hereSettings.AppCode}")
                      .ToString();

            return((await HttpHepler.GetResult <HereGeocoder>(url))?.GetCoordinate());
        }
示例#6
0
        public async Task <PlacesSuggestionResponse> GetHerePlacesSuggestion(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            var url = new StringBuilder()
                      .Append("https://places.demo.api.here.com/places/v1/autosuggest")
                      .Append($"?app_id={_hereSettings.AppId}")
                      .Append($"&app_code={_hereSettings.AppCode}")
                      .Append("&at=55.6125538,55.6125538")
                      .Append($"&q={text}")
                      .Append("&Accept-Language=ru-RU")
                      //.Append("&Accept-Language=ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7")
                      .ToString();

            return(await HttpHepler.GetResult <PlacesSuggestionResponse>(url));
        }