@@ -11,16 +11,19 @@ pub struct TileJSON {
11
11
pub tilejson : & ' static str ,
12
12
13
13
/// The tileset id.
14
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
14
15
pub id : Option < String > ,
15
16
16
17
/// A name describing the tileset. The name can
17
18
/// contain any legal character. Implementations SHOULD NOT interpret the
18
19
/// name as HTML.
20
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
19
21
pub name : Option < String > ,
20
22
21
23
/// A text description of the tileset. The
22
24
/// description can contain any legal character. Implementations SHOULD NOT
23
25
/// interpret the description as HTML.
26
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
24
27
pub description : Option < String > ,
25
28
26
29
/// A semver.org style version number. When
@@ -30,29 +33,34 @@ pub struct TileJSON {
30
33
/// level MUST only have changes to tiles that are contained within one tile.
31
34
/// When tiles change significantly, the major version MUST be increased.
32
35
/// Implementations MUST NOT use tiles with different major versions.
36
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
33
37
pub version : Option < String > ,
34
38
35
39
/// Contains an attribution to be displayed
36
40
/// when the map is shown to a user. Implementations MAY decide to treat this
37
41
/// as HTML or literal text. For security reasons, make absolutely sure that
38
42
/// this field can't be abused as a vector for XSS or beacon tracking.
43
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
39
44
pub attribution : Option < String > ,
40
45
41
46
/// Contains a mustache template to be used to
42
47
/// format data from grids for interaction.
43
48
/// See https://github.com/mapbox/utfgrid-spec/tree/master/1.2
44
49
/// for the interactivity specification.
50
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
45
51
pub template : Option < String > ,
46
52
47
53
/// Contains a legend to be displayed with the map.
48
54
/// Implementations MAY decide to treat this as HTML or literal text.
49
55
/// For security reasons, make absolutely sure that this field can't be
50
56
/// abused as a vector for XSS or beacon tracking.
57
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
51
58
pub legend : Option < String > ,
52
59
53
60
/// Either "xyz" or "tms". Influences the y
54
61
/// direction of the tile coordinates.
55
62
/// The global-mercator (aka Spherical Mercator) profile is assumed.
63
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
56
64
pub scheme : Option < String > ,
57
65
58
66
/// An array of tile endpoints. {z}, {x} and {y}, if present,
@@ -69,6 +77,7 @@ pub struct TileJSON {
69
77
/// for this tileset.
70
78
/// See https://github.com/mapbox/utfgrid-spec/tree/master/1.2
71
79
/// for the interactivity specification.
80
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
72
81
pub grids : Option < Vec < String > > ,
73
82
74
83
/// An array of data files in GeoJSON format.
@@ -78,18 +87,22 @@ pub struct TileJSON {
78
87
/// All endpoints MUST return the same content for the same URL.
79
88
/// If the array doesn't contain any entries, then no data is present in
80
89
/// the map.
90
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
81
91
pub data : Option < Vec < String > > ,
82
92
83
93
/// An integer specifying the minimum zoom level.
94
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
84
95
pub minzoom : Option < u8 > ,
85
96
86
97
/// An integer specifying the maximum zoom level. MUST be >= minzoom.
98
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
87
99
pub maxzoom : Option < u8 > ,
88
100
89
101
/// The maximum extent of available map tiles. Bounds MUST define an area
90
102
/// covered by all zoom levels. The bounds are represented in WGS:84
91
103
/// latitude and longitude values, in the order left, bottom, right, top.
92
104
/// Values may be integers or floating point numbers.
105
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
93
106
pub bounds : Option < Vec < f32 > > ,
94
107
95
108
/// The first value is the longitude, the second is latitude (both in
@@ -99,6 +112,7 @@ pub struct TileJSON {
99
112
/// Implementations can use this value to set the default location. If the
100
113
/// value is null, implementations may use their own algorithm for
101
114
/// determining a default location.
115
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
102
116
pub center : Option < Vec < i32 > > ,
103
117
}
104
118
@@ -130,7 +144,7 @@ impl TileJSONBuilder {
130
144
name : None ,
131
145
description : None ,
132
146
version : Some ( "1.0.0" . to_owned ( ) ) ,
133
- attribution : Some ( "" . to_string ( ) ) ,
147
+ attribution : None ,
134
148
template : None ,
135
149
legend : None ,
136
150
scheme : Some ( "xyz" . to_owned ( ) ) ,
@@ -299,7 +313,7 @@ mod tests {
299
313
300
314
assert_eq ! (
301
315
serialized_tilejson,
302
- r#"{"tilejson":"2.2.0","id":null," name":"compositing","description":null," version":"1.0.0","attribution":"","template":null,"legend":null," scheme":"tms","tiles":["http://localhost:8888/admin/1.0.0/world-light,broadband/{z}/{x}/{y}.png"],"grids":null,"data":null," minzoom":0,"maxzoom":30,"bounds":[-180.0,-90.0,180.0,90.0],"center":null }"#
316
+ r#"{"tilejson":"2.2.0","name":"compositing","version":"1.0.0","scheme":"tms","tiles":["http://localhost:8888/admin/1.0.0/world-light,broadband/{z}/{x}/{y}.png"],"minzoom":0,"maxzoom":30,"bounds":[-180.0,-90.0,180.0,90.0]}"#
303
317
)
304
318
}
305
319
}
0 commit comments