Skip to content

feat: count features without coordinates across all layer types [PR7] [DHIS2-18242]#3651

Open
BRaimbault wants to merge 9 commits into
feat/DHIS2-18242-PR6from
feat/DHIS2-18242-PR7
Open

feat: count features without coordinates across all layer types [PR7] [DHIS2-18242]#3651
BRaimbault wants to merge 9 commits into
feat/DHIS2-18242-PR6from
feat/DHIS2-18242-PR7

Conversation

@BRaimbault
Copy link
Copy Markdown
Collaborator

@BRaimbault BRaimbault commented May 4, 2026

Parent

Implements

  • DHIS2-237: Count events without coordinates (event layer)
  • DHIS2-19850: Count org units without coordinates (thematic, facility, org unit, earth engine layers)

Overview

Seventh PR in the series. Adds a "Count … without coordinates" checkbox to all five layer types. When enabled, the legend shows a Data quality section with the count of features that could not be mapped due to missing coordinates, and those features appear in the data table so they can still be inspected.

Changes

Event layer — count events without coordinates DHIS2-237

A "Count events without coordinates" checkbox is added to the Style tab of the event dialog. When checked, withCoordinatesOnly(false) is passed to the analytics request so all events are returned regardless of coordinate presence. createEventFeatures (geojson.js) now guards against null geometry in buildEventGeometryGetter and splits the result into data (events with coordinates) and dataWithoutCoords (events without). loadData (event.js) returns the split. eventLoader stores dataWithoutCoords on the layer config and sets legend.eventsWithoutCoordinatesCount. Server clustering is disabled when counting is active (encoded in shouldUseServerCluster). The flag is serialised into config.config JSON by favorites.js.

Files: src/util/geojson.js, src/util/event.js, src/loaders/eventLoader.js, src/components/edit/event/EventDialog.jsx, src/util/favorites.js

Org unit / facility / thematic / earth engine layers — count org units without coordinates DHIS2-19850

A "Count org units without coordinates" checkbox is added to the style tabs of the org unit, facility, thematic and earth engine dialogs. When checked, getOrgUnitsWithoutCoordsCount (orgUnits.js) queries the analytics API (using a first available data element as a proxy dimension) to discover which of the requested org unit IDs in the selection have no geometry. The count is stored on legend.orgUnitsWithoutCoordinatesCount; the missing org unit features are stored on config.dataWithoutCoords. For the org unit and thematic layers, fetchOrgUnitDetails enriches each missing feature with its level and parent name before it reaches the data table. For earth engine, countFeaturesWithoutCoordinates is kept as a top-level layer property (consistent with other EE props) rather than embedded in the config JSON.

Files: src/util/orgUnits.js, src/util/requests.js, src/loaders/facilityLoader.js, src/loaders/orgUnitLoader.js, src/loaders/thematicLoader.js, src/loaders/earthEngineLoader.js, src/components/edit/FacilityDialog.jsx, src/components/edit/orgUnit/OrgUnitDialog.jsx, src/components/edit/thematic/ThematicDialog.jsx, src/components/edit/earthEngine/StyleTab.jsx, src/util/favorites.js

Shared plumbing

addGroupCountsToLegend, addLevelCountsToLegend, loadGroupSetData, fetchAndParseGroupSet, fetchAssociatedGeometries are extracted into orgUnits.js and shared by both loaders, reducing cognitive complexity in facilityLoader and orgUnitLoader from ~21 to ~12. useTableData merges dataWithoutCoords into the displayed rows. Legend.jsx shows a Data quality section when either count is set.

Files: src/util/orgUnits.js, src/components/datatable/useTableData.js, src/components/legend/Legend.jsx, src/components/legend/styles/Legend.module.css

Bug fix — null layerEdit in connected component selectors

When a layer dialog closes, LAYER_CANCEL sets layerEdit to null before child components unmount. connect's mapStateToProps runs synchronously in Redux subscription callbacks, causing a crash on any direct layerEdit.x property access. Optional chaining added to all affected connect selectors (StyleByGroupSet, Labels, IsolatedClass, BufferRadius, GeometryCentroid, Classification, SingleColor, NumericLegendStyle, CompletedOnlyCheckbox, RadiusSelect, AggregationTypeSelect, AggregationSelect, BandSelect). Pre-existing bug, surfaced by Cypress testing the org unit dialog close flow.

Files: 13 component files under src/components/

Tests update

  • src/util/__tests__/orgUnits.spec.jsgetStyledOrgUnits (facility item, org unit layer); addGroupCountsToLegend (reset, increment, no-match, missing dimensions); addLevelCountsToLegend (reset, increment, no-match); getOrgUnitsWithoutCoordsCount (empty ids, no data element, count missing, query error); fetchAndParseGroupSet (success, failure); loadGroupSetData (skip when not needed, skip when already loaded, mutates groupSet, error string on failure)
  • src/util/__tests__/geojson.spec.jsbuildEventGeometryGetter with null / empty-string geometry; createEventFeatures splits into data + dataWithoutCoords
  • src/util/__tests__/favorites.spec.jscountFeaturesWithoutCoordinates serialised to config JSON for thematic and event layers; preserved as top-level property for earth engine layer

Manual testing

Netlify: https://pr-3651.maps.netlify.dhis2.org/ + Instance: https://dev.im.dhis2.org/maps-app-42-3

Quality checklist

  • Jest tests added/updated
  • Docs added N/A
  • d2-ci dependencies replaced N/A
  • Include plugin in testing
  • Tester approved (KFMT)

@BRaimbault BRaimbault changed the base branch from master to feat/DHIS2-18242-PR6 May 4, 2026 16:13
@dhis2-bot
Copy link
Copy Markdown
Contributor

dhis2-bot commented May 4, 2026

🚀 Deployed on https://pr-3651.maps.netlify.dhis2.org

@dhis2-bot dhis2-bot temporarily deployed to netlify May 4, 2026 16:15 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify May 4, 2026 21:25 Inactive
@BRaimbault BRaimbault changed the title Feat/dhis2 18242 pr7 feat: count features without coordinates across all layer types [PR7] [DHIS2-18242] May 4, 2026
@BRaimbault BRaimbault requested a review from a team May 4, 2026 21:51
Copy link
Copy Markdown
Collaborator Author

@BRaimbault BRaimbault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for review

@BRaimbault BRaimbault marked this pull request as ready for review May 4, 2026 21:53
@dhis2-bot dhis2-bot temporarily deployed to netlify May 14, 2026 10:07 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify May 14, 2026 16:53 Inactive
@BRaimbault BRaimbault force-pushed the feat/DHIS2-18242-PR7 branch from 9410582 to 9d9607a Compare May 14, 2026 16:53
@dhis2-bot dhis2-bot temporarily deployed to netlify May 14, 2026 17:07 Inactive
Copy link
Copy Markdown
Contributor

@HendrikThePendric HendrikThePendric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me. I left a few comments, but nothing critical.

Comment thread src/util/orgUnits.js Outdated
Comment thread src/util/orgUnits.js Outdated
Comment thread src/util/orgUnits.js
Co-authored-by: Hendrik de Graaf <HendrikThePendric@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

@dhis2-bot dhis2-bot temporarily deployed to netlify May 18, 2026 13:10 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants