當前位置: 首頁>>代碼示例>>C#>>正文


C# TagsCollection.ContainsKeyValue方法代碼示例

本文整理匯總了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);
        }
開發者ID:nagyistoce,項目名稱:OsmSharp-core,代碼行數:11,代碼來源:TagsCollectionTests.cs

示例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);
        }
開發者ID:OpenMaps,項目名稱:OsmSharp,代碼行數:14,代碼來源:TagsCollectionBaseTests.cs

示例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));
         }
     }
 }
開發者ID:robert-hickey,項目名稱:OsmSharp,代碼行數:21,代碼來源:DataProviderOsmTests.cs

示例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));
                    //}
//.........這裏部分代碼省略.........
開發者ID:UnifyKit,項目名稱:OsmSharp,代碼行數:101,代碼來源:Scene2DPrimitivesSerializerTests.cs


注:本文中的OsmSharp.Collections.Tags.TagsCollection.ContainsKeyValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。