Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "flatten" option to the new FeatureInfo #1056

Open
jacobwod opened this issue Apr 11, 2022 · 3 comments
Open

Add a "flatten" option to the new FeatureInfo #1056

jacobwod opened this issue Apr 11, 2022 · 3 comments
Assignees
Labels
Milestone

Comments

@jacobwod
Copy link
Member

While #1034 solves the general problem as suggested, there might by occasions where it would be more preferable to see the returned features as a flat list, rather than grouped by category. Here's one such example. One could argue that browsing these results would be easier if the collection was flat:
Skärmavbild 2022-04-11 kl  08 51 07

@jacobwod jacobwod added the idea label Apr 11, 2022
@jacobwod jacobwod added this to the 3.x milestone Apr 11, 2022
@jacobwod jacobwod self-assigned this Apr 11, 2022
@jacobwod
Copy link
Member Author

I tested the following implementation:

// new-client/src/components/MapClickViewer/views/FeatureCollectionsListView.js

  const [flatten, setFlatten] = useState(false);
  const [flatCollection, setFlatCollection] = useState([]);

  const toggleFlatten = () => {
    if (flatten === false) {
      // Flatten features
      const features = featureCollections.flatMap((fc) => fc.features);
      setFlatCollection([
        {
          displayFields: [],
          displayName: "Samlade resultat",
          features: features,
          infoClickDefinition: "",
          infoclickIcon: "",
          layerId: "flattened_layer.0",
          numHits: features.length,
          secondaryLabelFields: [],
          shortDisplayFields: [],
          type: "GetFeatureInfoResults",
        },
      ]);

      setFlatten(true);
    } else {
      // Un-flat
      setFlatCollection([]);
      setFlatten(false);
    }
  };

  const fcs = flatCollection.length > 0 ? flatCollection : featureCollections;

This won't work, as the made-up layerId does not exist in the real featureCollections set. So this line will fail to select find a matching collection, and we end up with an empty list:

<FeaturesListView
featureCollection={featureCollections.find(
(fc) => fc.layerId === selectedFeatureCollection
)}


We have a couple of alternatives here.

  • A: build the entire "flatted" workflow side-by-side with the existing one. We would need to change a lot of things (info click definition, display fields, etc) that are currently stored on the feature collection and move them to the features themselves.
  • B: Mix with the list and detail view. Basically create a grand total of results and supply that to the pagination component, plus ensure that pagination continues between collections.

I'm pausing this for now as other stuff are more important to focus on currently. Leaving you with this sum-up.

@lina-sbk-gbg
Copy link

We looked at this issue and have some thoughts we would like to discuss with you if you have some time @jacobwod?

@lina-sbk-gbg
Copy link

lina-sbk-gbg commented Jun 22, 2022

As we talked about, we support this proposal and preferably according to the original design sketch.

The user case that formed the basis of the design:
You usually get a handful, 1-5 hits when you click.
I want to see a comprehensive overview of all 1-5 to get an overview and control.
Not so important how they are hierarchically arranged, more "put them on the table" to see them.

The design sketch below has a little more text than the original to more clearly describe the different parts.

image

hajk3_infoklick_m_översikt_skiss_2022-06-21.pptx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants