本文整理汇总了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);
}
示例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));
}
}
示例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));
}
示例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();
}
示例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);
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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!");
}
示例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);
}
示例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);
}
示例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);
}
示例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"));
}
示例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);
}