public void ImportData(osm osmData) { foreach (osmNode originalNode in osmData.Node) { OsmObjectAction objectAction = ParseOsmObjectAction(originalNode.Action); if (objectAction == OsmObjectAction.Delete) { continue; } OsmNode node = new OsmNode(originalNode.Id, originalNode.Lat, originalNode.Lon); if (originalNode.Timestamp != null) { node.Timestamp = DateTime.Parse(originalNode.Timestamp, CultureInfo.InvariantCulture); } node.User = OsmUser.Fetch(originalNode.User, originalNode.Uid); node.ChangesetId = originalNode.Changeset; node.Visible = originalNode.Visible; node.Action = objectAction; foreach (tag tag in originalNode.Tag) { node.SetTag(tag.K, tag.V); } AddNode(node); } foreach (osmWay originalWay in osmData.Way) { OsmObjectAction objectAction = ParseOsmObjectAction(originalWay.Action); if (objectAction == OsmObjectAction.Delete) { continue; } OsmWay way = new OsmWay(originalWay.Id); if (originalWay.Timestamp != null) { way.Timestamp = DateTime.Parse(originalWay.Timestamp, CultureInfo.InvariantCulture); } way.User = OsmUser.Fetch(originalWay.User, originalWay.Uid); way.ChangesetId = originalWay.Changeset; way.Visible = originalWay.Visible; way.Action = objectAction; foreach (osmWayND nd in originalWay.Nd) { way.AddNode(nd.Ref); } foreach (tag tag in originalWay.Tag) { way.SetTag(tag.K, tag.V); } AddWay(way); } foreach (osmRelation originalRelation in osmData.Relation) { OsmObjectAction objectAction = ParseOsmObjectAction(originalRelation.Action); if (objectAction == OsmObjectAction.Delete) { continue; } if (originalRelation.Action == "delete") { continue; } OsmRelation relation = new OsmRelation(originalRelation.Id); if (originalRelation.Timestamp != null) { relation.Timestamp = DateTime.Parse(originalRelation.Timestamp, CultureInfo.InvariantCulture); } relation.User = OsmUser.Fetch(originalRelation.User, originalRelation.Uid); relation.ChangesetId = originalRelation.Changeset; relation.Visible = originalRelation.Visible; relation.Action = objectAction; foreach (osmRelationMember member in originalRelation.Member) { OsmReferenceType referenceType = ParseOsmReferenceType(member.Type); relation.AddMember(referenceType, member.Ref, member.Role); } foreach (tag tag in originalRelation.Tag) { relation.SetTag(tag.K, tag.V); } AddRelation(relation); } }
/// <summary> /// Formats a specified value of <see cref="OsmObjectAction"/> into a string. /// </summary> /// <param name="action">The OSM object action value.</param> /// <returns>The OSM object action value in a string form.</returns> static public string FormatOsmObjectAction(OsmObjectAction action) { return(osmObjectActionStringConstants [(int)action]); }