Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
05d8465
add resolution to Image
sharkAndshark Jun 15, 2025
4108e8b
add auto_web option
sharkAndshark Jun 18, 2025
55a5ee1
add web zoom if auto_web enabled
sharkAndshark Jun 18, 2025
df8c954
add intersect_tiles() to Image
sharkAndshark Jun 18, 2025
209224f
wip
sharkAndshark Jun 18, 2025
a212c37
add origin to image
sharkAndshark Jun 23, 2025
17d0528
add doc
sharkAndshark Jun 23, 2025
aaed0d1
reanme func
sharkAndshark Jun 23, 2025
bfe18cc
refactor
sharkAndshark Jun 23, 2025
3a4a946
wip: finish func clip
sharkAndshark Jun 23, 2025
c5e4b9a
add crates
sharkAndshark Jun 23, 2025
7981a38
finish clip method
sharkAndshark Jun 25, 2025
40b5ee3
clip imag when web friendly enabled
sharkAndshark Jun 25, 2025
c8010ec
wip
sharkAndshark Jul 14, 2025
32dab67
add doc
sharkAndshark Jul 14, 2025
1bab765
update cargo lock
sharkAndshark Jul 14, 2025
f571457
clippy
sharkAndshark Jul 14, 2025
dbc603a
wip: clippy
sharkAndshark Jul 15, 2025
e79b088
clippy
sharkAndshark Jul 16, 2025
0f2ee38
clean up
sharkAndshark Jul 16, 2025
02f425a
add test cases
sharkAndshark Jul 16, 2025
1ecd40a
Merge remote-tracking branch 'maplibre/main' into cog_web_5
sharkAndshark Jul 17, 2025
8a9d551
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 17, 2025
acd389e
add auto_web as a source config
sharkAndshark Jul 21, 2025
cf6ac10
Merge remote-tracking branch 'maplibre/main' into cog_web_5
sharkAndshark Jul 21, 2025
843c016
bless test
sharkAndshark Jul 21, 2025
8292dde
Merge branch 'main' into cog_web_5
sharkAndshark Jul 22, 2025
3cbd185
add test cases
sharkAndshark Aug 7, 2025
73b8b7c
cleanup
sharkAndshark Aug 7, 2025
f5da83c
cleanup
sharkAndshark Aug 8, 2025
78c2a99
Merge remote-tracking branch 'maplibre/main' into cog_web_5
sharkAndshark Aug 8, 2025
73331e1
add test cases
sharkAndshark Aug 8, 2025
c9a071f
Merge branch 'main' into cog_web_5
sharkAndshark Aug 10, 2025
0cd936f
cleanup
sharkAndshark Aug 11, 2025
b48a52b
Merge remote-tracking branch 'maplibre/main' into cog_web_5
sharkAndshark Aug 14, 2025
92baf2a
update test
sharkAndshark Aug 14, 2025
a348677
Merge remote-tracking branch 'maplibre/main' into cog_web_5
sharkAndshark Aug 15, 2025
0145c8e
bless tests
sharkAndshark Aug 15, 2025
04c4eb1
bless
sharkAndshark Aug 15, 2025
7d7ac8a
fix bug
sharkAndshark Aug 15, 2025
326fcd8
Merge remote-tracking branch 'maplibre/main' into cog_web_5
sharkAndshark Aug 16, 2025
17308ab
naming
sharkAndshark Aug 16, 2025
6aad230
bless
sharkAndshark Aug 16, 2025
fa372c6
Merge remote-tracking branch 'maplibre/main' into cog_web_5
sharkAndshark Aug 16, 2025
0b1cb8c
bless
sharkAndshark Aug 16, 2025
bf8f726
add doc
sharkAndshark Aug 16, 2025
b6039a7
add tests
sharkAndshark Aug 16, 2025
ada9be0
cargo clippy
sharkAndshark Aug 16, 2025
0833a42
cargo sort
sharkAndshark Aug 16, 2025
ccba0ee
Merge remote-tracking branch 'maplibre/main' into cog_web_5
sharkAndshark Aug 24, 2025
a348df2
sort toml
sharkAndshark Aug 24, 2025
d4b0f83
Merge branch 'main' into cog_web_5
sharkAndshark Aug 26, 2025
5f194bb
refactor xyz_to_bbox function
sharkAndshark Aug 28, 2025
51270d4
better doc
sharkAndshark Aug 28, 2025
8e35aa1
doc improvement
sharkAndshark Aug 28, 2025
1f04451
Merge branch 'main' into cog_web_5
CommanderStorm Aug 31, 2025
f4ad640
Merge branch 'main' into cog_web_5
CommanderStorm Sep 15, 2025
a8e716a
Merge branch 'main' into cog_web_5
CommanderStorm Sep 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
520 changes: 514 additions & 6 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ env_logger = "0.11"
flate2 = "1"
flume = "0.11"
futures = "0.3"
image = "0.25.6"
imageproc = "0.25.0"
Comment on lines +52 to +53
Copy link
Member

Choose a reason for hiding this comment

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

as far as I remember these two need to be marked as "please always optimise these at O3" as otherwise debug builds handling images are.. painfull.

