本文整理汇总了C#中OsmSharp.Collections.Tags.TagsCollection.ContainsKeyValue方法的典型用法代码示例。如果您正苦于以下问题:C# TagsCollection.ContainsKeyValue方法的具体用法?C# TagsCollection.ContainsKeyValue怎么用?C# TagsCollection.ContainsKeyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsmSharp.Collections.Tags.TagsCollection
的用法示例。
在下文中一共展示了TagsCollection.ContainsKeyValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSimpleTagsCollectionSimple
public void TestSimpleTagsCollectionSimple()
{
var collection = new TagsCollection();
collection["simple"] = "yes";
Assert.IsTrue(collection.ContainsKey("simple"));
Assert.IsTrue(collection.ContainsKeyValue("simple", "yes"));
Assert.AreEqual("yes", collection["simple"]);
Assert.AreEqual(1, collection.Count);
}
示例2: TestTagsCollectionSimple
/// <summary>
/// Tests an empty tags collection.
/// </summary>
protected void TestTagsCollectionSimple()
{
TagsCollectionBase collection = new TagsCollection();
collection["simple"] = "yes";
Assert.IsTrue(collection.ContainsKey("simple"));
Assert.IsTrue(collection.ContainsKeyValue("simple","yes"));
Assert.AreEqual("yes", collection["simple"]);
Assert.AreEqual(1, collection.Count);
}
示例3: CompareTags
/// <summary>
/// Compares two tag collection for indentical content.
/// </summary>
/// <param name="expectedTags"></param>
/// <param name="foundTags"></param>
private void CompareTags(TagsCollection expectedTags, TagsCollection foundTags)
{
if (expectedTags == null)
{
Assert.IsNull(foundTags);
}
else
{
Assert.IsNotNull(foundTags);
Assert.AreEqual(expectedTags.Count, foundTags.Count);
foreach (Tag expectedTag in expectedTags)
{
Assert.IsTrue(foundTags.ContainsKeyValue(expectedTag.Key, expectedTag.Value));
}
}
}
示例4: Scene2DSimpleSerializeDeserializeTest
public void Scene2DSimpleSerializeDeserializeTest()
{
// create the MapCSS image source.
var imageSource = new MapCSSDictionaryImageSource();
// load mapcss style interpreter.
var mapCSSInterpreter = new MapCSSInterpreter(
Assembly.GetExecutingAssembly().GetManifestResourceStream(
"OsmSharp.UI.Test.Unittests.Data.MapCSS.test.mapcss"),
imageSource);
// initialize the data source.
var xmlSource = new XmlOsmStreamSource(
Assembly.GetExecutingAssembly().GetManifestResourceStream(
"OsmSharp.UI.Test.Unittests.Data.test.osm"));
IEnumerable<OsmGeo> dataSource = xmlSource;
MemoryDataSource source = MemoryDataSource.CreateFrom(xmlSource);
// get data.
var scene = new Scene2D(new OsmSharp.Math.Geo.Projections.WebMercator(), 16);
var projection = new WebMercator();
GeoCoordinateBox box = null;
foreach (var osmGeo in dataSource)
{
ICompleteOsmGeo completeOsmGeo = null;
switch (osmGeo.Type)
{
case OsmGeoType.Node:
completeOsmGeo = osmGeo as Node;
if(completeOsmGeo.Tags == null)
{ // make sure every node has a tags collection.
completeOsmGeo.Tags = new TagsCollection();
}
break;
case OsmGeoType.Way:
completeOsmGeo = CompleteWay.CreateFrom(osmGeo as Way,
source);
break;
case OsmGeoType.Relation:
completeOsmGeo = CompleteRelation.CreateFrom(osmGeo as Relation,
source);
break;
}
// update box.
if (completeOsmGeo != null)
{
if (box == null) { box = completeOsmGeo.BoundingBox; }
else if (completeOsmGeo.BoundingBox != null) { box = box + completeOsmGeo.BoundingBox; }
}
// translate each object into scene object.
mapCSSInterpreter.Translate(scene, projection, source, osmGeo as OsmGeo);
}
// create the stream.
TagsCollectionBase metaTags = new TagsCollection();
metaTags.Add("SomeTestKey", "SomeTestValue");
var stream = new MemoryStream();
scene.Serialize(stream, true, metaTags);
// deserialize the stream.
metaTags = null;
stream.Seek(0, SeekOrigin.Begin);
IPrimitives2DSource sceneSource = Scene2D.Deserialize(stream, true, out metaTags);
// test meta tags.
Assert.IsTrue(metaTags.ContainsKeyValue("SomeTestKey", "SomeTestValue"));
if (box != null)
{
// query both and get the same results.
int counter = 100;
var rand = new Random();
while (counter > 0)
{
var queryBox = new GeoCoordinateBox(
box.GenerateRandomIn(rand),
box.GenerateRandomIn(rand));
var zoomFactor = (float)projection.ToZoomFactor(15);
View2D testView = View2D.CreateFromBounds(
projection.LatitudeToY(queryBox.MaxLat),
projection.LongitudeToX(queryBox.MinLon),
projection.LatitudeToY(queryBox.MinLat),
projection.LongitudeToX(queryBox.MaxLon));
var testScene = new Scene2D(new OsmSharp.Math.Geo.Projections.WebMercator(), 16);
IEnumerable<Primitive2D> primitives = sceneSource.Get(testView, zoomFactor);
// var resultIndex = new HashSet<Scene2DPrimitive>(testScene.Get(testView, zoomFactor));
// var resultReference = new HashSet<Scene2DPrimitive>(scene.Get(testView, zoomFactor));
//Assert.AreEqual(resultReference.Count, resultIndex.Count);
//foreach (var data in resultIndex)
//{
// Assert.IsTrue(resultReference.Contains(data));
//}
//foreach (var data in resultReference)
//{
// Assert.IsTrue(resultIndex.Contains(data));
//}
//.........这里部分代码省略.........