PBF file (Protocolbuffer Binary Format)

Hy Everyone,

Is it possible to load PBF file (Protocolbuffer Binary Format) in MW OCX?

I never work in this PBF format and I find a web service with this file format and I want to show as kind of WMS in MapWindow OCX.

Hi,

Yes it supports loading PBF file (Protocolbuffer Binary Format).

Here is simple example:

First open the file with:
var ogr = new OgrDatasourceClass();
var ret = ogr.Open(fullPath);

Open returns true if the file could be opended.

You can then check the layers located in the file like this:
for(int i = 0;i < ogr.LayerCount;i++)
{
var layerName = ogr.GetLayerName(i);
System.Diagnostics.Debug.WriteLine($“#{i} LayerName: {layerName}”);
}

And to add a layer to the map control (_map my MapWinGIS control):
var ogrLayer = ogr.GetLayer(3);
_map.AddLayer(ogrLayer, true);

And to set extent to show the added layer:
var shapefile = ogrLayer.GetBuffer();
_map.Extents = shapefile.Extents;