/// <summary> /// Adds or objects the given object. /// </summary> public static void AddOrUpdate(this ISnapshotDb db, OsmGeo osmGeo) { db.AddOrUpdate(new OsmGeo[] { osmGeo }); }
private ICompleteOsmGeo _current; // Holds the current complete object. /// <summary> /// Moves to the next object. /// </summary> public override bool MoveNext() { if (!_cachingDone) { // first seek & cache. this.Seek(); _cachingDone = true; } while (_simpleSource.MoveNext()) { // there is data. var currentSimple = _simpleSource.Current(); switch (currentSimple.Type) { case OsmGeoType.Node: // create complete version. _current = currentSimple as Node; if (_current != null && _current.Tags == null) { // make sure nodes have a default tag collection that is empty not null. _current.Tags = new OsmSharp.Tags.TagsCollection(); } if (_nodesToInclude.Contains(currentSimple.Id.Value)) { // node needs to be cached. _dataCache.AddOrUpdate(currentSimple as Node); _nodesToInclude.Remove(currentSimple.Id.Value); } break; case OsmGeoType.Way: // create complete way. _current = (currentSimple as Way).CreateComplete(_dataCache); if (_waysToInclude.Contains(currentSimple.Id.Value)) { // keep the way because it is needed later on. _dataCache.AddOrUpdate(currentSimple as Way); _waysToInclude.Remove(currentSimple.Id.Value); } else { // only report that the nodes have been used when the way can be let-go. var way = currentSimple as Way; if (way.Nodes != null) { // report usage. for (var i = 0; i < way.Nodes.Length; i++) { this.ReportNodeUsage(way.Nodes[i]); } } } break; case OsmGeoType.Relation: // create complate relation. _current = (currentSimple as Relation).CreateComplete(_dataCache); if (!_relationsToInclude.Contains(currentSimple.Id.Value)) { // only report relation usage when the relation can be let go. var relation = currentSimple as Relation; if (relation.Members != null) { foreach (var member in relation.Members) { switch (member.Type) { case OsmGeoType.Node: this.ReportNodeUsage(member.Id); break; case OsmGeoType.Way: this.ReportWayUsage(member.Id); break; case OsmGeoType.Relation: this.ReportRelationUsage(member.Id); break; } } } } break; } if (_current != null) { // only return complete objects. return(true); } } return(false); }