indoc = "2"
insta = "1"
itertools = "0.14"
Expand Down
1 change: 1 addition & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- [PostgreSQL Connections](pg-connections.md)
- [PostgreSQL Table Sources](sources-pg-tables.md)
- [PostgreSQL Function Sources](sources-pg-functions.md)
- [Cloud-Optimized-GeoTIFF Sources](sources-cog-files.md)
- [Composite Sources](sources-composite.md)
- [Supporting Resources](sources-resources.md)
- [Sprites](sources-sprites.md)
Expand Down
52 changes: 23 additions & 29 deletions docs/src/sources-cog-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,38 @@ Martin can also serve raster sources like local [COG(Cloud Optimized GeoTIFF)](h
* Deflate
* PackBits

## Run Martin with CLI to serve cog files
## Supported Projection

```bash
# Configured with a directory containing `*.tif` or `*.tiff` TIFF files.
martin /with/tiff/dir1 /with/tiff/dir2
# Configured with dedicated TIFF file
martin /path/to/target1.tif /path/to/target2.tiff
# Configured with a combination of directories and dedicated TIFF files.
martin /with/tiff/files /path/to/target1.tif /path/to/target2.tiff
Comment on lines -23 to -28
Copy link
Collaborator Author

@sharkAndshark sharkAndshark Aug 16, 2025

Choose a reason for hiding this comment

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

Enable auto-web in CLI Next PR.

```
Currently we only support COGS with [EPSG:3857](https://epsg.io/3857) by enable the `auto-web` option.

## Run Martin with configuration file
It's beacause the [Tile Matrix Set](https://docs.ogc.org/is/17-083r2/17-083r2.html#72) inside each COG file is highly customized for its extent and tilesize. It's not aligned
with any well knowed TIle Matrix Set.

```yml
keep_alive: 75
To load COG file, there are two approaches generally:

# The socket address to bind [default: 0.0.0.0:3000]
listen_addresses: '0.0.0.0:3000'
1. The client(`Maplibre`, `OpenLayers`,etc) load COG file with the specific customized [Tile Matrix Set](https://docs.ogc.org/is/17-083r2/17-083r2.html#72).
To not break the compatibility with the [TileJson spec](https://github.com/mapbox/tilejson-spec), the `/catalog` seems a good choice to add the customized TMS info (Other data sources could benefit from this if we want to support other projections either, [Join our discussion there](https://github.com/maplibre/martin/issues/343))

# Number of web server workers
worker_processes: 8
2. Martin serve COG files with well known [Tile Matrix Set](https://docs.ogc.org/is/17-083r2/17-083r2.html#72) and do the clipping internally.
Currently, we support [WebMercatorQuad](https://docs.ogc.org/is/17-083r2/17-083r2.html#72) if `auto-web: true` is configured.

# Amount of memory (in MB) to use for caching tiles [default: 512, 0 to disable]
cache_size_mb: 8

# Database configuration. This can also be a list of PG configs.
## Configuration file

```yml
cog:
paths:
# scan this whole dir, matching all *.tif and *.tiff files
- /dir-path
# specific TIFF file will be published as a cog source
- /path/to/target1.tif
- /path/to/target2.tiff
# Default false
# If enabled:
# Serve COG with WebMercatorQuad
# Note: Just work for COG files with EPSG:3857
auto_web: false
sources:
# named source matching source name to a single file
cog-src1: /path/to/cog1.tif
cog-src2: /path/to/cog2.tif
cog-src2: tests/fixtures/cog/rgb_u8.tif
cog-src1: tests/fixtures/cog/rgba_u8.tif
# Test COG with auto_webmercator enabled
cog-auto-web:
path: tests/fixtures/cog/rgba_u8_nodata.tiff
# inline option. Would override the global dauto_web.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# inline option. Would override the global dauto_web.
# Allows overriding the global auto_web for just this source.

auto_web: true
Copy link
Member

Choose a reason for hiding this comment

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

🤔 do we actually need this?
When I think about projections this is more or less a global thing.
I am Unsure.

This is also motivated by new_sources_with_config being kind of hacky in its manual serialisation..

```

## About COG
Expand Down
4 changes: 3 additions & 1 deletion martin-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ homepage.workspace = true

[features]
default = ["fonts", "styles", "sprites", "mbtiles", "cog"]
cog = ["dep:png", "dep:tiff"]
cog = ["dep:tiff", "dep:png", "dep:image", "dep:imageproc"]
fonts = [
"dep:bit-set",
"dep:pbf_font_tools",
Expand All @@ -36,6 +36,8 @@ async-trait.workspace = true
bit-set = { workspace = true, optional = true }
dashmap = { workspace = true, optional = true }
futures = { workspace = true, optional = true }
image = { workspace = true, optional = true }
imageproc = { workspace = true, optional = true }
itertools = { workspace = true, optional = true }
log.workspace = true
martin-tile-utils.workspace = true
Expand Down
4 changes: 4 additions & 0 deletions martin-core/src/tiles/cog/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ pub enum CogError {
)]
GetFullResolutionFailed(PathBuf),

/// Failed to create image buffer
#[error("Failed to create image buffer for {0}: {1}")]
ImageBufferCreationFailed(PathBuf, String),

/// IO error.
#[error("IO error {0}: {1}")]
IoError(std::io::Error, PathBuf),
Expand Down
Loading
Loading