mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-05 23:41:44 +00:00
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:
@@ -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²");
|
||||
// UTF-8 for U+00B2, not an "²" 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;
|
||||
|
||||
Reference in New Issue
Block a user