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


C# Osm.Way类代码示例

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


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

示例1: Create

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

示例2: AddWay

        public override void AddWay(Way way)
        {
            if (!way.Id.HasValue)
                return;

            MaxStringLength(way.UserName, ref WayUsr);

            if (way.Tags == null)
                return;

            foreach (Tag tag in way.Tags)
            {
                MaxStringLength(tag.Key, ref WayTagsKey);
                MaxStringLength(tag.Value, ref WayTagsValue);
            }
        }
开发者ID:OsmSharp,项目名称:sqlserver-dataprovider,代码行数:16,代码来源:SQLServerDDLChecksStreamTarget.cs

示例3: TestWayAreaIsYesArea

        public void TestWayAreaIsYesArea()
        {
            var node1 = new Node();
            node1.Id = 1;
            node1.Latitude = 0;
            node1.Longitude = 0;
            var node2 = new Node();
            node2.Id = 2;
            node2.Latitude = 1;
            node2.Longitude = 0;
            var node3 = new Node();
            node3.Id = 3;
            node3.Latitude = 0;
            node3.Longitude = 1;

            var way = new Way();
            way.Id = 1;
            way.Nodes = new List<long>();
            way.Nodes.Add(1);
            way.Nodes.Add(2);
            way.Nodes.Add(3);
            way.Nodes.Add(1);
            way.Tags = new TagsCollection();
            way.Tags.Add("area", "yes");

            var source = new List<OsmGeo>();
            source.Add(node1);
            source.Add(node2);
            source.Add(node3);
            source.Add(way);

            // create source stream.
            var sourceStream = new OsmSharp.Osm.Streams.Complete.OsmSimpleCompleteStreamSource(source.ToOsmStreamSource());

            // create features source.
            var featuresSourceStream = new OsmFeatureStreamSource(sourceStream);

            // pull stream.
            var features = new List<Feature>(featuresSourceStream);

            Assert.IsNotNull(features);
            Assert.AreEqual(1, features.Count);
            var feature = features[0];
            Assert.IsInstanceOf<LineairRing>(feature.Geometry);
            Assert.IsTrue(feature.Attributes.ContainsKeyValue("area", "yes"));
        }
开发者ID:UnifyKit,项目名称:OsmSharp,代码行数:46,代码来源:OsmFeatureStreamSourceTests.cs

示例4: TestEmptyCSS

        public void TestEmptyCSS()
        {
            // create 'test' objects.
            Node node1 = new Node();
            node1.Id = 1;
            node1.Latitude = 1;
            node1.Longitude = 1;

            Node node2 = new Node();
            node2.Id = 2;
            node2.Latitude = 2;
            node2.Longitude = 2;

            Way way = new Way();
            way.Id = 1;
            way.Nodes = new List<long>();
            way.Nodes.Add(1);
            way.Nodes.Add(2);

            // create the datasource.
            MemoryDataSource dataSource = new MemoryDataSource();
            dataSource.AddNode(node1);
            dataSource.AddNode(node2);
            dataSource.AddWay(way);

            // create the projection and scene objects.
            var mercator = new WebMercator();
            Scene2D scene = new Scene2D(new OsmSharp.Math.Geo.Projections.WebMercator(), 16);

            // create the interpreter.
            MapCSSInterpreter interpreter = new MapCSSInterpreter(string.Empty,
                new MapCSSDictionaryImageSource());
            interpreter.Translate(scene, mercator, dataSource, node1);
            interpreter.Translate(scene, mercator, dataSource, node2);
            interpreter.Translate(scene, mercator, dataSource, way);

            // test the scene contents.
            Assert.AreEqual(0, scene.Count);
            Assert.AreEqual(SimpleColor.FromKnownColor(KnownColor.Black).Value, scene.BackColor);
        }
开发者ID:JoeCooper,项目名称:ui,代码行数:40,代码来源:MapCSSInterpretationTests.cs

示例5: TestWayAreaIsYes

        public void TestWayAreaIsYes()
        {
            Node node1 = new Node();
            node1.Id = 1;
            node1.Latitude = 0;
            node1.Longitude = 0;
            Node node2 = new Node();
            node2.Id = 2;
            node2.Latitude = 1;
            node2.Longitude = 0;
            Node node3 = new Node();
            node3.Id = 3;
            node3.Latitude = 0;
            node3.Longitude = 1;

            Way way = new Way();
            way.Id = 1;
            way.Nodes = new List<long>();
            way.Nodes.Add(1);
            way.Nodes.Add(2);
            way.Nodes.Add(3);
            way.Nodes.Add(1);
            way.Tags = new TagsCollection();
            way.Tags.Add("area", "yes");

            var source = new List<OsmGeo>();
            source.Add(node1);
            source.Add(node2);
            source.Add(node3);
            source.Add(way);

            // the use of natural=water implies an area-type.
            var interpreter = new SimpleFeatureInterpreter();
            var completeStreamSource = new OsmSimpleCompleteStreamSource(source.ToOsmStreamSource());

            // use the stream to interpret.
            var features = new List<Feature>(new FeatureInterpreterStreamSource(completeStreamSource, interpreter));

            Assert.AreEqual(1, features.Count);
        }
开发者ID:APLANA-Alexey-Stolyarov,项目名称:OsmSharpDataProcessor,代码行数:40,代码来源:GeometryInterpreterStreamSourceTests.cs

示例6: CompareSimple

        /// <summary>
        /// Compares a found way to an expected way.
        /// </summary>
        public static void CompareSimple(Way expected, Way actual)
        {
            Assert.IsNotNull(expected);
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.ChangeSetId, actual.ChangeSetId);
            Assert.AreEqual(expected.TimeStamp, actual.TimeStamp);
            Assert.AreEqual(expected.Type, actual.Type);
            Assert.AreEqual(expected.UserId, actual.UserId);
            Assert.AreEqual(expected.UserName, actual.UserName);
            Assert.AreEqual(expected.Version, actual.Version);
            Assert.AreEqual(expected.Visible, actual.Visible);

            if (expected.Nodes == null)
            {
                Assert.IsNull(actual.Nodes);
            }
            else
            {
                Assert.IsNotNull(actual.Nodes);
                Assert.AreEqual(expected.Nodes.Count, actual.Nodes.Count);
                for (int idx = 0; idx < expected.Nodes.Count; idx++)
                {
                    Assert.AreEqual(expected.Nodes[idx], actual.Nodes[idx]);
                }
            }

            ComparisonHelpers.CompareTags(expected.Tags, actual.Tags);
        }
开发者ID:OsmSharp,项目名称:sqlserver-dataprovider,代码行数:32,代码来源:ComparisonHelpers.cs

示例7: RegisterNodeWayRelation

 /// <summary>
 /// Adds the node-way relations for the given way.
 /// </summary>
 /// <param name="way"></param>
 private void RegisterNodeWayRelation(Way way)
 {
     foreach (Node node in way.Nodes)
     {
         if (!_ways_per_node.ContainsKey(node.Id))
         {
             _ways_per_node.Add(node.Id, new List<long>());
         }
         _ways_per_node[node.Id].Add(way.Id);
     }
 }
开发者ID:jorik041,项目名称:osmsharp,代码行数:15,代码来源:KmlDataSource.cs

示例8: AddWay

        /// <summary>
        /// Adds a way.
        /// </summary>
        /// <param name="way"></param>
        private void AddWay(Way way)
        {
            if (_ways.ContainsKey(way.Id))
            {
                throw new InvalidOperationException("Cannot add an object that already exists in this source!" + Environment.NewLine +
                    "If there is a modification use a changeset!");
            }
            else
            {
                _ways.Add(way.Id, way);

                foreach (Node node in way.Nodes)
                {
                    if (this.GetNode(node.Id) == null)
                    {
                        this.AddNode(node);
                    }
                }

            }
        }
开发者ID:jorik041,项目名称:osmsharp,代码行数:25,代码来源:KmlDataSource.cs

示例9: WayCachePut

 private void WayCachePut(Way way)
 {
     _ways.Add(way.Id, way);
 }
开发者ID:jorik041,项目名称:osmsharp,代码行数:4,代码来源:MemoryDataSource.cs

示例10: ToSimple

 /// <summary>
 /// Converts this relation into it's simple counterpart.
 /// </summary>
 /// <returns></returns>
 public override OsmGeo ToSimple()
 {
     var way = new Way();
     way.Id = this.Id;
     way.ChangeSetId = this.ChangeSetId;
     way.Tags = this.Tags;
     way.TimeStamp = this.TimeStamp;
     way.UserId = this.UserId;
     way.UserName = this.User;
     way.Version = (ulong?)this.Version;
     way.Visible = this.Visible;
     way.Nodes = new List<long>();
     foreach (Node node in this.Nodes)
     {
         way.Nodes.Add(node.Id.Value);
     }
     return way;
 }
开发者ID:nagyistoce,项目名称:OsmSharp-core,代码行数:22,代码来源:CompleteWay.cs

示例11: CompareWays

        /// <summary>
        /// Compares a found way to an expected way.
        /// </summary>
        /// <param name="expected"></param>
        /// <param name="found"></param>
        private void CompareWays(Way expected, Way found)
        {
            Assert.IsNotNull(expected);
            Assert.IsNotNull(found);
            Assert.AreEqual(expected.Id, found.Id);
            Assert.AreEqual(expected.ChangeSetId, found.ChangeSetId);
            Assert.AreEqual(expected.TimeStamp, found.TimeStamp);
            Assert.AreEqual(expected.Type, found.Type);
            Assert.AreEqual(expected.UserId, found.UserId);
            Assert.AreEqual(expected.UserName, found.UserName);
            Assert.AreEqual(expected.Version, found.Version);
            Assert.AreEqual(expected.Visible, found.Visible);

            if (expected.Nodes == null)
            {
                Assert.IsNull(found.Nodes);
            }
            else
            {
                Assert.IsNotNull(found.Nodes);
                Assert.AreEqual(expected.Nodes.Count, found.Nodes.Count);
                for (int idx = 0; idx < expected.Nodes.Count; idx++)
                {
                    Assert.AreEqual(expected.Nodes[idx], found.Nodes[idx]);
                }
            }

            this.CompareTags(expected.Tags, found.Tags);
        }
开发者ID:robert-hickey,项目名称:OsmSharp,代码行数:34,代码来源:DataProviderOsmTests.cs

示例12: TestCanvasJOSMSettingsCSS

        public void TestCanvasJOSMSettingsCSS()
        {
            // create CSS.
            string css = "canvas { " +
                "background-color: white; " +
                "default-points: true; " + // adds default points for every node (color: black, size: 2).
                "default-lines: true; " + // adds default lines for every way (color: red, width: 1).
                "} ";

            // create 'test' objects.
            Node node1 = new Node();
            node1.Id = 1;
            node1.Latitude = 1;
            node1.Longitude = 1;

            Node node2 = new Node();
            node2.Id = 2;
            node2.Latitude = 2;
            node2.Longitude = 2;

            Way way = new Way();
            way.Id = 1;
            way.Nodes = new List<long>();
            way.Nodes.Add(1);
            way.Nodes.Add(2);

            // create the datasource.
            MemoryDataSource dataSource = new MemoryDataSource();
            dataSource.AddNode(node1);
            dataSource.AddNode(node2);
            dataSource.AddWay(way);

            // create the projection and scene objects.
            var mercator = new WebMercator();
            Scene2D scene = new Scene2D(new OsmSharp.Math.Geo.Projections.WebMercator(), 16);

            // create the interpreter.
            MapCSSInterpreter interpreter = new MapCSSInterpreter(css,
                new MapCSSDictionaryImageSource());
            interpreter.Translate(scene, mercator, dataSource, node1);
            interpreter.Translate(scene, mercator, dataSource, node2);
            interpreter.Translate(scene, mercator, dataSource, way);

            // test the scene contents.
            Assert.AreEqual(3, scene.Count);
            Assert.AreEqual(SimpleColor.FromKnownColor(KnownColor.White).Value, scene.BackColor);

            // test the scene point 1.
            Primitive2D primitive = scene.Get(0);
            Assert.IsNotNull(primitive);
            Assert.IsInstanceOf<Primitive2D>(primitive);
            Point2D pointObject = primitive as Point2D;
            Assert.AreEqual(2, pointObject.Size);
            Assert.AreEqual(SimpleColor.FromKnownColor(KnownColor.Black).Value, pointObject.Color);
            Assert.AreEqual(mercator.LongitudeToX(1), pointObject.X);
            Assert.AreEqual(mercator.LatitudeToY(1), pointObject.Y);

            // test the scene point 2.
            primitive = scene.Get(1);
            Assert.IsNotNull(primitive);
            Assert.IsInstanceOf<Point2D>(primitive);
            pointObject = primitive as Point2D;
            Assert.AreEqual(2, pointObject.Size);
            Assert.AreEqual(SimpleColor.FromKnownColor(KnownColor.Black).Value, pointObject.Color);
            Assert.AreEqual(mercator.LongitudeToX(2), pointObject.X);
            Assert.AreEqual(mercator.LatitudeToY(2), pointObject.Y);

            // test the scene line 2.
            primitive = scene.Get(2);
            Assert.IsNotNull(primitive);
            Assert.IsInstanceOf<Line2D>(primitive);
            Line2D line = primitive as Line2D;
            Assert.AreEqual(1, line.Width);
            Assert.AreEqual(SimpleColor.FromKnownColor(KnownColor.Red).Value, line.Color);
            Assert.IsNotNull(line.X);
            Assert.IsNotNull(line.Y);
            Assert.AreEqual(2, line.X.Length);
            Assert.AreEqual(2, line.Y.Length);
            Assert.AreEqual(mercator.LongitudeToX(1), line.X[0]);
            Assert.AreEqual(mercator.LatitudeToY(1), line.Y[0]);
            Assert.AreEqual(mercator.LongitudeToX(2), line.X[1]);
            Assert.AreEqual(mercator.LatitudeToY(2), line.Y[1]);
        }
开发者ID:JoeCooper,项目名称:ui,代码行数:83,代码来源:MapCSSInterpretationTests.cs

示例13: Create

        private void Create(Way way)
        {
            OracleCommand command;

            DateTime? timestamp = way.TimeStamp;
            string timestamp_str = timestamp.Value.ToString("HH:mm dd/MM/yyyy");

            command = this.CreateCommand(string.Format(
                "insert into way (id,changeset_id,timestamp,visible,version,usr,usr_id) values (:id,:changeset_id,to_date('{0}','HH24:MI DD/MM/YYYY'),:visible,:version,:usr,:usr_id)",
                timestamp_str));

            // format data and create parameters.
            long? id = way.Id;
            command.Parameters.Add(new OracleParameter("id", id.ConvertToDBValue<long>()));

            long? changeset_id = way.ChangeSetId;
            command.Parameters.Add(new OracleParameter("changeset_id", changeset_id.ConvertToDBValue<long>()));

            bool? visible = way.Visible;
            int visible_int = 1;
            if (!visible.HasValue)
            {
                visible_int = 0;
            }
            command.Parameters.Add(new OracleParameter("visible", visible_int));

            long? version = (long)way.Version;
            command.Parameters.Add(new OracleParameter("version", version.ConvertToDBValue<long>()));

            command.Parameters.Add("usr", way.UserName);
            command.Parameters.Add("usr_id", way.UserId);

            command.ExecuteNonQuery();
            command.Dispose();

            // insert tags.
            this.CreateTags(way.Id.Value, way.Tags, "way_tags", "way_id");

            // insert way_nodes.
            this.CreateWayNodes(way.Id.Value, way.Nodes);
        }
开发者ID:vcotlearov,项目名称:OsmSharp,代码行数:41,代码来源:OracleOsmChangesetStreamTarget.cs

示例14: AddWay

        /// <summary>
        /// Adds a way.
        /// </summary>
        /// <param name="way"></param>
        public void AddWay(Way way)
        {
            if (way == null) throw new ArgumentNullException();
            if (!way.Id.HasValue) throw new ArgumentException("Ways without a valid id cannot be saved!");

            _ways[way.Id.Value] = way;

            if(way.Nodes != null)
            {
                foreach(long nodeId in way.Nodes)
                {
                    HashSet<long> wayIds;
                    if (!_waysPerNode.TryGetValue(nodeId, out wayIds))
                    {
                        wayIds = new HashSet<long>();
                        _waysPerNode.Add(nodeId, wayIds);
                    }
                    wayIds.Add(way.Id.Value);
                }
            }
        }
开发者ID:robert-hickey,项目名称:OsmSharp,代码行数:25,代码来源:MemoryDataSource.cs

示例15: APITestWayCreateGetDelete

        public void APITestWayCreateGetDelete()
        {
            // intialize the connection.
            var apiInstance = new APIConnection("http://api06.dev.openstreetmap.org/",
                "osmsharp", "osmsharp");

            // open a changeset.
            apiInstance.ChangeSetOpen("Simple Way Creation Test");

            // initialize the way.
            var way = new Way();
            way.Tags = new TagsCollection();
            way.Tags.Add("type", "testway");
            way.Nodes = new List<long>();
            way.Visible = true;

            // initialize the nodes.
            var node = new Node();
            node.Latitude = -0.494497;
            node.Longitude = -24.119325;
            node.Tags = new TagsCollection();
            node.Tags.Add("type", "testnode1");
            node.Visible = true;
            node = apiInstance.NodeCreate(node);
            way.Nodes.Add(node.Id.Value);
            node = new Node();
            node.Latitude = -0.494497 + 0.0001f;
            node.Longitude = -24.119325 + 0.0001f;
            node.Tags = new TagsCollection();
            node.Tags.Add("type", "testnode2");
            node.Visible = true;
            node = apiInstance.NodeCreate(node);
            way.Nodes.Add(node.Id.Value);

            // save the way.
            way = apiInstance.WayCreate(way);

            // close the changeset.
            apiInstance.ChangeSetClose();

            // check if the id now has a value.
            Assert.IsTrue(way.Id.HasValue);

            // get the new way id.
            long wayId = way.Id.Value;

            // get the way again: a way can only be deleted using the correct changesetid and version.
            way = apiInstance.WayGet(way.Id.Value);

            // open new changeset.
            apiInstance.ChangeSetOpen("Simple Way Delete Test");

            // get the way.
            apiInstance.WayDelete(way);

            // close the current changeset.
            apiInstance.ChangeSetClose();

            // get the way.
            Way apiWay = apiInstance.WayGet(way.Id.Value);
            Assert.IsNull(apiWay);
        }
开发者ID:UnifyKit,项目名称:OsmSharp,代码行数:62,代码来源:APITests.cs


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