当前位置: 首页>>代码示例>>C#>>正文


C# Tags.TagsCollection类代码示例

本文整理汇总了C#中OsmSharp.Collections.Tags.TagsCollection的典型用法代码示例。如果您正苦于以下问题:C# TagsCollection类的具体用法?C# TagsCollection怎么用?C# TagsCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TagsCollection类属于OsmSharp.Collections.Tags命名空间,在下文中一共展示了TagsCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsVehicleAllowed

 /// <summary>
 /// Returns true if the vehicle is allowed on the way represented by these tags
 /// </summary>
 /// <param name="tags"></param>
 /// <param name="highwayType"></param>
 /// <returns></returns>
 protected override bool IsVehicleAllowed(TagsCollection tags, string highwayType)
 {
     // do the designated tags.
     if (tags.ContainsKey("bicycle"))
     {
         if (tags["bicycle"] == "designated")
         {
             return true; // designated bicycle
         }
         if (tags["bicycle"] == "yes")
         {
             return true; // yes for bicycle
         }
         if (tags["bicycle"] == "no")
         {
             return false; //  no for bicycle
         }
     }
     if (tags.ContainsKey("foot"))
     {
         if (tags["foot"] == "designated")
         {
             return false; // designated foot
         }
     }
     return AccessibleTags.ContainsKey(highwayType);
 }
开发者ID:jboneng,项目名称:OsmSharp,代码行数:33,代码来源:Vehicle.cs

示例2: TestRandomBlockTagSerializatonNonBeginPosition

        public void TestRandomBlockTagSerializatonNonBeginPosition()
        {
            TagsTableCollectionIndex tagsIndex = new TagsTableCollectionIndex();

            TagsCollection tagsCollection = new TagsCollection();
            for (int i = 0; i < 100; i++)
            {
                int tagCollectionSize = OsmSharp.Math.Random.StaticRandomGenerator.Get().Generate(10) + 1;
                for (int idx = 0; idx < tagCollectionSize; idx++)
                {
                    int tagValue = OsmSharp.Math.Random.StaticRandomGenerator.Get().Generate(10);
                    tagsCollection.Add(
                        string.Format("key_{0}", tagValue),
                        string.Format("value_{0}", tagValue));
                }
                uint tagsId = tagsIndex.Add(tagsCollection);
            }

            ITagsCollectionIndexReadonly tagsIndexReadonly = this.SerializeDeserializeBlock(tagsIndex, 10, 123);
            Assert.AreEqual(tagsIndex.Max, tagsIndexReadonly.Max);
            for (uint idx = 0; idx < tagsIndex.Max; idx++)
            {
                ComparisonHelpers.CompareTags(tagsIndex.Get(idx),
                    tagsIndexReadonly.Get(idx));
            }
        }
开发者ID:OpenMaps,项目名称:OsmSharp,代码行数:26,代码来源:TagsCollectionIndexSerializerTests.cs

示例3: TestEdgeMatcher

        public void TestEdgeMatcher()
        {
            IEdgeMatcher matcher = new DefaultEdgeMatcher();

            // create edge tags.
            var edgeTags = new TagsCollection();
            //edge_tags["highway"] = "footway";

            // create point tags.
            var pointTags = new TagsCollection();
            //point_tags["highway"] = "footway";

            // test with empty point tags.
            Assert.IsTrue(matcher.MatchWithEdge(Vehicle.Car, null, null));
            Assert.IsTrue(matcher.MatchWithEdge(Vehicle.Car, pointTags, null));

            // test with empty edge tags.
            pointTags["name"] = "Ben Abelshausen Boulevard";
            Assert.IsFalse(matcher.MatchWithEdge(Vehicle.Car, pointTags, null));
            Assert.IsFalse(matcher.MatchWithEdge(Vehicle.Car, pointTags, edgeTags));

            // test with matching name.
            edgeTags["name"] = "Ben Abelshausen Boulevard";
            Assert.IsTrue(matcher.MatchWithEdge(Vehicle.Car, pointTags, edgeTags));

            // test with none-matching name.
            edgeTags["name"] = "Jorieke Vyncke Boulevard";
            Assert.IsFalse(matcher.MatchWithEdge(Vehicle.Car, pointTags, edgeTags));
        }
开发者ID:cmberryau,项目名称:routing,代码行数:29,代码来源:EdgeMatcherTests.cs

