Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
eee31e4
feat(labels): labels keep off a point layer's points, with an obstacl…
jgregoriorincon Dec 1, 2026
6cc203a
fix(labels): bound point obstacles by the screen, count what is drawn…
jgregoriorincon Dec 1, 2026
9bba3e0
fix(labels): a point's label goes over an obstacle where its own poin…
jgregoriorincon Dec 1, 2026
376c994
fix(labels): require label-obstacles of an inline project's notebook …
jgregoriorincon Dec 1, 2026
e8dd434
fix(labels): keep a tilted view's ground obstacle whose reach point d…
jgregoriorincon Dec 1, 2026
92f49a1
fix(labels): tilted views take obstacles from the markers they draw, …
jgregoriorincon Dec 1, 2026
ec7a918
Merge remote-tracking branch 'upstream/main' into feat/3526-label-poi…
jgregoriorincon Dec 1, 2026
ae7a7c1
fix(engine): asking what an inline project's obstacle weights need re…
jgregoriorincon Dec 1, 2026
8ef7448
fix(labels): merge obstacles by point of the screen with their reach …
jgregoriorincon Dec 1, 2026
bc0f768
fix(labels): bound a frame's obstacles by memory, skip far rows by ex…
jgregoriorincon Dec 1, 2026
da62f43
fix(labels): cull a CPU-drawn layer in a GPU frame as the CPU does, l…
jgregoriorincon Dec 1, 2026
a5ce755
fix(labels): a tilted view's bands share their obstacles and their li…
jgregoriorincon Dec 1, 2026
b66456d
fix(labels): say obstacles were left out without a count, and read an…
jgregoriorincon Dec 1, 2026
4e83a96
fix(labels): say what a tilted view's bands leave out together
jgregoriorincon Dec 2, 2026
083f043
fix(labels): say how many obstacles were left out in all, hold the ma…
jgregoriorincon Dec 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/engine/command-surface.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ labels.fonts search?
labels.lock on?
labels.move layer? class? feature? row? to
labels.pause on?
labels.placement layer? class? position? to? side? offset? repeat? lineOffset? otherPositions? fit? abbreviations? showAll? weight? clearance? removeDuplicates? callout? guide?
labels.placement layer? class? position? to? side? offset? repeat? lineOffset? otherPositions? fit? abbreviations? showAll? weight? obstacleWeight? clearance? removeDuplicates? callout? guide?
labels.resetMoved layer? class? all?
labels.scaleRange layer? class? min? max? clear?
labels.style layer? class? size? color? halo? haloColor? haloWidth? spacing? stretch? bold? italic? font? background? wrapChar? wrapLength? lineAlign?
Expand Down
37 changes: 33 additions & 4 deletions crates/engine/src/cmd/labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ pub fn commands() -> Vec<C> {
// A position that isn't a placement name is refused, not dropped for the others (null:
// none, as for the other keys).
None if p.get("position").is_some_and(|v| !v.is_null()) => return Err("position must be a placement name".into()),
None if ["offset", "repeat", "lineOffset", "otherPositions", "showAll", "weight", "clearance", "removeDuplicates", "callout", "to", "side", "fit", "abbreviations", "guide"]
None if ["offset", "repeat", "lineOffset", "otherPositions", "showAll", "weight", "obstacleWeight", "clearance", "removeDuplicates", "callout", "to", "side", "fit", "abbreviations", "guide"]
.iter()
.any(|k| p.get(k).is_some()) =>
{
None
}
None => {
return Err("position is required (or an offset, a repeat, a lineOffset, otherPositions, showAll, a weight, a clearance, removeDuplicates, a callout, to, side, fit, abbreviations or a guide)".into());
return Err("position is required (or an offset, a repeat, a lineOffset, otherPositions, showAll, a weight, an obstacleWeight, a clearance, removeDuplicates, a callout, to, side, fit, abbreviations or a guide)".into());
}
};
// Along a line placed curved, the label fitted to the room the line gives (#2265).
Expand Down Expand Up @@ -213,6 +213,15 @@ pub fn commands() -> Vec<C> {
};
let weight_asked = weight.filter(|w| w.fract() != 0.0 || !rustgis_map::symbology::LABEL_WEIGHT.contains(w));
let weight = weight.map(rustgis_map::symbology::label_weight);
// How much labels keep off the layer's points (#3526): 0 to 10, null back to 0. A
// number out of range or a fraction is held to a whole one, and says so.
let obstacle = match p.get("obstacleWeight") {
None => None,
Some(Value::Null) => Some(0.0),
Some(v) => Some(number(v).ok_or("obstacleWeight must be a number from 0 to 10 (0 or null: none)")?),
};
let obstacle_asked = obstacle.filter(|w| w.fract() != 0.0 || !rustgis_map::symbology::LABEL_WEIGHT.contains(w));
let obstacle = obstacle.map(rustgis_map::symbology::label_weight);
// The room its labels keep free of other labels (#2828): 0 to 100 points, null back to
// 2. A number out of range is held to it, and says so.
let clearance = match p.get("clearance") {
Expand Down Expand Up @@ -276,12 +285,20 @@ pub fn commands() -> Vec<C> {
let clears = matches!(to, Some(None));
let id = s.layer_id(p)?;
let held = held_geometries(s.map().layer(id).ok_or("no such layer")?);
let (_, lines, _) = held;
let (points, lines, _) = held;
// On a layer with no points it would do nothing; off is taken anywhere.
if obstacle.is_some_and(|w| w > 0) && !points {
return Err("obstacleWeight is for layers with points: lines and polygons aren't obstacles yet".into());
}
let guide = label_guide(s, p, s.map().layer(id).ok_or("no such layer")?)?;
// A repeat or line offset given where it does nothing (not along a line), kept for
// when the class is placed along one, and said (#2639).
let mut unused: Vec<&str> = Vec::new();
let done = with_labels(s, p, |labels| {
// The layer's, whatever class is named.
if let Some(w) = obstacle {
labels.obstacle_weight = w;
}
let c = class_in(labels, p)?;
if let Some(pos) = pos {
c.placement = pos;
Expand Down Expand Up @@ -401,6 +418,18 @@ pub fn commands() -> Vec<C> {
false,
);
}
if let Some(asked) = obstacle_asked {
let name = s.map().layer(id).map(|l| l.name.clone()).unwrap_or_default();
let kept = rustgis_map::symbology::label_weight(asked);
let asked = if asked.abs() < 1e6 { asked.to_string() } else { format!("{asked:e}") };
s.notify_text(
NoticeText::format(
"{name}: obstacleWeight {asked} adjusted to {kept} (an obstacle weight is a whole number from 0 to 10)",
[("name", name.into()), ("asked", asked.into()), ("kept", kept.to_string().into())],
),
false,
);
}
if let Some(asked) = clearance_asked {
let name = s.map().layer(id).map(|l| l.name.clone()).unwrap_or_default();
let kept = rustgis_map::symbology::label_clearance(asked);
Expand Down Expand Up @@ -430,7 +459,7 @@ pub fn commands() -> Vec<C> {
.inputs(super::Inputs::single_layer)
.when(need_feature_layer)
.params(
r#"{"layer"?, "class"?: name (none: the Default class, by whatever name it has), "position"?: "auto"|"center"|"above"|"below"|"left"|"right"|"aboveRight"|"aboveLeft"|"belowRight"|"belowLeft"|"parallel" (along a line, straight)|"curved" (along a line, following its bends)|"perpendicular" (a point's, square to the nearest line of `to`, starting at the point; none that near: as auto) (required without offset, repeat, lineOffset, otherPositions, showAll, weight, clearance, removeDuplicates, callout, to, side, fit, abbreviations or guide), "to"?: {"layer": a line or polygon layer's name, "within"?: points (1 to 500; 20)} | null, "side"?: "away" (the side of the line the point isn't on; the default)|"left"|"right" (as the line runs), "offset"?: [right, down] points (-200 to 200 each) the label moves from where its position puts it ([0, 0]: none; perpendicular: [out along the normal, down as the text reads]; a label along a line isn't moved), "repeat"?: points (10 to 10000) between a line's labels, spaced out from the one at its middle, at most 32 a line (0 or null: the one at its middle; parallel and curved only), "lineOffset"?: points (-200 to 200) between a line and its label's nearest edge, above the line as the text reads, negative below it (0 or null: on the line; parallel and curved only), "otherPositions"?: bool (a label whose place is taken tries others: a point's round the point, corners first; a line's along the line, nearest its middle first, placed parallel or curved without a repeat; a polygon's goes first where its shape fits best inside it, then where it goes without this; then, if its text fits the box of the polygon on the screen, up to 16 places further inside, a text box from the first and then two, corners first, where all of it is inside and in view, or else round that box, corners first; true is refused for any other line label, and on polygons for a curved label or one along a guide), "fit"?: "auto"|"off" (curved along a line: "auto" abbreviates a name that can't follow the line, sets one longer than a third of it on its straightest stretch, and spreads one over labels.style's stretch of a line more than three times its length; "off" or null: as placed), "abbreviations"?: {word: abbreviation} (whole words a fitted label puts short, ignoring case, over the built-in English, Portuguese and Spanish list, as {"Creek": "Cr.", "Córrego": "Cór."}; null or {}: the built-in list alone), "showAll"?: bool (every label drawn, over the others where they crowd), "weight"?: 0 to 10 (where labels compete for a place, the heavier class's wins, whatever its layer's place; equal weights: the layer above, then the class listed first; a fraction rounded; null: 5), "clearance"?: points (0 to 100: the room the class's labels keep free of other labels, two labels keeping both their clearances apart; null: 2), "removeDuplicates"?: points (1 to 2000: a label is left out within this distance of one placed before it for another feature of its layer and class with the same text; a label moved by hand always shows; false or null: off), "callout"?: true|false|points (5 to 500: a label crowded off its spot moves to a free one nearby, a line drawn back to its feature at most this long; true keeps its length, or 40; false, 0 or null: none; not labels along a line or with an icon), "guide"?: {"layer": a line layer's name (as ridge or valley lines; not drawn by this), "field"?: a field both layers have} | null (points and polygons, not perpendicular ones: each label curved along its guide line, the one with the feature's value in field, else the longest in view under the label inside its polygon, or the nearest to its point within the text's width; a feature with none its text fits along is labelled as without a guide; null: none)}"#,
r#"{"layer"?, "class"?: name (none: the Default class, by whatever name it has), "position"?: "auto"|"center"|"above"|"below"|"left"|"right"|"aboveRight"|"aboveLeft"|"belowRight"|"belowLeft"|"parallel" (along a line, straight)|"curved" (along a line, following its bends)|"perpendicular" (a point's, square to the nearest line of `to`, starting at the point; none that near: as auto) (required without offset, repeat, lineOffset, otherPositions, showAll, weight, obstacleWeight, clearance, removeDuplicates, callout, to, side, fit, abbreviations or guide), "to"?: {"layer": a line or polygon layer's name, "within"?: points (1 to 500; 20)} | null, "side"?: "away" (the side of the line the point isn't on; the default)|"left"|"right" (as the line runs), "offset"?: [right, down] points (-200 to 200 each) the label moves from where its position puts it ([0, 0]: none; perpendicular: [out along the normal, down as the text reads]; a label along a line isn't moved), "repeat"?: points (10 to 10000) between a line's labels, spaced out from the one at its middle, at most 32 a line (0 or null: the one at its middle; parallel and curved only), "lineOffset"?: points (-200 to 200) between a line and its label's nearest edge, above the line as the text reads, negative below it (0 or null: on the line; parallel and curved only), "otherPositions"?: bool (a label whose place is taken tries others: a point's round the point, corners first; a line's along the line, nearest its middle first, placed parallel or curved without a repeat; a polygon's goes first where its shape fits best inside it, then where it goes without this; then, if its text fits the box of the polygon on the screen, up to 16 places further inside, a text box from the first and then two, corners first, where all of it is inside and in view, or else round that box, corners first; true is refused for any other line label, and on polygons for a curved label or one along a guide), "fit"?: "auto"|"off" (curved along a line: "auto" abbreviates a name that can't follow the line, sets one longer than a third of it on its straightest stretch, and spreads one over labels.style's stretch of a line more than three times its length; "off" or null: as placed), "abbreviations"?: {word: abbreviation} (whole words a fitted label puts short, ignoring case, over the built-in English, Portuguese and Spanish list, as {"Creek": "Cr.", "Córrego": "Cór."}; null or {}: the built-in list alone), "showAll"?: bool (every label drawn, over the others where they crowd), "weight"?: 0 to 10 (where labels compete for a place, the heavier class's wins, whatever its layer's place; equal weights: the layer above, then the class listed first; a fraction rounded; null: 5), "obstacleWeight"?: 0 to 10 (the layer's, for layers with points, whatever class is named: a label whose class's weight isn't above it isn't placed over one of the layer's points, its own feature's aside; labels moved by hand go where they were put; a fraction rounded; 0 or null: no obstacle), "clearance"?: points (0 to 100: the room the class's labels keep free of other labels, two labels keeping both their clearances apart; null: 2), "removeDuplicates"?: points (1 to 2000: a label is left out within this distance of one placed before it for another feature of its layer and class with the same text; a label moved by hand always shows; false or null: off), "callout"?: true|false|points (5 to 500: a label crowded off its spot moves to a free one nearby, a line drawn back to its feature at most this long; true keeps its length, or 40; false, 0 or null: none; not labels along a line or with an icon), "guide"?: {"layer": a line layer's name (as ridge or valley lines; not drawn by this), "field"?: a field both layers have} | null (points and polygons, not perpendicular ones: each label curved along its guide line, the one with the feature's value in field, else the longest in view under the label inside its polygon, or the nearest to its point within the text's width; a feature with none its text fits along is labelled as without a guide; null: none)}"#,
),
// Labels moved by hand (the Move Label tool, as QGIS's): kept by their feature's id.
C::new("labels.move", "Move Label", "Labeling › Label Placement", |s, p| {
Expand Down
1 change: 1 addition & 0 deletions crates/engine/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ pub const CAPABILITIES: &[&str] = &[
"layout-publication-crs",
"shaded-relief-generalize",
PROJECT_OPEN_LAYOUT,
"label-obstacles",
];
/// An offline area keeping the versions that lost a sync or a Bring Back
/// (`OfflineArea::conflicts`, #2468): an older reader would save it again without them.
Expand Down
Loading
Loading