Repository navigation
feat(symbology): size classified points by a field alongside their colours (#1017) - #2130
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A Unique Values or Graduated Colors point layer can now also be sized by a number field. Each point keeps its class's colour and takes the size its value gives. GeoLibre projects that colour by one field and size by another now import with both channels.
Layer::size_by(field,min,max,min_size,max_size,scaling).Stylerapplies it after the class symbol and beforesymbol_byexpressions, so a Size expression still wins where it gives a value. Stacked marks scale with it as they do with a size expression. It sits on the layer rather than inside the two renderer variants, so the 45 places that build those renderers stay unchanged. Under Single or Proportional it is kept but unused.areagrows the marker's area with the value. It reuses the Proportional Symbols formula, now one sharedscaled_size, so Proportional Symbols draw as before, except that a range so wide its width overflows (beyond about 1e308) now takes the middle size for every value instead of the smallest, and a NaN value gives the middle size where it gave a NaN size.radiusgrows the size linearly, as GeoLibre/MapLibre does.layer.sizeByrejects both. A final size of zero draws no marker, after a Size expression has had its say. Attribute values are only read, never changed.layer.sizeBy {"layer"?, "field": numeric|null, "min"?, "max"?, "minSize"?, "maxSize"?, "scaling"?: "area"|"radius"}. Values not given keep the mapping's, else they default to the field's range, 4–24 pt and area. It refuses non-point layers, other renderers, non-numeric fields, an empty range and sizes outside 0–400 pt, and a refused call adds no undo step. Repair checks the field like the rotation field. On the desktop, finding the field's range runs on the background read queue with progress and Cancel; a result for a layer whose rows or fields changed meanwhile is refused. A streamed layer needs explicit bounds, and a range too wide to scale over is refused. The command is admitted on the scoped MCP route like the other layer styling commands."requires": ["classified-point-size"], so a RustGIS that can't keep the mapping refuses the file rather than dropping it on the next save. A file without one keeps format 1 and its exact previous form, and removing the last mapping removes the requirement. A malformedsize_byis refused, not dropped; a long field name that RustGIS writes reads back. The schema lists the capability and says files are written as format 1 or 2;schema/fixtures/size_by.rgisis the read fixture.run, command search, the Assistant and MCP (its parameter help lists every option). The phone interface has no symbology editor, so it reaches the mapping only by drawing it. No ribbon button: the rows sit in the Symbology pane. The way back: each change is undoable,{"field": null}or None removes the mapping, and saved projects reopen with it.Testing
symbol_by::a_size_mapping_sizes_classed_points_and_keeps_their_colours: radius and area scaling, null, text and out-of-range values, empty range, a zero size drawing nothing, colours and attributes unchanged, legend rows with stacked marks scaled, unused under Single.symbol_by::a_size_mapping_is_saved_only_when_set_and_refused_when_malformed: omitted when absent, round trip, malformed values refused.symbol_by::a_size_range_too_wide_to_divide_uses_the_midpoint: a finite range whose width overflowsf64takes the middle size.geolibre::style_tests::geolibre_colour_classes_keep_their_proportional_size: the earthquakes shape gives a radius mapping with no note; an absent field or empty range gives a note; clamped bounds are reported.tests::a_classified_point_layer_is_sized_by_a_field: command defaults, refusals without an undo step, undo, removal, and the fixture read back.tests::a_size_field_range_is_prepared_off_the_window_thread: the range scan runs on the read queue, and a result for a layer that changed meanwhile is refused.tests::a_streamed_layer_needs_bounds_for_its_size_mapping: a streamed layer's range isn't taken from the view's features; explicit bounds work.tests::size_mappings_require_a_reader_that_keeps_them: format 2 and the requirement only while a mapping exists, in projects, items and packages.panes::tests::size_fields_with_constant_or_missing_values_can_be_configured: a constant or all-null field opens editable bounds and applies.project_save_roundtripincludeslayer.sizeBysteps. Locally on this head (after merging main and the autofix commit): the tests above, the renderlegendtests (16 passed), clippy-D warningson map, engine, render, assistant and ui-egui, a wasm check, and fmt. Full gate: fork CI (Linux) passed on this head.https://share.geolibre.app/giswqs/earthquakes-last-30-days.geolibre.json(graduated bydepth_km, sized bymag2.5–7.5 → radius 2–18 px). Then I saved it as.rgis, reopened it, and compared screenshots. Depth colours, magnitude sizes, the legend and the editor all survive the reopen. The import's remaining notes are the pop-ups, which are unrelated. Withui_shot, a field that is all null and one that is constant both set up through the draft rows; the saved files are format 2 with the requirement and keep the mapping.UI evidence
The "before" is main's import result reproduced on this build: the mapping removed and the classes at main's fixed 12 pt, so it also shows the new Size by row set to None. I didn't build a separate main binary.
Before (main's result: depth colours, fixed size):
After import (depth colours, magnitude sizes, Size by editor, size rows in the legend):
After save and reopen:
A field with no values yet (
missing), applied with typed bounds; its points take the smallest size:Choosing a field with one value throughout (
constant) opens the draft rows with editable bounds, Apply and Cancel:Limits: the Layers pane fits its swatches in a small box, so it draws the size rows on one shared scale rather than at their map sizes. The GPU fast path is skipped for a layer with a size mapping, which is then drawn on the CPU as layers with symbol expressions are.
Related issue
Closes #1017
Summary by CodeRabbit
layer.sizeBy; bounds can be detected from field values when available. Legends show size variations, and GeoLibre imports support combined color and size styles.