Skip to content
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

Incorrect center field type #11

Closed
nyurik opened this issue May 18, 2022 · 0 comments · Fixed by #13
Closed

Incorrect center field type #11

nyurik opened this issue May 18, 2022 · 0 comments · Fixed by #13
Assignees
Labels

Comments

@nyurik
Copy link
Member

nyurik commented May 18, 2022

The center field is declared as center: Option<Vec<i32>>, which does not match specification:

OPTIONAL. Array. Default: null.
The first value is the longitude, the second is latitude (both in WGS:84 values), the third value is the zoom level as an integer. Longitude and latitude MUST be within the specified bounds. The zoom level MUST be between minzoom and maxzoom. Implementations MAY use this center value to set the default location. If the value is null, implementations MAY use their own algorithm for determining a default location.

{
  "center": [ -76.275329586789, 39.153492567373, 8 ]
}

Possible solutions

I think we should use this opportunity to improve the bounds value as well.

tuple

center: Option<(f32, f32, u8)>,
bounds: Option<(f32, f32, f32, f32)>,

structured

Per serde-rs/serde#637, uses serde_tuple crate.

#[derive(Serialize_tuple, Deserialize_tuple)]
struct Center {
  pub longitude: f32, 
  pub latitude: f32, 
  pub zoom: u8, 
}

#[derive(Serialize_tuple, Deserialize_tuple)]
struct Bounds {
  pub left: f32, 
  pub bottom: f32, 
  pub right: f32, 
  pub top: f32, 
}

...
center: Option<Center>,
bounds: Option<Bounds>,
@nyurik nyurik added the bug label May 18, 2022
@nyurik nyurik self-assigned this May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant