Esempio n. 1
0
 public static string GetUrl(string staticMapUrl, string templateName, double latitude, double longitude, string imageUrl, PokemonTeam team = PokemonTeam.All, OsmFeature feature = null, MultiPolygon multiPolygon = null)
 {
     var baseUrl = $"{staticMapUrl}/staticmap/{templateName}?lat={latitude}&lon={longitude}&url2={imageUrl}";
     if (team != PokemonTeam.All)
     {
         baseUrl += $"&team_id={team}";
     }
     if (feature != null)
     {
         var latlng = OsmManager.MultiPolygonToLatLng(feature.Geometry?.Coordinates, true);
         baseUrl += $"&path={latlng}";
     }
     if (multiPolygon != null)
     {
         var latlng = OsmManager.MultiPolygonToLatLng(new List<MultiPolygon> { multiPolygon }, false);
         baseUrl += $"&path={latlng}";
     }
     return baseUrl;
 }
Esempio n. 2
0
        // TODO: Provide better way for replacement values
        public static string GetStaticMapsUrl(string templateFileName, string staticMapUrl, int staticMapZoom, double latitude, double longitude, string markerImageUrl, PokemonTeam?team, OsmFeature feature = null, MultiPolygon multiPolygon = null)
        {
            var staticMapData = Renderer.Parse(templateFileName, new
            {
                lat                  = latitude,
                lon                  = longitude,
                team                 = team?.ToString(),
                team_id              = Convert.ToInt32(team ?? 0),
                marker               = markerImageUrl,
                pkmn_img_url         = markerImageUrl,
                quest_reward_img_url = markerImageUrl,
                weather_img_url      = markerImageUrl,
                tilemaps_url         = staticMapUrl
            });
            StaticMapConfig staticMap = JsonConvert.DeserializeObject <StaticMapConfig>(staticMapData);

            var url = string.Format(staticMapUrl, latitude, longitude, staticMapZoom);
            //var markerUrl = staticMap.Markers.Count > 0 ? url + "?markers=" + Uri.EscapeDataString(JsonConvert.SerializeObject(staticMap.Markers)) : string.Empty;
            var markerUrl = staticMap.Markers.Count > 0 ? url + "?markers=" + JsonConvert.SerializeObject(staticMap.Markers) : string.Empty;

            if (feature != null)
            {
                var latlng     = OsmManager.MultiPolygonToLatLng(feature.Geometry?.Coordinates, true);
                var polygonKey = "&polygons=";
                var polygonUrl = @"[{""fill_color"":""rgba(100.0%,0.0%,0.0%,0.5)"",""stroke_color"":""black"",""stroke_width"":1,""path"":""" + latlng + @"""}]";
                markerUrl += polygonKey + Uri.EscapeDataString(polygonUrl);
            }

            if (multiPolygon != null)
            {
                var latlng = OsmManager.MultiPolygonToLatLng(new List <MultiPolygon> {
                    multiPolygon
                }, false);
                var polygonKey = "&polygons=";
                var polygonUrl = @"[{""fill_color"":""rgba(100.0%,0.0%,0.0%,0.5)"",""stroke_color"":""black"",""stroke_width"":1,""path"":""" + latlng + @"""}]";
                markerUrl += polygonKey + polygonUrl;//Uri.EscapeDataString(polygonUrl);
            }

            return(markerUrl);
        }
Esempio n. 3
0
        public static string PrepareStaticMapUrl(string staticMapUrl, string marker, double lat, double lng, OsmFeature feature = null)
        {
            var url       = string.Format(staticMapUrl, lat, lng);
            var markerKey = "?markers=";
            var markerUrl = "[{\"url\":\"<marker>\",\"height\":32,\"width\":32,\"x_offset\":0,\"y_offset\":0,\"latitude\":<lat>,\"longitude\":<lng>}]";

            markerUrl = markerUrl
                        .Replace("<marker>", marker)
                        .Replace("<lat>", lat.ToString())
                        .Replace("<lng>", lng.ToString());
            markerUrl = Uri.EscapeDataString(markerUrl);
            url      += markerKey + markerUrl;

            if (feature != null)
            {
                var latlng     = OsmManager.MultiPolygonToLatLng(feature.Geometry?.Coordinates);
                var polygonKey = "&polygons=";
                var polygonUrl = "[{\"fill_color\":\"rgba(100.0%,0.0%,0.0%,0.5)\",\"stroke_color\":\"black\",\"stroke_width\":1,\"path\":" + latlng + "}]";
                polygonUrl = Uri.EscapeDataString(polygonUrl);
                url       += polygonKey + polygonUrl;
            }

            return(url);
        }