Skip to content

[BUG] features selection in ItemListCard #15

@enury

Description

@enury

The selection of features to display in an ItemListCard is not working properly.

The facet counts and the numbers displayed in the HoverBubble are always correct, as far as we could see, However the actual features in the list are practically always wrong after they were filtered because of a facet search.

This problem is easily visible when selecting a type. Here for instance, we are supposed to see the papyri of type "Recording of Information" located in Hermopolites. There should be four of them, the correct number is given in the HoverBubble, but in the list there are actually 5, and only the first one is of the correct type.

If I add a console.log(items); in Facet.js, I can check that the facet is returning the correct features. But they don't make it into the ItemListCard. After some digging, this is what I understand:

  • in Map.jsx at lines 114-119, the code is getting the nearest colocated neighbours from the whole dataset, instead of only the features selected by the facets.
  • it may come from the following line of code: const neighbours = knn(this.spatialIndex, x, y, n + 1); in the line 115 of Store.js ?

So it would need to

  1. either create another tree with only the features of the query, but I don't really understand how the variable this.spatialIndex is filled;
  2. or add a filter function to knn(), looping over all the facet filters to select only the features that satisfy all of them...

EDIT: I'm not sure about the last! I've tried adding a filter function just to see if it could be implemented, but it seems that the wrong selection of features had already happened. I changed the code below in Store.js, and the items that were logged into the console did not match the facet selection:

  getNearestNeighbours = (feature, n) => {
    const [x, y] = centroid(feature)?.geometry.coordinates;
    const neighbours = knn(this.spatialIndex, x, y, n + 1, function (item) {
      console.log(item.node.properties);
      return item;
  });

Dear @rsimon , @docuracy , @thegsi if you have any advice on how to proceed, that would be helpful!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions