From b295872dbcdb4878862d3a01ddd1f61499ba9b38 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Fri, 30 Aug 2024 04:57:34 +0200 Subject: [PATCH 01/17] implemented sdf --- docs/src/sources-sprites.md | 11 +++++++ martin/src/args/root.rs | 17 ++++++++++- martin/src/sprites/mod.rs | 61 ++++++++++++++++++++++++++----------- 3 files changed, 71 insertions(+), 18 deletions(-) diff --git a/docs/src/sources-sprites.md b/docs/src/sources-sprites.md index 5b24cb8e1..a257c3264 100644 --- a/docs/src/sources-sprites.md +++ b/docs/src/sources-sprites.md @@ -57,6 +57,13 @@ configuration to the config file. martin --sprite /path/to/sprite_a --sprite /path/to/other/sprite_b ``` +To use generate Signed Distance Fields (SDFs) images instead, the `--make_sdf` Option can be added. +This makes images be handled as a SDFs allowing their color to be set at runtime in the map redering engines. + +```bash +martin --sprite /path/to/sprite_a --sprite /path/to/other/sprite_b --make_sdf +``` + ### Configuring with Config File A sprite directory can be configured from the config file with the `sprite` key, similar to @@ -71,6 +78,10 @@ sprites: sources: # SVG images in this directory will be published under the sprite_id "my_sprites" my_sprites: /path/to/some_dir + # This tells Martin to handle images in directories as Signed Distance Fields (SDFs) + # Images are handled as a signed-distance field (SDF) allow their color to be set at runtime in the map redering enines. + # Defaults to `false`. + make_sdf: false ``` The sprites are now avaliable at `/sprite/my_images,some_dir.png`/ ... diff --git a/martin/src/args/root.rs b/martin/src/args/root.rs index 7bcda8103..6a07a98c6 100644 --- a/martin/src/args/root.rs +++ b/martin/src/args/root.rs @@ -1,3 +1,4 @@ +use std::collections::BTreeMap; use std::path::PathBuf; use clap::Parser; @@ -9,6 +10,7 @@ use crate::args::srv::SrvArgs; use crate::config::Config; #[cfg(any(feature = "mbtiles", feature = "pmtiles", feature = "sprites"))] use crate::file_config::FileConfigEnum; +use crate::sprites::SpriteConfig; use crate::MartinError::ConfigAndConnectionsError; use crate::{MartinResult, OptOneMany}; @@ -59,6 +61,12 @@ pub struct ExtraArgs { /// Export a directory with SVG files as a sprite source. Can be specified multiple times. #[arg(short, long)] pub sprite: Vec, + /// tells Martin to handle images in directories as Signed Distance Fields (SDFs) + /// Images handled as a SDF allow their color to be set at runtime in the map redering enines. + /// + /// Defaults to `false`. + #[arg(long)] + pub make_sdf: bool, /// Export a font file or a directory with font files as a font source (recursive). Can be specified multiple times. #[arg(short, long)] pub font: Vec, @@ -109,7 +117,14 @@ impl Args { #[cfg(feature = "sprites")] if !self.extras.sprite.is_empty() { - config.sprites = FileConfigEnum::new(self.extras.sprite); + config.sprites = FileConfigEnum::new_extended( + self.extras.sprite, + BTreeMap::new(), + SpriteConfig { + make_sdf: self.extras.make_sdf, + ..Default::default() + }, + ); } if !self.extras.font.is_empty() { diff --git a/martin/src/sprites/mod.rs b/martin/src/sprites/mod.rs index 07e1c769a..8454bbd8a 100644 --- a/martin/src/sprites/mod.rs +++ b/martin/src/sprites/mod.rs @@ -60,6 +60,11 @@ pub type SpriteCatalog = BTreeMap; #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct SpriteConfig { + /// This tells Martin to handle images in directories as Signed Distance Fields (SDFs) + /// Images are handled as a signed-distance field (SDF) allow their color to be set at runtime in the map redering enines. + /// + /// Defaults to `false`. + pub make_sdf: bool, #[serde(flatten)] pub unrecognized: UnrecognizedValues, } @@ -71,7 +76,14 @@ impl ConfigExtras for SpriteConfig { } #[derive(Debug, Clone, Default)] -pub struct SpriteSources(HashMap); +pub struct SpriteSources { + sources: HashMap, + /// This tells Martin to handle images in directories as Signed Distance Fields (SDFs) + /// Images are handled as a signed-distance field (SDF) allow their color to be set at runtime in the map redering enines. + /// + /// Defaults to `false`. + make_sdf: bool, +} impl SpriteSources { pub fn resolve(config: &mut FileConfigEnum) -> FileResult { @@ -79,7 +91,10 @@ impl SpriteSources { return Ok(Self::default()); }; - let mut results = Self::default(); + let mut results = Self { + make_sdf: cfg.custom.make_sdf, + ..Default::default() + }; let mut directories = Vec::new(); let mut configs = BTreeMap::new(); @@ -110,7 +125,7 @@ impl SpriteSources { pub fn get_catalog(&self) -> SpriteResult { // TODO: all sprite generation should be pre-cached let mut entries = SpriteCatalog::new(); - for (id, source) in &self.0 { + for (id, source) in &self.sources { let paths = get_svg_input_paths(&source.path, true) .map_err(|e| SpriteProcessingError(e, source.path.clone()))?; let mut images = Vec::with_capacity(paths.len()); @@ -131,7 +146,7 @@ impl SpriteSources { if path.is_file() { warn!("Ignoring non-directory sprite source {id} from {disp_path}"); } else { - match self.0.entry(id) { + match self.sources.entry(id) { Entry::Occupied(v) => { warn!("Ignoring duplicate sprite source {} from {disp_path} because it was already configured for {}", v.key(), v.get().path.display()); @@ -156,13 +171,13 @@ impl SpriteSources { let sprite_ids = ids .split(',') .map(|id| { - self.0 + self.sources .get(id) .ok_or_else(|| SpriteError::SpriteNotFound(id.to_string())) }) .collect::>>()?; - get_spritesheet(sprite_ids.into_iter(), dpi).await + get_spritesheet(sprite_ids.into_iter(), dpi, self.make_sdf).await } } @@ -194,6 +209,7 @@ async fn parse_sprite( pub async fn get_spritesheet( sources: impl Iterator, pixel_ratio: u8, + make_sdf: bool, ) -> SpriteResult { // Asynchronously load all SVG files from the given sources let mut futures = Vec::new(); @@ -208,6 +224,9 @@ pub async fn get_spritesheet( } let sprites = try_join_all(futures).await?; let mut builder = SpritesheetBuilder::new(); + if make_sdf { + builder.make_sdf(); + } builder.sprites(sprites.into_iter().collect()); // TODO: decide if this is needed and/or configurable @@ -231,27 +250,35 @@ mod tests { PathBuf::from("../tests/fixtures/sprites/src2"), ]); - let sprites = SpriteSources::resolve(&mut cfg).unwrap().0; + let sprites = SpriteSources::resolve(&mut cfg).unwrap().sources; assert_eq!(sprites.len(), 2); - test_src(sprites.values(), 1, "all_1").await; - test_src(sprites.values(), 2, "all_2").await; + //.sdf => generate sdf from png, add sdf == true + //- => does not generate sdf, omits sdf == true + for extension in [".sdf", ""] { + test_src(sprites.values(), 1, "all_1", extension).await; + test_src(sprites.values(), 2, "all_2", extension).await; - test_src(sprites.get("src1").into_iter(), 1, "src1_1").await; - test_src(sprites.get("src1").into_iter(), 2, "src1_2").await; + test_src(sprites.get("src1").into_iter(), 1, "src1_1", extension).await; + test_src(sprites.get("src1").into_iter(), 2, "src1_2", extension).await; - test_src(sprites.get("src2").into_iter(), 1, "src2_1").await; - test_src(sprites.get("src2").into_iter(), 2, "src2_2").await; + test_src(sprites.get("src2").into_iter(), 1, "src2_1", extension).await; + test_src(sprites.get("src2").into_iter(), 2, "src2_2", extension).await; + } } async fn test_src( sources: impl Iterator, pixel_ratio: u8, filename: &str, + extension: &str, ) { - let path = PathBuf::from(format!("../tests/fixtures/sprites/expected/{filename}")); - - let sprites = get_spritesheet(sources, pixel_ratio).await.unwrap(); + let path = PathBuf::from(format!( + "../tests/fixtures/sprites/expected/{filename}{extension}" + )); + let sprites = get_spritesheet(sources, pixel_ratio, extension == ".sdf") + .await + .unwrap(); let mut json = serde_json::to_string_pretty(sprites.get_index()).unwrap(); json.push('\n'); let png = sprites.encode_png().unwrap(); @@ -269,7 +296,7 @@ mod tests { #[cfg(not(feature = "bless-tests"))] { let expected = std::fs::read_to_string(path.with_extension("json")) - .expect("Unable to open expected JSON file, make sure to bless tests with\n cargo test --features bless-tests\n"); + .expect("Unable to open expected JSON file, make sure to bless tests with\n cargo test --features bless-tests,sprites\n"); assert_eq!( serde_json::from_str::(&json).unwrap(), From 26915574eff2d2d32892f98f1dd5fb452f355d07 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Thu, 26 Sep 2024 00:05:27 +0800 Subject: [PATCH 02/17] improve the wording in the docs --- debian/config.yaml | 1 + docs/src/config-file.md | 1 + docs/src/sources-sprites.md | 4 ++-- tests/config.yaml | 1 + tests/expected/configured/save_config.yaml | 1 + 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/debian/config.yaml b/debian/config.yaml index 30b9ad27e..39b34c953 100644 --- a/debian/config.yaml +++ b/debian/config.yaml @@ -40,6 +40,7 @@ cache_size_mb: 512 # - /path/to/sprites_dir # sources: # sprite1: /path/to/sprites_dir2 +# make_sdf: false # fonts: # - /path/to/font/file.ttf diff --git a/docs/src/config-file.md b/docs/src/config-file.md index 11d7a5402..95caa4222 100644 --- a/docs/src/config-file.md +++ b/docs/src/config-file.md @@ -207,6 +207,7 @@ sprites: sources: # SVG images in this directory will be published as a "my_sprites" sprite source my_sprites: /path/to/some_dir + make_sdf: false # Font configuration fonts: diff --git a/docs/src/sources-sprites.md b/docs/src/sources-sprites.md index a257c3264..101e4c8ac 100644 --- a/docs/src/sources-sprites.md +++ b/docs/src/sources-sprites.md @@ -58,7 +58,7 @@ martin --sprite /path/to/sprite_a --sprite /path/to/other/sprite_b ``` To use generate Signed Distance Fields (SDFs) images instead, the `--make_sdf` Option can be added. -This makes images be handled as a SDFs allowing their color to be set at runtime in the map redering engines. +SDF-Images allow their color to be set at runtime in the map redering engine. ```bash martin --sprite /path/to/sprite_a --sprite /path/to/other/sprite_b --make_sdf @@ -79,7 +79,7 @@ sprites: # SVG images in this directory will be published under the sprite_id "my_sprites" my_sprites: /path/to/some_dir # This tells Martin to handle images in directories as Signed Distance Fields (SDFs) - # Images are handled as a signed-distance field (SDF) allow their color to be set at runtime in the map redering enines. + # SDF-Images allow their color to be set at runtime in the map redering engine. # Defaults to `false`. make_sdf: false ``` diff --git a/tests/config.yaml b/tests/config.yaml index 70b08a05c..d28a0f007 100644 --- a/tests/config.yaml +++ b/tests/config.yaml @@ -179,6 +179,7 @@ sprites: paths: tests/fixtures/sprites/src1 sources: mysrc: tests/fixtures/sprites/src2 + make_sdf: false fonts: - tests/fixtures/fonts/overpass-mono-regular.ttf diff --git a/tests/expected/configured/save_config.yaml b/tests/expected/configured/save_config.yaml index 308490c10..1b91e08fe 100644 --- a/tests/expected/configured/save_config.yaml +++ b/tests/expected/configured/save_config.yaml @@ -170,6 +170,7 @@ sprites: paths: tests/fixtures/sprites/src1 sources: mysrc: tests/fixtures/sprites/src2 + make_sdf: false fonts: - tests/fixtures/fonts/overpass-mono-regular.ttf - tests/fixtures/fonts From 8cade369dfc4c64213bbca2694c652506caa4a8d Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Thu, 26 Sep 2024 00:19:06 +0800 Subject: [PATCH 03/17] removed unnessesary change --- martin/src/sprites/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/martin/src/sprites/mod.rs b/martin/src/sprites/mod.rs index 8454bbd8a..e78fb0902 100644 --- a/martin/src/sprites/mod.rs +++ b/martin/src/sprites/mod.rs @@ -296,7 +296,7 @@ mod tests { #[cfg(not(feature = "bless-tests"))] { let expected = std::fs::read_to_string(path.with_extension("json")) - .expect("Unable to open expected JSON file, make sure to bless tests with\n cargo test --features bless-tests,sprites\n"); + .expect("Unable to open expected JSON file, make sure to bless tests with\n cargo test --features bless-tests\n"); assert_eq!( serde_json::from_str::(&json).unwrap(), From cf15c0f2cde91c729b0ac2cc899df5cc92543971 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Thu, 26 Sep 2024 00:30:12 +0800 Subject: [PATCH 04/17] fixed the testcase having faulty handling of extensions --- martin/src/sprites/mod.rs | 4 +-- .../fixtures/sprites/expected/all_1_sdf.json | 34 ++++++++++++++++++ tests/fixtures/sprites/expected/all_1_sdf.png | Bin 0 -> 785 bytes .../fixtures/sprites/expected/all_2_sdf.json | 34 ++++++++++++++++++ tests/fixtures/sprites/expected/all_2_sdf.png | Bin 0 -> 1567 bytes .../fixtures/sprites/expected/src1_1_sdf.json | 26 ++++++++++++++ .../fixtures/sprites/expected/src1_1_sdf.png | Bin 0 -> 758 bytes .../fixtures/sprites/expected/src1_2_sdf.json | 26 ++++++++++++++ .../fixtures/sprites/expected/src1_2_sdf.png | Bin 0 -> 1515 bytes .../fixtures/sprites/expected/src2_1_sdf.json | 10 ++++++ .../fixtures/sprites/expected/src2_1_sdf.png | Bin 0 -> 189 bytes .../fixtures/sprites/expected/src2_2_sdf.json | 10 ++++++ .../fixtures/sprites/expected/src2_2_sdf.png | Bin 0 -> 344 bytes 13 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/sprites/expected/all_1_sdf.json create mode 100644 tests/fixtures/sprites/expected/all_1_sdf.png create mode 100644 tests/fixtures/sprites/expected/all_2_sdf.json create mode 100644 tests/fixtures/sprites/expected/all_2_sdf.png create mode 100644 tests/fixtures/sprites/expected/src1_1_sdf.json create mode 100644 tests/fixtures/sprites/expected/src1_1_sdf.png create mode 100644 tests/fixtures/sprites/expected/src1_2_sdf.json create mode 100644 tests/fixtures/sprites/expected/src1_2_sdf.png create mode 100644 tests/fixtures/sprites/expected/src2_1_sdf.json create mode 100644 tests/fixtures/sprites/expected/src2_1_sdf.png create mode 100644 tests/fixtures/sprites/expected/src2_2_sdf.json create mode 100644 tests/fixtures/sprites/expected/src2_2_sdf.png diff --git a/martin/src/sprites/mod.rs b/martin/src/sprites/mod.rs index e78fb0902..5d96f13b7 100644 --- a/martin/src/sprites/mod.rs +++ b/martin/src/sprites/mod.rs @@ -255,7 +255,7 @@ mod tests { //.sdf => generate sdf from png, add sdf == true //- => does not generate sdf, omits sdf == true - for extension in [".sdf", ""] { + for extension in ["_sdf", ""] { test_src(sprites.values(), 1, "all_1", extension).await; test_src(sprites.values(), 2, "all_2", extension).await; @@ -276,7 +276,7 @@ mod tests { let path = PathBuf::from(format!( "../tests/fixtures/sprites/expected/{filename}{extension}" )); - let sprites = get_spritesheet(sources, pixel_ratio, extension == ".sdf") + let sprites = get_spritesheet(sources, pixel_ratio, extension == "_sdf") .await .unwrap(); let mut json = serde_json::to_string_pretty(sprites.get_index()).unwrap(); diff --git a/tests/fixtures/sprites/expected/all_1_sdf.json b/tests/fixtures/sprites/expected/all_1_sdf.json new file mode 100644 index 000000000..1ca1cd595 --- /dev/null +++ b/tests/fixtures/sprites/expected/all_1_sdf.json @@ -0,0 +1,34 @@ +{ + "another_bicycle": { + "height": 15, + "pixelRatio": 1, + "width": 15, + "x": 20, + "y": 16, + "sdf": true + }, + "bear": { + "height": 16, + "pixelRatio": 1, + "width": 16, + "x": 20, + "y": 0, + "sdf": true + }, + "bicycle": { + "height": 15, + "pixelRatio": 1, + "width": 15, + "x": 35, + "y": 16, + "sdf": true + }, + "sub/circle": { + "height": 20, + "pixelRatio": 1, + "width": 20, + "x": 0, + "y": 0, + "sdf": true + } +} diff --git a/tests/fixtures/sprites/expected/all_1_sdf.png b/tests/fixtures/sprites/expected/all_1_sdf.png new file mode 100644 index 0000000000000000000000000000000000000000..ffb3546925d2136c95e615982d07ad025b0077b1 GIT binary patch literal 785 zcmV+s1Md8ZP)=B?mot@{dB2B1GuLlM8yW9Oy`WDNkQ17yH(lJ_CT z7_uHse62o#Z%bwPR4Kwj#;g|1zF5%=AIm4AaU{NDAC6%R#-e6nYIuXoL`e_=^1kK) z&Mqc~e0%RA6wK(a{9qXV#+jkRKbPmOx$&s&kO`MLjZn#$4V>l0TjwZYe=g5W0cswP z>#M3Jl7gT}!>Rjcmrt$u8t@QTZGPf-1GOq9LV{}yMw%L-Fc`^Uf`OQbq*YfVt7<}C zm4}INEr4(TGheqGNKiBS$vxhn45Euxm$; zYoxFDfP3>}493n3hxe-*vA8$8Q(o`#SKM3s^Wr?*OpU>VtCz6t5-(0Xt~qY>BnRjxGi7bIscLKL$SqRqNPd5n~{m7;^am<6CWOBeqb4L8ZkImgEo9g5Rj#@ zqws3_41Po+@!i=QNGz=sr45vq%!l}GZbTJ!O)^3c#YayuO&m4bkEq- zX9WE7mi+Td+77`IOnTZ$N+zVF?EnnHI=x>PTop zB%Mg0rsan%Ewwvqe&cFdei&2|acak@t^18DX_+C<63|ok8&}f)M;GEZGHKe$PrH)| P00000NkvXXu0mjfNXl@1 literal 0 HcmV?d00001 diff --git a/tests/fixtures/sprites/expected/all_2_sdf.json b/tests/fixtures/sprites/expected/all_2_sdf.json new file mode 100644 index 000000000..5d1fb2e53 --- /dev/null +++ b/tests/fixtures/sprites/expected/all_2_sdf.json @@ -0,0 +1,34 @@ +{ + "another_bicycle": { + "height": 30, + "pixelRatio": 2, + "width": 30, + "x": 40, + "y": 32, + "sdf": true + }, + "bear": { + "height": 32, + "pixelRatio": 2, + "width": 32, + "x": 40, + "y": 0, + "sdf": true + }, + "bicycle": { + "height": 30, + "pixelRatio": 2, + "width": 30, + "x": 70, + "y": 32, + "sdf": true + }, + "sub/circle": { + "height": 40, + "pixelRatio": 2, + "width": 40, + "x": 0, + "y": 0, + "sdf": true + } +} diff --git a/tests/fixtures/sprites/expected/all_2_sdf.png b/tests/fixtures/sprites/expected/all_2_sdf.png new file mode 100644 index 0000000000000000000000000000000000000000..e1ce6514bfef7520f22e378a4d87aece82c7f688 GIT binary patch literal 1567 zcmaJ>dpOg37@s35w>IYxA|f(VM$F|Xmou?pw2dK`q1+v-gtBZo<(m5}vbl`Zazdt% z%amI#MVQVgJV&R<+>)Hk<@}zbJm;_TKF{}kKkw!9e&6@|$2Zv-V=FD8Bmn|}q)~QA zEMU(9=j0wyK!1c{RzV;UuCoK)25=YptBQ#5EdYT)9kkF}Zra;8*9Eo>xHm)SF4{mg z2mdWqK|}gu3g#+jv`-hudx!{CA96u$MZe(^F84C z?(j%|LavJrFarf=l8Vu~hSDIQt$;NnP9F3$RK)A;H`CWOh3i;p%32+kHPTRkX&!=W z9MDseKBgqCq9Cs+Cm|yxDYbVu@D!;ti~zupBe5792n>j-nwlCM4mY>3u(Y&9p`Dza zoe4ffVg!jqqEIMQDm5b`BQrCzfKgObT+Ax3s;aJT4KMI4CM^fHQ|@{ zrrkOGe1Uju$H4+~W7r)A(;Pvi;`ZD4&wziBIcn5iaJMx;TT14j?QxlgSH|Cr}!}7kn^^7{Pz#FMES^a6#NB!**tKQ#UpfuMZ)?0j}CP6jU$&H^R zBiU@=TkqPO%6rr@wS_tU=&x90!>%w}=8&JVU1pb+ zy6rm!ETYkY?W)+ZLN;_X-LU4TW1jNJspG?vk+r5>E4%#?246wzC1@aGh2y25Q_ZhM zF06^l;*&5>ZOSS>mt*-wDrOUXtf59-=zT}ASMzWBSU8d#RKzDf<*BKe7~yvLWG~Ll z#P;rF4U86#I3@QpfQc8A%4I|omys9};tm;eqc-J7#tUc>^O&sMP!tJKwz{smA?Ybm Ve{~mr*&O&LKqwmwveKFu{}0I}$vOZ4 literal 0 HcmV?d00001 diff --git a/tests/fixtures/sprites/expected/src1_1_sdf.json b/tests/fixtures/sprites/expected/src1_1_sdf.json new file mode 100644 index 000000000..05675714b --- /dev/null +++ b/tests/fixtures/sprites/expected/src1_1_sdf.json @@ -0,0 +1,26 @@ +{ + "another_bicycle": { + "height": 15, + "pixelRatio": 1, + "width": 15, + "x": 20, + "y": 16, + "sdf": true + }, + "bear": { + "height": 16, + "pixelRatio": 1, + "width": 16, + "x": 20, + "y": 0, + "sdf": true + }, + "sub/circle": { + "height": 20, + "pixelRatio": 1, + "width": 20, + "x": 0, + "y": 0, + "sdf": true + } +} diff --git a/tests/fixtures/sprites/expected/src1_1_sdf.png b/tests/fixtures/sprites/expected/src1_1_sdf.png new file mode 100644 index 0000000000000000000000000000000000000000..b3c301e8271c15e67ee8cc03248ad96fd6c5fe1e GIT binary patch literal 758 zcmV+ zBHA*&OvLt}ld(f`8KRd)JPZ%Ac^oJ|-!J@LiCIF7P1?(T@FjWg{oZ?@{NC^VB6t}H z!YGr<)MNsZPJJ1#d2jEI551f`z4|Oa05v(g@S}H%P(eN*N&bRP+#u> zUdb&Vt4I#V_j4dE?4;($_FlQts={9u=HO<23?5v)gl#UXfMS`jSLj@**PcwxrDANe zue7nJ-rPC=$?b<~h5%y<4pXGW#A0P~!wcr)WBDf@uN#mUW^^dARi3cw*im>reFlHF zD17I+gTf=ryFr!O`niT~1l4UAkK^;tDe@78U}nJtM3n46aGqG?Py zTRTTUF`-K)GU@bwooSt^!Bn8WjzQEZ5;{GrOa?`!NPR$lV$?9}^yF<|su7GxU?x+V z`_p?QrrQ=z(T&n<$JV6r0`+s~Mue54Wri)G!TzLZnVq0xBnMlW!p>~Ga oY2Wb(jejxFGwnORW&db@0M)*rOP_5XIsgCw07*qoM6N<$g3p#|H~;_u literal 0 HcmV?d00001 diff --git a/tests/fixtures/sprites/expected/src1_2_sdf.json b/tests/fixtures/sprites/expected/src1_2_sdf.json new file mode 100644 index 000000000..1430954ff --- /dev/null +++ b/tests/fixtures/sprites/expected/src1_2_sdf.json @@ -0,0 +1,26 @@ +{ + "another_bicycle": { + "height": 30, + "pixelRatio": 2, + "width": 30, + "x": 40, + "y": 32, + "sdf": true + }, + "bear": { + "height": 32, + "pixelRatio": 2, + "width": 32, + "x": 40, + "y": 0, + "sdf": true + }, + "sub/circle": { + "height": 40, + "pixelRatio": 2, + "width": 40, + "x": 0, + "y": 0, + "sdf": true + } +} diff --git a/tests/fixtures/sprites/expected/src1_2_sdf.png b/tests/fixtures/sprites/expected/src1_2_sdf.png new file mode 100644 index 0000000000000000000000000000000000000000..c291da9581d0adef937f54f08f1510c6b9526f73 GIT binary patch literal 1515 zcmaJ=do&Yz9G~kZ@3%ZwNXa8HkA)BumyNtO)@9|fQl6t$AvHCRo5$v{&HI_OaoaG= zD{}}Z?;_O{mDfd?h%Q5S=PKv^b-(BQzTeOH@%jF~-`_dE`))1{5~3=i002M&>S*V| zw~qXCT3C>;*^ZBC0Du77%^6|Ocez81Vn5J#J^}!`NFmwhw0AMt^Y|`crv_6zwfWgB z#E(=}1e6u)O+x5W;5xfCt;v^3aBcFxW&B7>V!)3kKPh`$653XaVv}#0i$7H< zAS@b5_SEIifPOMX2LX~Mg z{>tjP)!E=D5N4R6Ld`2Go??t0$PPD=^3Ogq0Bpmi71{U2rHWLEw>OS1lP|^0mVRK) z)oCSiEzb0{y@-%g<}a@e;`LAZYIx z*V?_W&_dp<)HU!DRpG0Zu`(+c!~NCD;LmB6#pcvyqlTr4cN~#Q;o~E^+R2i#lpSWt zl23{PmXwOYZR9_kY%8VQLhoD4Z20n=7~1;nnUD^{CQrsI5a66QK4&4hRUZ)E3{PJf zTXevsPcgQnr(^$eG775MAF1m2F0*OTnn(V=72JiSR~G8%j3ez9&TqYyDpkByG9V_l zI=pGx0ZDlxJgvu&`TT*kKHFO1r8XB}tQz&mYHm$66v)H~6I){!(YPM+B9^XrVleY{ zPp07GIXx&a?Hhwiy15v_>gOGPvwbMHK=DdG0hAafm5r~D{g%Wj%Hn2DsS|4O#eGWW z78)4>Sj0t|d}OQS*_ko|xJy*y=+)IQE>iz_Q z&p4@qw4Zq@diavxbV8gXg=`WxG!!GGmBF91a*JU`Eq^25X2@QPjBmo+^Yq!*){auS zUr3?Vy3cs4rPK3zQ*t{|j-6|xa&9iY2Pu~2VundeUgjgB)8%yHrL{)mVB-2cwRuC| zX*8s8G$ZGu-Y2rz<4q6rdK7G%BPe=GV?gsYdMq-g9|f-OQS84NiSL~$-)V*SNa|iw z`7N)nlyiZi~qz33=-$Uws7p}*5o z1x3D&7Oxe|6N1j^}e&78|@cVRq+D z*yWuOExr{RY~_kNMk%{{bZmGxE%I`ocS9w{WHYb+$rQJ3LJK4WIe4@)9yK94Lu n8anw)-I_yM51;Ih`@r_@kyZWXw}R(^?qTqB^>bP0l+XkKf=NX( literal 0 HcmV?d00001 diff --git a/tests/fixtures/sprites/expected/src2_2_sdf.json b/tests/fixtures/sprites/expected/src2_2_sdf.json new file mode 100644 index 000000000..8cd9eaa1a --- /dev/null +++ b/tests/fixtures/sprites/expected/src2_2_sdf.json @@ -0,0 +1,10 @@ +{ + "bicycle": { + "height": 30, + "pixelRatio": 2, + "width": 30, + "x": 0, + "y": 0, + "sdf": true + } +} diff --git a/tests/fixtures/sprites/expected/src2_2_sdf.png b/tests/fixtures/sprites/expected/src2_2_sdf.png new file mode 100644 index 0000000000000000000000000000000000000000..7c947fd364eebb22bbc03f31683d44387bcec788 GIT binary patch literal 344 zcmV-e0jK_nP)7|On})+;BBS8uB27)~kG>If-{MVi+;39?h(zH_8>u3xVHZlT zQh2}@1oW81=bqmdcNDE*K*3Wc-upC(eYwTRf|h(Iym3*bGMtVTL><_S29&BOayOWP zfmxI9nX7^EXJnXZNhacgX3~oS!1zWI+C(yFQzxOICPfrH^jH+rD9~0W|MVs^iG}&6 z8RSp!ph>oZJvhQSL7)DRrr8KMrG*PdjL@3X#}&MNSrXbzo^Pb qX1BEnwUZCXnB`GsDR_(jS$qKT!s)}bPuy?-0000 Date: Thu, 26 Sep 2024 00:47:32 +0800 Subject: [PATCH 05/17] fix an import error made earlier --- martin/src/args/root.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/martin/src/args/root.rs b/martin/src/args/root.rs index 6a07a98c6..ac3e5c41c 100644 --- a/martin/src/args/root.rs +++ b/martin/src/args/root.rs @@ -1,4 +1,3 @@ -use std::collections::BTreeMap; use std::path::PathBuf; use clap::Parser; @@ -10,7 +9,6 @@ use crate::args::srv::SrvArgs; use crate::config::Config; #[cfg(any(feature = "mbtiles", feature = "pmtiles", feature = "sprites"))] use crate::file_config::FileConfigEnum; -use crate::sprites::SpriteConfig; use crate::MartinError::ConfigAndConnectionsError; use crate::{MartinResult, OptOneMany}; @@ -119,8 +117,8 @@ impl Args { if !self.extras.sprite.is_empty() { config.sprites = FileConfigEnum::new_extended( self.extras.sprite, - BTreeMap::new(), - SpriteConfig { + std::collections::BTreeMap::new(), + crate::sprites::SpriteConfig { make_sdf: self.extras.make_sdf, ..Default::default() }, From 947bc6e48975d2b8185356bb9961bb4e903d6573 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Thu, 26 Sep 2024 01:11:46 +0800 Subject: [PATCH 06/17] made sure that the docs are not all over the place in terms of wording for this feature --- docs/src/sources-sprites.md | 6 +++--- martin/src/args/root.rs | 4 ++-- martin/src/sprites/mod.rs | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/src/sources-sprites.md b/docs/src/sources-sprites.md index 101e4c8ac..679b6d3d7 100644 --- a/docs/src/sources-sprites.md +++ b/docs/src/sources-sprites.md @@ -58,7 +58,7 @@ martin --sprite /path/to/sprite_a --sprite /path/to/other/sprite_b ``` To use generate Signed Distance Fields (SDFs) images instead, the `--make_sdf` Option can be added. -SDF-Images allow their color to be set at runtime in the map redering engine. +SDF Images allow their color to be set at runtime in the map rendering engine. ```bash martin --sprite /path/to/sprite_a --sprite /path/to/other/sprite_b --make_sdf @@ -78,8 +78,8 @@ sprites: sources: # SVG images in this directory will be published under the sprite_id "my_sprites" my_sprites: /path/to/some_dir - # This tells Martin to handle images in directories as Signed Distance Fields (SDFs) - # SDF-Images allow their color to be set at runtime in the map redering engine. + # Tells Martin to handle sprites as Signed Distance Fields (SDFs) + # SDF Images allow their color to be set at runtime in the map rendering engine. # Defaults to `false`. make_sdf: false ``` diff --git a/martin/src/args/root.rs b/martin/src/args/root.rs index ac3e5c41c..0ab29e3ee 100644 --- a/martin/src/args/root.rs +++ b/martin/src/args/root.rs @@ -59,8 +59,8 @@ pub struct ExtraArgs { /// Export a directory with SVG files as a sprite source. Can be specified multiple times. #[arg(short, long)] pub sprite: Vec, - /// tells Martin to handle images in directories as Signed Distance Fields (SDFs) - /// Images handled as a SDF allow their color to be set at runtime in the map redering enines. + /// Tells Martin to handle sprites as Signed Distance Fields (SDFs) + /// SDF Images allow their color to be set at runtime in the map rendering engine. /// /// Defaults to `false`. #[arg(long)] diff --git a/martin/src/sprites/mod.rs b/martin/src/sprites/mod.rs index 5d96f13b7..fd37d9413 100644 --- a/martin/src/sprites/mod.rs +++ b/martin/src/sprites/mod.rs @@ -60,8 +60,8 @@ pub type SpriteCatalog = BTreeMap; #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct SpriteConfig { - /// This tells Martin to handle images in directories as Signed Distance Fields (SDFs) - /// Images are handled as a signed-distance field (SDF) allow their color to be set at runtime in the map redering enines. + /// Tells Martin to handle sprites as Signed Distance Fields (SDFs) + /// SDF Images allow their color to be set at runtime in the map rendering engine. /// /// Defaults to `false`. pub make_sdf: bool, @@ -78,8 +78,8 @@ impl ConfigExtras for SpriteConfig { #[derive(Debug, Clone, Default)] pub struct SpriteSources { sources: HashMap, - /// This tells Martin to handle images in directories as Signed Distance Fields (SDFs) - /// Images are handled as a signed-distance field (SDF) allow their color to be set at runtime in the map redering enines. + /// Tells Martin to handle sprites as Signed Distance Fields (SDFs) + /// SDF Images allow their color to be set at runtime in the map rendering engine. /// /// Defaults to `false`. make_sdf: bool, From cb8c1b8abd484be6f84f7444cdb998b8ab3090f9 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sun, 20 Oct 2024 18:17:37 +0200 Subject: [PATCH 07/17] adapted the docs to a better way of configuring sdf files --- docs/src/config-file.md | 1 - docs/src/sources-sprites.md | 25 +++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/src/config-file.md b/docs/src/config-file.md index 95caa4222..11d7a5402 100644 --- a/docs/src/config-file.md +++ b/docs/src/config-file.md @@ -207,7 +207,6 @@ sprites: sources: # SVG images in this directory will be published as a "my_sprites" sprite source my_sprites: /path/to/some_dir - make_sdf: false # Font configuration fonts: diff --git a/docs/src/sources-sprites.md b/docs/src/sources-sprites.md index 679b6d3d7..f1628b13c 100644 --- a/docs/src/sources-sprites.md +++ b/docs/src/sources-sprites.md @@ -1,6 +1,7 @@ ## Sprite Sources -Given a directory with SVG images, Martin will generate a sprite -- a JSON index and a PNG image, for both low and highresolution displays. The SVG filenames without extension will be used as the sprites' image IDs (remember that one sprite and thus `sprite_id` contains multiple images). +Given a directory with SVG images, Martin will generate a sprite -- a JSON index and a PNG image, for both low and highresolution displays. +The SVG filenames without extension will be used as the sprites' image IDs (remember that one sprite and thus `sprite_id` contains multiple images). The images are searched recursively in the given directory, so subdirectory names will be used as prefixes for the image IDs. For example `icons/bicycle.svg` will be available as `icons/bicycle` sprite image. @@ -40,6 +41,17 @@ the PNG, there is a high DPI version available at `/sprite/@2x.json`. } ``` +##### Coloring at runtime via Sprite Signed Distance Fields (SDFs) + +If you want to set the color of a sprite at runtime, you will need use the [Signed Distance Fields (SDFs)](https://steamcdn-a.akamaihd.net/apps/valve/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf)-endpoints instead. +For example, maplibre does support the image being modified via the [`icon-color`](https://maplibre.org/maplibre-style-spec/layers/#icon-color) and [`icon-halo-color`](https://maplibre.org/maplibre-style-spec/layers/#icon-halo-color) properties. +SDFs have the significant downside of only allowing one color and are thus not the default. +If you want multiple colors, you will need to layer icons. + +The following to APIs are available: +- `/sprite/sdf/.json` for getting a sprite index as SDF and +- `/sprite/sdf/.png` for getting sprite PNGs as SDF + #### Combining Multiple Sprites Multiple `sprite_id` values can be combined into one sprite with the same pattern as for tile @@ -57,13 +69,6 @@ configuration to the config file. martin --sprite /path/to/sprite_a --sprite /path/to/other/sprite_b ``` -To use generate Signed Distance Fields (SDFs) images instead, the `--make_sdf` Option can be added. -SDF Images allow their color to be set at runtime in the map rendering engine. - -```bash -martin --sprite /path/to/sprite_a --sprite /path/to/other/sprite_b --make_sdf -``` - ### Configuring with Config File A sprite directory can be configured from the config file with the `sprite` key, similar to @@ -78,10 +83,6 @@ sprites: sources: # SVG images in this directory will be published under the sprite_id "my_sprites" my_sprites: /path/to/some_dir - # Tells Martin to handle sprites as Signed Distance Fields (SDFs) - # SDF Images allow their color to be set at runtime in the map rendering engine. - # Defaults to `false`. - make_sdf: false ``` The sprites are now avaliable at `/sprite/my_images,some_dir.png`/ ... From 1d8a8f8827f25664e11e42289124ecf442040a85 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sun, 20 Oct 2024 19:29:24 +0200 Subject: [PATCH 08/17] ripped out the old way of configuring sdfs and added a new endpoint --- debian/config.yaml | 1 - martin/src/args/root.rs | 15 +--------- martin/src/sprites/mod.rs | 23 ++++----------- martin/src/srv/sprites.rs | 33 +++++++++++++++++++--- tests/config.yaml | 1 - tests/expected/configured/save_config.yaml | 1 - 6 files changed, 35 insertions(+), 39 deletions(-) diff --git a/debian/config.yaml b/debian/config.yaml index 39b34c953..30b9ad27e 100644 --- a/debian/config.yaml +++ b/debian/config.yaml @@ -40,7 +40,6 @@ cache_size_mb: 512 # - /path/to/sprites_dir # sources: # sprite1: /path/to/sprites_dir2 -# make_sdf: false # fonts: # - /path/to/font/file.ttf diff --git a/martin/src/args/root.rs b/martin/src/args/root.rs index 0ab29e3ee..7bcda8103 100644 --- a/martin/src/args/root.rs +++ b/martin/src/args/root.rs @@ -59,12 +59,6 @@ pub struct ExtraArgs { /// Export a directory with SVG files as a sprite source. Can be specified multiple times. #[arg(short, long)] pub sprite: Vec, - /// Tells Martin to handle sprites as Signed Distance Fields (SDFs) - /// SDF Images allow their color to be set at runtime in the map rendering engine. - /// - /// Defaults to `false`. - #[arg(long)] - pub make_sdf: bool, /// Export a font file or a directory with font files as a font source (recursive). Can be specified multiple times. #[arg(short, long)] pub font: Vec, @@ -115,14 +109,7 @@ impl Args { #[cfg(feature = "sprites")] if !self.extras.sprite.is_empty() { - config.sprites = FileConfigEnum::new_extended( - self.extras.sprite, - std::collections::BTreeMap::new(), - crate::sprites::SpriteConfig { - make_sdf: self.extras.make_sdf, - ..Default::default() - }, - ); + config.sprites = FileConfigEnum::new(self.extras.sprite); } if !self.extras.font.is_empty() { diff --git a/martin/src/sprites/mod.rs b/martin/src/sprites/mod.rs index fd37d9413..82ccca066 100644 --- a/martin/src/sprites/mod.rs +++ b/martin/src/sprites/mod.rs @@ -60,11 +60,6 @@ pub type SpriteCatalog = BTreeMap; #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct SpriteConfig { - /// Tells Martin to handle sprites as Signed Distance Fields (SDFs) - /// SDF Images allow their color to be set at runtime in the map rendering engine. - /// - /// Defaults to `false`. - pub make_sdf: bool, #[serde(flatten)] pub unrecognized: UnrecognizedValues, } @@ -78,11 +73,6 @@ impl ConfigExtras for SpriteConfig { #[derive(Debug, Clone, Default)] pub struct SpriteSources { sources: HashMap, - /// Tells Martin to handle sprites as Signed Distance Fields (SDFs) - /// SDF Images allow their color to be set at runtime in the map rendering engine. - /// - /// Defaults to `false`. - make_sdf: bool, } impl SpriteSources { @@ -91,10 +81,7 @@ impl SpriteSources { return Ok(Self::default()); }; - let mut results = Self { - make_sdf: cfg.custom.make_sdf, - ..Default::default() - }; + let mut results = Self::default(); let mut directories = Vec::new(); let mut configs = BTreeMap::new(); @@ -161,7 +148,7 @@ impl SpriteSources { /// Given a list of IDs in a format "id1,id2,id3", return a spritesheet with them all. /// `ids` may optionally end with "@2x" to request a high-DPI spritesheet. - pub async fn get_sprites(&self, ids: &str) -> SpriteResult { + pub async fn get_sprites(&self, ids: &str, as_sdf: bool) -> SpriteResult { let (ids, dpi) = if let Some(ids) = ids.strip_suffix("@2x") { (ids, 2) } else { @@ -177,7 +164,7 @@ impl SpriteSources { }) .collect::>>()?; - get_spritesheet(sprite_ids.into_iter(), dpi, self.make_sdf).await + get_spritesheet(sprite_ids.into_iter(), dpi, as_sdf).await } } @@ -209,7 +196,7 @@ async fn parse_sprite( pub async fn get_spritesheet( sources: impl Iterator, pixel_ratio: u8, - make_sdf: bool, + as_sdf: bool, ) -> SpriteResult { // Asynchronously load all SVG files from the given sources let mut futures = Vec::new(); @@ -224,7 +211,7 @@ pub async fn get_spritesheet( } let sprites = try_join_all(futures).await?; let mut builder = SpritesheetBuilder::new(); - if make_sdf { + if as_sdf { builder.make_sdf(); } builder.sprites(sprites.into_iter().collect()); diff --git a/martin/src/srv/sprites.rs b/martin/src/srv/sprites.rs index 55a61a81b..174d5c02f 100644 --- a/martin/src/srv/sprites.rs +++ b/martin/src/srv/sprites.rs @@ -15,7 +15,18 @@ async fn get_sprite_png( path: Path, sprites: Data, ) -> ActixResult { - let sheet = get_sprite(&path, &sprites).await?; + let sheet = get_sprite(&path, &sprites, false).await?; + Ok(HttpResponse::Ok() + .content_type(ContentType::png()) + .body(sheet.encode_png().map_err(map_internal_error)?)) +} + +#[route("/sprite/sdf/{source_ids}.png", method = "GET", method = "HEAD")] +async fn get_sprite_sdf_png( + path: Path, + sprites: Data, +) -> ActixResult { + let sheet = get_sprite(&path, &sprites, true).await?; Ok(HttpResponse::Ok() .content_type(ContentType::png()) .body(sheet.encode_png().map_err(map_internal_error)?)) @@ -31,13 +42,27 @@ async fn get_sprite_json( path: Path, sprites: Data, ) -> ActixResult { - let sheet = get_sprite(&path, &sprites).await?; + let sheet = get_sprite(&path, &sprites, false).await?; + Ok(HttpResponse::Ok().json(sheet.get_index())) +} + +#[route( + "/sprite/sdf/{source_ids}.json", + method = "GET", + method = "HEAD", + wrap = "middleware::Compress::default()" +)] +async fn get_sprite_sdf_json( + path: Path, + sprites: Data, +) -> ActixResult { + let sheet = get_sprite(&path, &sprites, true).await?; Ok(HttpResponse::Ok().json(sheet.get_index())) } -async fn get_sprite(path: &SourceIDsRequest, sprites: &SpriteSources) -> ActixResult { +async fn get_sprite(path: &SourceIDsRequest, sprites: &SpriteSources, as_sdf:bool) -> ActixResult { sprites - .get_sprites(&path.source_ids) + .get_sprites(&path.source_ids, as_sdf) .await .map_err(|e| match e { SpriteError::SpriteNotFound(_) => ErrorNotFound(e.to_string()), diff --git a/tests/config.yaml b/tests/config.yaml index d28a0f007..70b08a05c 100644 --- a/tests/config.yaml +++ b/tests/config.yaml @@ -179,7 +179,6 @@ sprites: paths: tests/fixtures/sprites/src1 sources: mysrc: tests/fixtures/sprites/src2 - make_sdf: false fonts: - tests/fixtures/fonts/overpass-mono-regular.ttf diff --git a/tests/expected/configured/save_config.yaml b/tests/expected/configured/save_config.yaml index 1b91e08fe..308490c10 100644 --- a/tests/expected/configured/save_config.yaml +++ b/tests/expected/configured/save_config.yaml @@ -170,7 +170,6 @@ sprites: paths: tests/fixtures/sprites/src1 sources: mysrc: tests/fixtures/sprites/src2 - make_sdf: false fonts: - tests/fixtures/fonts/overpass-mono-regular.ttf - tests/fixtures/fonts From 689cbb1625004568e8a1be41738ce9b98d21f766 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sun, 20 Oct 2024 20:41:14 +0200 Subject: [PATCH 09/17] made sure that the sdf images are correctly generated --- martin/src/sprites/mod.rs | 9 ++++-- martin/src/srv/sprites.rs | 6 +++- .../fixtures/sprites/expected/all_1_sdf.json | 26 +++++++++--------- tests/fixtures/sprites/expected/all_1_sdf.png | Bin 785 -> 945 bytes .../fixtures/sprites/expected/all_2_sdf.json | 26 +++++++++--------- tests/fixtures/sprites/expected/all_2_sdf.png | Bin 1567 -> 1863 bytes .../fixtures/sprites/expected/src1_1_sdf.json | 18 ++++++------ .../fixtures/sprites/expected/src1_1_sdf.png | Bin 758 -> 900 bytes .../fixtures/sprites/expected/src1_2_sdf.json | 18 ++++++------ .../fixtures/sprites/expected/src1_2_sdf.png | Bin 1515 -> 1699 bytes .../fixtures/sprites/expected/src2_1_sdf.json | 4 +-- .../fixtures/sprites/expected/src2_1_sdf.png | Bin 189 -> 377 bytes .../fixtures/sprites/expected/src2_2_sdf.json | 4 +-- .../fixtures/sprites/expected/src2_2_sdf.png | Bin 344 -> 675 bytes 14 files changed, 60 insertions(+), 51 deletions(-) diff --git a/martin/src/sprites/mod.rs b/martin/src/sprites/mod.rs index 82ccca066..05900d34c 100644 --- a/martin/src/sprites/mod.rs +++ b/martin/src/sprites/mod.rs @@ -177,6 +177,7 @@ async fn parse_sprite( name: String, path: PathBuf, pixel_ratio: u8, + as_sdf: bool, ) -> SpriteResult<(String, Sprite)> { let on_err = |e| SpriteError::IoError(e, path.clone()); @@ -188,7 +189,11 @@ async fn parse_sprite( let tree = Tree::from_data(&buffer, &Options::default()) .map_err(|e| SpriteParsingError(e, path.clone()))?; - let sprite = Sprite::new(tree, pixel_ratio).ok_or_else(|| SpriteInstError(path.clone()))?; + let sprite = if as_sdf { + Sprite::new_sdf(tree, pixel_ratio).ok_or_else(|| SpriteInstError(path.clone()))? + } else { + Sprite::new(tree, pixel_ratio).ok_or_else(|| SpriteInstError(path.clone()))? + }; Ok((name, sprite)) } @@ -206,7 +211,7 @@ pub async fn get_spritesheet( for path in paths { let name = sprite_name(&path, &source.path) .map_err(|e| SpriteProcessingError(e, source.path.clone()))?; - futures.push(parse_sprite(name, path, pixel_ratio)); + futures.push(parse_sprite(name, path, pixel_ratio, as_sdf)); } } let sprites = try_join_all(futures).await?; diff --git a/martin/src/srv/sprites.rs b/martin/src/srv/sprites.rs index 174d5c02f..2cd2811dd 100644 --- a/martin/src/srv/sprites.rs +++ b/martin/src/srv/sprites.rs @@ -60,7 +60,11 @@ async fn get_sprite_sdf_json( Ok(HttpResponse::Ok().json(sheet.get_index())) } -async fn get_sprite(path: &SourceIDsRequest, sprites: &SpriteSources, as_sdf:bool) -> ActixResult { +async fn get_sprite( + path: &SourceIDsRequest, + sprites: &SpriteSources, + as_sdf: bool, +) -> ActixResult { sprites .get_sprites(&path.source_ids, as_sdf) .await diff --git a/tests/fixtures/sprites/expected/all_1_sdf.json b/tests/fixtures/sprites/expected/all_1_sdf.json index 1ca1cd595..7a179b175 100644 --- a/tests/fixtures/sprites/expected/all_1_sdf.json +++ b/tests/fixtures/sprites/expected/all_1_sdf.json @@ -1,32 +1,32 @@ { "another_bicycle": { - "height": 15, + "height": 21, "pixelRatio": 1, - "width": 15, - "x": 20, - "y": 16, + "width": 21, + "x": 26, + "y": 22, "sdf": true }, "bear": { - "height": 16, + "height": 22, "pixelRatio": 1, - "width": 16, - "x": 20, + "width": 22, + "x": 26, "y": 0, "sdf": true }, "bicycle": { - "height": 15, + "height": 21, "pixelRatio": 1, - "width": 15, - "x": 35, - "y": 16, + "width": 21, + "x": 0, + "y": 26, "sdf": true }, "sub/circle": { - "height": 20, + "height": 26, "pixelRatio": 1, - "width": 20, + "width": 26, "x": 0, "y": 0, "sdf": true diff --git a/tests/fixtures/sprites/expected/all_1_sdf.png b/tests/fixtures/sprites/expected/all_1_sdf.png index ffb3546925d2136c95e615982d07ad025b0077b1..0575b9f7d803d2775d1637e87ef2b5623f1cc860 100644 GIT binary patch literal 945 zcmV;i15W&jP)5PcUex#o)GU&xI}KJWqL2jW9~A-@n#rN5AHPV8?$RfOCWMF>@{Yv?bm;T-sd zb~GCA){L-Nr0jsSYtPK{yq%p{$hbg&D}=Z~g!n)rdK%K(02iX&Yv|q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NPd5n~{m7;^am<6CWOBeqb4L8ZkImgEo9g5Rj#@ zqws3_41Po+@!i=QNGz=sr45vq%!l}GZbTJ!O)^3c#YayuO&m4bkEq- zX9WE7mi+Td+77`IOnTZ$N+zVF?EnnHI=x>PTop zB%Mg0rsan%Ewwvqe&cFdei&2|acak@t^18DX_+C<63|ok8&}f)M;GEZGHKe$PrH)| P00000NkvXXu0mjfNXl@1 diff --git a/tests/fixtures/sprites/expected/all_2_sdf.json b/tests/fixtures/sprites/expected/all_2_sdf.json index 5d1fb2e53..7da6e3238 100644 --- a/tests/fixtures/sprites/expected/all_2_sdf.json +++ b/tests/fixtures/sprites/expected/all_2_sdf.json @@ -1,32 +1,32 @@ { "another_bicycle": { - "height": 30, + "height": 36, "pixelRatio": 2, - "width": 30, - "x": 40, - "y": 32, + "width": 36, + "x": 84, + "y": 0, "sdf": true }, "bear": { - "height": 32, + "height": 38, "pixelRatio": 2, - "width": 32, - "x": 40, + "width": 38, + "x": 46, "y": 0, "sdf": true }, "bicycle": { - "height": 30, + "height": 36, "pixelRatio": 2, - "width": 30, - "x": 70, - "y": 32, + "width": 36, + "x": 84, + "y": 36, "sdf": true }, "sub/circle": { - "height": 40, + "height": 46, "pixelRatio": 2, - "width": 40, + "width": 46, "x": 0, "y": 0, "sdf": true diff --git a/tests/fixtures/sprites/expected/all_2_sdf.png b/tests/fixtures/sprites/expected/all_2_sdf.png index e1ce6514bfef7520f22e378a4d87aece82c7f688..8f370ed6dd5cce870bb272483466b87a21264e78 100644 GIT binary patch literal 1863 zcmV-N2e|l&P)6Q$ zFq+V>3RRW6iYliys?lUDK+bx78IO$245qXNmRMnxHP+c+lP23!Ws?mWtg*@pODvFW zpIG4wU)f6Bx5ZaJv%;s$wV$V6`$gBzseQs=g}TEYha63jL-yIBY1jsx{V3t?vY)+z!Ars)1D&doY?2@v18C#oe|@n;`g;U5pp9by7q(? ze)VaLoYxjvVmUE*%Pg_@QQWVBJ?6|_+ToTy_dF1pJkY1hrLd1VU{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_sdf.json index 05675714b..d90ee2d88 100644 --- a/tests/fixtures/sprites/expected/src1_1_sdf.json +++ b/tests/fixtures/sprites/expected/src1_1_sdf.json @@ -1,24 +1,24 @@ { "another_bicycle": { - "height": 15, + "height": 21, "pixelRatio": 1, - "width": 15, - "x": 20, - "y": 16, + "width": 21, + "x": 26, + "y": 22, "sdf": true }, "bear": { - "height": 16, + "height": 22, "pixelRatio": 1, - "width": 16, - "x": 20, + "width": 22, + "x": 26, "y": 0, "sdf": true }, "sub/circle": { - "height": 20, + "height": 26, "pixelRatio": 1, - "width": 20, + "width": 26, "x": 0, "y": 0, "sdf": true diff --git a/tests/fixtures/sprites/expected/src1_1_sdf.png b/tests/fixtures/sprites/expected/src1_1_sdf.png index b3c301e8271c15e67ee8cc03248ad96fd6c5fe1e..77717779ff2c6b09c4c56116630818ca92081691 100644 GIT binary patch literal 900 zcmV-~1AF|5P)dRYCv_Lv{^losCE-r<;vbu5X z&dt3V-QphK3Ve^gDl3Gn`+Ir=+@VjGeOV10yQ|#&g&92}ayZ1JDPJf=Pvl30s_~2m z3>4}?B(oE(-p>848NFhL1ybR;tYTBXHHbi*h4_Ibb-s(!Q2AM;IZ`a;Z75m+z~s>V z5D{W^y~aj3<9b1mAt9J30z_C+D?@@8j1dcuWtAYq25bC9L;%PAOkMxmF_lwHK?o-5 zOaW4AzKg4L$0EJU(=E~*po{*V`wu!T@&^c^S@jiQ&Trj{!>wtG#D9im4seY-JTUX> zz7isaWR)@8V8CquMpn{fOu91z(Ujj;JYj?tL#yUB7I_TzQB$O4O{QmpNHp$5Q^S2j z%0R1mV=)Afw9+bJ1Z7S!L&RviIluyIN2Sgzz$JoOfDDOgIu%jR8RlkYRtE#v%i1Kh zir{Df7IsB4-&_FJ^wB8_G1d<&m9!Np0rXpr*koVZU8Ien80XZA)F*%*v(3R}ddA+% z^TYbvKgk*XSX=3eCckBoNx+q@K(_fz$15XDzZc6p&!-{{jy_TcrM9yy)i0WTl$AwThzuJ)3TTvrDhi|xVymg z7B{yYmFj3%C{K@j(U2H#@g%VNRyM~h;%3Ahvssv8p&+R?xxn_UA)V(nr`MfVMA|S% zc*+Zd5Dkg$t)OGhi8ri}V3L=%LNp`0{KiO-@=*T593ufqg%iYf^=(Lj_TLrHc}##2 zBUxa~=VP55jmX9<-MnDM))LYA1T#V=h}r_MW(f1jHUFG&T2G%9L8M>2lS4Ox_Itpb zmt_NJT}27qIkHtz`*UD*Z*u!{U?7$u>RQmTq$UUSz|@*mvc&-PFdVaVM9H av-v*?b+J)b)eS%Z0000+ zBHA*&OvLt}ld(f`8KRd)JPZ%Ac^oJ|-!J@LiCIF7P1?(T@FjWg{oZ?@{NC^VB6t}H z!YGr<)MNsZPJJ1#d2jEI551f`z4|Oa05v(g@S}H%P(eN*N&bRP+#u> zUdb&Vt4I#V_j4dE?4;($_FlQts={9u=HO<23?5v)gl#UXfMS`jSLj@**PcwxrDANe zue7nJ-rPC=$?b<~h5%y<4pXGW#A0P~!wcr)WBDf@uN#mUW^^dARi3cw*im>reFlHF zD17I+gTf=ryFr!O`niT~1l4UAkK^;tDe@78U}nJtM3n46aGqG?Py zTRTTUF`-K)GU@bwooSt^!Bn8WjzQEZ5;{GrOa?`!NPR$lV$?9}^yF<|su7GxU?x+V z`_p?QrrQ=z(T&n<$JV6r0`+s~Mue54Wri)G!TzLZnVq0xBnMlW!p>~Ga oY2Wb(jejxFGwnORW&db@0M)*rOP_5XIsgCw07*qoM6N<$g3p#|H~;_u diff --git a/tests/fixtures/sprites/expected/src1_2_sdf.json b/tests/fixtures/sprites/expected/src1_2_sdf.json index 1430954ff..9b7683ec8 100644 --- a/tests/fixtures/sprites/expected/src1_2_sdf.json +++ b/tests/fixtures/sprites/expected/src1_2_sdf.json @@ -1,24 +1,24 @@ { "another_bicycle": { - "height": 30, + "height": 36, "pixelRatio": 2, - "width": 30, - "x": 40, - "y": 32, + "width": 36, + "x": 84, + "y": 0, "sdf": true }, "bear": { - "height": 32, + "height": 38, "pixelRatio": 2, - "width": 32, - "x": 40, + "width": 38, + "x": 46, "y": 0, "sdf": true }, "sub/circle": { - "height": 40, + "height": 46, "pixelRatio": 2, - "width": 40, + "width": 46, "x": 0, "y": 0, "sdf": true diff --git a/tests/fixtures/sprites/expected/src1_2_sdf.png b/tests/fixtures/sprites/expected/src1_2_sdf.png index c291da9581d0adef937f54f08f1510c6b9526f73..d61be9e07a2ae151d9134c01f55f923d99337dbd 100644 GIT binary patch literal 1699 zcmV;U23+}xP)?P6vux9o%GbHiCb`HCnmB0djm4SiEcqh>K4SYQfn}TrfFjc?c))(ktLKkZs{fX zDkuNcvAjqL7X8{fA)31N^}FZuen5CEu*3?hth2!;TU6K{D_coxiFH<4VTlF8<5SY| znJ<(x_mz_~Ye~ze;M%pZ*M8Qub2>g@utMEok3)_K<&gcPwPM%?9e$K>ci9i_Gvw!@ zYj@bsyl;nOGa^DcqiUbO$BsdVIwQqB!SAb46>=#ny0%IUzxpIa zo^&j-#B!$dmRVx)t+-zVd(5f5w9X}6dR!BmT+^jZL)gb0uqU0pG;PQI!5uLJe)1I| z2QIRsYriH}4T$OU!;#-$lO-3oxjbB%m0-_lb1TgIL>_rce)l?aONTlUryNUXFJDs@ z!VNJGjFR7w0pF={Jl0K)iMV9IP*=y?2)R5_qn}^({l$D-nU%rzi5VJZD31&c`-*ev zY!{h!s^x8tOuKRVjNb{yfV!D&C^hN~c;I*Xj+lRlIAVLEMinOl-(O`Z7gsuI(U(@9 zCdw}}y%vccWZIj0jRW8DVAl%SI;lmQD|)zeXw$ULFmnckI5dyg&F&8!_bW)yUi+{8s^)H(Rm;}^h7tcDu3_w~%Il#@xVrII z9%z8jBoj{)#9>y$%{I?iB5(d)gh}l>y2g zpED-iw)kO|W$!wpE?~RMV)#ZTT}r$4+y!_)gkq3g(uTEH_tJ*KIEReGK{Rq|ddKDX^}gD$aj9ohf4 z%E)bZ3`3?InB4nh$gMQ9g#&k{2iE5cSee8O*Q!95Up&~EJ`F2Ro5nI!t5t$2@+LEw zT)r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JK4WIe4@)9yK94Lu n8anw)-I_yM51;Ih`@r_@kyZWXw}R(^?qTqB^>bP0l+XkKf=NX( diff --git a/tests/fixtures/sprites/expected/src2_2_sdf.json b/tests/fixtures/sprites/expected/src2_2_sdf.json index 8cd9eaa1a..03636083d 100644 --- a/tests/fixtures/sprites/expected/src2_2_sdf.json +++ b/tests/fixtures/sprites/expected/src2_2_sdf.json @@ -1,8 +1,8 @@ { "bicycle": { - "height": 30, + "height": 36, "pixelRatio": 2, - "width": 30, + "width": 36, "x": 0, "y": 0, "sdf": true diff --git a/tests/fixtures/sprites/expected/src2_2_sdf.png b/tests/fixtures/sprites/expected/src2_2_sdf.png index 7c947fd364eebb22bbc03f31683d44387bcec788..78f861308997171ea138243ab0f386c11d099fa1 100644 GIT binary patch literal 675 zcmV;U0$lxxP)rsN*w!@OcDoR}ySiRiy{az72OBpSV2Dp%xEgTx%F(Cc2%nL7;cCR){o^dXQrY=Y^{rQ(iX2#WBDr^nl{f;3V0@aVJB< zOD~Qg@0o@kbb$Ww69=LyLH5Rj1_mWLd7#U5_W~f^j~$!>EIL46jBZsGdSSl0q180{ zDROg^SmC>XN~1fW-21BXFt-?Ef*Fi#nH}+n3JZgN;_5f|wpg1_8D)kEt!@P+n3T#n zjTDFid=^K~=FLID7CN=S+`<$TVU+d)6-2Cz8=Jit%!`71gp*XX$Xh7E7&kmrW3PPG z_Wgt%PV&v!{Gf`ed3ueqg~FJVTmc-R#4B&FwsRz$qtS-5S7XYAt8EK41}2!JXnELS zW1el%;1~Y#vu8*vgAo9A4jXw&C|b{nf*BU5XnIrtyaSbhdAq?#j~}Q-_*y5FS)!;2 zbpT5k)qqM2fMo8sY6N!P_=-jlyu$$ynj;(FJO&R-hu-+01qH zYXd)+ajE^wKqA;5^!ifz04NAeZ*7I5<9euH2B8IHKUn!cbjgh91#~X`7|On})+;BBS8uB27)~kG>If-{MVi+;39?h(zH_8>u3xVHZlT zQh2}@1oW81=bqmdcNDE*K*3Wc-upC(eYwTRf|h(Iym3*bGMtVTL><_S29&BOayOWP zfmxI9nX7^EXJnXZNhacgX3~oS!1zWI+C(yFQzxOICPfrH^jH+rD9~0W|MVs^iG}&6 z8RSp!ph>oZJvhQSL7)DRrr8KMrG*PdjL@3X#}&MNSrXbzo^Pb qX1BEnwUZCXnB`GsDR_(jS$qKT!s)}bPuy?-0000 Date: Sun, 20 Oct 2024 20:56:07 +0200 Subject: [PATCH 10/17] reverted an unnecessary breaking change --- martin/src/sprites/mod.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/martin/src/sprites/mod.rs b/martin/src/sprites/mod.rs index 05900d34c..05e17694b 100644 --- a/martin/src/sprites/mod.rs +++ b/martin/src/sprites/mod.rs @@ -71,9 +71,7 @@ impl ConfigExtras for SpriteConfig { } #[derive(Debug, Clone, Default)] -pub struct SpriteSources { - sources: HashMap, -} +pub struct SpriteSources(HashMap); impl SpriteSources { pub fn resolve(config: &mut FileConfigEnum) -> FileResult { @@ -112,7 +110,7 @@ impl SpriteSources { pub fn get_catalog(&self) -> SpriteResult { // TODO: all sprite generation should be pre-cached let mut entries = SpriteCatalog::new(); - for (id, source) in &self.sources { + for (id, source) in &self.0 { let paths = get_svg_input_paths(&source.path, true) .map_err(|e| SpriteProcessingError(e, source.path.clone()))?; let mut images = Vec::with_capacity(paths.len()); @@ -133,7 +131,7 @@ impl SpriteSources { if path.is_file() { warn!("Ignoring non-directory sprite source {id} from {disp_path}"); } else { - match self.sources.entry(id) { + match self.0.entry(id) { Entry::Occupied(v) => { warn!("Ignoring duplicate sprite source {} from {disp_path} because it was already configured for {}", v.key(), v.get().path.display()); @@ -158,7 +156,7 @@ impl SpriteSources { let sprite_ids = ids .split(',') .map(|id| { - self.sources + self.0 .get(id) .ok_or_else(|| SpriteError::SpriteNotFound(id.to_string())) }) @@ -242,7 +240,7 @@ mod tests { PathBuf::from("../tests/fixtures/sprites/src2"), ]); - let sprites = SpriteSources::resolve(&mut cfg).unwrap().sources; + let sprites = SpriteSources::resolve(&mut cfg).unwrap().0; assert_eq!(sprites.len(), 2); //.sdf => generate sdf from png, add sdf == true From 20e65191dcde3655ff30b085f81466f1044261df Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sun, 20 Oct 2024 20:56:15 +0200 Subject: [PATCH 11/17] reworded parts of the docs --- docs/src/sources-sprites.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/src/sources-sprites.md b/docs/src/sources-sprites.md index f1628b13c..c7689b053 100644 --- a/docs/src/sources-sprites.md +++ b/docs/src/sources-sprites.md @@ -41,14 +41,15 @@ the PNG, there is a high DPI version available at `/sprite/@2x.json`. } ``` -##### Coloring at runtime via Sprite Signed Distance Fields (SDFs) +##### Coloring at runtime via Signed Distance Fields (SDFs) -If you want to set the color of a sprite at runtime, you will need use the [Signed Distance Fields (SDFs)](https://steamcdn-a.akamaihd.net/apps/valve/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf)-endpoints instead. -For example, maplibre does support the image being modified via the [`icon-color`](https://maplibre.org/maplibre-style-spec/layers/#icon-color) and [`icon-halo-color`](https://maplibre.org/maplibre-style-spec/layers/#icon-halo-color) properties. -SDFs have the significant downside of only allowing one color and are thus not the default. -If you want multiple colors, you will need to layer icons. +If you want to set the color of a sprite at runtime, you will need use the [Signed Distance Fields (SDFs)](https://steamcdn-a.akamaihd.net/apps/valve/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf)-endpoints. +For example, maplibre does support the image being modified via the [`icon-color`](https://maplibre.org/maplibre-style-spec/layers/#icon-color) and [`icon-halo-color`](https://maplibre.org/maplibre-style-spec/layers/#icon-halo-color) properties if using SDFs. -The following to APIs are available: +SDFs have the significant **downside of only allowing one color**. +If you want multiple colors, you will need to layer icons on top of each other. + +The following APIs are available: - `/sprite/sdf/.json` for getting a sprite index as SDF and - `/sprite/sdf/.png` for getting sprite PNGs as SDF From 54697b1c088918fef88fc09a98f6aaff4cde903c Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sun, 20 Oct 2024 21:07:21 +0200 Subject: [PATCH 12/17] fixed markdown linting issues --- docs/src/sources-sprites.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/sources-sprites.md b/docs/src/sources-sprites.md index c7689b053..1bcbc9ccb 100644 --- a/docs/src/sources-sprites.md +++ b/docs/src/sources-sprites.md @@ -50,6 +50,7 @@ SDFs have the significant **downside of only allowing one color**. If you want multiple colors, you will need to layer icons on top of each other. The following APIs are available: + - `/sprite/sdf/.json` for getting a sprite index as SDF and - `/sprite/sdf/.png` for getting sprite PNGs as SDF From 988c22db2375660e16912ce91e706b9fbd0334a6 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Mon, 21 Oct 2024 21:47:02 +0200 Subject: [PATCH 13/17] changed the url as requested --- docs/src/sources-sprites.md | 4 ++-- martin/src/srv/sprites.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/src/sources-sprites.md b/docs/src/sources-sprites.md index 1bcbc9ccb..ac865b12c 100644 --- a/docs/src/sources-sprites.md +++ b/docs/src/sources-sprites.md @@ -51,8 +51,8 @@ If you want multiple colors, you will need to layer icons on top of each other. The following APIs are available: -- `/sprite/sdf/.json` for getting a sprite index as SDF and -- `/sprite/sdf/.png` for getting sprite PNGs as SDF +- `/sdf_sprite/.json` for getting a sprite index as SDF and +- `/sdf_sprite/.png` for getting sprite PNGs as SDF #### Combining Multiple Sprites diff --git a/martin/src/srv/sprites.rs b/martin/src/srv/sprites.rs index 2cd2811dd..d9d4c2845 100644 --- a/martin/src/srv/sprites.rs +++ b/martin/src/srv/sprites.rs @@ -21,7 +21,7 @@ async fn get_sprite_png( .body(sheet.encode_png().map_err(map_internal_error)?)) } -#[route("/sprite/sdf/{source_ids}.png", method = "GET", method = "HEAD")] +#[route("/sdf_sprite/{source_ids}.png", method = "GET", method = "HEAD")] async fn get_sprite_sdf_png( path: Path, sprites: Data, @@ -47,7 +47,7 @@ async fn get_sprite_json( } #[route( - "/sprite/sdf/{source_ids}.json", + "/sdf_sprite/{source_ids}.json", method = "GET", method = "HEAD", wrap = "middleware::Compress::default()" From bf00d85a5c8e1bac00adb5764e80f54716d0b26a Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Mon, 21 Oct 2024 21:55:49 +0200 Subject: [PATCH 14/17] fixed the service not being registered --- martin/src/srv/server.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/martin/src/srv/server.rs b/martin/src/srv/server.rs index c4f3e0f3a..75af0e6b2 100755 --- a/martin/src/srv/server.rs +++ b/martin/src/srv/server.rs @@ -114,7 +114,9 @@ pub fn router(cfg: &mut web::ServiceConfig, #[allow(unused_variables)] usr_cfg: .service(get_tile); #[cfg(feature = "sprites")] - cfg.service(crate::srv::sprites::get_sprite_json) + cfg.service(crate::srv::sprites::get_sprite_sdf_json) + .service(crate::srv::sprites::get_sprite_json) + .service(crate::srv::sprites::get_sprite_sdf_png) .service(crate::srv::sprites::get_sprite_png); #[cfg(feature = "fonts")] From 8ed9be0a0f519174d373ea3b1d5e9e3829d1bee8 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 21 Oct 2024 15:59:57 -0400 Subject: [PATCH 15/17] Update martin/src/sprites/mod.rs Co-authored-by: Frank Elsinga --- martin/src/sprites/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/martin/src/sprites/mod.rs b/martin/src/sprites/mod.rs index 05e17694b..033f9631f 100644 --- a/martin/src/sprites/mod.rs +++ b/martin/src/sprites/mod.rs @@ -188,10 +188,11 @@ async fn parse_sprite( .map_err(|e| SpriteParsingError(e, path.clone()))?; let sprite = if as_sdf { - Sprite::new_sdf(tree, pixel_ratio).ok_or_else(|| SpriteInstError(path.clone()))? + Sprite::new_sdf(tree, pixel_ratio) } else { - Sprite::new(tree, pixel_ratio).ok_or_else(|| SpriteInstError(path.clone()))? + Sprite::new(tree, pixel_ratio) }; + let sprite = sprite.ok_or_else(|| SpriteInstError(path.clone()))?; Ok((name, sprite)) } From f425c4e11fc046b67cdbd1dc589bec7bb7838fd8 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Tue, 22 Oct 2024 13:19:40 +0200 Subject: [PATCH 16/17] added a test to `test.sh` --- tests/expected/configured/sdf_spr_cmp.json | 34 +++++++++++++++++ tests/expected/configured/sdf_spr_cmp.png | Bin 0 -> 945 bytes tests/expected/configured/sdf_spr_cmp.png.txt | 1 + tests/expected/configured/sdf_spr_cmp_2.json | 34 +++++++++++++++++ tests/expected/configured/sdf_spr_cmp_2.png | Bin 0 -> 1863 bytes .../expected/configured/sdf_spr_cmp_2.png.txt | 1 + tests/expected/configured/sdf_spr_mysrc.json | 10 +++++ tests/expected/configured/sdf_spr_mysrc.png | Bin 0 -> 675 bytes .../expected/configured/sdf_spr_mysrc.png.txt | 1 + tests/expected/configured/sdf_spr_src1.json | 26 +++++++++++++ tests/expected/configured/sdf_spr_src1.png | Bin 0 -> 900 bytes .../expected/configured/sdf_spr_src1.png.txt | 1 + tests/expected/configured/sdf_spr_src1_.json | 26 +++++++++++++ tests/expected/configured/sdf_spr_src1_.png | Bin 0 -> 1699 bytes .../expected/configured/sdf_spr_src1_.png.txt | 1 + tests/test.sh | 36 ++++++++++++------ 16 files changed, 159 insertions(+), 12 deletions(-) create mode 100644 tests/expected/configured/sdf_spr_cmp.json create mode 100644 tests/expected/configured/sdf_spr_cmp.png create mode 100644 tests/expected/configured/sdf_spr_cmp.png.txt create mode 100644 tests/expected/configured/sdf_spr_cmp_2.json create mode 100644 tests/expected/configured/sdf_spr_cmp_2.png create mode 100644 tests/expected/configured/sdf_spr_cmp_2.png.txt create mode 100644 tests/expected/configured/sdf_spr_mysrc.json create mode 100644 tests/expected/configured/sdf_spr_mysrc.png create mode 100644 tests/expected/configured/sdf_spr_mysrc.png.txt create mode 100644 tests/expected/configured/sdf_spr_src1.json create mode 100644 tests/expected/configured/sdf_spr_src1.png create mode 100644 tests/expected/configured/sdf_spr_src1.png.txt create mode 100644 tests/expected/configured/sdf_spr_src1_.json create mode 100644 tests/expected/configured/sdf_spr_src1_.png create mode 100644 tests/expected/configured/sdf_spr_src1_.png.txt diff --git a/tests/expected/configured/sdf_spr_cmp.json b/tests/expected/configured/sdf_spr_cmp.json new file mode 100644 index 000000000..7a179b175 --- /dev/null +++ b/tests/expected/configured/sdf_spr_cmp.json @@ -0,0 +1,34 @@ +{ + "another_bicycle": { + "height": 21, + "pixelRatio": 1, + "width": 21, + "x": 26, + "y": 22, + "sdf": true + }, + "bear": { + "height": 22, + "pixelRatio": 1, + "width": 22, + "x": 26, + "y": 0, + "sdf": true + }, + "bicycle": { + "height": 21, + "pixelRatio": 1, + "width": 21, + "x": 0, + "y": 26, + "sdf": true + }, + "sub/circle": { + "height": 26, + "pixelRatio": 1, + "width": 26, + "x": 0, + "y": 0, + "sdf": true + } +} diff --git a/tests/expected/configured/sdf_spr_cmp.png b/tests/expected/configured/sdf_spr_cmp.png new file mode 100644 index 0000000000000000000000000000000000000000..0575b9f7d803d2775d1637e87ef2b5623f1cc860 GIT binary patch literal 945 zcmV;i15W&jP)5PcUex#o)GU&xI}KJWqL2jW9~A-@n#rN5AHPV8?$RfOCWMF>@{Yv?bm;T-sd zb~GCA){L-Nr0jsSYtPK{yq%p{$hbg&D}=Z~g!n)rdK%K(02iX&Yv|qK76bH21~j{C z*!8S?F}lYHUk_x2p(qOk&4+M$V?1EUE{8N5H|%a|_t)0w328$TJXz&yfrx1RghVu6 z@QATMJ<`hAjSxBa_txkQOO!Aq12b z?k7l*iR%q^Bo)s~2AMDf6U6{2R;*Pa$17&YNM zA?iv13~O%5m2pC=Ej``C)BpoAa_&FqrIrscgs>V4K*8U-$Cm!0DXT3itZIN;Jm8U; zZ@SkI8HiPm;SOVF`xh#u$uY^!j7gJzU+|16)*RY#*`TaruphO6(V9%p94To$kfwzD z4ugFwz|O`HgJ@-|oFmX;utdty4r+iB8>M#4EJh!3D?o+ZYBn;WT`CmT%vzleATQfV z`rHUKz!K&NneSH9<+L|N31;$PDy40b_Tj$8W0OO0xf7ChD$a#X(y#`2YavOe=@r*r zK0lm)|DWUvzin9=kR~E26r_0aK?@LCyB}PA+$mmTCIAsa1OSyf<}>ps6+vU0wao2a z1%TsoadNTix(JTQ#A<^16y?Q<<@%DXYC0p9%v; z0DSp`jv$pUcI(7N;KgUl9*~Y&vyB&@N3$qrTeaq>efiYq!0wZ*)xP=gsZX+%ky>-+ zdGV=gQPe2udfh|d&8IGoBB5II>G$SSmv@ma^t$8Ar|0nJ({uRq=`;NKJlFX@vN3Um T+6cww00000NkvXXu0mjfF6G3o literal 0 HcmV?d00001 diff --git a/tests/expected/configured/sdf_spr_cmp.png.txt b/tests/expected/configured/sdf_spr_cmp.png.txt new file mode 100644 index 000000000..8f3852018 --- /dev/null +++ b/tests/expected/configured/sdf_spr_cmp.png.txt @@ -0,0 +1 @@ +tests/output/configured/sdf_spr_cmp.png: PNG image data, 48 x 47, 8-bit gray+alpha, non-interlaced diff --git a/tests/expected/configured/sdf_spr_cmp_2.json b/tests/expected/configured/sdf_spr_cmp_2.json new file mode 100644 index 000000000..7da6e3238 --- /dev/null +++ b/tests/expected/configured/sdf_spr_cmp_2.json @@ -0,0 +1,34 @@ +{ + "another_bicycle": { + "height": 36, + "pixelRatio": 2, + "width": 36, + "x": 84, + "y": 0, + "sdf": true + }, + "bear": { + "height": 38, + "pixelRatio": 2, + "width": 38, + "x": 46, + "y": 0, + "sdf": true + }, + "bicycle": { + "height": 36, + "pixelRatio": 2, + "width": 36, + "x": 84, + "y": 36, + "sdf": true + }, + "sub/circle": { + "height": 46, + "pixelRatio": 2, + "width": 46, + "x": 0, + "y": 0, + "sdf": true + } +} diff --git a/tests/expected/configured/sdf_spr_cmp_2.png b/tests/expected/configured/sdf_spr_cmp_2.png new file mode 100644 index 0000000000000000000000000000000000000000..8f370ed6dd5cce870bb272483466b87a21264e78 GIT binary patch literal 1863 zcmV-N2e|l&P)6Q$ zFq+V>3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Brb^{y|gAc*|`^e*Cf7-V#OW*LOjEsoB!vA+tCr=-1+5Q{(@{F! zAicmZ>Yx7x04!)*#y-O==?_EB4_4nLSV-29NF77k(B{5RrL8g7>q*Koj=J!U2 zn5Nt}H`&CL0!?#d19{I(k4a43pUtAi#%~0b}>o!Y`M-AJoH6Ar< zGuC+24SD7okGdg;s`02z3svJ$n-;3Zqc$y6jYn--s2Y#jv`{r3wP`cgc+?Ykh8mCm z0&roCNBx0I*Lc+3q)XR$)Hi6&P~%b0X{mCJM_m(-(ls7+Pc2K=c+`FIP`bvW?#sgp zH6Hce0H{>sQRgk5N;Mw!-o&d^<5BNz+W%Ym_BV#=4rJQV9dQ5v002ovPDHLkV1jL* BqW%B? literal 0 HcmV?d00001 diff --git a/tests/expected/configured/sdf_spr_cmp_2.png.txt b/tests/expected/configured/sdf_spr_cmp_2.png.txt new file mode 100644 index 000000000..803547c0b --- /dev/null +++ b/tests/expected/configured/sdf_spr_cmp_2.png.txt @@ -0,0 +1 @@ +tests/output/configured/sdf_spr_cmp_2.png: PNG image data, 120 x 72, 8-bit gray+alpha, non-interlaced diff --git a/tests/expected/configured/sdf_spr_mysrc.json b/tests/expected/configured/sdf_spr_mysrc.json new file mode 100644 index 000000000..03636083d --- /dev/null +++ b/tests/expected/configured/sdf_spr_mysrc.json @@ -0,0 +1,10 @@ +{ + "bicycle": { + "height": 36, + "pixelRatio": 2, + "width": 36, + "x": 0, + "y": 0, + "sdf": true + } +} diff --git a/tests/expected/configured/sdf_spr_mysrc.png b/tests/expected/configured/sdf_spr_mysrc.png new file mode 100644 index 0000000000000000000000000000000000000000..78f861308997171ea138243ab0f386c11d099fa1 GIT binary patch literal 675 zcmV;U0$lxxP)rsN*w!@OcDoR}ySiRiy{az72OBpSV2Dp%xEgTx%F(Cc2%nL7;cCR){o^dXQrY=Y^{rQ(iX2#WBDr^nl{f;3V0@aVJB< zOD~Qg@0o@kbb$Ww69=LyLH5Rj1_mWLd7#U5_W~f^j~$!>EIL46j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jFcm=A+{)@a_RpYJQ zU)A{+z)!`A0~ZjbCjcu@Igqzk)&BngD{#yh?O!qJlXOnaO*U*ldEKNR=Va1e$34!R z&(~QFg4UrXeV+xT$?aL-YwqU|w3fY6pVEs*Ua@JYIVLS7QZq=Uot$=0ONwd5rzMTG zQ?q)UVcb<=!-nxbg!RHBqDjvSi@f&v7aof?+E($Zn&_=g(Z)wz%YY^+3`wPBP&($c ztF$y9YpDMVEiKb2w;lQM+p@hCiqfyog8ERirolrnILK+&;9*Psf6K7&!2{B<%#o&M zL-Qtf`j&2_U(IuCH0;B}aQHX5UBg59SVU(I!$Y4lb91~C@+91ba9zKQn*ay~_(A(0 zo&ZSaL^t&rRU*C_^5kH3rj-m|E^*{w0oSK+!uH8iJXeKG@pSNDhKk{vh{bj*JuKC9tqN^uPrc!WzWT_G2+)Z*Q#$T^+34;Op*Vwy~^ThL;fy3-@) z6cQ|I7ml1Uy{oC0OFO}G>0f?4H$5$gOV6_{i2wD6o1V5jD2e26dFYJY^6&u;CGAW- zTBqZiS_Gc6spTV>GoI8l^{RGg(Xeex%A(q~botu0rH`TAu^ZF02e10pjcFfAx0ALW t?&ohk{Ai~9`sUJ-VQ=ScF8xTR{2vfV^LGALUUC2c002ovPDHLkV1m`bNv8k+ literal 0 HcmV?d00001 diff --git a/tests/expected/configured/sdf_spr_src1_.png.txt b/tests/expected/configured/sdf_spr_src1_.png.txt new file mode 100644 index 000000000..b1c908d2d --- /dev/null +++ b/tests/expected/configured/sdf_spr_src1_.png.txt @@ -0,0 +1 @@ +tests/output/configured/sdf_spr_src1_.png: PNG image data, 120 x 46, 8-bit gray+alpha, non-interlaced diff --git a/tests/test.sh b/tests/test.sh index 1675918fd..77ddf3a44 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -357,18 +357,30 @@ test_png pmt_0_0_0 pmt/0/0/0 test_png pmt2_0_0_0 pmt2/0/0/0 # HTTP pmtiles # Test sprites -test_jsn spr_src1 sprite/src1.json -test_png spr_src1 sprite/src1.png -test_jsn spr_src1_2x sprite/src1@2x.json -test_png spr_src1_2x sprite/src1@2x.png -test_jsn spr_mysrc sprite/mysrc.json -test_png spr_mysrc sprite/mysrc.png -test_jsn spr_mysrc_2x sprite/mysrc@2x.json -test_png spr_mysrc_2x sprite/mysrc@2x.png -test_jsn spr_cmp sprite/src1,mysrc.json -test_png spr_cmp sprite/src1,mysrc.png -test_jsn spr_cmp_2x sprite/src1,mysrc@2x.json -test_png spr_cmp_2x sprite/src1,mysrc@2x.png +test_jsn spr_src1 sprite/src1.json +test_jsn sdf_spr_src1 sdf_sprite/src1.json +test_png spr_src1 sprite/src1.png +test_png sdf_spr_src1 sdf_sprite/src1.png +test_jsn spr_src1_2x sprite/src1@2x.json +test_jsn sdf_spr_src1_ sdf_sprite/src1@2x.json +test_png spr_src1_2x sprite/src1@2x.png +test_png sdf_spr_src1_ sdf_sprite/src1@2x.png +test_jsn spr_mysrc sprite/mysrc.json +test_jsn sdf_spr_mysrc sdf_sprite/mysrc.json +test_png spr_mysrc sprite/mysrc.png +test_png sdf_spr_mysrc sdf_sprite/mysrc.png +test_jsn spr_mysrc_2x sprite/mysrc@2x.json +test_jsn sdf_spr_mysrc sdf_sprite/mysrc@2x.json +test_png spr_mysrc_2x sprite/mysrc@2x.png +test_png sdf_spr_mysrc sdf_sprite/mysrc@2x.png +test_jsn spr_cmp sprite/src1,mysrc.json +test_jsn sdf_spr_cmp sdf_sprite/src1,mysrc.json +test_png spr_cmp sprite/src1,mysrc.png +test_png sdf_spr_cmp sdf_sprite/src1,mysrc.png +test_jsn spr_cmp_2x sprite/src1,mysrc@2x.json +test_jsn sdf_spr_cmp_2 sdf_sprite/src1,mysrc@2x.json +test_png spr_cmp_2x sprite/src1,mysrc@2x.png +test_png sdf_spr_cmp_2 sdf_sprite/src1,mysrc@2x.png # Test fonts test_font font_1 font/Overpass%20Mono%20Light/0-255 From 41eda7489b001264d70349724d60372e96ce582c Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Tue, 22 Oct 2024 13:27:46 +0200 Subject: [PATCH 17/17] added the new endpoint to the endpoints --- docs/src/using.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/src/using.md b/docs/src/using.md index 82c11ee41..3e5c40567 100644 --- a/docs/src/using.md +++ b/docs/src/using.md @@ -2,18 +2,19 @@ Martin data is available via the HTTP `GET` endpoints: -| URL | Description | -|-----------------------------------------|------------------------------------------------| -| `/` | Web UI | -| `/catalog` | [List of all sources](#catalog) | -| `/{sourceID}` | [Source TileJSON](#source-tilejson) | -| `/{sourceID}/{z}/{x}/{y}` | Map Tiles | -| `/{source1},…,{sourceN}` | [Composite Source TileJSON](#source-tilejson) | -| `/{source1},…,{sourceN}/{z}/{x}/{y}` | [Composite Source Tiles](sources-composite.md) | -| `/sprite/{spriteID}[@2x].{json,png}` | [Sprite sources](sources-sprites.md) | -| `/font/{font}/{start}-{end}` | [Font source](sources-fonts.md) | -| `/font/{font1},…,{fontN}/{start}-{end}` | [Composite Font source](sources-fonts.md) | -| `/health` | Martin server health check: returns 200 `OK` | +| URL | Description | +|------------------------------------------|------------------------------------------------| +| `/` | Web UI | +| `/catalog` | [List of all sources](#catalog) | +| `/{sourceID}` | [Source TileJSON](#source-tilejson) | +| `/{sourceID}/{z}/{x}/{y}` | Map Tiles | +| `/{source1},…,{sourceN}` | [Composite Source TileJSON](#source-tilejson) | +| `/{source1},…,{sourceN}/{z}/{x}/{y}` | [Composite Source Tiles](sources-composite.md) | +| `/sprite/{spriteID}[@2x].{json,png}` | [Sprite sources](sources-sprites.md) | +| `/sdf_sprite/{spriteID}[@2x].{json,png}` | [SDF Sprite sources](sources-sprites.md) | +| `/font/{font}/{start}-{end}` | [Font source](sources-fonts.md) | +| `/font/{font1},…,{fontN}/{start}-{end}` | [Composite Font source](sources-fonts.md) | +| `/health` | Martin server health check: returns 200 `OK` | ### Duplicate Source ID