Extract all SpatialZones of a given type for a Bundle
Feature Group: Extract | PostgreSQL
Extraction of all SpatialZones
The intent is to extract in bulk all defined Apartments, Commons, Parkings,... from a bundle
By All SpatialZones of a given type, it is meant all Units of a Bundle that have been defined as a SpatialZone using one of the following types:
- IfcSpatialZone (preferred)
- IfcBuildingStorey
- IfcZone
- IfcGroup
- IfcSpace
Submit the processing request
The extract is started by sending a POST with a Json Body as defined in pydantic with:
- the bundleId (bundle_id in PostgreSQL) of the bundle that contains the data of the IfcJSON from the conversion of the IFC file
- the choice of using or not the useRepresentationsCache for each unit
- the elementType as listed hereunder
- withIFC as True or False; if True, an IFC will also be produced
#
# Extract all spatial units from an IFC
#
class ExtractAllSpatialUnits_Instruction(BaseModel):
bundleId: str | None = "1"
useRepresentationsCache: bool | None = False
elementType: Literal['IfcBuildingStorey', 'IfcZone', 'IfcSpatialZone', 'IfcSpace', 'IfcGroup'] | None = 'IfcSpatialZone'
withIFC: bool | None = True
@computed_field()
def includeRelationshipTypes(self) -> list[str]:
if self.elementType == 'IfcBuildingStorey':
return ['IfcRelAggregates','IfcRelContainedInSpatialStructure','IfcRelFillsElement','IfcRelVoidsElement']
elif self.elementType == 'IfcSpatialZone' or self.elementType == 'IfcSpace':
return ['IfcRelAggregates','IfcRelContainedInSpatialStructure','IfcRelFillsElement','IfcRelVoidsElement','IfcRelSpaceBoundary','IfcRelReferencedInSpatialStructure']
elif self.elementType == 'IfcZone' or self.elementType == 'IfcGroup':
return ['IfcRelAggregates','IfcRelContainedInSpatialStructure','IfcRelFillsElement','IfcRelVoidsElement','IfcRelSpaceBoundary','IfcRelReferencedInSpatialStructure']
else:
return ['IfcRelAggregates','IfcRelContainedInSpatialStructure','IfcRelFillsElement','IfcRelVoidsElement']
class ExtractAllSpatialUnits_ResultItem(BaseModel):
unitId: str
result: dict[
ExtractSpatialUnit_Result | None ,
ConvertIfcJsonToIfc_Result | None
]
class ExtractAllSpatialUnits_Result(BaseModel):
result: list[ExtractAllSpatialUnits_ResultItem]
Processing
The processing is done by using a Celery Workflow of type chord
This type of workflow makes it possible to execute all extractions in parallel and then journalize and notify the result when all parallel tasks have individually completed or failed.
%%{init: {"flowchart": {"htmlLabels": true}} }%%
flowchart
direction TB
start
subgraph fastapi ["header"]
direction TB
task-1
task-2
task-n
end
callback
start --> task-1
start --> task-2
start --> task-n
task-1 --> callback
task-2 --> callback
task-n --> callback
So, the total processing time is the runtime of the longest running task and not the sum of all runtimes.