public List <StreetSegment> CreateStreetSegments(List <Way> OsmStreets, Dictionary <long?, OsmGeo> allNodes) { var boundLines = this.geometryService.CreateBoundingLines(); List <StreetSegment> streetSegments = new List <StreetSegment>(); foreach (var osmStreet in OsmStreets) { var points = new List <XYZ>(); foreach (var nodeId in osmStreet.Nodes) { var geometry = allNodes[nodeId]; if (geometry is Node node) { var coords = coordService.GetRevitCoords((double)node.Latitude, (double)node.Longitude); points.Add(coords); } } for (int i = 0; i < points.Count - 1; i++) { var start = points[i]; var end = points[i + 1]; if (!geometryService.IsInsideBounds(boundLines, start) && !geometryService.IsInsideBounds(boundLines, end)) { continue; } var line = Line.CreateBound(points[i], points[i + 1]); var segment = new StreetSegment(); segment.Id = (long)osmStreet.Id; segment.SegmentId = osmStore.MoveNextId(); segment.Line = line; segment.Width = osmStore.DefaultStreetWidth; if (osmStreet.Tags.TryGetValue("name", out string name)) { segment.Name = name; } streetSegments.Add(segment); } } return(streetSegments); }
public List <StreetSegment> CreateStreetSegments(List <Way> OsmStreets, Dictionary <long?, OsmGeo> allNodes) { var boundLines = this.geometryService.CreateBoundingLines(); List <StreetSegment> streetSegments = new List <StreetSegment>(); foreach (var osmStreet in OsmStreets) { var points = this.geometryService.GetPointsFromNodes(osmStreet.Nodes, allNodes); if (points == null) { continue; } for (int i = 0; i < points.Count - 1; i++) { var start = points[i]; var end = points[i + 1]; if (!geometryService.IsInsideBounds(boundLines, start) && !geometryService.IsInsideBounds(boundLines, end)) { continue; } var line = Line.CreateBound(points[i], points[i + 1]); var segment = new StreetSegment(); segment.Id = (long)osmStreet.Id; segment.SegmentId = osmStore.MoveNextId(); segment.Line = line; segment.Width = osmStore.DefaultStreetWidth; if (osmStreet.Tags.TryGetValue("name", out string name)) { segment.Name = name; } streetSegments.Add(segment); } } return(streetSegments); }