/// <summary> /// Tests a simple relation read/write operation. /// </summary> /// <param name="cache"></param> public void DoOsmDataCacheTestRelation(OsmDataCache cache) { Relation relation = Relation.Create(1, new TagsCollection( Tag.Create("relation", "yes")), RelationMember.Create(1, "something", OsmGeoType.Node)); // test invalid stuff. Assert.Throws <ArgumentNullException>(() => cache.AddRelation(null)); Assert.Throws <Exception>(() => cache.AddRelation(new Relation())); Assert.IsNull(cache.GetRelation(relation.Id.Value)); cache.AddRelation(relation); Assert.IsTrue(cache.ContainsRelation(relation.Id.Value)); Relation readRelation = cache.GetRelation(relation.Id.Value); Assert.IsNotNull(readRelation); Assert.AreEqual(1, readRelation.Id.Value); Assert.IsNotNull(relation.Tags); Assert.AreEqual(1, relation.Tags.Count); Assert.AreEqual("yes", relation.Tags["relation"]); Assert.IsTrue(cache.TryGetRelation(relation.Id.Value, out readRelation)); Assert.IsNotNull(readRelation); Assert.AreEqual(1, readRelation.Id.Value); Assert.IsNotNull(relation.Tags); Assert.AreEqual(1, relation.Tags.Count); Assert.AreEqual("yes", relation.Tags["relation"]); Assert.IsTrue(cache.RemoveRelation(relation.Id.Value)); Assert.IsFalse(cache.ContainsRelation(relation.Id.Value)); Assert.IsFalse(cache.RemoveRelation(relation.Id.Value)); }
/// <summary> /// Tests the clear functionality on the datacache. /// </summary> /// <param name="cache"></param> public void DoOsmDataCacheTestClear(OsmDataCache cache) { Node node = Node.Create(1, new TagsCollection( Tag.Create("node", "yes")), 1, 2); Way way = Way.Create(1, new TagsCollection( Tag.Create("way", "yes")), 1, 2); Relation relation = Relation.Create(1, new TagsCollection( Tag.Create("relation", "yes")), RelationMember.Create(1, "something", OsmGeoType.Node)); cache.AddNode(node); cache.AddWay(way); cache.AddRelation(relation); Assert.IsTrue(cache.ContainsNode(node.Id.Value)); Assert.IsTrue(cache.ContainsWay(way.Id.Value)); Assert.IsTrue(cache.ContainsRelation(relation.Id.Value)); cache.Clear(); Assert.IsFalse(cache.ContainsNode(node.Id.Value)); Assert.IsFalse(cache.ContainsWay(way.Id.Value)); Assert.IsFalse(cache.ContainsRelation(relation.Id.Value)); }
private bool IsChild(OsmGeo currentSimple) { switch (currentSimple.Type) { case OsmGeoType.Node: HashSet <long> nodesToInclude = this._nodesToInclude; long? id1 = currentSimple.Id; long num1 = id1.Value; if (nodesToInclude.Contains(num1)) { return(true); } OsmDataCache dataCache1 = this._dataCache; id1 = currentSimple.Id; long id2 = id1.Value; return(dataCache1.ContainsNode(id2)); case OsmGeoType.Way: HashSet <long> waysToInclude = this._waysToInclude; long? id3 = currentSimple.Id; long num2 = id3.Value; if (waysToInclude.Contains(num2)) { return(true); } OsmDataCache dataCache2 = this._dataCache; id3 = currentSimple.Id; long id4 = id3.Value; return(dataCache2.ContainsWay(id4)); case OsmGeoType.Relation: HashSet <long> relationsToInclude = this._relationsToInclude; long? id5 = currentSimple.Id; long num3 = id5.Value; if (relationsToInclude.Contains(num3)) { return(true); } OsmDataCache dataCache3 = this._dataCache; id5 = currentSimple.Id; long id6 = id5.Value; return(dataCache3.ContainsRelation(id6)); default: return(false); } }
/// <summary> /// Returns true if the given object is an object that needs to be included. /// </summary> /// <param name="currentSimple"></param> /// <returns></returns> private bool IsChild(OsmGeo currentSimple) { switch (currentSimple.Type) { case OsmGeoType.Node: return(_nodesToInclude.Contains(currentSimple.Id.Value) || _dataCache.ContainsNode(currentSimple.Id.Value)); case OsmGeoType.Way: return(_waysToInclude.Contains(currentSimple.Id.Value) || _dataCache.ContainsWay(currentSimple.Id.Value)); case OsmGeoType.Relation: return(_relationsToInclude.Contains(currentSimple.Id.Value) || _dataCache.ContainsRelation(currentSimple.Id.Value)); } return(false); }