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

Style spec references code from maplibre-gl #2054

Closed
rotu opened this issue Jan 10, 2023 · 12 comments · Fixed by #2356
Closed

Style spec references code from maplibre-gl #2054

rotu opened this issue Jan 10, 2023 · 12 comments · Fixed by #2356

Comments

@rotu
Copy link
Contributor

rotu commented Jan 10, 2023

The following identifiers are defined in the maplibre-gl package but are referenced from the style spec. Their definitions should be moved to the style spec. The code needs to be reorganized to prevent the style spec from being dependent on the implementation:

  • CanonicalTileID
  • MercatorCoordinate
  • EXTENT
@rotu
Copy link
Contributor Author

rotu commented Jan 10, 2023

Once resolved, I'd like to enforce this from happening again by enabling the eslint import/no-relative-packages rule

@rotu
Copy link
Contributor Author

rotu commented Jan 10, 2023

The build scripts for style-spec live in the maplibre-gl package. They should probably also be moved within the style spec subpackage.

@wipfli
Copy link
Contributor

wipfli commented Jan 28, 2023

Place in style spec which reference maplibre-gl-js code are:

import type {CanonicalTileID} from '../../source/tile_id';

import type {CanonicalTileID} from '../../source/tile_id';

import type {CanonicalTileID} from '../../../source/tile_id';

import MercatorCoordinate from '../../geo/mercator_coordinate';
import EXTENT from '../../data/extent';
import {CanonicalTileID} from '../../source/tile_id';

import type {CanonicalTileID} from '../../source/tile_id';

@wipfli
Copy link
Contributor

wipfli commented Jan 28, 2023

Removing CanonicalTileID and the others from gl js is probably a breaking change, so we should do it as part of v3, #1716

@HarelM
Copy link
Collaborator

HarelM commented Jan 28, 2023

Wht are these referenced? Moving the style spec to a different repo will also help solving this.

@wipfli
Copy link
Contributor

wipfli commented Jan 28, 2023

Ah the references are just the places where file in the src/style-spec folder import something from outside the src/style-spec folder. So these are the places where the style-spec package depends on maplibre-gl-js.

@wipfli
Copy link
Contributor

wipfli commented Jan 28, 2023

Some of these circular dependencies were introduced here: mapbox/mapbox-gl-js#9428 and here: mapbox/mapbox-gl-js#9352

@rotu
Copy link
Contributor Author

rotu commented Jan 28, 2023

Wht are these referenced? Moving the style spec to a different repo will also help solving this.

  1. Moving the style spec to another repo won’t solve this. The other way round. Solving this is required to move the code to another repo.
  2. Moving to another repo is also unnecessary to enforce this separation. The eslint import/no-relative-packages is sufficient.
  3. I’m not sure that it’s correct to move CanonicalTileID to style-spec. As far as I can tell, this logic belongs in the style implementation, not style-spec.

@rotu
Copy link
Contributor Author

rotu commented Feb 2, 2023

@wipfli, could you fix the refs in feature_filter.test? I tried and I don't understand the code well enough to disentangle this.

@wipfli
Copy link
Contributor

wipfli commented Feb 3, 2023

EXTENT seems to be hardcoded in a bunch of places.

@wipfli
Copy link
Contributor

wipfli commented Feb 3, 2023

And the class mercator coordinate defined here:

class MercatorCoordinate {

Might be similar to this point module or how it is called and maybe could be factored out.

@birkskyum
Copy link
Member

The style-spec actually compiles without importing anything from maplibre-gl-js at this point.

This is obtained by having MercatorCoordinate is inside of style-spec here:
https://github.com/maplibre/maplibre-gl-style-spec/blob/main/src/coordinates/mercator_coordinate.ts

Only the type of CanonicalTileID is used in style-spec, so there is an interface ICanonicalTileID here, which is imported maplibre-gl-js as well:
https://github.com/maplibre/maplibre-gl-style-spec/blob/main/src/tiles_and_coordinates.ts

Also, the LngLat type is necessary for MercatorCoordinate, so it's also to be found in style-spec here:
https://github.com/maplibre/maplibre-gl-style-spec/blob/main/src/coordinates/lng_lat.ts

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

Successfully merging a pull request may close this issue.

4 participants