Skip to content

feat: add COG support for MapLibre#51

Open
fgravin wants to merge 1 commit intomainfrom
maplibre-cog
Open

feat: add COG support for MapLibre#51
fgravin wants to merge 1 commit intomainfrom
maplibre-cog

Conversation

@fgravin
Copy link
Copy Markdown
Member

@fgravin fgravin commented Feb 26, 2026

Summary

  • Add geotiff layer type support in the MapLibre package using @geomatico/maplibre-cog-protocol
  • Register a custom cog:// protocol to load Cloud Optimized GeoTIFFs as raster tile sources
  • Add unit tests for the new layer type
  • Add a MapLibre COG example component

Test plan

  • MapLibre unit tests pass (npx vitest run in packages/maplibre)
  • Verify COG raster renders in the example app (npm run dev in apps/examples)
  • Test with different COG URLs

Notes

Works well with the examples from the library, does not work with the COG in the OL examples though.
Opened an issue for that geomatico/maplibre-cog-protocol#36

@fgravin fgravin changed the base branch from main to flatstyle February 26, 2026 15:51
@fgravin fgravin requested a review from jahow February 26, 2026 15:54
Add geotiff layer type handling in the MapLibre package using
@geomatico/maplibre-cog-protocol. This registers a custom `cog://`
protocol to load COG files as raster sources.

Includes unit tests and an example component.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Base automatically changed from flatstyle to main March 2, 2026 08:59
Copy link
Copy Markdown

@jonathanlurie jonathanlurie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure the review was supposed to be on general design, and I don't want this feedback to be blocking as it's mostly about non-functional improvements

type: 'xyz',
url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
},
{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cog being addressed as geotiff (as defined in MapContextLayerGeotiff from packages/core/lib/model/map-context.ts) is misleading and could lead to think that any geotif would work, and not just cog. So unless all geotiff works, including non-cloud-optimized, then I would advice renaming the type cog and also all the internal terminology that refers to "geotiff".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also surprised, @jahow why did you choose this keyword ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it works with plain geotiffs in OL

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can throw an error in MapLibre if it doesn't support non-COG geotiff

],
};
}
case "geotiff": {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using the string "geotiff" in many occasion, it would be nice to have a variables instead. Also true for the other types, because a string is more prone to errors.

],
};
}
case "geotiff": {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many cases here, the switch scope in its entirety is 150 lines already and is expected to contain even more in the future. To reduce reading complexity and improve maintainability (and onboarding of new devs), it would be nice each case enty calls a dedicated function (that are not exported and lay in the same file, at least for a start)

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.

3 participants