WorldHistoricalGazetteer / whg3

Version 3 beta
BSD 3-Clause "New" or "Revised" License
4 stars 4 forks source link

Dataset Collections and "AggPlaces" (new approach) #174

Closed kgeographer closed 5 months ago

kgeographer commented 6 months ago

Designing a major modification to the existing feature, 'dataset collection' (DC), began walking through its implementation and bogged down at the required changes in mapAndTable.js. The implied changes to backend and frontend are closely intertwined, and I am unable to determine what the front end plausibly needs, nor am I able to refactor the frontend javascript.

The scenario being supported:

Use case steps

challenges The refactor bogs down there -- allFeatures[] is generated from lists of individual features (Place records) in datasets. Now, each item in allFeatures[] needs to comprise a summary of data from a set of >=1 Place instances, not from a single Place instance

On the backend, the addition of a dataset to a DC must generate a new list of that collection's place sets. With the addition of a dataset, what was {1234, 5678} may now be {1234, 5678, 7654}, and the summary of that "AggPlace" needs to be reflected in the collection's dc_browse screen map and table.

If there is to be an AggPlace model/table, it would have at minimum fields (id, collection_id, pid_set), and before regenerating records upon a dataset_add() function, previous records for that collection would be deleted.

So...the dc_browse template would have to fetch a collection.agg_places() context object (not ds_list), and deliver that to mapAndTable.js, which constructs allFeatures[] from it.

Or...the generation of new AggPlace rows could include building the composite/summary info needed for dc_browse

Simple, eh? (not) Figures below for options 1 and 2 (#1 was favored by the team so far)

image image
docuracy commented 6 months ago

I think a more efficient answer will be to:

  1. ~Add a close_matches @property to the Place model.~

  2. ~Extend the fetch_mapdata_ds function in datasets.utils so that if passed a close_matches=True parameter each feature it returns (i.e. each place) will include the pids of close matches.~

  3. ~Adapt the mapAndTable.js code to perform the grouping, headword computation, and aggregation currently envisaged for the various functions in collection.views.py.~

  4. ~Write a separate fetch_mapdata function for Dataset Collections, which aggregates the features into a single FeatureCollection, each feature having a matchset UUID and its dataset id.~

  5. ~Adapt the mapAndTable.js code to group matching matchsets and to perform the headword computation and aggregation currently envisaged for the various functions in collection.views.py.~

This will much simplify dealing with geometry visualisation and events associated with the Datasets selector.

EDIT: no, make a single feature for each matchset, including a GeometryCollection (including a centroid representative point), headword, and aggregated types.