Skip to content

Commit d911c58

Browse files
committed
handle vertical datums correctly
1 parent 5c1356c commit d911c58

3 files changed

Lines changed: 51 additions & 3 deletions

File tree

features/rules/GRF/GRF007_valid-vertical-datum-crs-type.feature

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
@implementer-agreement
22
@GRF
3-
@version1
3+
@version2
44
Feature: GRF007 - Valid vertical datum CRS type
5-
The rule verifies that any coordinate reference system (CRS) assigned as a vertical datum is either a vertical CRS or a compound CRS containing a vertical component, to ensure valid height referencing.
5+
The rule verifies that any coordinate reference system (CRS) or datum assigned as a vertical datum is either a vertical CRS,
6+
a compound CRS containing a vertical component, or a vertical datum, to ensure valid height referencing.
67
https://pyproj4.github.io/pyproj/stable/api/crs/crs.html
8+
https://pyproj4.github.io/pyproj/stable/api/crs/datum.html
79

810

911
Scenario: WKT specification for missing EPSG in the name

features/steps/steps/crs.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from math import isclose
22
from pyproj.database import query_crs_info
33
from pyproj import CRS
4+
from pyproj.crs import Datum
5+
from pyproj.enums import WktVersion
46
from validation_handling import gherkin_ifc
57
import ifcopenshell.util.unit as unit
68

@@ -23,7 +25,18 @@ def step_impl(context, inst):
2325
if crs.is_compound or crs.is_vertical:
2426
yield ValidationOutcome(inst=inst, severity=OutcomeSeverity.PASSED)
2527
else:
26-
yield ValidationOutcome(inst=inst, severity=OutcomeSeverity.ERROR)
28+
# IfcProjectedCRS.VerticalDatum can also be just a vertical datum - doesn't need to be a full CRS definition
29+
# example: https://epsg.io/5127-datum
30+
if str(inst[:5]) == "EPSG:":
31+
epsg_code = int(inst.split(":")[1])
32+
vdatum = Datum.from_epsg(epsg_code)
33+
else:
34+
vdatum = Datum.from_string(inst)
35+
wkt_repr = vdatum.to_wkt(version=WktVersion.WKT2_2019)
36+
if wkt_repr.split("[")[0] == "VDATUM":
37+
yield ValidationOutcome(inst=inst, severity=OutcomeSeverity.PASSED)
38+
else:
39+
yield ValidationOutcome(inst=inst, severity=OutcomeSeverity.ERROR)
2740

2841

2942

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
ISO-10303-21;
2+
HEADER;
3+
FILE_DESCRIPTION(('ViewDefinition [ReferenceView]'),'2;1');
4+
FILE_NAME('fail-grf007-invalid_vertical_datum_espg_code.ifc','2023-01-25T18:40:40',(''),(''),'','redacted - redacted - v3.14159','');
5+
FILE_SCHEMA(('IFC4X3_ADD2'));
6+
ENDSEC;
7+
DATA;
8+
#1=IFCPERSON($,$,'',$,$,$,$,$);
9+
#2=IFCORGANIZATION($,'',$,$,$);
10+
#3=IFCPERSONANDORGANIZATION(#1,#2,$);
11+
#4=IFCAPPLICATION(#2,'redacted','redacted','');
12+
#5=IFCOWNERHISTORY(#3,#4,$,.NOCHANGE.,$,#3,#4,1674672040);
13+
#6=IFCDIRECTION((1.,0.,0.));
14+
#7=IFCDIRECTION((0.,0.,1.));
15+
#8=IFCCARTESIANPOINT((0.,0.,0.));
16+
#9=IFCAXIS2PLACEMENT3D(#8,#7,#6);
17+
#10=IFCDIRECTION((0.,1.));
18+
#11=IFCGEOMETRICREPRESENTATIONCONTEXT($,'Model',3,1.E-05,#9,#10);
19+
#12=IFCDIMENSIONALEXPONENTS(0,0,0,0,0,0,0);
20+
#13=IFCSIUNIT(*,.LENGTHUNIT.,$,.METRE.);
21+
#14=IFCSIUNIT(*,.AREAUNIT.,$,.SQUARE_METRE.);
22+
#15=IFCSIUNIT(*,.VOLUMEUNIT.,$,.CUBIC_METRE.);
23+
#16=IFCSIUNIT(*,.PLANEANGLEUNIT.,$,.RADIAN.);
24+
#17=IFCMEASUREWITHUNIT(IFCPLANEANGLEMEASURE(0.017453292519943295),#16);
25+
#18=IFCCONVERSIONBASEDUNIT(#12,.PLANEANGLEUNIT.,'DEGREE',#17);
26+
#19=IFCUNITASSIGNMENT((#13,#14,#15,#18));
27+
#20=IFCPROJECT('2X9wjf5oPB4PQjenCYrhHZ',#5,'',$,$,$,$,(#11),#19);
28+
#21=IFCPROJECTEDCRS('EPSG:2056','CH1903+ / LV95; heights in LN02 (EPSG:5728)','EPSG:6150','EPSG:6150','Swiss Oblique Mercator 1995',$,#13);
29+
#22=IFCMAPCONVERSION(#11,#21,316131.64,5690966.11,1.,1.,0.,$);
30+
#23=IFCGEOMETRICREPRESENTATIONCONTEXT($,'Model',3,1.E-05,#9,#10);
31+
#24=IFCMAPCONVERSION(#23,#21,316131.64,5690966.11,1.,1.,0.,$);
32+
ENDSEC;
33+
END-ISO-10303-21;

0 commit comments

Comments
 (0)