You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are two usecases for this lib -- with and without defaults:
A typically use case with defaults -- a client code that gets a JSON, resolves maxzoom to 30 if missing, and takes actions like loading tiles.
Without defaults -- a tile server needs to create and send a minimal tilejson, e.g. if it doesn't support grids value, it shouldn't set it to the default [ ], but instead not set it at all.
Current API actually does the opposite -- the client use-case" serde_json::from_str(str) ignores tilespec defaults, while the server use case with TileJSON::new() sets the defaults.
Also, per specification, several fields must be present from the start, so it would make sense to introduce them as arguments:
When instantiating, tilejson could still be defaulted to the current version, i.e. 3.0.0. The tiles on the other hand MUST be a non-empty array.
Proposed API (breaking)
implTileJSONBuilder{/// create a builder with tilejson = 3.0.0 and tiles = [ source ]fnnew(source:String) -> Self{}/// create a builder with custom version and possibly multiple sources./// If version is None, will use current default.fnnew_ext(sources:Vec<String>,version:Option<String>) -> Self{}/// generate TileJSON **without** defaults. Breaking change, so new method name.fnbuild() -> TileJSON{}// remove fn tiles(...)}implTileJSON{/// consume to ensure each optional value has a proper default per spec. Name is TBDfnwith_defaults(self) -> Self{}}
Note that "vector_layers" is required conditionally - depending on the type of the tiles, so in our case we could treat it as optional unless we want to perform validation.
There are two usecases for this lib -- with and without defaults:
maxzoom
to 30 if missing, and takes actions like loading tiles.grids
value, it shouldn't set it to the default[ ]
, but instead not set it at all.Current API actually does the opposite -- the client use-case"
serde_json::from_str(str)
ignores tilespec defaults, while the server use case withTileJSON::new()
sets the defaults.Also, per specification, several fields must be present from the start, so it would make sense to introduce them as arguments:
When instantiating,
tilejson
could still be defaulted to the current version, i.e.3.0.0
. Thetiles
on the other hand MUST be a non-empty array.Proposed API (breaking)
Note that
"vector_layers"
is required conditionally - depending on the type of the tiles, so in our case we could treat it as optional unless we want to perform validation.cc: @stepankuzmin @maxammann @Drabble @ka7eh
The text was updated successfully, but these errors were encountered: