Beispiel #1
0
        public static BHX.Building ToGBXML(this BHE.Building building)
        {
            BHX.Building gbBuilding = new BHX.Building();

            gbBuilding.Name = building.Name;

            BHP.BuildingContextFragment context = building.FindFragment <BHP.BuildingContextFragment>(typeof(BHP.BuildingContextFragment));

            if (context != null)
            {
                gbBuilding.StreetAddress = context.PlaceName;
            }

            XMLBuildingType fragment = building.FindFragment <XMLBuildingType>(typeof(XMLBuildingType));

            if (fragment != null)
            {
                gbBuilding.BuildingType = fragment.Type;
            }

            if (gbBuilding.BuildingType == "")
            {
                gbBuilding.BuildingType = "Unknown";
            }

            return(gbBuilding);
        }
Beispiel #2
0
        public static BHE.Building ToBHoM(this BHX.Building gbBuilding)
        {
            BHE.Building building = new BHE.Building();

            building.Name = gbBuilding.Name;
            BHP.BuildingContextFragment props = new BHP.BuildingContextFragment();
            props.PlaceName = gbBuilding.StreetAddress;
            building.Fragments.Add(props);
            building.CustomData.Add("Building Name", gbBuilding.BuildingType);

            return(building);
        }
Beispiel #3
0
        public static BHE.Building FromTAS(this TBD.Building tbdBuilding)
        {
            BHE.Building building = new BHE.Building();
            building.Name = tbdBuilding.name;
            building.Location.Latitude  = tbdBuilding.latitude;
            building.Location.Longitude = tbdBuilding.longitude;
            building.Elevation          = tbdBuilding.maxBuildingAltitude;
            //building.Elevation = tbdBuilding.GetWeatherYear().altitude; //Consider switching to this if maxBuildingAltitude does not work

            //EnvironmentContextProperties
            BHP.OriginContextFragment environmentContextProperties = new BHP.OriginContextFragment();
            environmentContextProperties.ElementID   = tbdBuilding.GUID.RemoveBrackets();
            environmentContextProperties.Description = tbdBuilding.description;
            environmentContextProperties.TypeName    = tbdBuilding.name;
            building.Fragments.Add(environmentContextProperties);

            //BuildingAnalyticalProperties
            BHP.BuildingAnalyticalFragment buildingAnalyticalProperties = new BHP.BuildingAnalyticalFragment();
            buildingAnalyticalProperties.NorthAngle = tbdBuilding.northAngle; //North Angle (degrees) Measured clockwise with respect to the Y - axis of the building plan.
            buildingAnalyticalProperties.Year       = tbdBuilding.year;
            buildingAnalyticalProperties.GMTOffset  = tbdBuilding.timeZone;
            building.Fragments.Add(buildingAnalyticalProperties);

            //BuildingContextProperties
            TBD.WeatherYear weatherYear = tbdBuilding.GetWeatherYear();
            if (weatherYear != null)
            {
                BHP.BuildingContextFragment buildingContextProperties = new BHP.BuildingContextFragment();
                buildingContextProperties.PlaceName      = weatherYear.name;
                buildingContextProperties.WeatherStation = weatherYear.description;
                building.Fragments.Add(buildingContextProperties);
            }

            //BuildingResultsProperties
            BHP.BuildingResultFragment buildingResultsProperties = new BHP.BuildingResultFragment();
            buildingResultsProperties.PeakCooling = tbdBuilding.peakCooling;
            buildingResultsProperties.PeakHeating = tbdBuilding.peakHeating;
            building.Fragments.Add(buildingResultsProperties);

            //Extended Properties

            TASBuilding tasData = new TASBuilding();

            tasData.ID       = tbdBuilding.GUID.RemoveBrackets();
            tasData.TASID    = tbdBuilding.TBDGUID;
            tasData.PathFile = tbdBuilding.path3DFile;
            building.Fragments.Add(tasData);

            return(building);
        }
Beispiel #4
0
        public static BHE.Building FromGBXML(this BHX.Location location)
        {
            BHE.Building building = new oM.Environment.Elements.Building();

            building.Elevation          = location.Elevation;
            building.Location.Longitude = location.Longitude;
            building.Location.Latitude  = location.Latitude;

            BHP.BuildingContextFragment props = new BHP.BuildingContextFragment();
            props.PlaceName      = location.Name;
            props.WeatherStation = location.StationID.ID;
            building.Fragments.Add(props);

            return(building);
        }
Beispiel #5
0
        public static BHE.Building FromGBXML(this BHX.Building gbBuilding)
        {
            BHE.Building building = new BHE.Building();

            building.Name = gbBuilding.Name;
            BHP.BuildingContextFragment props = new BHP.BuildingContextFragment();
            props.PlaceName = gbBuilding.StreetAddress;
            building.Fragments.Add(props);
            XMLBuildingType fragment = new XMLBuildingType();

            fragment.Type = gbBuilding.BuildingType;
            building.Fragments.Add(fragment);

            return(building);
        }
Beispiel #6
0
        public static BHX.Location ToGBXMLLocation(this BHE.Building building, GBXMLSettings settings)
        {
            BHX.Location location = new BHX.Location();
            location.Longitude = Math.Round(building.Location.Longitude, settings.RoundingSettings.BuildingLocation);
            location.Latitude  = Math.Round(building.Location.Latitude, settings.RoundingSettings.BuildingLocation);
            location.Elevation = Math.Round(building.Elevation, settings.RoundingSettings.BuildingLocation);

            BHP.BuildingContextFragment context = building.FindFragment <BHP.BuildingContextFragment>(typeof(BHP.BuildingContextFragment));

            if (context != null)
            {
                location.Name         = context.PlaceName;
                location.StationID.ID = context.WeatherStation;
            }

            return(location);
        }
Beispiel #7
0
        public static BHX.Building ToGBXML(this BHE.Building building)
        {
            BHX.Building gbBuilding = new BHX.Building();

            gbBuilding.Name = building.Name;

            BHP.BuildingContextFragment context = building.FindFragment <BHP.BuildingContextFragment>(typeof(BHP.BuildingContextFragment));

            if (context != null)
            {
                gbBuilding.StreetAddress = context.PlaceName;
            }

            if (building.CustomData.ContainsKey("Building Name"))
            {
                gbBuilding.BuildingType = (building.CustomData["Building Name"]).ToString();
            }

            return(gbBuilding);
        }
Beispiel #8
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static void SerializeCollection(IEnumerable <Building> inputBuildings, BH.oM.XML.GBXML gbx, XMLSettings settings)
        {
            List <Building> buildings = inputBuildings.ToList();

            gbx.Campus.Building = new oM.XML.Building[buildings.Count];
            for (int x = 0; x < buildings.Count; x++)
            {
                gbx.Campus.Building[x] = buildings[x].ToGBXML();
                gbx.Campus.Location    = buildings[x].ToGBXMLLocation();

                BHP.BuildingContextFragment props = buildings[x].FindFragment <BHP.BuildingContextFragment>(typeof(BHP.BuildingContextFragment));
                if (props != null)
                {
                    gbx.Campus.Building[x].StreetAddress = props.PlaceName;
                }

                if (buildings[x].CustomData.ContainsKey("Building Name"))
                {
                    gbx.Campus.Building[x].BuildingType = (buildings[x].CustomData["Building Name"]).ToString();
                }
            }
        }