OsmFile

References
public class OsmFile
Represents an OSM file.

Properties

BoundingBox

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

NodeCount

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

NodeIds

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

Nodes

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

ReferencedNodes

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

WayCount

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

WayIds

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

Ways

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

Methods

AddToRhinoDocument

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

Duplicate

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

FindNode

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

FindNodesByTag

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

FindWay

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

FindWaysByTag

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

GetWayGeometry

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

GetWayGeometry

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

GetWayLength

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

MergeWays

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

ParseFile

#
public static OsmFile ParseFile(string file, OsmSettings filter, out List<Message> messages)
Parse an OpenStreetMap xml file.
file (string)File.
filter (OsmSettings)Optional filter.
messages (out List<Message>)Array of messages encountered during parsing.
Loaded map.

ParseFile

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

RemoveExoticTags

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

RemoveMetaTags

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

RemoveTaggedWays

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

RemoveTags

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

RemoveTags

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

RemoveUnusedNodes

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

RemoveWays

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

RetainTaggedWays

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

ToString

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

ToStringFull

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