protected override void RunActualProcess()
        {
            SqlConnection.RecreateTable <OsmFeature>(Stage.Raw, Constants.PresentSlice);
            var          db          = SqlConnection.GetDatabaseConnection(Stage.Raw, Constants.PresentSlice);
            const string jsonfile    = "U:\\SimZukunft\\RawDataForMerging\\roadsBurgdorf.geojson";
            var          json        = File.ReadAllText(jsonfile);
            var          collection1 = JsonConvert.DeserializeObject <FeatureCollection>(json);

            const string jsonfileBuildings = "U:\\SimZukunft\\RawDataForMerging\\buildingsBurgdorf.geojson";
            var          jsonBuildings     = File.ReadAllText(jsonfileBuildings);
            var          collection2       = JsonConvert.DeserializeObject <FeatureCollection>(jsonBuildings);

            collection1.Features.AddRange(collection2.Features);
            db.Database.BeginTransaction();
            foreach (var feature in collection1.Features)
            {
                var osmf = new OsmFeature(feature, Guid.NewGuid().ToString());
                if (feature.Geometry.Type == GeoJSONObjectType.Polygon)
                {
                    var p  = (Polygon)feature.Geometry;
                    var ls = p.Coordinates[0];
                    foreach (var coordinate in ls.Coordinates)
                    {
                        var wp = new WgsPoint(coordinate.Longitude, coordinate.Latitude);
                        osmf.WgsPoints.Add(wp);
                    }
                }

                db.Database.Save(osmf);
            }

            db.Database.CompleteTransaction();
        }
Пример #2
0
        public bool FindDirectlyMatchingPolygon([NotNull][ItemNotNull] List <WgsPoint> points, [CanBeNull] out OsmFeature firstmatchingFeature)
        {
            foreach (var point in points)
            {
                foreach (var feature in OsmFeaturesInRectangle)
                {
                    if (IsPointInPolygon(feature.WgsPoints, point))
                    {
                        firstmatchingFeature = feature;
                        return(true);
                    }
                }
            }

            firstmatchingFeature = null;
            return(false);
        }
Пример #3
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;
 }
Пример #4
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);
        }
Пример #5
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);
        }