OsmFile

References
public class OsmFile
Represents an OSM file.

Properties

BoundingBox

#
Gets the bounding box for this map.
public BoundingBox BoundingBox { get; }

NodeCount

#
Gets the number of nodes in this map.
public int NodeCount { get; }

NodeIds

#
Iterate over all node ids.
public IEnumerable<long> NodeIds { get; }

Nodes

#
Iterate over all nodes.
public IEnumerable<OsmNode> Nodes { get; }

ReferencedNodes

#
Gets a hash set of all the nodes currently being referenced by at least one way.
public HashSet<long> ReferencedNodes { get; }

WayCount

#
Gets the number of ways in this map.
public int WayCount { get; }

WayIds

#
Iterate over all way ids.
public IEnumerable<long> WayIds { get; }

Ways

#
Iterate over all ways.
public IEnumerable<OsmWay> Ways { get; }

Methods

AddToRhinoDocument

#
Add the entire map to a rhino document.
public Guid[] AddToRhinoDocument(
document,
Document to populate.
mapping,
Mapping function or null to use 1:1 mapping.
settings
Insertion settings.
)
Array of Rhino object IDs that were added.

Duplicate

#
Create a duplicate of this file.
public OsmFile Duplicate()
Duplicate.

FindNode

#
Find the node with the specified id.
public OsmNode FindNode(
id
Identifier to search for.
)
Node with given id or null if no such node can be found.

FindNodesByTag

#
Find all nodes that pass a custom test.
public IEnumerable<OsmNode> FindNodesByTag(
filter
Filter tag (optionally with wildcard characters).
)
Enumeration of nodes.

FindWay

#
Find the way with the specified id.
public OsmWay FindWay(
id
Identifier to search for.
)
Way with given id or null if no such way can be found.

FindWaysByTag

#
Find all nodes that pass a custom test.
public IEnumerable<OsmWay> FindWaysByTag(
filter
Filter tag (optionally with wildcard characters).
)
Enumeration of ways.

GetWayGeometry

#
Get the actual geometry of a way.
public Polyline GetWayGeometry(
way,
Way to parse.
mapping
Mapping function or null for 1:1 mapping.
)
Polyline geometry.

GetWayGeometry

#
Get the actual geometry of a way.
public Polyline GetWayGeometry(
way
Way to parse.
)
Polyline geometry.

GetWayLength

#
Compute the length (in lon-lat space) of a way.
public double GetWayLength(
way
Way to measure.
)
Length of way.

MergeWays

#
Merge ways into single ways.
public int MergeWays(
retainDirection,
If true, ways will not be reversed in order to be merged.
mergeParent,
Determines which way comes out 'on top' when two ways merge.
combineAllTags,
If true, tags will be copied from all ways, not just the parent way.
exemptIds
Optional collection of exempt way ids to not be merged. May be null.
)
Number of ways that disappeared.

ParseFile

#
Parse an OpenStreetMap xml file.
public static OsmFile ParseFile(
file,
File.
filter,
Optional filter.
messages
Array of messages encountered during parsing.
)
Loaded map.

ParseFile

#
Parse an OpenStreetMap xml document. If the document contains more than one osm node, only the first one will be loaded.
public static OsmFile ParseFile(
doc,
Document.
filter,
Optional filter.
messages
Array of messages encountered during parsing.
)
Loaded map.

RemoveExoticTags

#
Remove all exotic tags from nodes and ways.
public int RemoveExoticTags()
Number of tags removed.

RemoveMetaTags

#
Remove all meta tags from nodes and ways.
public int RemoveMetaTags()
Number of tags removed.

RemoveTaggedWays

#
Remove all ways that have a matching tag.
public int RemoveTaggedWays(
removeOrphanedNodes,
If true, nodes which have been orphaned will be removed.
params OsmTag[]
tags
Tags to match. If any tag in a way matches one of the supplied tags, it will be removed.
)
Number of ways removed.

RemoveTags

#
Remove all specific tags from nodes and ways.
public int RemoveTags()
Number of tags removed.

RemoveTags

#
Remove all specific tags from nodes and ways.
public int RemoveTags(
tagNames
Tag names (may include wilcard characters).
)
Number of tags removed.

RemoveUnusedNodes

#
Remove all nodes that are not used by any ways.
public int RemoveUnusedNodes(
retainNodesWithTags
If true, nodes with at least one tag will not be removed.
)
Number of nodes removed.

RemoveWays

#
Remove a set of ways from this file.
public void RemoveWays(
wayIds,
Ways to remove.
removeOrphanedNodes
If true, all nodes currently orphaned will also be removed.
)

RetainTaggedWays

#
Retain all ways that have a matching tag.
public int RetainTaggedWays(
removeOrphanedNodes,
If true, nodes which have been orphaned will be removed.
params OsmTag[]
tags
Tags to match. If any tag in a way matches one of the supplied tags, it will be retained.
)
Number of ways removed.

ToString

#
Get a short description of this file.
public override string ToString()
String description.
Object.ToString

ToStringFull

#
Get a long description of this file.
public string ToStringFull(
elaborateNodes,
If true, each node will be described.
elaborateWays
If true, each way will be described.
)
String description.