Esempio n. 1
0
        public static Tuple <string, string>[] CreateLocationParams4x(string key, LocationWithTimestamp[] locations, bool combineToOneAsPolyline = false)
        {
            if (locations == null)
            {
                return(new Tuple <string, string> [0]);
            }

            if (combineToOneAsPolyline)
            {
                var encodedLocs = OsrmPolylineConverter.Encode(locations);
                return(new Tuple <string, string>[] { new Tuple <string, string>(key, encodedLocs) });
            }
            else
            {
                var res = new List <Tuple <string, string> >();
                locations.ToList().ForEach(x =>
                {
                    res.Add(new Tuple <string, string>(key, x.Latitude.ToString("", CultureInfo.InvariantCulture)
                                                       + "," + x.Longitude.ToString("", CultureInfo.InvariantCulture)));
                    if (x.UnixTimeStamp.HasValue)
                    {
                        res.AddStringParameter("t", x.UnixTimeStamp.Value.ToString());
                    }
                });

                return(res.ToArray());
            }
        }
Esempio n. 2
0
        public static string CreateCoordinatesUrl(Location[] locations, bool combineToOneAsPolyline = false)
        {
            if (locations == null)
            {
                return(string.Empty);
            }

            if (combineToOneAsPolyline)
            {
                var encodedLocs = OsrmPolylineConverter.Encode(locations, 1E5);
                return("polyline(" + encodedLocs + ")");
            }
            else
            {
                return(string.Join(";", locations.Select(x => x.Longitude.ToString("", CultureInfo.InvariantCulture)
                                                         + "," + x.Latitude.ToString("", CultureInfo.InvariantCulture))));
            }
        }
Esempio n. 3
0
        public static Tuple <string, string>[] CreateLocationParams(string key, Location[] locations, bool combineToOneAsPolyline = false)
        {
            if (locations == null)
            {
                return(new Tuple <string, string> [0]);
            }

            if (combineToOneAsPolyline)
            {
                var encodedLocs = OsrmPolylineConverter.Encode(locations);
                return(new Tuple <string, string>[] { new Tuple <string, string>(key, encodedLocs) });
            }
            else
            {
                return(locations.Select(x =>
                                        new Tuple <string, string>(key, x.Latitude.ToString("", CultureInfo.InvariantCulture)
                                                                   + "," + x.Longitude.ToString("", CultureInfo.InvariantCulture))).ToArray());
            }
        }