public IActionResult Index() { string jsonString1 = System.IO.File.ReadAllText(@"c:\projects\FIX\18JAN\cegledHelykozi.geojson"); //string jsonString2 = System.IO.File.ReadAllText(@"c:\projects\_GISAPP\MapSource\2g_indoor.json"); string jsonString3 = System.IO.File.ReadAllText(@"C:\projects\_GISAPP\MapSource\TESTGEOJSON\multiline_vasut.geojson"); // //GeoJson gdata = JsonConvert.DeserializeObject<GeoJson>(jsonString1); //GeoJson gdatapoly = JsonConvert.DeserializeObject<GeoJson>(jsonString2); FeatureCollection Col1 = FeatureCollection.FromJson(jsonString1); //FeatureCollection Col2 = FeatureCollection.FromJson(jsonString2); FeatureCollection Col3 = FeatureCollection.FromJson(jsonString3); var egyik = Col1.Features.ToList(); //var masik = Col2.Features.ToList(); var harmadik = Col3.Features.ToList(); //var sum = egyik.Concat(masik); MyGeojson myGeojson = new MyGeojson(GeoJsonType.FeatureCollection, false, null, "tesztguid"); myGeojson.features = harmadik; //GeoJson gj = new GeoJson(); object Json = JsonConvert.SerializeObject(myGeojson); return(View()); }
private static async Task <FeatureCollection> FetchMany(string where = "1=1", int?limit = null) { List <Feature> fullSet = new List <Feature>(); while (true) { int before = fullSet.Count; string json = await FetchOnce(fullSet.Count, where); FeatureCollection collection = FeatureCollection.FromJson(json); // can throw Newtonsoft.Json.JsonReaderException fullSet.AddRange(collection.Features); int added = fullSet.Count - before; if (added < MaxRecords || fullSet.Count >= limit) { break; } } return(new FeatureCollection(fullSet)); }
private RouteFeature[] ReadAndParseFeatures(string path) { var routeFeatures = new List <RouteFeature>(); var features = FeatureCollection.FromJson(File.ReadAllText(path)).Features; foreach (var f in features) { routeFeatures.Add(new RouteFeature() { Feature = new RoadFeature() { Coordinates = ((LineString)(f.Geometry)).Coordinates.Select(x => new CustomPosition() { Longitude = x.Longitude, Latitude = x.Latitude }).ToArray(), Properties = f.Properties }, //Length = CalculateLength(((LineString)f.Geometry).Coordinates) }); } return(routeFeatures.ToArray()); }
public bool UpdateSource(string sourceId, IGeoJSONObject geoJsonObject) { var source = mapStyle.GetSource(sourceId) as Com.Mapbox.Mapboxsdk.Style.Sources.GeoJsonSource; if (source == null) { return(false); } var json = JsonConvert.SerializeObject(geoJsonObject); switch (geoJsonObject) { case GeoJSON.Net.Feature.Feature feature: source.SetGeoJson(Feature.FromJson(json)); break; default: source.SetGeoJson(FeatureCollection.FromJson(json)); break; } return(true); }
public static Source ToSource(this NxSource source, Context context) { switch (source) { case NxGeojsonSource geojsonSource: if (geojsonSource.Data != null) { var json = JsonConvert.SerializeObject(geojsonSource.Data); switch (geojsonSource.Data) { case GeoJSON.Net.Feature.Feature feature: { var mapboxFeature = Feature.FromJson(json); return(new GeoJsonSource(geojsonSource.Id, mapboxFeature, geojsonSource.Options.ToOptions())); } default: var feaureCollection = FeatureCollection.FromJson(json); return(new GeoJsonSource(geojsonSource.Id, feaureCollection, geojsonSource.Options.ToOptions())); } } if (string.IsNullOrWhiteSpace(geojsonSource.Url)) { return(new GeoJsonSource(geojsonSource.Id)); } if (false == geojsonSource.IsLocal) { return(new GeoJsonSource(geojsonSource.Id, new Java.Net.URL(geojsonSource.Url), geojsonSource.Options.ToOptions())); } var localUrl = geojsonSource.Url.StartsWith("asset://", System.StringComparison.OrdinalIgnoreCase) ? new Java.Net.URI(geojsonSource.Url) : new Java.Net.URI("asset://" + geojsonSource.Url); return(new GeoJsonSource(geojsonSource.Id, localUrl, geojsonSource.Options.ToOptions())); case NxRasterSource rasterSource: if (rasterSource.TileSet != null) { var tileSet = rasterSource.TileSet.ToNative(); return(rasterSource.TileSize.HasValue ? new RasterSource(rasterSource.Id, tileSet, rasterSource.TileSize.Value) : new RasterSource(rasterSource.Id, tileSet)); } return(rasterSource.TileSize.HasValue ? new RasterSource(rasterSource.Id, rasterSource.ConfigurationURL, rasterSource.TileSize.Value) : new RasterSource(rasterSource.Id, rasterSource.ConfigurationURL)); case NxRasterDemSource rasterDemSource: if (rasterDemSource.TileSet != null) { var tileSet = rasterDemSource.TileSet.ToNative(); return(rasterDemSource.TileSize.HasValue ? new RasterDemSource(rasterDemSource.Id, tileSet, rasterDemSource.TileSize.Value) : new RasterDemSource(rasterDemSource.Id, tileSet)); } return(rasterDemSource.TileSize.HasValue ? new RasterDemSource(rasterDemSource.Id, rasterDemSource.Url, rasterDemSource.TileSize.Value) : new RasterDemSource(rasterDemSource.Id, rasterDemSource.Url)); case NxVectorSource vectorSource: if (vectorSource.TileSet != null) { var tileSet = vectorSource.TileSet.ToNative(); return(new VectorSource(vectorSource.Id, tileSet)); } return(new VectorSource(vectorSource.Id, vectorSource.Url)); case NxImageSource imageSource: return(new ImageSource(imageSource.Id, imageSource.Coordinates.ToNative(), imageSource.Source.GetBitmap(context))); } return(null); }