Skip to content

feat(mbtiles) - Add validation to martin .mbtiles #741 #1689

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

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

Auspicus
Copy link

@Auspicus Auspicus commented Feb 15, 2025

closes #741

validation_error.to_string(),
));
}
OnInvalid::Warn => {
Copy link
Author

Choose a reason for hiding this comment

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

We might want to do further processing of the validation_error to determine if this is a critical issue or not.

Copy link
Member

Choose a reason for hiding this comment

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

I keep wondering if "fast" and "skip" are actually the same thing. We should always do some basic validation - like making sure the tiles table exists with the right columns - or else we can't even use it. The only difference is in what we do afterwards - ignore the source or continue with it... So perhaps:

  • validation level is fast vs thorough (no skip)
  • severity would be good, warn, error
  • and the action could be abort or ignore source for error, and abort or ignore source or warn on warning?
  • we may even introduce warnings-as-errors parameter? (slowly building a compiler here :) )

Copy link
Member

@nyurik nyurik left a comment

Choose a reason for hiding this comment

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

I really like where you are going with this! I left a few minor comments inline.

A few overall thoughts:

  • we may have more than one type of "local source validation" (pmtiles, sprites, fonts, cog files, ...) - so we should keep CLI parameters simple and global (not mbtiles specific)
  • all configuration sources may introduce some format-specific validation steps, but we should try to keep them all consistent from configuration file perspective
  • we should have multi-level config: CLI / config file root / per source type / specific path/file
  • lets cleanup error handling dup code somehow
  • as i wrote more in depth in a comment, we may want to have warning-as-error non-default mode

overall, awesome work! I think it is pretty close to the working state. One last thing - usually you do not want to submit PRs from the main branch of your fork, but that's really a minor thing :)

validation_error.to_string(),
));
}
OnInvalid::Warn => {
Copy link
Member

Choose a reason for hiding this comment

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

I keep wondering if "fast" and "skip" are actually the same thing. We should always do some basic validation - like making sure the tiles table exists with the right columns - or else we can't even use it. The only difference is in what we do afterwards - ignore the source or continue with it... So perhaps:

  • validation level is fast vs thorough (no skip)
  • severity would be good, warn, error
  • and the action could be abort or ignore source for error, and abort or ignore source or warn on warning?
  • we may even introduce warnings-as-errors parameter? (slowly building a compiler here :) )

@nyurik
Copy link
Member

nyurik commented Mar 4, 2025

hi @Auspicus, let me know if you need any help moving it forward, seems like a really good feature to have in the longer term

@Auspicus
Copy link
Author

Auspicus commented Mar 8, 2025

Hey @nyurik! Thanks for checking in.

I'm working on this in the interest of using Martin as a replacement for MapTiler Server for my day job. Just had to pause for a bit to tackle some other things that have come up but should be able to get back to this next week, hopefully.

Cheers!

@nyurik
Copy link
Member

nyurik commented Mar 8, 2025

Thx! You might be interested in my work on https://github.com/nyurik/maplibre-native-rs - ability to do server-side rendering... still some time away, but already shows promising results

@sharkAndshark
Copy link
Collaborator

sharkAndshark commented Mar 8, 2025

Thx! You might be interested in my work on https://github.com/nyurik/maplibre-native-rs - ability to do server-side rendering... still some time away, but already shows promising results

Wow. Really excited for this! Sadly I know nothing about cpp ( need some cpp knowledge to get involved in I guess?)

.collect::<TileInfoSources>();

let mut sources_to_prune: Vec<usize> = vec![];
for (idx, source) in resolved_sources.iter().enumerate() {
Copy link
Author

Choose a reason for hiding this comment

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

need to do parallel validation rather than this.

let cfg = serde_yaml::from_str::<FileConfigEnum<MbtConfig>>(indoc! {"
let cfg: FileConfigEnum<MbtConfig> =
serde_yaml::from_str::<FileConfigEnum<MbtConfig>>(indoc! {"
validate: thorough
Copy link
Author

Choose a reason for hiding this comment

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

might want to make consistent with validation_level name

@Auspicus
Copy link
Author

Hey @nyurik I've adjusted this one a bit to be more in line with what you were talking about:

  • removed skip validation level, always apply at least fast
  • moved validation_level and on_invalid to global arguments / config that can apply to any tile source (could be extended to fonts, sprites and styles) not sure if server args are the best place for them but I didn't see any other existing structs that made sense to put it in
  • moved the validation check to a higher level so that it can be applied to all tile sources although it is disabled by default for any tile source other than mbtiles
  • validation_level and on_invalid can still be specified at the tile source level and will override global default

I don't think it's 100% over the line yet but before I polish this off I'd like to know if this general direction makes sense to you. Let me know.

Cheers! 🍻

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.

Add more validations to .mbtiles detection
3 participants