|
|
@@ -53,13 +53,23 @@ impl<'a> DenseNode<'a> {
|
|
53
|
53
|
self.timestamp * i64::from(self.block.get_date_granularity())
|
|
54
|
54
|
}
|
|
55
|
55
|
|
|
56
|
|
- /// Returns an iterator over the tags of this way (See [OSM wiki](http://wiki.openstreetmap.org/wiki/Tags)).
|
|
|
56
|
+ /// Returns an iterator over the tags of this node (See [OSM wiki](http://wiki.openstreetmap.org/wiki/Tags)).
|
|
57
|
57
|
pub fn tags(&self) -> DenseTagIter<'a> {
|
|
58
|
58
|
DenseTagIter {
|
|
59
|
59
|
block: self.block,
|
|
60
|
60
|
keys_vals_indices: self.keys_vals_indices.iter(),
|
|
61
|
61
|
}
|
|
62
|
62
|
}
|
|
|
63
|
+
|
|
|
64
|
+ /// Returns an iterator over the tags of this node
|
|
|
65
|
+ /// (See [OSM wiki](http://wiki.openstreetmap.org/wiki/Tags)).
|
|
|
66
|
+ /// A tag is represented as a pair of indices (key and value) to the stringtable of the current
|
|
|
67
|
+ /// `PrimitiveBlock`.
|
|
|
68
|
+ pub fn raw_tags(&self) -> DenseRawTagIter<'a> {
|
|
|
69
|
+ DenseRawTagIter {
|
|
|
70
|
+ keys_vals_indices: self.keys_vals_indices.iter(),
|
|
|
71
|
+ }
|
|
|
72
|
+ }
|
|
63
|
73
|
}
|
|
64
|
74
|
|
|
65
|
75
|
/// An iterator over dense nodes. It decodes the delta encoded values.
|
|
|
@@ -228,8 +238,35 @@ impl<'a> Iterator for DenseTagIter<'a> {
|
|
228
|
238
|
}
|
|
229
|
239
|
|
|
230
|
240
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
|
231
|
|
- self.keys_vals_indices.size_hint()
|
|
|
241
|
+ let len = self.keys_vals_indices.len() / 2;
|
|
|
242
|
+ (len, Some(len))
|
|
232
|
243
|
}
|
|
233
|
244
|
}
|
|
234
|
245
|
|
|
235
|
246
|
impl<'a> ExactSizeIterator for DenseTagIter<'a> {}
|
|
|
247
|
+
|
|
|
248
|
+/// An iterator over the tags of a node. It returns a pair of indices (key and value) to the
|
|
|
249
|
+/// stringtable of the current `PrimitiveBlock`.
|
|
|
250
|
+#[derive(Clone, Debug)]
|
|
|
251
|
+pub struct DenseRawTagIter<'a> {
|
|
|
252
|
+ keys_vals_indices: std::slice::Iter<'a, i32>,
|
|
|
253
|
+}
|
|
|
254
|
+
|
|
|
255
|
+//TODO return Result
|
|
|
256
|
+impl<'a> Iterator for DenseRawTagIter<'a> {
|
|
|
257
|
+ type Item = (i32, i32);
|
|
|
258
|
+
|
|
|
259
|
+ fn next(&mut self) -> Option<Self::Item> {
|
|
|
260
|
+ match (self.keys_vals_indices.next(), self.keys_vals_indices.next()) {
|
|
|
261
|
+ (Some(&key_index), Some(&val_index)) => Some((key_index, val_index)),
|
|
|
262
|
+ _ => None,
|
|
|
263
|
+ }
|
|
|
264
|
+ }
|
|
|
265
|
+
|
|
|
266
|
+ fn size_hint(&self) -> (usize, Option<usize>) {
|
|
|
267
|
+ let len = self.keys_vals_indices.len() / 2;
|
|
|
268
|
+ (len, Some(len))
|
|
|
269
|
+ }
|
|
|
270
|
+}
|
|
|
271
|
+
|
|
|
272
|
+impl<'a> ExactSizeIterator for DenseRawTagIter<'a> {}
|