示例4: TestSerialization

        /// <summary>
        /// Tests preprocessing data from a PBF file.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pbfFile"></param>
        public static void TestSerialization(string name, string pbfFile)
        {
            FileInfo testFile = new FileInfo(string.Format(@".\TestFiles\{0}", pbfFile));
            Stream stream = testFile.OpenRead();
            PBFOsmStreamSource source = new PBFOsmStreamSource(stream);

            FileInfo testOutputFile = new FileInfo(@"test.routing");
            testOutputFile.Delete();
            Stream writeStream = testOutputFile.OpenWrite();

            CHEdgeGraphFileStreamTarget target = new CHEdgeGraphFileStreamTarget(writeStream,
                Vehicle.Car);
            target.RegisterSource(source);

            PerformanceInfoConsumer performanceInfo = new PerformanceInfoConsumer("CHSerializer");
            performanceInfo.Start();
            performanceInfo.Report("Pulling from {0}...", testFile.Name);

            var data = CHEdgeGraphOsmStreamTarget.Preprocess(
                source, new OsmRoutingInterpreter(), Vehicle.Car);

            TagsCollectionBase metaData = new TagsCollection();
            metaData.Add("some_key", "some_value");
            var routingSerializer = new CHEdgeDataDataSourceSerializer(true);
            routingSerializer.Serialize(writeStream, data, metaData);

            stream.Dispose();
            writeStream.Dispose();

            OsmSharp.Logging.Log.TraceEvent("CHSerializer", OsmSharp.Logging.TraceEventType.Information,
                string.Format("Serialized file: {0}KB", testOutputFile.Length / 1024));

            performanceInfo.Stop();
        }
开发者ID:nubix-biz,项目名称:OsmSharp,代码行数:39,代码来源:CHEdgeGraphFileStreamTargetTests.cs

示例5: RoutingSerializationV2CHRoutingComparisonTest

        public void RoutingSerializationV2CHRoutingComparisonTest()
        {
            const string embeddedString = "OsmSharp.Test.Unittests.test_network_real1.osm";

            // creates a new interpreter.
            var interpreter = new OsmRoutingInterpreter();

            // do the data processing.
            var original = CHEdgeGraphOsmStreamTarget.Preprocess(new XmlOsmStreamSource(
                                                                   Assembly.GetExecutingAssembly()
                                                                           .GetManifestResourceStream(embeddedString)),
                                                               interpreter,
                                                               Vehicle.Car);

            // create serializer.
            var routingSerializer = new OsmSharp.Routing.CH.Serialization.Sorted.CHEdgeDataDataSourceSerializer();

            // serialize/deserialize.
            TagsCollectionBase metaData = new TagsCollection();
            metaData.Add("some_key", "some_value");
            byte[] byteArray;
            using (var stream = new MemoryStream())
            {
                try
                {
                    routingSerializer.Serialize(stream, original, metaData);
                    byteArray = stream.ToArray();
                }
                catch (Exception)
                {
                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }
                    throw;
                }
            }

            IBasicRouterDataSource<CHEdgeData> deserializedVersion =
                routingSerializer.Deserialize(new MemoryStream(byteArray), out metaData);
            Assert.AreEqual(original.TagsIndex.Get(0), deserializedVersion.TagsIndex.Get(0));

            // create reference router.
            original = CHEdgeGraphOsmStreamTarget.Preprocess(new XmlOsmStreamSource(
                                                                   Assembly.GetExecutingAssembly()
                                                                           .GetManifestResourceStream(embeddedString)),
                                                               interpreter,
                                                               Vehicle.Car);
            var basicRouterOriginal = new CHRouter();
            Router referenceRouter = Router.CreateCHFrom(
                original, basicRouterOriginal, interpreter);

            // try to do some routing on the deserialized version.
            var basicRouter = new CHRouter();
            Router router = Router.CreateCHFrom(
                deserializedVersion, basicRouter, interpreter);

            //this.TestCompareAll(original, referenceRouter, router);
        }
开发者ID:kochizufan,项目名称:OsmSharp,代码行数:59,代码来源:RoutingSerializationComparisonTests.cs

示例6: MapCSSEvalTagTest

        public void MapCSSEvalTagTest()
        {
            string function = "tag('width')";
            TagsCollectionBase tags = new TagsCollection();
            tags.Add("width", "2");

            Assert.AreEqual(2, EvalInterpreter.Instance.InterpretDouble(function, tags));
        }
开发者ID:JoeCooper,项目名称:ui,代码行数:8,代码来源:MapCSSEvalTests.cs

示例7: Create

 /// <summary>
 /// Creates a new way.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="nodes"></param>
 /// <param name="tags"></param>
 /// <returns></returns>
 public static Way Create(long id, TagsCollection tags, params long[] nodes)
 {
     Way way = new Way();
     way.Id = id;
     way.Nodes = new List<long>(nodes);
     way.Tags = tags;
     return way;
 }
开发者ID:robert-hickey,项目名称:OsmSharp,代码行数:15,代码来源:Way.cs

示例8: Create

 /// <summary>
 /// Creates a new relation.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="tags"></param>
 /// <param name="members"></param>
 /// <returns></returns>
 public static Relation Create(long id, TagsCollection tags, params RelationMember[] members)
 {
     Relation relation = new Relation();
     relation.Id = id;
     relation.Members = new List<RelationMember>(members);
     relation.Tags = tags;
     return relation;
 }
开发者ID:robert-hickey,项目名称:OsmSharp,代码行数:15,代码来源:Relation.cs

示例9: GetName

 /// <summary>
 ///     Returns the name of a given way.
 /// </summary>
 /// <param name="tags"></param>
 /// <returns></returns>
 public string GetName(TagsCollection tags)
 {
     var name = string.Empty;
     if (tags.ContainsKey("name"))
     {
         name = tags["name"];
     }
     return name;
 }
开发者ID:robert-hickey,项目名称:OsmSharp,代码行数:14,代码来源:EdgeInterpreter.cs

示例10: Add

 /// <summary>
 /// Adds tags to this index.
 /// </summary>
 /// <param name="tags"></param>
 /// <returns></returns>
 public uint Add(TagsCollection tags)
 {
     var osmTags = new OsmTags(tags);
     if (osmTags != null)
     {
         return _tagsTable.Add(osmTags);
     }
     throw new ArgumentNullException("tags", "Tags dictionary cannot be null or empty!");
 }
开发者ID:jboneng,项目名称:OsmSharp,代码行数:14,代码来源:SimpleTagsIndex.cs

示例11: 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

示例12: TextProbableSpeed

        /// <summary>
        /// Tests the probable speed.
        /// </summary>
        /// <param name="vehicle"></param>
        /// <param name="speed"></param>
        /// <param name="tags"></param>
        protected void TextProbableSpeed(Vehicle vehicle, double speed, params string[] tags)
        {
            // build tags collection.
            TagsCollection tagsCollection = new TagsCollection();
            for (int idx = 0; idx < tags.Length; idx = idx + 2)
            {
                tagsCollection.Add(tags[idx], tags[idx + 1]);
            }

            Assert.AreEqual(speed, vehicle.ProbableSpeed(tagsCollection).Value);
        }
开发者ID:cmberryau,项目名称:routing,代码行数:17,代码来源:VehicleBaseTests.cs

示例13: 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

示例14: TestBooleanParsing

        public void TestBooleanParsing()
        {
            // test IsTrue.
            TagsCollectionBase tags = new TagsCollection();
            tags.Add("area", "yes");
            Assert.IsTrue(tags.IsTrue("area"));

            tags = new TagsCollection();
            tags.Add("area", "1");
            Assert.IsTrue(tags.IsTrue("area"));

            tags = new TagsCollection();
            tags.Add("area", "true");
            Assert.IsTrue(tags.IsTrue("area"));

            tags = new TagsCollection();
            tags.Add("area", "false");
            Assert.IsFalse(tags.IsTrue("area"));

            tags = new TagsCollection();
            tags.Add("area", "0");
            Assert.IsFalse(tags.IsTrue("area"));

            tags = new TagsCollection();
            tags.Add("area", "no");
            Assert.IsFalse(tags.IsTrue("area"));

            // test IsFalse.
            tags = new TagsCollection();
            tags.Add("area", "yes");
            Assert.IsFalse(tags.IsFalse("area"));

            tags = new TagsCollection();
            tags.Add("area", "1");
            Assert.IsFalse(tags.IsFalse("area"));

            tags = new TagsCollection();
            tags.Add("area", "true");
            Assert.IsFalse(tags.IsFalse("area"));

            tags = new TagsCollection();
            tags.Add("area", "false");
            Assert.IsTrue(tags.IsFalse("area"));

            tags = new TagsCollection();
            tags.Add("area", "0");
            Assert.IsTrue(tags.IsFalse("area"));

            tags = new TagsCollection();
            tags.Add("area", "no");
            Assert.IsTrue(tags.IsFalse("area"));
        }
开发者ID:UnifyKit,项目名称:OsmSharp,代码行数:52,代码来源:TagParsingTests.cs

示例15: TestSerialize

        /// <summary>
        /// Tests serializing a stream.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="stream"></param>
        /// <param name="scene"></param>
        /// <param name="compress"></param>
        public static void TestSerialize(string name, Stream stream, Scene2D scene, bool compress)
        {
            PerformanceInfoConsumer performanceInfo = new PerformanceInfoConsumer(string.Format("{0}.Serialize", name));
            performanceInfo.Start();
            performanceInfo.Report("Serializing stream...");

            TagsCollectionBase metaTags = new TagsCollection();
            metaTags.Add("generated_by", "performance_test");
            scene.Serialize(stream, compress, metaTags);

            performanceInfo.Stop();

            Console.Write("", scene.BackColor);
        }
开发者ID:nubix-biz,项目名称:OsmSharp,代码行数:21,代码来源:Scene2DTests.cs


注:本文中的OsmSharp.Collections.Tags.TagsCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。