SvgSerializer: emit IfcSpace area as a data-area attribute

--print-space-areas already computed the IfcSpace area for the visible
text label, but did not expose it as a machine-readable attribute on
the SVG group, forcing consumers to parse the label text. Reuse the
existing per-element data-name/data-guid attribute convention (also
namespaced via --svg-xmlns as ifc:area) to carry it.

Also fix the area label text double-escaping its "m²" entity:
IfcUtil::escape_xml() unconditionally escapes "&", so the pre-encoded
entity was turned into the literal "m²" once the label passed
through escaping. Emit the raw UTF-8 bytes for U+00B2 instead, which
are not affected by XML escaping.

Generated with the assistance of an AI coding tool.
This commit is contained in:
Petru Conduraru
2026-07-21 22:35:07 +03:00
parent e52e5e2e58
commit 2c6db3dd95
+3 -1
View File
@@ -1933,7 +1933,9 @@ void SvgSerializer::write(const geometry_data& data) {
const double area = prop.Mass();
std::stringstream ss;
ss << std::setprecision(2) << std::fixed << std::showpoint << area;
labels.push_back(ss.str() + "m&#178;");
// UTF-8 for U+00B2, not an "&#178;" entity, to avoid double-escaping below.
labels.push_back(ss.str() + "m\xc2\xb2");
po()->first += " " + namespace_prefix_ + "area=\"" + ss.str() + "\"";
}
util::string_buffer path;