bloritsch / Discarta

An offline first map project for C#. The concept is an MVVM friendly (but not mandated) set of map controls for applications.
Apache License 2.0
3 stars 2 forks source link

Create map tiler/warper for map files #4

Open bloritsch opened 8 years ago

bloritsch commented 8 years ago

Main functions:

NOTE: this may simply build on the shape file loader.

bloritsch commented 8 years ago

Tiling is simple image splitting. Bitmap save as indexed PNG w/alpha: use PngBitmapDecoder/Encoder

var sourceDataset = Gdal.Open(...) var destDataset = GDal.AutoCreateWarpedVRT(sourceDataset, sourceWkt, destWkt, ResampleAlg, precision)

Dump data to Image IntPtr using destDataset.ReadRaster()

NOTE: reading a raster may require an intermediate step to change the destination bits before saving, but that is regular image data translation. destDataset transforms the origin bits to the new bits for the new projection.

Ex.

BitmapData data = bitmap.LockBits(destImageRect, ImageLockMode.ReadWrite, pixelFormat) int stride = bitmapData.Stride IntPtr buf = bitmapData.Scan0

readRaster to buf

bitmap.UnlockBits(data)

bloritsch commented 8 years ago

Good article here on reading the map files https://trac.osgeo.org/gdal/wiki/GdalOgrCsharpRaster