本文整理汇总了C#中OsmSharp.Osm.Xml.Streams.XmlOsmStreamSource.Current方法的典型用法代码示例。如果您正苦于以下问题:C# XmlOsmStreamSource.Current方法的具体用法?C# XmlOsmStreamSource.Current怎么用?C# XmlOsmStreamSource.Current使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsmSharp.Osm.Xml.Streams.XmlOsmStreamSource
的用法示例。
在下文中一共展示了XmlOsmStreamSource.Current方法的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();
}