Ejemplo n.º 1
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document   doc   = uidoc.Document;

            ContainerStore.Registration <MapStreamHttpService>();

            var osmServie = ContainerStore.Resolve <OsmService>();

            using (Transaction t = new Transaction(doc, "Build City"))
            {
                t.Start();

                // -73.8513, 40.6796, -73.8386, 40.6890
                // -74.0533, 40.6804, -73.9976, 40.7124
                // Define the map bounding box
                var mapbounds = new MapBounds
                {
                    Left   = -73.8513,
                    Bottom = 40.6796,
                    Right  = -73.8386,
                    Top    = 40.6890
                };

                OsmStore.Geolocate(mapbounds);
                osmServie.Run(doc);

                t.Commit();
            }


            return(Result.Succeeded);
        }
Ejemplo n.º 2
0
        private static void GenerateRevitFile(DesignAutomationData daData)
        {
            var      rvtApp = daData.RevitApp;
            Document newDoc = rvtApp.NewProjectDocument(UnitSystem.Imperial) ?? throw new InvalidOperationException("Could not create new document.");

            var osmServie = ContainerStore.Resolve <OsmService>();

            using (Transaction t = new Transaction(newDoc, "Build City"))
            {
                t.Start();

                MapBounds mapBounds = MapBounds.Deserialize(File.ReadAllText(MapBoundsFile));
                OsmStore.Geolocate(mapBounds);
                osmServie.Run(newDoc);
                t.Commit();
            }

            newDoc.SaveAs(ResultFile);
        }
Ejemplo n.º 3
0
        private List <OsmGeo> GetOsmGeoListFromMapStreamService(MapBounds mapbounds)
        {
            List <OsmGeo> list = new List <OsmGeo>();

            if (mapbounds.IsLarge(false))
            {
                var split = mapbounds.Split(false);
                list.AddRange(GetOsmGeoListFromMapStreamService(split[0]));
                list.AddRange(GetOsmGeoListFromMapStreamService(split[1]));
            }
            else if (mapbounds.IsLarge(true))
            {
                var split = mapbounds.Split(true);
                list.AddRange(GetOsmGeoListFromMapStreamService(split[0]));
                list.AddRange(GetOsmGeoListFromMapStreamService(split[1]));
            }
            else
            {
                var streamService = ContainerStore.Resolve <IMapStreamService>();
                return(streamService.GetOsmGeoList(mapbounds));
            }

            return(list.GroupBy(n => n.Id).Select(g => g.First()).ToList());
        }