Exemple #1
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);
        }
Exemple #2
0
        public static TBD.Building ToTAS(this BHE.Building building, TBD.Building tbdBuilding)
        {
            //TODO:Add BuildingHeightAdjustmentFactor, MeanHeightOfSurroundings, TerrainType, NumberOfPreconditioningDays, GroundSolarReflectance, ExternalPollutant
            //TODO:Check if Longitude, Latitude, NorthAngle, Timezone, Path3Dfile, BuildingYear is pushed

            if (building == null)
            {
                return(tbdBuilding);
            }

            tbdBuilding.name                = building.Name;
            tbdBuilding.latitude            = (float)building.Location.Latitude;
            tbdBuilding.longitude           = (float)building.Location.Longitude;
            tbdBuilding.maxBuildingAltitude = (float)building.Elevation;

            TASBuilding tasFragment = building.FindFragment <TASBuilding>(typeof(TASBuilding));

            if (tasFragment != null)
            {
                tbdBuilding.GUID       = tasFragment.ID;
                tbdBuilding.TBDGUID    = tasFragment.TASID;
                tbdBuilding.path3DFile = tasFragment.PathFile;
            }

            BHP.OriginContextFragment environmentContextFragment = new BHP.OriginContextFragment();
            if (environmentContextFragment != null)
            {
                tbdBuilding.description = environmentContextFragment.Description;
            }

            BHP.BuildingResultFragment buildingResultsFragment = building.FindFragment <BHP.BuildingResultFragment>(typeof(BHP.BuildingResultFragment));
            if (buildingResultsFragment != null)
            {
                tbdBuilding.peakCooling = (float)System.Convert.ToDouble(buildingResultsFragment.PeakCooling);
                tbdBuilding.peakHeating = (float)System.Convert.ToDouble(buildingResultsFragment.PeakHeating);
            }

            BHP.BuildingAnalyticalFragment analyticalFragment = building.FindFragment <BHP.BuildingAnalyticalFragment>(typeof(BHP.BuildingAnalyticalFragment));
            if (analyticalFragment != null)
            {
                tbdBuilding.northAngle = (float)System.Convert.ToDouble(analyticalFragment.NorthAngle);
                tbdBuilding.timeZone   = (float)System.Convert.ToDouble(analyticalFragment.GMTOffset);
            }

            return(tbdBuilding);
        }