Веб-плитки
Contents
[
Hide
]
Робота з XYZ плитками
XYZ Tile (“Slippy Map”) - це підхід до побудови картографування в Інтернеті. Світова карта поділена на частини, які називаються плитками. Всі плитки зберігаються у веб-сервісах картографічних служб, таких як Openstreetmaps, Google Hybrid, Bing, OpenCycleMap, Thunderforest тощо. А бібліотека Aspose.GIS C# дозволяє вам працювати з XYZ Tiles.
Рендер однієї xyz плитки
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var mapPath = Path.Combine(RunExamples.GetDataDir(), "out_osm_tile.png"); | |
// we use the osm tile server | |
string url = "http://tile.openstreetmap.org/{z}/{x}/{y}.png"; | |
using (var layer = Drivers.XyzTiles.OpenLayer(new XyzConnection(url))) | |
{ | |
// print tile info | |
var tile = layer.GetTile(2, 3, 1); | |
Console.WriteLine($"CellX: {tile.CellX}, CellY: {tile.CellY}" ); | |
Console.WriteLine($"Path: {tile.AsPath()}"); | |
// render tile | |
var resampling = new RasterMapResampling() { Height = 256, Width = 256 }; | |
using (var map = new Map(800, 800)) | |
{ | |
var raster = tile.AsRaster(); | |
map.Add(new RasterMapLayer(raster){Resampling = resampling}); | |
map.Render(mapPath, Renderers.Png); | |
} | |
Console.WriteLine($"Rendered Map: {mapPath}"); | |
} |
Рендер xyz плиток за обсягом
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var mapPath = Path.Combine(RunExamples.GetDataDir(), "out_osm_tiles.png"); | |
// we use the osm tile server | |
string url = "http://tile.openstreetmap.org/{z}/{x}/{y}.png"; | |
using (var layer = Drivers.XyzTiles.OpenLayer(new XyzConnection(url))) | |
{ | |
// print tiles info | |
var extent = new Extent(-90, -40, 90, 40) {SpatialReferenceSystem = SpatialReferenceSystem.Wgs84}; | |
var tiles = layer.GetTiles(2, extent).ToList(); | |
// render tiles | |
var resampling = new RasterMapResampling() { Height = 800, Width = 800 }; | |
using (var map = new Map(800, 800)) | |
{ | |
foreach (var tile in tiles) | |
{ | |
var raster = tile.AsRaster(); | |
map.Add(new RasterMapLayer(raster) { Resampling = resampling }); | |
} | |
map.Render(mapPath, Renderers.Png); | |
} | |
Console.WriteLine($"Rendered Map: {mapPath}"); | |
} |
Відкриття xyz плитки з папки
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string url = "C://tiles/{z}/{x}/{y}.png"; | |
using (var layer = Drivers.XyzTiles.OpenLayer(new XyzConnection(url))) | |
{ | |
// print tile info | |
var tile = layer.GetTile(0, 0, 0); | |
Console.WriteLine($"CellX: {tile.CellX}, CellY: {tile.CellY}"); | |
Console.WriteLine($"Path: {tile.AsPath()}"); | |
} |