Canonicalize a map-unit label to the spelling the rest of this module
compares against: American METER to METRE, the foot spellings to FOOT,
the US survey foot to US SURVEY FOOT, and an SI prefix kept rather than
swallowed. Anything not recognised is returned normalised-but-unchanged, for
the caller to REFUSE rather than guess at.
The label is NORMALISED and then matched EXACTLY — never substring-matched.
What the normalisation accepts:
any case and any separators: metres, Meters, MILLI-METRE;
METRE and METER, each carrying any IfcSIPrefix member;
FOOT and FEET;
one English plural suffix, stripped once and re-matched exactly;
the US survey foot, glued or separated in any word order.
What it REFUSES, by leaving the label alone so resolveMapUnitReference
returns null and MapUnit stays $ with a warning:
a label that merely CONTAINS a unit. MILLIMETRE, CENTIMETRE and
KILOMETRE all contain METRE, and an includes('METRE') test wrote all
three into the file as a plain .METRE. — a silent 1000x error in the CRS
scale (#3274). The foot half of that same test was includes('FOOT'), and
it was satisfied by FOOTCANDLE (an illuminance), FOOT-POUND (an
energy), FOOTPRINT, and by SQUARE FOOT and CUBIC FEET — an area and
a volume written as a LENGTH unit, which is a wrong DIMENSION rather than
a wrong magnitude, and no scale factor can be right for it;
a survey foot with no nationality: SURVEY FOOT, CLARKE'S FOOT,
INDIAN FOOT, SEARS FOOT, BRITISH FOOT (1936) are five different
ratios, and includes('FOOT') gave every one of them the international
0.3048;
INCH, YARD, MILE and anything else this exporter cannot express.
Normalising a recognisable spelling onto a table entry is NOT that
approximation: the answer is still one exact table hit, so MILLIMETERS
resolves to MILLIMETRE and not to METRE.
Sibling of inferMapUnitScaleFromLabel in
packages/parser/src/map-unit-label.ts and infer_map_unit_scale in
rust/core/src/unit_labels.rs, which apply these same rules on the reading
side. This exporter's accepted set is the smaller one — it writes only what
it can express as an IfcNamedUnit — but no spelling may be accepted here
that those refuse, or refused here that those accept as a length.
Canonicalize a map-unit label to the spelling the rest of this module compares against: American
METERtoMETRE, the foot spellings toFOOT, the US survey foot toUS SURVEY FOOT, and an SI prefix kept rather than swallowed. Anything not recognised is returned normalised-but-unchanged, for the caller to REFUSE rather than guess at.The label is NORMALISED and then matched EXACTLY — never substring-matched.
What the normalisation accepts:
metres,Meters,MILLI-METRE;METREandMETER, each carrying anyIfcSIPrefixmember;FOOTandFEET;What it REFUSES, by leaving the label alone so
resolveMapUnitReferencereturnsnullandMapUnitstays$with a warning:MILLIMETRE,CENTIMETREandKILOMETREall containMETRE, and anincludes('METRE')test wrote all three into the file as a plain.METRE.— a silent 1000x error in the CRS scale (#3274). The foot half of that same test wasincludes('FOOT'), and it was satisfied byFOOTCANDLE(an illuminance),FOOT-POUND(an energy),FOOTPRINT, and bySQUARE FOOTandCUBIC FEET— an area and a volume written as a LENGTH unit, which is a wrong DIMENSION rather than a wrong magnitude, and no scale factor can be right for it;SURVEY FOOT,CLARKE'S FOOT,INDIAN FOOT,SEARS FOOT,BRITISH FOOT (1936)are five different ratios, andincludes('FOOT')gave every one of them the international 0.3048;INCH,YARD,MILEand anything else this exporter cannot express.Normalising a recognisable spelling onto a table entry is NOT that approximation: the answer is still one exact table hit, so
MILLIMETERSresolves toMILLIMETREand not toMETRE.Sibling of
inferMapUnitScaleFromLabelin packages/parser/src/map-unit-label.ts andinfer_map_unit_scalein rust/core/src/unit_labels.rs, which apply these same rules on the reading side. This exporter's accepted set is the smaller one — it writes only what it can express as anIfcNamedUnit— but no spelling may be accepted here that those refuse, or refused here that those accept as a length.