Created
April 26, 2020 08:22
-
-
Save bertt/c9900031abe2c8741e44d8c6e5d3c610 to your computer and use it in GitHub Desktop.
OG Read multipatch shapefile
This file contains 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
Ogr.RegisterAll(); | |
var driver = Ogr.GetDriverByName("ESRI Shapefile"); | |
var shp = @"D:\dev\github.com\Mattgerg\ShapefileSharp\ShapefileSharp Tests\Data\multipatch.shp"; | |
var dataSource = driver.Open(shp, 0); | |
var layer = dataSource.GetLayerByIndex(0); | |
Console.WriteLine(layer.GetFeatureCount(0)); | |
Console.WriteLine(layer.GetGeomType().ToString()); | |
for(var i = 0; i < layer.GetFeatureCount(0); i++) | |
{ | |
var feature = layer.GetFeature(i); | |
var geom = feature.GetGeometryRef(); | |
for(var j=0; j<geom.GetGeometryCount(); j++) | |
{ | |
var poly = geom.GetGeometryRef(j); | |
for(var k=0; k< poly.GetGeometryCount(); k++) | |
{ | |
var ring = poly.GetGeometryRef(k); | |
for(var l = 0; l < ring.GetPointCount(); l++) | |
{ | |
double[] p = { 0, 0, 0 }; | |
ring.GetPoint(l, p); | |
Console.WriteLine($"{p[0]}, {p[1]}, {p[2]}"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment