using OSGeo.OGR;
using System;
namespace MapboxVectorTile
{
class Program
{
static void Main(string[] args)
{
Ogr.RegisterAll();
Driver jsonDriver = Ogr.GetDriverByName("ESRIJSON");
Driver mvtDriver = Ogr.GetDriverByName("MVT");
if (jsonDriver == null || mvtDriver == null)
return;
DataSource originDataSource = jsonDriver.Open(@"in.json", 0);
if (originDataSource == null || originDataSource.GetLayerCount() == 0)
return;
Layer originLayer = originDataSource.GetLayerByIndex(0);
DataSource targetDatasource = mvtDriver.CreateDataSource(@"outDir", new string[] { "COMPRESS=NO" });
if (targetDatasource == null)
return;
targetDatasource.CopyLayer(originLayer, "out", new string[] { "MINZOOM=0", "MAXZOOM=11" });
targetDatasource.Dispose();
originDataSource.Dispose();
}
}
}
C# GDAL 实现矢量数据切片
最新推荐文章于 2024-05-24 02:30:00 发布