mapbox / mapbox/mapbox-gl-js

Support arbitrary expressions on "requires" property

Open
#4,130 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cross-platform :tv:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

_From @davidtheclark on October 4, 2016 2:7_

I'm thinking about:
- https://github.com/mapbox/mapbox-gl-style-spec/issues/497, in which enum values are changed from an array to an object to allow for additional metadata on each value)
- https://github.com/mapbox/mapbox-gl-style-spec/pull/495, in which a `<=` key shows up on an object in the `"requires"` array.
- https://github.com/mapbox/mapbox-gl-style-spec/issues/504, in which we had to allow the value of an object in the `"requires"` array to itself be an array.
- The weirdness of having keys in objects represent either a property name or an operator (`"!"`).
- The weirdness of having items in the `"requires"` array be sometimes strings and sometimes objects.
- The complexity caused by that weirdness in some Studio code I've been looking into.
- https://github.com/mapbox/mapbox-gl-style-spec/issues/499, which is about validating the `"requires"` values — with validation code that will have to deal with the above.

So I'm wondering if it might be worthwhile to reconsider the current format of the `"requires"` value, changing it to something that can be more consistent and robust.

How about this: The value of `"requires"` is always an array of objects, each object with these properties:
- `property` (required): The required property name.
- `operator` (optional): An operator pertaining to the property (e.g. `"!"`, `"<="`).
- `values` (optional): An array of objects representing satisfactory values for the specified property, each object with these properties:
- `value` (required): The satisfactory value.
- `operator` (optional): An operator pertaining to the value. For example, maybe you in the future we'll want to specify that some property must have any value other than `0`, or any value greater than `0`.

The main principle here is that an object is going to be more flexible and future-proof than a string.

That's my idea.

_Copied from original issue: mapbox/mapbox-gl-style-spec#513_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue identifies no files, tests, or entry points. Start by reviewing the linked style-spec issues and pull request to understand the existing requires formats and validation concerns. Done would require an agreed replacement format and a defined implementation scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.