Skip to content

Instantly share code, notes, and snippets.

@xivk
Last active August 29, 2015 14:04
Show Gist options
  • Save xivk/e61d61dc627cf2e98526 to your computer and use it in GitHub Desktop.
Save xivk/e61d61dc627cf2e98526 to your computer and use it in GitHub Desktop.
var sourceStream = new PBFOsmStreamSource(
new FileInfo(@"path\to\file.osm.pbf").OpenRead());
var completeStreamSource = new OsmSimpleCompleteStreamSource(sourceStream);
foreach(var osmGeoComplete in completeStreamSource)
{
if(osmGeoComplete.Type == Osm.CompleteOsmType.Way &&
osmGeoComplete.Tags != null &&
osmGeoComplete.Tags.ContainsKey("highway"))
{
// do something with the road here.
// the nodes are actuall here, just extract their coordinates.
var completeWay = (osmGeoComplete as CompleteWay);
var coordinates = completeWay.GetCoordinates();
}
}
@xivk
Copy link
Author

xivk commented Jul 25, 2014

This uses a PBF source and wraps this source into a 'complete' stream. The complete stream composes ways and releations with the actual instances of the nodes and members.

Be careful when using this on a large file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment