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


C# XmlOsmStreamSource.MoveNextWay方法代码示例

本文整理汇总了C#中OsmSharp.Osm.Xml.Streams.XmlOsmStreamSource.MoveNextWay方法的典型用法代码示例。如果您正苦于以下问题:C# XmlOsmStreamSource.MoveNextWay方法的具体用法?C# XmlOsmStreamSource.MoveNextWay怎么用?C# XmlOsmStreamSource.MoveNextWay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OsmSharp.Osm.Xml.Streams.XmlOsmStreamSource的用法示例。


在下文中一共展示了XmlOsmStreamSource.MoveNextWay方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getBuildingsAndLanduses

        /// <summary>
        /// Sets all the info about the buildings and landuses into their lists
        /// </summary>
        private void getBuildingsAndLanduses() {
            FileInfo fileInfo = new FileInfo(OSMFILE);
            XmlOsmStreamSource xmlSource = new XmlOsmStreamSource(fileInfo.OpenRead());
            xmlSource.Initialize();

            while (xmlSource.MoveNextWay()) {
                OsmSharp.Osm.Way way = (OsmSharp.Osm.Way)xmlSource.Current();
                if ((way != null) && (way.Visible.HasValue) && (bool)(way.Visible) && (way.Tags != null)) {

                    // Info about buildings
                    if (way.Tags.ContainsKey("building")) {
                        List<long> buildingNodes = new List<long>();
                        int height = 10; // Standard height is 10
                        string amenity = "";

                        // Check amenity and if it is a church
                        if (way.Tags.ContainsKey("amenity")) {
                            amenity = way.Tags["amenity"];

                            if (amenity == "place_of_worship") height = 25;
                        }

                        // Check height
                        if (way.Tags.ContainsKey("height")) {
                            height = (int)(float.Parse(way.Tags["height"], System.Globalization.CultureInfo.InvariantCulture));
                        } else if (way.Tags.ContainsKey("building:levels")) {
                            string[] verdiepen = way.Tags["building:levels"].Split('-');
                            height = 3 * Convert.ToInt32(verdiepen[verdiepen.Length - 1]);
                            amenity = "apartment";
                        }

                        foreach (long id in way.Nodes) buildingNodes.Add(id);

                        buildings.Add(new Building(buildingNodes, height, amenity, ZOOM));
                    }

                    // Info about landuses
                    if (way.Tags.ContainsKey("landuse")) {
                        List<long> landuseNodes = new List<long>();
                        foreach (long id in way.Nodes) landuseNodes.Add(id);

                        landuses.Add(new Landuse(landuseNodes, 0, way.Tags["landuse"], ZOOM));
                    }
                }
            }

            xmlSource.Dispose();
        }
开发者ID:whztt07,项目名称:Osm3DBuildingGenerator,代码行数:51,代码来源:OsmData.cs


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