Exemplo n.º 1
0
        public TopographySurface Run(Document doc)
        {
            var bb0 = coordService.GetRevitCoords(osmStore.MapBottom, osmStore.MapLeft);
            var bb1 = coordService.GetRevitCoords(osmStore.MapTop, osmStore.MapLeft);
            var bb2 = coordService.GetRevitCoords(osmStore.MapTop, osmStore.MapRight);
            var bb3 = coordService.GetRevitCoords(osmStore.MapBottom, osmStore.MapRight);

            var points = new List <XYZ>()
            {
                bb0, bb1, bb2, bb3
            };

            var topography = TopographySurface.Create(doc, points);

            return(topography);
        }
Exemplo n.º 2
0
        private DirectShape RunBuilding(Document doc, Way building, Dictionary <long?, OsmGeo> allNodes)
        {
            var points = new List <XYZ>();

            foreach (var nodeId in building.Nodes)
            {
                var geometry = allNodes[nodeId];
                if (geometry is Node node)
                {
                    var coords = coordService.GetRevitCoords((double)node.Latitude, (double)node.Longitude);
                    points.Add(coords);
                }
            }

            var curveLoop = new CurveLoop();

            for (int i = 0; i < points.Count - 1; i++)
            {
                Line line = Line.CreateBound(points[i], points[i + 1]);
                curveLoop.Append(line);
            }

            var heightTag  = building.Tags.FirstOrDefault(tag => tag.Key == "height");
            var heightFeet = UnitUtils.ConvertToInternalUnits(3, DisplayUnitType.DUT_METERS);

            if (double.TryParse(heightTag.Value, out double heightMeters))
            {
                heightFeet = UnitUtils.ConvertToInternalUnits(heightMeters, DisplayUnitType.DUT_METERS);
            }

            return(shapeService.Build(doc, new List <CurveLoop> {
                curveLoop
            }, heightFeet, new ElementId(BuiltInCategory.OST_GenericModel)));
        }
Exemplo n.º 3
0
        public CurveLoop CreateBoundingLines()
        {
            var bb0 = coordService.GetRevitCoords(osmStore.MapBottom, osmStore.MapLeft);
            var bb1 = coordService.GetRevitCoords(osmStore.MapTop, osmStore.MapLeft);
            var bb2 = coordService.GetRevitCoords(osmStore.MapTop, osmStore.MapRight);
            var bb3 = coordService.GetRevitCoords(osmStore.MapBottom, osmStore.MapRight);

            var l0 = Line.CreateBound(bb0, bb1);
            var l1 = Line.CreateBound(bb1, bb2);
            var l2 = Line.CreateBound(bb2, bb3);
            var l3 = Line.CreateBound(bb3, bb0);

            var loop = new CurveLoop();
            loop.Append(l0);
            loop.Append(l1);
            loop.Append(l2);
            loop.Append(l3);

            return loop;
        }
Exemplo n.º 4
0
        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);
        }