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

New image tile source #14262

Closed
wants to merge 16 commits into from
Closed

New image tile source #14262

wants to merge 16 commits into from

Conversation

tschaub
Copy link
Member

@tschaub tschaub commented Nov 5, 2022

This adds a new ImageTile source that extends the DataSource as a convenience for working with image tiles. This is part 2 in the plan mentioned in #14258.

The simplest example of its use looks like this:

import Layer from 'ol/layer/WebGLTile.js';
import Map from 'ol/Map.js';
import Source from 'ol/source/ImageTile.js';
import View from 'ol/View.js';

const map = new Map({
  target: 'map',
  layers: [
    new Layer({
      source: new Source({
        url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
      }),
    }),
  ],
  view: new View({
    center: [0, 0],
    zoom: 0,
  }),
});

The source is purely a convenience for creating an image loader given a URL. The url option can be a single URL template, an array of templates, or a function that returns a URL. The resulting loader returns a promise that creates an image, sets its src, and resolves when the image loads. For more complex image loading scenarios, the source can be passed a loader option.

When a data tile is disposed, we now dispatch an abort event on an abort controller's signal. The GeoTIFF source shows how the abort signal can be passed to fetch.

There is probably more to do to support all the functionality of the current image tile stuff, but I think this makes for a simpler foundation than what we have currently. If we continue with this, we could eventually remove things like:

  • ol/source/UrlTile.js
  • ol/source/TileImage.js
  • ol/source/XYZ.js
  • ol/ImageTile.js
  • ol/tileurlfunction.js

Still todo:

  • deal with interim tiles

src/ol/tileurlfunction.js Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Nov 5, 2022

📦 Preview the website for this branch here: https://deploy-preview-14262--ol-site.netlify.app/.

@tschaub tschaub force-pushed the new-source branch 6 times, most recently from 6a67cce to 4580fcb Compare November 8, 2022 22:14
@tschaub tschaub marked this pull request as ready for review November 8, 2022 22:16
@ahocevar
Copy link
Member

ahocevar commented Nov 8, 2022

Thanks for your work on this, @tschaub. I'll be glad to review this, but please be patient. In the process of reviewing, I'd like to play around with the new ImageTile source, with the goal of making it compatible with the canvas tile renderer (or vice verse).

@tschaub
Copy link
Member Author

tschaub commented Nov 9, 2022

No rush, @ahocevar. I would also like to do the same. One significant difference is that the data tile source doesn’t cache tiles. So this will mean adding a cache to the canvas renderer.

@tschaub
Copy link
Member Author

tschaub commented Feb 19, 2024

I've squashed these changes in order to make it easier to deal with the conflicts. New pull request #15568.

@tschaub tschaub closed this Feb 19, 2024
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 this pull request may close these issues.

None yet

2 participants