Skip to content

Commit

Permalink
Extracted more CityGml data Issue#386 Issue#356 (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas-Nan authored Jul 14, 2024
2 parents 7a7b6d6 + 9c644d2 commit a93a738
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 4 deletions.
3 changes: 3 additions & 0 deletions backend/src/BIE.DataPipeline/DbHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,12 @@ Id INT PRIMARY KEY IDENTITY(1,1),
DistrictKey VARCHAR(255),
CheckDate DATE,
GroundArea FLOAT,
BuildingVolume FLOAT,
BuildingWallHeight FLOAT,
WallArea FLOAT,
LivingArea FLOAT,
RoofArea FLOAT,
SolarPotential FLOAT,
);
END";
}
Expand Down
74 changes: 72 additions & 2 deletions backend/src/BIE.DataPipeline/Import/CityGmlImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,24 @@ public bool ReadLine(out string nextLine)
string checkDate = GetBuildingCheckDate(buildingNode);
float groundArea = GetBuildingGroundArea(buildingNode);
float buildingWallHeight = GetBuildingWallHeight(buildingNode);
float wallArea = GetWallArea(buildingNode);
float buildingVolume = GetBuildingVolume(buildingNode, groundArea, buildingWallHeight);
float livingArea = GetLivingArea(buildingNode, groundArea, buildingWallHeight);
float roofArea = GetRoofArea(buildingNode);
float solarPotential = GetSolarPotential(buildingNode, roofArea);

nextLine = $"geometry::STGeomFromText('{geometry.AsText()}', 4326)";
nextLine += string.Format(",'{0}'", buildingNode.InnerXml);
nextLine += string.Format(",'{0}'", groundHeight.ToString(culture));
nextLine += string.Format(",'{0}'", districtKey);
nextLine += string.Format(",'{0}'", checkDate);
nextLine += string.Format(",{0}", groundArea.ToString(culture));
nextLine += string.Format(",{0}", buildingVolume.ToString(culture));
nextLine += string.Format(",{0}", buildingWallHeight.ToString(culture));
nextLine += string.Format(",{0}", wallArea.ToString(culture));
nextLine += string.Format(",{0}", livingArea.ToString(culture));
nextLine += string.Format(",{0}", roofArea.ToString(culture));
nextLine += string.Format(",{0}", solarPotential.ToString(culture));

this.buildingIndex++;
return true;
Expand Down Expand Up @@ -307,18 +313,59 @@ private float GetBuildingGroundArea(XmlNode buildingNode)
return res;
}

private float GetBuildingVolume(XmlNode buildingNode, float groundArea, float wallHeight)
{
float wallVolume = groundArea * wallHeight;
float roofHeight = GetBuildingRoofHeight(buildingNode);
float averageRoofAngle = GetAverageRoofAngle(buildingNode);
float roofFactor = (1 - (averageRoofAngle / 90)); //scale the averageRoofange between 0 and 1 where 0 is 90 degress (flat roof) and 1 is 0 degree (steep roof)
float roofVolume = groundArea * roofHeight * roofFactor;
return wallVolume + roofVolume;
}

private float GetBuildingRoofHeight(XmlNode buildingNode)
{
float niedrigsteTraufeDesGebaeudes = GetStringAttributeValue(buildingNode, "NiedrigsteTraufeDesGebaeudes");
float hoeheDach = GetStringAttributeValue(buildingNode, "HoeheDach");
if (hoeheDach == -1 || niedrigsteTraufeDesGebaeudes == -1)
{
return -1;
}
else
{
return hoeheDach - niedrigsteTraufeDesGebaeudes;
}
}

private float GetBuildingWallHeight(XmlNode buildingNode)
{
float hoeheGrund = GetStringAttributeValue(buildingNode, "HoeheGrund");
float niedrigsteTraufeDesGebaeudes = GetStringAttributeValue(buildingNode, "NiedrigsteTraufeDesGebaeudes");
if(hoeheGrund == -1 || niedrigsteTraufeDesGebaeudes == -1)
float hoeheDach = GetStringAttributeValue(buildingNode, "HoeheDach");
if(hoeheGrund == -1 || niedrigsteTraufeDesGebaeudes == -1 || hoeheDach == -1)
{
return -1;
}
else
{
return niedrigsteTraufeDesGebaeudes - hoeheGrund;
return ((niedrigsteTraufeDesGebaeudes - hoeheGrund) + (hoeheDach - hoeheGrund)) / 2f;
}
}

private float GetWallArea(XmlNode buildingNode)
{
XmlNodeList wallNodes = buildingNode.SelectNodes(".//bldg:WallSurface", this.nsmgr);
float wallArea = 0;
foreach (XmlNode wallNode in wallNodes)
{
float wallTileArea = GetStringAttributeValue(wallNode, "Flaeche");
if (wallTileArea != -1)
{
wallArea += wallTileArea;
}
}

return wallArea;
}

private float GetLivingArea(XmlNode buildingNode, float groundArea, float buildingWallHeight)
Expand All @@ -332,6 +379,24 @@ private float GetLivingArea(XmlNode buildingNode, float groundArea, float buildi
return groundArea * (float)Math.Ceiling(buildingWallHeight / averageFloorHeight);
}

private float GetAverageRoofAngle(XmlNode buildingNode)
{
XmlNodeList roofNodes = buildingNode.SelectNodes(".//bldg:RoofSurface", this.nsmgr);
float roofAngle = 0;
float numAngle = 0;
foreach (XmlNode roofNode in roofNodes)
{
float roofTileAngle = GetStringAttributeValue(roofNode, "Dachneigung");
if (roofTileAngle != -1)
{
numAngle++;
roofAngle += roofTileAngle;
}
}

return roofAngle / numAngle;
}

private float GetRoofArea(XmlNode buildingNode)
{
XmlNodeList roofNodes = buildingNode.SelectNodes(".//bldg:RoofSurface", this.nsmgr);
Expand Down Expand Up @@ -389,5 +454,10 @@ private float ParseArea(XmlNode node)

return result;
}

private float GetSolarPotential(XmlNode node, float roofArea)
{
return roofArea * 0.5f; //dummy function
}
}
}
3 changes: 1 addition & 2 deletions backend/src/BIE.DataPipeline/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@

case "CITYGML":
importer = new CityGmlImporter(description, dbHelper);
dbHelper.SetInfo(description.table_name,
"Location, XmlData, GroundHeight, DistrictKey, CheckDate, GroundArea, BuildingWallHeight, LivingArea, RoofArea");
dbHelper.SetInfo(description.table_name, "Location, XmlData, GroundHeight, DistrictKey, CheckDate, GroundArea, BuildingVolume, BuildingWallHeight, WallArea, LivingArea, RoofArea, SolarPotential");
break;

default:
Expand Down

0 comments on commit a93a738

Please sign in to comment.