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

Feature: Create map layer from Resource Layer subset / query #10655

Open
whatisgalen opened this issue Mar 5, 2024 · 4 comments
Open

Feature: Create map layer from Resource Layer subset / query #10655

whatisgalen opened this issue Mar 5, 2024 · 4 comments

Comments

@whatisgalen
Copy link
Member

Current map layers include custom overlays, resource layers, and basemaps. Resource layers show all instances of a given resource model, however there are cases where creating a map layer showing only a subset of all instances would be preferable to have as its own toggle-able layer from the map card widget. For example, if there was a node called "Eligibility" on a resource model called "Historic Resource", a map layer might be defined as "Historic Resource - Eligibility: Potentially Eligible", along with another map layer defined as "Historic Resource - Eligibility: Ineligible". Ideally one could customize the text label for such layers.

This would function in a similar principle as the saved searches where the admins of an Arches instance know that their users will want to see specific subsets of resource instances without knowing how to search for them. Such Resource Layer subsets/queries could derive from saved searches, or they could just be configurable on their own in the map layer manager.

Presumably, the spec on the backend would include some kind of addition to the geojson API that could handle a list of search parameters (a list of nodes and their corresponding target node values). On the frontend, perhaps a new category of thing would be added to the map layer manager, for example "Resource Layer Queries". A user would select an existing resource layer and then either:

  • paste in the same search string that they would for creating a saved search in Settings
  • or there would be a select2 to choose a node and then a second field corresponding to the datatype to enter in a target value
@dwuthrich
Copy link
Contributor

@whatisgalen This is a nice summary of very desirable functionality.

I think that what you propose may already be possible using either pg_featureserv (https://github.com/CrunchyData/pg_featureserv) or pg_tileserv (https://github.com/CrunchyData/pg_tileserv). In either case you can write a PostGIS function that selects just the instances of the model that you wish to include and either the pg_tileserv or pg_featureserv servers will create the appropriate tile service or geojson service.

You can register the services with your Arches instance and style them as desired. Of course, this approach assumes that a developer, admin, or some one comfortable with PostGIS is defining the content of a layer. If you are imaging that a generic user can define the contents of the map layer, then more front-end development would be required. Just wanted you to know that it's already possible to add overlays as you've described.

@whatisgalen
Copy link
Member Author

@dwuthrich that's great news, thanks for illuminating this existing functionality! It seems like just using a sql query with postgis functions would let you compose literally any query which is awesome.

Regarding building out a frontend (which to me feels like the majority of the feature's potential impact) I think the shortest route would be to leverage the geojson api endpoint since it already takes several arguments and it represents a pre-existing backend service that already has permission checking, caching, and map layer clustering patterns.

@aj-he
Copy link
Contributor

aj-he commented Mar 6, 2024

@whatisgalen we use the Spatial Views function in Arches (https://arches.readthedocs.io/en/stable/administering/spatial-views) to serve custom resource views to pg_tileserv. We then add this service as an overlay and use the CQL filtering capabilities to filter the resources. The spatial view data source means that the popups work as expected.

We've not yet created a UI for this yet, hence the "preview' label. We also need to update it to use the resource displayname now stored in the resource_instances table.

One thing to consider though is that card and resource permissions are not honoured. I think there is scope for modifying the MVT endpoint to provide a way for these spatial views to respect permissions. Putting it in the MVT endpoint will ensure it is fast too.

@whatisgalen
Copy link
Member Author

@aj-he thanks for adding to the thread -- I agree, I think ensuring resource permissions get validated is pretty critical and leveraging MVT sounds promising!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants