1#[allow(missing_docs)]
3pub mod osm {
4#[allow(unused_imports)]
5use flatdata::{flatdata_read_bytes, flatdata_write_bytes};
6
7
8 pub const INVALID_IDX: u64 = 1_099_511_627_775;
10#[repr(transparent)]
12#[derive(Clone)]
13pub struct Header {
14 data: [u8; 51],
15}
16
17impl Header {
18 pub unsafe fn new_unchecked( ) -> Self {
20 Self{data : [0; 51]}
21 }
22}
23
24impl flatdata::Struct for Header {
25 unsafe fn create_unchecked( ) -> Self {
26 Self{data : [0; 51]}
27 }
28
29 const SIZE_IN_BYTES: usize = 51;
30 const IS_OVERLAPPING_WITH_NEXT : bool = false;
31}
32
33impl Header {
34 pub fn new( ) -> Self {
35 Self{data : [0; 51]}
36 }
37
38 pub fn from_bytes(data: &[u8; 51]) -> &Self {
40 unsafe{ std::mem::transmute( data ) }
42 }
43
44 pub fn from_bytes_mut(data: &mut [u8; 51]) -> &mut Self {
46 unsafe{ std::mem::transmute( data ) }
48 }
49
50 pub fn from_bytes_slice(data: &[u8]) -> Result<&Self, flatdata::ResourceStorageError> {
52 if data.len() < 51 {
54 assert_eq!(data.len(), 51);
55 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
56 }
57 let ptr = data.as_ptr() as *const [u8; 51];
58 Ok(Self::from_bytes(unsafe { &*ptr }))
60 }
61
62 pub fn from_bytes_slice_mut(data: &mut [u8]) -> Result<&mut Self, flatdata::ResourceStorageError> {
64 if data.len() < 51 {
66 assert_eq!(data.len(), 51);
67 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
68 }
69 let ptr = data.as_ptr() as *mut [u8; 51];
70 Ok(Self::from_bytes_mut(unsafe { &mut *ptr }))
72 }
73
74 pub fn as_bytes(&self) -> &[u8; 51] {
75 &self.data
76 }
77}
78
79impl Default for Header {
80 fn default( ) -> Self {
81 Self::new( )
82 }
83}
84
85unsafe impl flatdata::NoOverlap for Header {}
86
87impl Header {
88 #[inline]
91 pub fn coord_scale(&self) -> i32 {
92 let value = flatdata_read_bytes!(i32, self.data.as_ptr(), 0, 32);
93 unsafe { std::mem::transmute::<i32, i32>(value) }
94 }
95
96 #[inline]
98 pub fn bbox_left(&self) -> i32 {
99 let value = flatdata_read_bytes!(i32, self.data.as_ptr(), 32, 32);
100 unsafe { std::mem::transmute::<i32, i32>(value) }
101 }
102
103 #[inline]
105 pub fn bbox_right(&self) -> i32 {
106 let value = flatdata_read_bytes!(i32, self.data.as_ptr(), 64, 32);
107 unsafe { std::mem::transmute::<i32, i32>(value) }
108 }
109
110 #[inline]
112 pub fn bbox_top(&self) -> i32 {
113 let value = flatdata_read_bytes!(i32, self.data.as_ptr(), 96, 32);
114 unsafe { std::mem::transmute::<i32, i32>(value) }
115 }
116
117 #[inline]
119 pub fn bbox_bottom(&self) -> i32 {
120 let value = flatdata_read_bytes!(i32, self.data.as_ptr(), 128, 32);
121 unsafe { std::mem::transmute::<i32, i32>(value) }
122 }
123
124 #[inline]
126 pub fn writingprogram_idx(&self) -> u64 {
127 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 160, 40);
128 unsafe { std::mem::transmute::<u64, u64>(value) }
129 }
130
131 #[inline]
133 pub fn source_idx(&self) -> u64 {
134 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 200, 40);
135 unsafe { std::mem::transmute::<u64, u64>(value) }
136 }
137
138 #[inline]
143 pub fn replication_timestamp(&self) -> i64 {
144 let value = flatdata_read_bytes!(i64, self.data.as_ptr(), 240, 64);
145 unsafe { std::mem::transmute::<i64, i64>(value) }
146 }
147
148 #[inline]
152 pub fn replication_sequence_number(&self) -> i64 {
153 let value = flatdata_read_bytes!(i64, self.data.as_ptr(), 304, 64);
154 unsafe { std::mem::transmute::<i64, i64>(value) }
155 }
156
157 #[inline]
159 pub fn replication_base_url_idx(&self) -> u64 {
160 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 368, 40);
161 unsafe { std::mem::transmute::<u64, u64>(value) }
162 }
163
164}
165
166impl std::fmt::Debug for Header {
167 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
168 f.debug_struct("Header")
169 .field("coord_scale", &self.coord_scale())
170 .field("bbox_left", &self.bbox_left())
171 .field("bbox_right", &self.bbox_right())
172 .field("bbox_top", &self.bbox_top())
173 .field("bbox_bottom", &self.bbox_bottom())
174 .field("writingprogram_idx", &self.writingprogram_idx())
175 .field("source_idx", &self.source_idx())
176 .field("replication_timestamp", &self.replication_timestamp())
177 .field("replication_sequence_number", &self.replication_sequence_number())
178 .field("replication_base_url_idx", &self.replication_base_url_idx())
179 .finish()
180 }
181}
182
183impl std::cmp::PartialEq for Header {
184 #[inline]
185 fn eq(&self, other: &Self) -> bool {
186 self.coord_scale() == other.coord_scale() && self.bbox_left() == other.bbox_left() && self.bbox_right() == other.bbox_right() && self.bbox_top() == other.bbox_top() && self.bbox_bottom() == other.bbox_bottom() && self.writingprogram_idx() == other.writingprogram_idx() && self.source_idx() == other.source_idx() && self.replication_timestamp() == other.replication_timestamp() && self.replication_sequence_number() == other.replication_sequence_number() && self.replication_base_url_idx() == other.replication_base_url_idx() }
187}
188
189impl Header {
190 #[inline]
193 #[allow(missing_docs)]
194 pub fn set_coord_scale(&mut self, value: i32) {
195 flatdata_write_bytes!(i32; value, self.data, 0, 32)
196 }
197
198 #[inline]
200 #[allow(missing_docs)]
201 pub fn set_bbox_left(&mut self, value: i32) {
202 flatdata_write_bytes!(i32; value, self.data, 32, 32)
203 }
204
205 #[inline]
207 #[allow(missing_docs)]
208 pub fn set_bbox_right(&mut self, value: i32) {
209 flatdata_write_bytes!(i32; value, self.data, 64, 32)
210 }
211
212 #[inline]
214 #[allow(missing_docs)]
215 pub fn set_bbox_top(&mut self, value: i32) {
216 flatdata_write_bytes!(i32; value, self.data, 96, 32)
217 }
218
219 #[inline]
221 #[allow(missing_docs)]
222 pub fn set_bbox_bottom(&mut self, value: i32) {
223 flatdata_write_bytes!(i32; value, self.data, 128, 32)
224 }
225
226 #[inline]
228 #[allow(missing_docs)]
229 pub fn set_writingprogram_idx(&mut self, value: u64) {
230 flatdata_write_bytes!(u64; value, self.data, 160, 40)
231 }
232
233 #[inline]
235 #[allow(missing_docs)]
236 pub fn set_source_idx(&mut self, value: u64) {
237 flatdata_write_bytes!(u64; value, self.data, 200, 40)
238 }
239
240 #[inline]
245 #[allow(missing_docs)]
246 pub fn set_replication_timestamp(&mut self, value: i64) {
247 flatdata_write_bytes!(i64; value, self.data, 240, 64)
248 }
249
250 #[inline]
254 #[allow(missing_docs)]
255 pub fn set_replication_sequence_number(&mut self, value: i64) {
256 flatdata_write_bytes!(i64; value, self.data, 304, 64)
257 }
258
259 #[inline]
261 #[allow(missing_docs)]
262 pub fn set_replication_base_url_idx(&mut self, value: u64) {
263 flatdata_write_bytes!(u64; value, self.data, 368, 40)
264 }
265
266
267 #[inline]
269 pub fn fill_from(&mut self, other: &Header) {
270 self.set_coord_scale(other.coord_scale());
271 self.set_bbox_left(other.bbox_left());
272 self.set_bbox_right(other.bbox_right());
273 self.set_bbox_top(other.bbox_top());
274 self.set_bbox_bottom(other.bbox_bottom());
275 self.set_writingprogram_idx(other.writingprogram_idx());
276 self.set_source_idx(other.source_idx());
277 self.set_replication_timestamp(other.replication_timestamp());
278 self.set_replication_sequence_number(other.replication_sequence_number());
279 self.set_replication_base_url_idx(other.replication_base_url_idx());
280 }
281}
282#[repr(transparent)]
284#[derive(Clone)]
285pub struct Tag {
286 data: [u8; 10],
287}
288
289impl Tag {
290 pub unsafe fn new_unchecked( ) -> Self {
292 Self{data : [0; 10]}
293 }
294}
295
296impl flatdata::Struct for Tag {
297 unsafe fn create_unchecked( ) -> Self {
298 Self{data : [0; 10]}
299 }
300
301 const SIZE_IN_BYTES: usize = 10;
302 const IS_OVERLAPPING_WITH_NEXT : bool = false;
303}
304
305impl Tag {
306 pub fn new( ) -> Self {
307 Self{data : [0; 10]}
308 }
309
310 pub fn from_bytes(data: &[u8; 10]) -> &Self {
312 unsafe{ std::mem::transmute( data ) }
314 }
315
316 pub fn from_bytes_mut(data: &mut [u8; 10]) -> &mut Self {
318 unsafe{ std::mem::transmute( data ) }
320 }
321
322 pub fn from_bytes_slice(data: &[u8]) -> Result<&Self, flatdata::ResourceStorageError> {
324 if data.len() < 10 {
326 assert_eq!(data.len(), 10);
327 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
328 }
329 let ptr = data.as_ptr() as *const [u8; 10];
330 Ok(Self::from_bytes(unsafe { &*ptr }))
332 }
333
334 pub fn from_bytes_slice_mut(data: &mut [u8]) -> Result<&mut Self, flatdata::ResourceStorageError> {
336 if data.len() < 10 {
338 assert_eq!(data.len(), 10);
339 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
340 }
341 let ptr = data.as_ptr() as *mut [u8; 10];
342 Ok(Self::from_bytes_mut(unsafe { &mut *ptr }))
344 }
345
346 pub fn as_bytes(&self) -> &[u8; 10] {
347 &self.data
348 }
349}
350
351impl Default for Tag {
352 fn default( ) -> Self {
353 Self::new( )
354 }
355}
356
357unsafe impl flatdata::NoOverlap for Tag {}
358
359impl Tag {
360 #[inline]
362 pub fn key_idx(&self) -> u64 {
363 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 0, 40);
364 unsafe { std::mem::transmute::<u64, u64>(value) }
365 }
366
367 #[inline]
369 pub fn value_idx(&self) -> u64 {
370 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 40, 40);
371 unsafe { std::mem::transmute::<u64, u64>(value) }
372 }
373
374}
375
376impl std::fmt::Debug for Tag {
377 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
378 f.debug_struct("Tag")
379 .field("key_idx", &self.key_idx())
380 .field("value_idx", &self.value_idx())
381 .finish()
382 }
383}
384
385impl std::cmp::PartialEq for Tag {
386 #[inline]
387 fn eq(&self, other: &Self) -> bool {
388 self.key_idx() == other.key_idx() && self.value_idx() == other.value_idx() }
389}
390
391impl Tag {
392 #[inline]
394 #[allow(missing_docs)]
395 pub fn set_key_idx(&mut self, value: u64) {
396 flatdata_write_bytes!(u64; value, self.data, 0, 40)
397 }
398
399 #[inline]
401 #[allow(missing_docs)]
402 pub fn set_value_idx(&mut self, value: u64) {
403 flatdata_write_bytes!(u64; value, self.data, 40, 40)
404 }
405
406
407 #[inline]
409 pub fn fill_from(&mut self, other: &Tag) {
410 self.set_key_idx(other.key_idx());
411 self.set_value_idx(other.value_idx());
412 }
413}
414#[repr(transparent)]
420pub struct Node {
421 data: [u8; 13],
422}
423
424impl Node {
425 pub unsafe fn new_unchecked( ) -> Self {
427 Self{data : [0; 13]}
428 }
429}
430
431impl flatdata::Struct for Node {
432 unsafe fn create_unchecked( ) -> Self {
433 Self{data : [0; 13]}
434 }
435
436 const SIZE_IN_BYTES: usize = 13;
437 const IS_OVERLAPPING_WITH_NEXT : bool = true;
438}
439
440impl flatdata::Overlap for Node {}
441
442impl Node {
443 #[inline]
445 pub fn lat(&self) -> i32 {
446 let value = flatdata_read_bytes!(i32, self.data.as_ptr(), 0, 32);
447 unsafe { std::mem::transmute::<i32, i32>(value) }
448 }
449
450 #[inline]
452 pub fn lon(&self) -> i32 {
453 let value = flatdata_read_bytes!(i32, self.data.as_ptr(), 32, 32);
454 unsafe { std::mem::transmute::<i32, i32>(value) }
455 }
456
457 #[inline]
461 pub fn tag_first_idx(&self) -> u64 {
462 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 64, 40);
463 unsafe { std::mem::transmute::<u64, u64>(value) }
464 }
465
466 #[inline]
470 pub fn tags(&self) -> std::ops::Range<u64> {
471 let start = flatdata_read_bytes!(u64, self.data.as_ptr(), 64, 40);
472 let end = flatdata_read_bytes!(u64, self.data.as_ptr(), 64 + 13 * 8, 40);
473 start..end
474 }
475
476}
477
478impl std::fmt::Debug for Node {
479 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
480 f.debug_struct("Node")
481 .field("lat", &self.lat())
482 .field("lon", &self.lon())
483 .field("tag_first_idx", &self.tag_first_idx())
484 .finish()
485 }
486}
487
488impl std::cmp::PartialEq for Node {
489 #[inline]
490 fn eq(&self, other: &Self) -> bool {
491 self.lat() == other.lat() && self.lon() == other.lon() && self.tag_first_idx() == other.tag_first_idx() }
492}
493
494impl Node {
495 #[inline]
497 #[allow(missing_docs)]
498 pub fn set_lat(&mut self, value: i32) {
499 flatdata_write_bytes!(i32; value, self.data, 0, 32)
500 }
501
502 #[inline]
504 #[allow(missing_docs)]
505 pub fn set_lon(&mut self, value: i32) {
506 flatdata_write_bytes!(i32; value, self.data, 32, 32)
507 }
508
509 #[inline]
513 #[allow(missing_docs)]
514 pub fn set_tag_first_idx(&mut self, value: u64) {
515 flatdata_write_bytes!(u64; value, self.data, 64, 40)
516 }
517
518
519 #[inline]
521 pub fn fill_from(&mut self, other: &Node) {
522 self.set_lat(other.lat());
523 self.set_lon(other.lon());
524 self.set_tag_first_idx(other.tag_first_idx());
525 }
526}
527#[repr(transparent)]
529#[derive(Clone)]
530pub struct NodeIndex {
531 data: [u8; 5],
532}
533
534impl NodeIndex {
535 pub unsafe fn new_unchecked( ) -> Self {
537 Self{data : [0; 5]}
538 }
539}
540
541impl flatdata::Struct for NodeIndex {
542 unsafe fn create_unchecked( ) -> Self {
543 Self{data : [0; 5]}
544 }
545
546 const SIZE_IN_BYTES: usize = 5;
547 const IS_OVERLAPPING_WITH_NEXT : bool = false;
548}
549
550impl NodeIndex {
551 pub fn new( ) -> Self {
552 Self{data : [0; 5]}
553 }
554
555 pub fn from_bytes(data: &[u8; 5]) -> &Self {
557 unsafe{ std::mem::transmute( data ) }
559 }
560
561 pub fn from_bytes_mut(data: &mut [u8; 5]) -> &mut Self {
563 unsafe{ std::mem::transmute( data ) }
565 }
566
567 pub fn from_bytes_slice(data: &[u8]) -> Result<&Self, flatdata::ResourceStorageError> {
569 if data.len() < 5 {
571 assert_eq!(data.len(), 5);
572 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
573 }
574 let ptr = data.as_ptr() as *const [u8; 5];
575 Ok(Self::from_bytes(unsafe { &*ptr }))
577 }
578
579 pub fn from_bytes_slice_mut(data: &mut [u8]) -> Result<&mut Self, flatdata::ResourceStorageError> {
581 if data.len() < 5 {
583 assert_eq!(data.len(), 5);
584 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
585 }
586 let ptr = data.as_ptr() as *mut [u8; 5];
587 Ok(Self::from_bytes_mut(unsafe { &mut *ptr }))
589 }
590
591 pub fn as_bytes(&self) -> &[u8; 5] {
592 &self.data
593 }
594}
595
596impl Default for NodeIndex {
597 fn default( ) -> Self {
598 Self::new( )
599 }
600}
601
602unsafe impl flatdata::NoOverlap for NodeIndex {}
603
604impl NodeIndex {
605 #[inline]
607 pub fn value(&self) -> Option<u64> {
608 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 0, 40);
609 let x = unsafe { std::mem::transmute::<u64, u64>(value) };
610 Some(x).filter(|&x| x != super::osm::INVALID_IDX)
611 }
612
613}
614
615impl std::fmt::Debug for NodeIndex {
616 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
617 f.debug_struct("NodeIndex")
618 .field("value", &self.value())
619 .finish()
620 }
621}
622
623impl std::cmp::PartialEq for NodeIndex {
624 #[inline]
625 fn eq(&self, other: &Self) -> bool {
626 self.value() == other.value() }
627}
628
629impl NodeIndex {
630 #[inline]
632 #[allow(missing_docs)]
633 pub fn set_value(&mut self, value: Option<u64>) {
634let value = value.unwrap_or(super::osm::INVALID_IDX); flatdata_write_bytes!(u64; value, self.data, 0, 40)
635 }
636
637
638 #[inline]
640 pub fn fill_from(&mut self, other: &NodeIndex) {
641 self.set_value(other.value());
642 }
643}
644#[repr(transparent)]
648pub struct Way {
649 data: [u8; 10],
650}
651
652impl Way {
653 pub unsafe fn new_unchecked( ) -> Self {
655 Self{data : [0; 10]}
656 }
657}
658
659impl flatdata::Struct for Way {
660 unsafe fn create_unchecked( ) -> Self {
661 Self{data : [0; 10]}
662 }
663
664 const SIZE_IN_BYTES: usize = 10;
665 const IS_OVERLAPPING_WITH_NEXT : bool = true;
666}
667
668impl flatdata::Overlap for Way {}
669
670impl Way {
671 #[inline]
675 pub fn tag_first_idx(&self) -> u64 {
676 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 0, 40);
677 unsafe { std::mem::transmute::<u64, u64>(value) }
678 }
679
680 #[inline]
684 pub fn tags(&self) -> std::ops::Range<u64> {
685 let start = flatdata_read_bytes!(u64, self.data.as_ptr(), 0, 40);
686 let end = flatdata_read_bytes!(u64, self.data.as_ptr(), 0 + 10 * 8, 40);
687 start..end
688 }
689
690 #[inline]
694 pub fn ref_first_idx(&self) -> u64 {
695 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 40, 40);
696 unsafe { std::mem::transmute::<u64, u64>(value) }
697 }
698
699 #[inline]
703 pub fn refs(&self) -> std::ops::Range<u64> {
704 let start = flatdata_read_bytes!(u64, self.data.as_ptr(), 40, 40);
705 let end = flatdata_read_bytes!(u64, self.data.as_ptr(), 40 + 10 * 8, 40);
706 start..end
707 }
708
709}
710
711impl std::fmt::Debug for Way {
712 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
713 f.debug_struct("Way")
714 .field("tag_first_idx", &self.tag_first_idx())
715 .field("ref_first_idx", &self.ref_first_idx())
716 .finish()
717 }
718}
719
720impl std::cmp::PartialEq for Way {
721 #[inline]
722 fn eq(&self, other: &Self) -> bool {
723 self.tag_first_idx() == other.tag_first_idx() && self.ref_first_idx() == other.ref_first_idx() }
724}
725
726impl Way {
727 #[inline]
731 #[allow(missing_docs)]
732 pub fn set_tag_first_idx(&mut self, value: u64) {
733 flatdata_write_bytes!(u64; value, self.data, 0, 40)
734 }
735
736 #[inline]
740 #[allow(missing_docs)]
741 pub fn set_ref_first_idx(&mut self, value: u64) {
742 flatdata_write_bytes!(u64; value, self.data, 40, 40)
743 }
744
745
746 #[inline]
748 pub fn fill_from(&mut self, other: &Way) {
749 self.set_tag_first_idx(other.tag_first_idx());
750 self.set_ref_first_idx(other.ref_first_idx());
751 }
752}
753#[repr(transparent)]
755#[derive(Clone)]
756pub struct TagIndex {
757 data: [u8; 5],
758}
759
760impl TagIndex {
761 pub unsafe fn new_unchecked( ) -> Self {
763 Self{data : [0; 5]}
764 }
765}
766
767impl flatdata::Struct for TagIndex {
768 unsafe fn create_unchecked( ) -> Self {
769 Self{data : [0; 5]}
770 }
771
772 const SIZE_IN_BYTES: usize = 5;
773 const IS_OVERLAPPING_WITH_NEXT : bool = false;
774}
775
776impl TagIndex {
777 pub fn new( ) -> Self {
778 Self{data : [0; 5]}
779 }
780
781 pub fn from_bytes(data: &[u8; 5]) -> &Self {
783 unsafe{ std::mem::transmute( data ) }
785 }
786
787 pub fn from_bytes_mut(data: &mut [u8; 5]) -> &mut Self {
789 unsafe{ std::mem::transmute( data ) }
791 }
792
793 pub fn from_bytes_slice(data: &[u8]) -> Result<&Self, flatdata::ResourceStorageError> {
795 if data.len() < 5 {
797 assert_eq!(data.len(), 5);
798 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
799 }
800 let ptr = data.as_ptr() as *const [u8; 5];
801 Ok(Self::from_bytes(unsafe { &*ptr }))
803 }
804
805 pub fn from_bytes_slice_mut(data: &mut [u8]) -> Result<&mut Self, flatdata::ResourceStorageError> {
807 if data.len() < 5 {
809 assert_eq!(data.len(), 5);
810 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
811 }
812 let ptr = data.as_ptr() as *mut [u8; 5];
813 Ok(Self::from_bytes_mut(unsafe { &mut *ptr }))
815 }
816
817 pub fn as_bytes(&self) -> &[u8; 5] {
818 &self.data
819 }
820}
821
822impl Default for TagIndex {
823 fn default( ) -> Self {
824 Self::new( )
825 }
826}
827
828unsafe impl flatdata::NoOverlap for TagIndex {}
829
830impl TagIndex {
831 #[inline]
833 pub fn value(&self) -> u64 {
834 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 0, 40);
835 unsafe { std::mem::transmute::<u64, u64>(value) }
836 }
837
838}
839
840impl std::fmt::Debug for TagIndex {
841 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
842 f.debug_struct("TagIndex")
843 .field("value", &self.value())
844 .finish()
845 }
846}
847
848impl std::cmp::PartialEq for TagIndex {
849 #[inline]
850 fn eq(&self, other: &Self) -> bool {
851 self.value() == other.value() }
852}
853
854impl TagIndex {
855 #[inline]
857 #[allow(missing_docs)]
858 pub fn set_value(&mut self, value: u64) {
859 flatdata_write_bytes!(u64; value, self.data, 0, 40)
860 }
861
862
863 #[inline]
865 pub fn fill_from(&mut self, other: &TagIndex) {
866 self.set_value(other.value());
867 }
868}
869#[repr(transparent)]
871#[derive(Clone)]
872pub struct NodeMember {
873 data: [u8; 10],
874}
875
876impl NodeMember {
877 pub unsafe fn new_unchecked( ) -> Self {
879 Self{data : [0; 10]}
880 }
881}
882
883impl flatdata::Struct for NodeMember {
884 unsafe fn create_unchecked( ) -> Self {
885 Self{data : [0; 10]}
886 }
887
888 const SIZE_IN_BYTES: usize = 10;
889 const IS_OVERLAPPING_WITH_NEXT : bool = false;
890}
891
892impl NodeMember {
893 pub fn new( ) -> Self {
894 Self{data : [0; 10]}
895 }
896
897 pub fn from_bytes(data: &[u8; 10]) -> &Self {
899 unsafe{ std::mem::transmute( data ) }
901 }
902
903 pub fn from_bytes_mut(data: &mut [u8; 10]) -> &mut Self {
905 unsafe{ std::mem::transmute( data ) }
907 }
908
909 pub fn from_bytes_slice(data: &[u8]) -> Result<&Self, flatdata::ResourceStorageError> {
911 if data.len() < 10 {
913 assert_eq!(data.len(), 10);
914 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
915 }
916 let ptr = data.as_ptr() as *const [u8; 10];
917 Ok(Self::from_bytes(unsafe { &*ptr }))
919 }
920
921 pub fn from_bytes_slice_mut(data: &mut [u8]) -> Result<&mut Self, flatdata::ResourceStorageError> {
923 if data.len() < 10 {
925 assert_eq!(data.len(), 10);
926 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
927 }
928 let ptr = data.as_ptr() as *mut [u8; 10];
929 Ok(Self::from_bytes_mut(unsafe { &mut *ptr }))
931 }
932
933 pub fn as_bytes(&self) -> &[u8; 10] {
934 &self.data
935 }
936}
937
938impl Default for NodeMember {
939 fn default( ) -> Self {
940 Self::new( )
941 }
942}
943
944unsafe impl flatdata::NoOverlap for NodeMember {}
945
946impl NodeMember {
947 #[inline]
949 pub fn node_idx(&self) -> Option<u64> {
950 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 0, 40);
951 let x = unsafe { std::mem::transmute::<u64, u64>(value) };
952 Some(x).filter(|&x| x != super::osm::INVALID_IDX)
953 }
954
955 #[inline]
959 pub fn role_idx(&self) -> u64 {
960 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 40, 40);
961 unsafe { std::mem::transmute::<u64, u64>(value) }
962 }
963
964}
965
966impl std::fmt::Debug for NodeMember {
967 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
968 f.debug_struct("NodeMember")
969 .field("node_idx", &self.node_idx())
970 .field("role_idx", &self.role_idx())
971 .finish()
972 }
973}
974
975impl std::cmp::PartialEq for NodeMember {
976 #[inline]
977 fn eq(&self, other: &Self) -> bool {
978 self.node_idx() == other.node_idx() && self.role_idx() == other.role_idx() }
979}
980
981impl NodeMember {
982 #[inline]
984 #[allow(missing_docs)]
985 pub fn set_node_idx(&mut self, value: Option<u64>) {
986let value = value.unwrap_or(super::osm::INVALID_IDX); flatdata_write_bytes!(u64; value, self.data, 0, 40)
987 }
988
989 #[inline]
993 #[allow(missing_docs)]
994 pub fn set_role_idx(&mut self, value: u64) {
995 flatdata_write_bytes!(u64; value, self.data, 40, 40)
996 }
997
998
999 #[inline]
1001 pub fn fill_from(&mut self, other: &NodeMember) {
1002 self.set_node_idx(other.node_idx());
1003 self.set_role_idx(other.role_idx());
1004 }
1005}
1006#[repr(transparent)]
1008#[derive(Clone)]
1009pub struct WayMember {
1010 data: [u8; 10],
1011}
1012
1013impl WayMember {
1014 pub unsafe fn new_unchecked( ) -> Self {
1016 Self{data : [0; 10]}
1017 }
1018}
1019
1020impl flatdata::Struct for WayMember {
1021 unsafe fn create_unchecked( ) -> Self {
1022 Self{data : [0; 10]}
1023 }
1024
1025 const SIZE_IN_BYTES: usize = 10;
1026 const IS_OVERLAPPING_WITH_NEXT : bool = false;
1027}
1028
1029impl WayMember {
1030 pub fn new( ) -> Self {
1031 Self{data : [0; 10]}
1032 }
1033
1034 pub fn from_bytes(data: &[u8; 10]) -> &Self {
1036 unsafe{ std::mem::transmute( data ) }
1038 }
1039
1040 pub fn from_bytes_mut(data: &mut [u8; 10]) -> &mut Self {
1042 unsafe{ std::mem::transmute( data ) }
1044 }
1045
1046 pub fn from_bytes_slice(data: &[u8]) -> Result<&Self, flatdata::ResourceStorageError> {
1048 if data.len() < 10 {
1050 assert_eq!(data.len(), 10);
1051 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
1052 }
1053 let ptr = data.as_ptr() as *const [u8; 10];
1054 Ok(Self::from_bytes(unsafe { &*ptr }))
1056 }
1057
1058 pub fn from_bytes_slice_mut(data: &mut [u8]) -> Result<&mut Self, flatdata::ResourceStorageError> {
1060 if data.len() < 10 {
1062 assert_eq!(data.len(), 10);
1063 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
1064 }
1065 let ptr = data.as_ptr() as *mut [u8; 10];
1066 Ok(Self::from_bytes_mut(unsafe { &mut *ptr }))
1068 }
1069
1070 pub fn as_bytes(&self) -> &[u8; 10] {
1071 &self.data
1072 }
1073}
1074
1075impl Default for WayMember {
1076 fn default( ) -> Self {
1077 Self::new( )
1078 }
1079}
1080
1081unsafe impl flatdata::NoOverlap for WayMember {}
1082
1083impl WayMember {
1084 #[inline]
1086 pub fn way_idx(&self) -> Option<u64> {
1087 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 0, 40);
1088 let x = unsafe { std::mem::transmute::<u64, u64>(value) };
1089 Some(x).filter(|&x| x != super::osm::INVALID_IDX)
1090 }
1091
1092 #[inline]
1096 pub fn role_idx(&self) -> u64 {
1097 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 40, 40);
1098 unsafe { std::mem::transmute::<u64, u64>(value) }
1099 }
1100
1101}
1102
1103impl std::fmt::Debug for WayMember {
1104 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1105 f.debug_struct("WayMember")
1106 .field("way_idx", &self.way_idx())
1107 .field("role_idx", &self.role_idx())
1108 .finish()
1109 }
1110}
1111
1112impl std::cmp::PartialEq for WayMember {
1113 #[inline]
1114 fn eq(&self, other: &Self) -> bool {
1115 self.way_idx() == other.way_idx() && self.role_idx() == other.role_idx() }
1116}
1117
1118impl WayMember {
1119 #[inline]
1121 #[allow(missing_docs)]
1122 pub fn set_way_idx(&mut self, value: Option<u64>) {
1123let value = value.unwrap_or(super::osm::INVALID_IDX); flatdata_write_bytes!(u64; value, self.data, 0, 40)
1124 }
1125
1126 #[inline]
1130 #[allow(missing_docs)]
1131 pub fn set_role_idx(&mut self, value: u64) {
1132 flatdata_write_bytes!(u64; value, self.data, 40, 40)
1133 }
1134
1135
1136 #[inline]
1138 pub fn fill_from(&mut self, other: &WayMember) {
1139 self.set_way_idx(other.way_idx());
1140 self.set_role_idx(other.role_idx());
1141 }
1142}
1143#[repr(transparent)]
1145#[derive(Clone)]
1146pub struct RelationMember {
1147 data: [u8; 10],
1148}
1149
1150impl RelationMember {
1151 pub unsafe fn new_unchecked( ) -> Self {
1153 Self{data : [0; 10]}
1154 }
1155}
1156
1157impl flatdata::Struct for RelationMember {
1158 unsafe fn create_unchecked( ) -> Self {
1159 Self{data : [0; 10]}
1160 }
1161
1162 const SIZE_IN_BYTES: usize = 10;
1163 const IS_OVERLAPPING_WITH_NEXT : bool = false;
1164}
1165
1166impl RelationMember {
1167 pub fn new( ) -> Self {
1168 Self{data : [0; 10]}
1169 }
1170
1171 pub fn from_bytes(data: &[u8; 10]) -> &Self {
1173 unsafe{ std::mem::transmute( data ) }
1175 }
1176
1177 pub fn from_bytes_mut(data: &mut [u8; 10]) -> &mut Self {
1179 unsafe{ std::mem::transmute( data ) }
1181 }
1182
1183 pub fn from_bytes_slice(data: &[u8]) -> Result<&Self, flatdata::ResourceStorageError> {
1185 if data.len() < 10 {
1187 assert_eq!(data.len(), 10);
1188 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
1189 }
1190 let ptr = data.as_ptr() as *const [u8; 10];
1191 Ok(Self::from_bytes(unsafe { &*ptr }))
1193 }
1194
1195 pub fn from_bytes_slice_mut(data: &mut [u8]) -> Result<&mut Self, flatdata::ResourceStorageError> {
1197 if data.len() < 10 {
1199 assert_eq!(data.len(), 10);
1200 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
1201 }
1202 let ptr = data.as_ptr() as *mut [u8; 10];
1203 Ok(Self::from_bytes_mut(unsafe { &mut *ptr }))
1205 }
1206
1207 pub fn as_bytes(&self) -> &[u8; 10] {
1208 &self.data
1209 }
1210}
1211
1212impl Default for RelationMember {
1213 fn default( ) -> Self {
1214 Self::new( )
1215 }
1216}
1217
1218unsafe impl flatdata::NoOverlap for RelationMember {}
1219
1220impl RelationMember {
1221 #[inline]
1223 pub fn relation_idx(&self) -> Option<u64> {
1224 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 0, 40);
1225 let x = unsafe { std::mem::transmute::<u64, u64>(value) };
1226 Some(x).filter(|&x| x != super::osm::INVALID_IDX)
1227 }
1228
1229 #[inline]
1233 pub fn role_idx(&self) -> u64 {
1234 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 40, 40);
1235 unsafe { std::mem::transmute::<u64, u64>(value) }
1236 }
1237
1238}
1239
1240impl std::fmt::Debug for RelationMember {
1241 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1242 f.debug_struct("RelationMember")
1243 .field("relation_idx", &self.relation_idx())
1244 .field("role_idx", &self.role_idx())
1245 .finish()
1246 }
1247}
1248
1249impl std::cmp::PartialEq for RelationMember {
1250 #[inline]
1251 fn eq(&self, other: &Self) -> bool {
1252 self.relation_idx() == other.relation_idx() && self.role_idx() == other.role_idx() }
1253}
1254
1255impl RelationMember {
1256 #[inline]
1258 #[allow(missing_docs)]
1259 pub fn set_relation_idx(&mut self, value: Option<u64>) {
1260let value = value.unwrap_or(super::osm::INVALID_IDX); flatdata_write_bytes!(u64; value, self.data, 0, 40)
1261 }
1262
1263 #[inline]
1267 #[allow(missing_docs)]
1268 pub fn set_role_idx(&mut self, value: u64) {
1269 flatdata_write_bytes!(u64; value, self.data, 40, 40)
1270 }
1271
1272
1273 #[inline]
1275 pub fn fill_from(&mut self, other: &RelationMember) {
1276 self.set_relation_idx(other.relation_idx());
1277 self.set_role_idx(other.role_idx());
1278 }
1279}
1280#[repr(transparent)]
1284pub struct Relation {
1285 data: [u8; 5],
1286}
1287
1288impl Relation {
1289 pub unsafe fn new_unchecked( ) -> Self {
1291 Self{data : [0; 5]}
1292 }
1293}
1294
1295impl flatdata::Struct for Relation {
1296 unsafe fn create_unchecked( ) -> Self {
1297 Self{data : [0; 5]}
1298 }
1299
1300 const SIZE_IN_BYTES: usize = 5;
1301 const IS_OVERLAPPING_WITH_NEXT : bool = true;
1302}
1303
1304impl flatdata::Overlap for Relation {}
1305
1306impl Relation {
1307 #[inline]
1311 pub fn tag_first_idx(&self) -> u64 {
1312 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 0, 40);
1313 unsafe { std::mem::transmute::<u64, u64>(value) }
1314 }
1315
1316 #[inline]
1320 pub fn tags(&self) -> std::ops::Range<u64> {
1321 let start = flatdata_read_bytes!(u64, self.data.as_ptr(), 0, 40);
1322 let end = flatdata_read_bytes!(u64, self.data.as_ptr(), 0 + 5 * 8, 40);
1323 start..end
1324 }
1325
1326}
1327
1328impl std::fmt::Debug for Relation {
1329 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1330 f.debug_struct("Relation")
1331 .field("tag_first_idx", &self.tag_first_idx())
1332 .finish()
1333 }
1334}
1335
1336impl std::cmp::PartialEq for Relation {
1337 #[inline]
1338 fn eq(&self, other: &Self) -> bool {
1339 self.tag_first_idx() == other.tag_first_idx() }
1340}
1341
1342impl Relation {
1343 #[inline]
1347 #[allow(missing_docs)]
1348 pub fn set_tag_first_idx(&mut self, value: u64) {
1349 flatdata_write_bytes!(u64; value, self.data, 0, 40)
1350 }
1351
1352
1353 #[inline]
1355 pub fn fill_from(&mut self, other: &Relation) {
1356 self.set_tag_first_idx(other.tag_first_idx());
1357 }
1358}
1359#[repr(transparent)]
1360#[derive(Clone)]
1361pub struct Id {
1362 data: [u8; 5],
1363}
1364
1365impl Id {
1366 pub unsafe fn new_unchecked( ) -> Self {
1368 Self{data : [0; 5]}
1369 }
1370}
1371
1372impl flatdata::Struct for Id {
1373 unsafe fn create_unchecked( ) -> Self {
1374 Self{data : [0; 5]}
1375 }
1376
1377 const SIZE_IN_BYTES: usize = 5;
1378 const IS_OVERLAPPING_WITH_NEXT : bool = false;
1379}
1380
1381impl Id {
1382 pub fn new( ) -> Self {
1383 Self{data : [0; 5]}
1384 }
1385
1386 pub fn from_bytes(data: &[u8; 5]) -> &Self {
1388 unsafe{ std::mem::transmute( data ) }
1390 }
1391
1392 pub fn from_bytes_mut(data: &mut [u8; 5]) -> &mut Self {
1394 unsafe{ std::mem::transmute( data ) }
1396 }
1397
1398 pub fn from_bytes_slice(data: &[u8]) -> Result<&Self, flatdata::ResourceStorageError> {
1400 if data.len() < 5 {
1402 assert_eq!(data.len(), 5);
1403 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
1404 }
1405 let ptr = data.as_ptr() as *const [u8; 5];
1406 Ok(Self::from_bytes(unsafe { &*ptr }))
1408 }
1409
1410 pub fn from_bytes_slice_mut(data: &mut [u8]) -> Result<&mut Self, flatdata::ResourceStorageError> {
1412 if data.len() < 5 {
1414 assert_eq!(data.len(), 5);
1415 return Err(flatdata::ResourceStorageError::UnexpectedDataSize);
1416 }
1417 let ptr = data.as_ptr() as *mut [u8; 5];
1418 Ok(Self::from_bytes_mut(unsafe { &mut *ptr }))
1420 }
1421
1422 pub fn as_bytes(&self) -> &[u8; 5] {
1423 &self.data
1424 }
1425}
1426
1427impl Default for Id {
1428 fn default( ) -> Self {
1429 Self::new( )
1430 }
1431}
1432
1433unsafe impl flatdata::NoOverlap for Id {}
1434
1435impl Id {
1436 #[inline]
1437 pub fn value(&self) -> u64 {
1438 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 0, 40);
1439 unsafe { std::mem::transmute::<u64, u64>(value) }
1440 }
1441
1442}
1443
1444impl std::fmt::Debug for Id {
1445 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1446 f.debug_struct("Id")
1447 .field("value", &self.value())
1448 .finish()
1449 }
1450}
1451
1452impl std::cmp::PartialEq for Id {
1453 #[inline]
1454 fn eq(&self, other: &Self) -> bool {
1455 self.value() == other.value() }
1456}
1457
1458impl Id {
1459 #[inline]
1460 #[allow(missing_docs)]
1461 pub fn set_value(&mut self, value: u64) {
1462 flatdata_write_bytes!(u64; value, self.data, 0, 40)
1463 }
1464
1465
1466 #[inline]
1468 pub fn fill_from(&mut self, other: &Id) {
1469 self.set_value(other.value());
1470 }
1471}
1472
1473
1474
1475#[derive(Clone)]
1477pub struct Ids {
1478 _storage: flatdata::StorageHandle,
1479 nodes : &'static [super::osm::Id],
1480 ways : &'static [super::osm::Id],
1481 relations : &'static [super::osm::Id],
1482}
1483
1484impl Ids {
1485 fn signature_name(archive_name: &str) -> String {
1486 format!("{}.archive", archive_name)
1487 }
1488
1489 #[inline]
1492 pub fn nodes(&self) -> &[super::osm::Id] {
1493 self.nodes
1494 }
1495
1496 #[inline]
1499 pub fn ways(&self) -> &[super::osm::Id] {
1500 self.ways
1501 }
1502
1503 #[inline]
1506 pub fn relations(&self) -> &[super::osm::Id] {
1507 self.relations
1508 }
1509
1510}
1511
1512impl ::std::fmt::Debug for Ids {
1513 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
1514 f.debug_struct("Ids")
1515 .field("nodes", &self.nodes())
1516 .field("ways", &self.ways())
1517 .field("relations", &self.relations())
1518 .finish()
1519 }
1520}
1521
1522impl Ids {
1523 pub fn open(storage: flatdata::StorageHandle)
1524 -> ::std::result::Result<Self, flatdata::ResourceStorageError>
1525 {
1526 #[allow(unused_imports)]
1527 use flatdata::SliceExt;
1528 #[allow(unused_variables)]
1529 use flatdata::ResourceStorageError as Error;
1530 #[allow(unused_variables)]
1532 let extend = |x : Result<&[u8], Error>| -> Result<&'static [u8], Error> {x.map(|x| unsafe{std::mem::transmute(x)})};
1533
1534 storage.read(&Self::signature_name("Ids"), schema::ids::IDS)?;
1535
1536 let nodes = {
1537 use flatdata::check_resource as check;
1538 let max_size = None;
1539 let resource = extend(storage.read("nodes", schema::ids::resources::NODES));
1540 check("nodes", |r| r.len(), max_size, resource.and_then(|x| <&[super::osm::Id]>::from_bytes(x)))?
1541 };
1542 let ways = {
1543 use flatdata::check_resource as check;
1544 let max_size = None;
1545 let resource = extend(storage.read("ways", schema::ids::resources::WAYS));
1546 check("ways", |r| r.len(), max_size, resource.and_then(|x| <&[super::osm::Id]>::from_bytes(x)))?
1547 };
1548 let relations = {
1549 use flatdata::check_resource as check;
1550 let max_size = None;
1551 let resource = extend(storage.read("relations", schema::ids::resources::RELATIONS));
1552 check("relations", |r| r.len(), max_size, resource.and_then(|x| <&[super::osm::Id]>::from_bytes(x)))?
1553 };
1554
1555 Ok(Self {
1556 _storage: storage,
1557 nodes,
1558 ways,
1559 relations,
1560 })
1561 }
1562}
1563
1564#[derive(Clone, Debug)]
1568pub struct IdsBuilder {
1569 storage: flatdata::StorageHandle
1570}
1571
1572impl IdsBuilder {
1573 #[inline]
1574 pub fn set_nodes(&self, vector: &[super::osm::Id]) -> ::std::io::Result<()> {
1578 use flatdata::SliceExt;
1579 self.storage.write("nodes", schema::ids::resources::NODES, vector.as_bytes())
1580 }
1581
1582 #[inline]
1591 pub fn start_nodes(&self) -> ::std::io::Result<flatdata::ExternalVector<super::osm::Id>> {
1592 flatdata::create_external_vector(&*self.storage, "nodes", schema::ids::resources::NODES)
1593 }
1594
1595 #[inline]
1596 pub fn set_ways(&self, vector: &[super::osm::Id]) -> ::std::io::Result<()> {
1600 use flatdata::SliceExt;
1601 self.storage.write("ways", schema::ids::resources::WAYS, vector.as_bytes())
1602 }
1603
1604 #[inline]
1613 pub fn start_ways(&self) -> ::std::io::Result<flatdata::ExternalVector<super::osm::Id>> {
1614 flatdata::create_external_vector(&*self.storage, "ways", schema::ids::resources::WAYS)
1615 }
1616
1617 #[inline]
1618 pub fn set_relations(&self, vector: &[super::osm::Id]) -> ::std::io::Result<()> {
1622 use flatdata::SliceExt;
1623 self.storage.write("relations", schema::ids::resources::RELATIONS, vector.as_bytes())
1624 }
1625
1626 #[inline]
1635 pub fn start_relations(&self) -> ::std::io::Result<flatdata::ExternalVector<super::osm::Id>> {
1636 flatdata::create_external_vector(&*self.storage, "relations", schema::ids::resources::RELATIONS)
1637 }
1638
1639}
1640
1641impl IdsBuilder {
1642 pub fn new(
1643 storage: flatdata::StorageHandle,
1644 ) -> Result<Self, flatdata::ResourceStorageError> {
1645 flatdata::create_archive("Ids", schema::ids::IDS, &storage)?;
1646 Ok(Self { storage })
1647 }
1648}
1649
1650
1651
1652#[derive(Clone, PartialEq)]
1657pub enum RelationMembersRef<'a> {
1658 #[allow(missing_docs)]
1659 NodeMember(&'a super::osm::NodeMember), #[allow(missing_docs)]
1660 WayMember(&'a super::osm::WayMember), #[allow(missing_docs)]
1661 RelationMember(&'a super::osm::RelationMember),}
1662
1663impl<'a> ::std::fmt::Debug for RelationMembersRef<'a> {
1664 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
1665 match *self {
1666 RelationMembersRef::NodeMember(ref inner) => write!(f, "{:?}", inner),
1667 RelationMembersRef::WayMember(ref inner) => write!(f, "{:?}", inner),
1668 RelationMembersRef::RelationMember(ref inner) => write!(f, "{:?}", inner),
1669 }
1670 }
1671}
1672
1673impl<'a> flatdata::VariadicRef for RelationMembersRef<'a> {
1674 #[inline]
1675 fn size_in_bytes(&self) -> usize {
1676 match *self {
1677 RelationMembersRef::NodeMember(_) => <super::osm::NodeMember as flatdata::Struct>::SIZE_IN_BYTES,
1678 RelationMembersRef::WayMember(_) => <super::osm::WayMember as flatdata::Struct>::SIZE_IN_BYTES,
1679 RelationMembersRef::RelationMember(_) => <super::osm::RelationMember as flatdata::Struct>::SIZE_IN_BYTES,
1680 }
1681 }
1682}
1683
1684pub struct RelationMembersBuilder<'a> {
1691 data: &'a mut Vec<u8>
1692}
1693
1694impl<'a> RelationMembersBuilder<'a> {
1695 #[inline]
1699 pub fn add_node_member<'b>(&'b mut self) -> &'b mut super::osm::NodeMember {
1700 let old_len = self.data.len();
1701 let increment = 1 + <super::osm::NodeMember as flatdata::Struct>::SIZE_IN_BYTES;
1702 self.data.resize(old_len + increment, 0);
1703 self.data[old_len] = 0;
1704 let slice = &mut self.data[1 + old_len..];
1705 super::osm::NodeMember::from_bytes_slice_mut(slice).expect("Logic error: Cannot create super::osm::NodeMember from slice")
1706 }
1707 #[inline]
1711 pub fn add_way_member<'b>(&'b mut self) -> &'b mut super::osm::WayMember {
1712 let old_len = self.data.len();
1713 let increment = 1 + <super::osm::WayMember as flatdata::Struct>::SIZE_IN_BYTES;
1714 self.data.resize(old_len + increment, 0);
1715 self.data[old_len] = 1;
1716 let slice = &mut self.data[1 + old_len..];
1717 super::osm::WayMember::from_bytes_slice_mut(slice).expect("Logic error: Cannot create super::osm::WayMember from slice")
1718 }
1719 #[inline]
1723 pub fn add_relation_member<'b>(&'b mut self) -> &'b mut super::osm::RelationMember {
1724 let old_len = self.data.len();
1725 let increment = 1 + <super::osm::RelationMember as flatdata::Struct>::SIZE_IN_BYTES;
1726 self.data.resize(old_len + increment, 0);
1727 self.data[old_len] = 2;
1728 let slice = &mut self.data[1 + old_len..];
1729 super::osm::RelationMember::from_bytes_slice_mut(slice).expect("Logic error: Cannot create super::osm::RelationMember from slice")
1730 }
1731}
1732
1733#[derive(Clone)]
1756pub struct RelationMembers {}
1757
1758impl flatdata::VariadicIndex for RelationMembers {
1759 type Index = super::_builtin::multivector::IndexType40;
1760}
1761
1762impl<'a> flatdata::VariadicStruct<'a> for RelationMembers {
1763 type Item = RelationMembersRef<'a>;
1764
1765 #[inline]
1766 fn create(index: flatdata::TypeIndex, data: &'a [u8]) -> Self::Item
1767 {
1768 match index {
1769 0 => RelationMembersRef::NodeMember(super::osm::NodeMember::from_bytes_slice(&data).expect("Corrupted data")),
1770 1 => RelationMembersRef::WayMember(super::osm::WayMember::from_bytes_slice(&data).expect("Corrupted data")),
1771 2 => RelationMembersRef::RelationMember(super::osm::RelationMember::from_bytes_slice(&data).expect("Corrupted data")),
1772 _ => panic!("invalid type index {} for variadic type RelationMembersRef", index),
1773 }
1774 }
1775
1776 type ItemMut = RelationMembersBuilder<'a>;
1777
1778 #[inline]
1779 fn create_mut(data: &'a mut Vec<u8>) -> Self::ItemMut
1780 {
1781 Self::ItemMut { data }
1782 }
1783}
1784
1785#[derive(Clone)]
1805pub struct Osm {
1806 _storage: flatdata::StorageHandle,
1807 header : &'static super::osm::Header,
1808 nodes : &'static [super::osm::Node],
1809 ways : &'static [super::osm::Way],
1810 relations : &'static [super::osm::Relation],
1811 relation_members : flatdata::MultiArrayView<'static, RelationMembers>,
1812 tags : &'static [super::osm::Tag],
1813 tags_index : &'static [super::osm::TagIndex],
1814 nodes_index : &'static [super::osm::NodeIndex],
1815 stringtable : flatdata::RawData<'static>,
1816 ids : Option<super::osm::Ids
1817>,
1818}
1819
1820impl Osm {
1821 fn signature_name(archive_name: &str) -> String {
1822 format!("{}.archive", archive_name)
1823 }
1824
1825 #[inline]
1827 pub fn header(&self) -> &super::osm::Header {
1828 self.header
1829 }
1830
1831 #[inline]
1835 pub fn nodes(&self) -> &[super::osm::Node] {
1836 self.nodes
1837 }
1838
1839 #[inline]
1846 pub fn ways(&self) -> &[super::osm::Way] {
1847 self.ways
1848 }
1849
1850 #[inline]
1856 pub fn relations(&self) -> &[super::osm::Relation] {
1857 self.relations
1858 }
1859
1860 #[inline]
1871 pub fn relation_members(&self) -> &flatdata::MultiArrayView<RelationMembers> {
1872 &self.relation_members
1873 }
1874
1875 #[inline]
1879 pub fn tags(&self) -> &[super::osm::Tag] {
1880 self.tags
1881 }
1882
1883 #[inline]
1886 pub fn tags_index(&self) -> &[super::osm::TagIndex] {
1887 self.tags_index
1888 }
1889
1890 #[inline]
1892 pub fn nodes_index(&self) -> &[super::osm::NodeIndex] {
1893 self.nodes_index
1894 }
1895
1896 #[inline]
1898 pub fn stringtable(&self) -> flatdata::RawData {
1899 self.stringtable
1900 }
1901
1902 #[inline]
1903 pub fn ids(&self) -> Option<&super::osm::Ids> {
1904 self.ids.as_ref()
1905 }
1906
1907}
1908
1909impl ::std::fmt::Debug for Osm {
1910 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
1911 f.debug_struct("Osm")
1912 .field("header", &self.header())
1913 .field("nodes", &self.nodes())
1914 .field("ways", &self.ways())
1915 .field("relations", &self.relations())
1916 .field("relation_members", &self.relation_members())
1917 .field("tags", &self.tags())
1918 .field("tags_index", &self.tags_index())
1919 .field("nodes_index", &self.nodes_index())
1920 .field("stringtable", &self.stringtable())
1921 .field("ids", &self.ids())
1922 .finish()
1923 }
1924}
1925
1926impl Osm {
1927 pub fn open(storage: flatdata::StorageHandle)
1928 -> ::std::result::Result<Self, flatdata::ResourceStorageError>
1929 {
1930 #[allow(unused_imports)]
1931 use flatdata::SliceExt;
1932 #[allow(unused_variables)]
1933 use flatdata::ResourceStorageError as Error;
1934 #[allow(unused_variables)]
1936 let extend = |x : Result<&[u8], Error>| -> Result<&'static [u8], Error> {x.map(|x| unsafe{std::mem::transmute(x)})};
1937
1938 storage.read(&Self::signature_name("Osm"), schema::osm::OSM)?;
1939
1940 let header = {
1941 use flatdata::check_resource as check;
1942 let max_size = None;
1943 let resource = extend(storage.read("header", schema::osm::resources::HEADER));
1944 check("header", |_| 0, max_size, resource.and_then(|x| super::osm::Header::from_bytes_slice(x)))?
1945 };
1946 let nodes = {
1947 use flatdata::check_resource as check;
1948 let max_size = Some(1099511627776);
1949 let resource = extend(storage.read("nodes", schema::osm::resources::NODES));
1950 check("nodes", |r| r.len(), max_size, resource.and_then(|x| <&[super::osm::Node]>::from_bytes(x)))?
1951 };
1952 let ways = {
1953 use flatdata::check_resource as check;
1954 let max_size = Some(1099511627776);
1955 let resource = extend(storage.read("ways", schema::osm::resources::WAYS));
1956 check("ways", |r| r.len(), max_size, resource.and_then(|x| <&[super::osm::Way]>::from_bytes(x)))?
1957 };
1958 let relations = {
1959 use flatdata::check_resource as check;
1960 let max_size = Some(1099511627776);
1961 let resource = extend(storage.read("relations", schema::osm::resources::RELATIONS));
1962 check("relations", |r| r.len(), max_size, resource.and_then(|x| <&[super::osm::Relation]>::from_bytes(x)))?
1963 };
1964 let relation_members = {
1965 use flatdata::check_resource as check;
1966 let max_size = None;
1967 let index_schema = &format!("index({})", schema::osm::resources::RELATION_MEMBERS);
1968 let index = extend(storage.read("relation_members_index", &index_schema));
1969 let data = extend(storage.read("relation_members", schema::osm::resources::RELATION_MEMBERS));
1970 let result = match (index, data) {
1971 (Ok(index), Ok(data)) => {
1972 Ok(flatdata::MultiArrayView::new(
1973 <&[super::_builtin::multivector::IndexType40]>::from_bytes(index)?,
1974 data
1975 ))
1976 }
1977 (Err(Error::Missing), Err(Error::Missing)) => Err(Error::Missing),
1979 (Ok(_), Err(Error::Missing)) | (Err(Error::Missing), Ok(_)) => Err(Error::MissingData),
1981 (Err(Error::Missing), Err(x)) | (Err(x), Err(Error::Missing)) => {return Err(x);}
1982 (_, Err(x)) | (Err(x), _) => {return Err(x);}
1983 };
1984 check("relation_members", |r| r.len(), max_size, result)?
1985 };
1986 let tags = {
1987 use flatdata::check_resource as check;
1988 let max_size = Some(1099511627776);
1989 let resource = extend(storage.read("tags", schema::osm::resources::TAGS));
1990 check("tags", |r| r.len(), max_size, resource.and_then(|x| <&[super::osm::Tag]>::from_bytes(x)))?
1991 };
1992 let tags_index = {
1993 use flatdata::check_resource as check;
1994 let max_size = Some(1099511627776);
1995 let resource = extend(storage.read("tags_index", schema::osm::resources::TAGS_INDEX));
1996 check("tags_index", |r| r.len(), max_size, resource.and_then(|x| <&[super::osm::TagIndex]>::from_bytes(x)))?
1997 };
1998 let nodes_index = {
1999 use flatdata::check_resource as check;
2000 let max_size = Some(1099511627776);
2001 let resource = extend(storage.read("nodes_index", schema::osm::resources::NODES_INDEX));
2002 check("nodes_index", |r| r.len(), max_size, resource.and_then(|x| <&[super::osm::NodeIndex]>::from_bytes(x)))?
2003 };
2004 let stringtable = {
2005 use flatdata::check_resource as check;
2006 let max_size = Some(1099511627776);
2007 let resource = extend(storage.read("stringtable", schema::osm::resources::STRINGTABLE));
2008 check("stringtable", |r| r.len(), max_size, resource.map(|x| flatdata::RawData::new(x)))?
2009 };
2010 let ids = {
2011 use flatdata::check_optional_resource as check;
2012 let max_size = None;
2013 check("ids", |_| 0, max_size, super::osm::Ids::open(storage.subdir("ids")))?
2014 };
2015
2016 Ok(Self {
2017 _storage: storage,
2018 header,
2019 nodes,
2020 ways,
2021 relations,
2022 relation_members,
2023 tags,
2024 tags_index,
2025 nodes_index,
2026 stringtable,
2027 ids,
2028 })
2029 }
2030}
2031
2032#[derive(Clone, Debug)]
2036pub struct OsmBuilder {
2037 storage: flatdata::StorageHandle
2038}
2039
2040impl OsmBuilder {
2041 #[inline]
2042 pub fn set_header(&self, resource: &super::osm::Header) -> ::std::io::Result<()> {
2047 let data = resource.as_bytes();
2048 self.storage.write("header", schema::osm::resources::HEADER, data)
2049 }
2050
2051 #[inline]
2052 pub fn set_nodes(&self, vector: &[super::osm::Node]) -> ::std::io::Result<()> {
2056 use flatdata::SliceExt;
2057 self.storage.write("nodes", schema::osm::resources::NODES, vector.as_bytes())
2058 }
2059
2060 #[inline]
2069 pub fn start_nodes(&self) -> ::std::io::Result<flatdata::ExternalVector<super::osm::Node>> {
2070 flatdata::create_external_vector(&*self.storage, "nodes", schema::osm::resources::NODES)
2071 }
2072
2073 #[inline]
2074 pub fn set_ways(&self, vector: &[super::osm::Way]) -> ::std::io::Result<()> {
2078 use flatdata::SliceExt;
2079 self.storage.write("ways", schema::osm::resources::WAYS, vector.as_bytes())
2080 }
2081
2082 #[inline]
2091 pub fn start_ways(&self) -> ::std::io::Result<flatdata::ExternalVector<super::osm::Way>> {
2092 flatdata::create_external_vector(&*self.storage, "ways", schema::osm::resources::WAYS)
2093 }
2094
2095 #[inline]
2096 pub fn set_relations(&self, vector: &[super::osm::Relation]) -> ::std::io::Result<()> {
2100 use flatdata::SliceExt;
2101 self.storage.write("relations", schema::osm::resources::RELATIONS, vector.as_bytes())
2102 }
2103
2104 #[inline]
2113 pub fn start_relations(&self) -> ::std::io::Result<flatdata::ExternalVector<super::osm::Relation>> {
2114 flatdata::create_external_vector(&*self.storage, "relations", schema::osm::resources::RELATIONS)
2115 }
2116
2117 #[inline]
2126 pub fn start_relation_members(&self) -> ::std::io::Result<flatdata::MultiVector<RelationMembers>> {
2127 flatdata::create_multi_vector(&*self.storage, "relation_members", schema::osm::resources::RELATION_MEMBERS)
2128 }
2129
2130 #[inline]
2131 pub fn set_tags(&self, vector: &[super::osm::Tag]) -> ::std::io::Result<()> {
2135 use flatdata::SliceExt;
2136 self.storage.write("tags", schema::osm::resources::TAGS, vector.as_bytes())
2137 }
2138
2139 #[inline]
2148 pub fn start_tags(&self) -> ::std::io::Result<flatdata::ExternalVector<super::osm::Tag>> {
2149 flatdata::create_external_vector(&*self.storage, "tags", schema::osm::resources::TAGS)
2150 }
2151
2152 #[inline]
2153 pub fn set_tags_index(&self, vector: &[super::osm::TagIndex]) -> ::std::io::Result<()> {
2157 use flatdata::SliceExt;
2158 self.storage.write("tags_index", schema::osm::resources::TAGS_INDEX, vector.as_bytes())
2159 }
2160
2161 #[inline]
2170 pub fn start_tags_index(&self) -> ::std::io::Result<flatdata::ExternalVector<super::osm::TagIndex>> {
2171 flatdata::create_external_vector(&*self.storage, "tags_index", schema::osm::resources::TAGS_INDEX)
2172 }
2173
2174 #[inline]
2175 pub fn set_nodes_index(&self, vector: &[super::osm::NodeIndex]) -> ::std::io::Result<()> {
2179 use flatdata::SliceExt;
2180 self.storage.write("nodes_index", schema::osm::resources::NODES_INDEX, vector.as_bytes())
2181 }
2182
2183 #[inline]
2192 pub fn start_nodes_index(&self) -> ::std::io::Result<flatdata::ExternalVector<super::osm::NodeIndex>> {
2193 flatdata::create_external_vector(&*self.storage, "nodes_index", schema::osm::resources::NODES_INDEX)
2194 }
2195
2196 #[inline]
2200 pub fn set_stringtable(&self, data: &[u8]) -> ::std::io::Result<()> {
2201 self.storage.write("stringtable", schema::osm::resources::STRINGTABLE, data)
2202 }
2203
2204 #[inline]
2208 pub fn ids(&self) -> Result<super::osm::IdsBuilder, flatdata::ResourceStorageError> {
2209 let storage = self.storage.subdir("ids");
2210 super::osm::IdsBuilder::new(storage)
2211 }
2212
2213}
2214
2215impl OsmBuilder {
2216 pub fn new(
2217 storage: flatdata::StorageHandle,
2218 ) -> Result<Self, flatdata::ResourceStorageError> {
2219 flatdata::create_archive("Osm", schema::osm::OSM, &storage)?;
2220 Ok(Self { storage })
2221 }
2222}
2223
2224
2225#[doc(hidden)]
2226pub mod schema {
2227pub mod ids {
2228
2229pub const IDS: &str = r#"namespace osm {
2230struct Id
2231{
2232 value : u64 : 40;
2233}
2234}
2235
2236namespace osm {
2237archive Ids
2238{
2239 nodes : vector< .osm.Id >;
2240 ways : vector< .osm.Id >;
2241 relations : vector< .osm.Id >;
2242}
2243}
2244
2245"#;
2246
2247pub mod resources {
2248pub const NODES: &str = r#"namespace osm {
2249struct Id
2250{
2251 value : u64 : 40;
2252}
2253}
2254
2255namespace osm {
2256archive Ids
2257{
2258 nodes : vector< .osm.Id >;
2259}
2260}
2261
2262"#;
2263pub const WAYS: &str = r#"namespace osm {
2264struct Id
2265{
2266 value : u64 : 40;
2267}
2268}
2269
2270namespace osm {
2271archive Ids
2272{
2273 ways : vector< .osm.Id >;
2274}
2275}
2276
2277"#;
2278pub const RELATIONS: &str = r#"namespace osm {
2279struct Id
2280{
2281 value : u64 : 40;
2282}
2283}
2284
2285namespace osm {
2286archive Ids
2287{
2288 relations : vector< .osm.Id >;
2289}
2290}
2291
2292"#;
2293}
2294}
2295pub mod osm {
2296
2297pub const OSM: &str = r#"namespace osm {
2298struct Header
2299{
2300 coord_scale : i32 : 32;
2301 bbox_left : i32 : 32;
2302 bbox_right : i32 : 32;
2303 bbox_top : i32 : 32;
2304 bbox_bottom : i32 : 32;
2305 writingprogram_idx : u64 : 40;
2306 source_idx : u64 : 40;
2307 replication_timestamp : i64 : 64;
2308 replication_sequence_number : i64 : 64;
2309 replication_base_url_idx : u64 : 40;
2310}
2311}
2312
2313namespace osm {
2314struct Node
2315{
2316 lat : i32 : 32;
2317 lon : i32 : 32;
2318 @range( tags )
2319 tag_first_idx : u64 : 40;
2320}
2321}
2322
2323namespace osm {
2324struct Way
2325{
2326 @range( tags )
2327 tag_first_idx : u64 : 40;
2328 @range( refs )
2329 ref_first_idx : u64 : 40;
2330}
2331}
2332
2333namespace osm {
2334struct Relation
2335{
2336 @range( tags )
2337 tag_first_idx : u64 : 40;
2338}
2339}
2340
2341namespace osm {
2342const u64 INVALID_IDX = 1099511627775;
2343}
2344
2345namespace osm {
2346struct NodeMember
2347{
2348 @optional( .osm.INVALID_IDX )
2349 node_idx : u64 : 40;
2350 role_idx : u64 : 40;
2351}
2352}
2353
2354namespace osm {
2355struct WayMember
2356{
2357 @optional( .osm.INVALID_IDX )
2358 way_idx : u64 : 40;
2359 role_idx : u64 : 40;
2360}
2361}
2362
2363namespace osm {
2364struct RelationMember
2365{
2366 @optional( .osm.INVALID_IDX )
2367 relation_idx : u64 : 40;
2368 role_idx : u64 : 40;
2369}
2370}
2371
2372namespace osm {
2373struct Tag
2374{
2375 key_idx : u64 : 40;
2376 value_idx : u64 : 40;
2377}
2378}
2379
2380namespace osm {
2381struct TagIndex
2382{
2383 value : u64 : 40;
2384}
2385}
2386
2387namespace osm {
2388struct NodeIndex
2389{
2390 @optional( .osm.INVALID_IDX )
2391 value : u64 : 40;
2392}
2393}
2394
2395namespace osm {
2396struct Id
2397{
2398 value : u64 : 40;
2399}
2400}
2401
2402namespace osm {
2403archive Ids
2404{
2405 nodes : vector< .osm.Id >;
2406 ways : vector< .osm.Id >;
2407 relations : vector< .osm.Id >;
2408}
2409}
2410
2411namespace osm {
2412@bound_implicitly( Relations : .osm.Osm.relations, .osm.Osm.relation_members )
2413archive Osm
2414{
2415 @explicit_reference( .osm.Header.writingprogram_idx, .osm.Osm.stringtable )
2416 @explicit_reference( .osm.Header.source_idx, .osm.Osm.stringtable )
2417 @explicit_reference( .osm.Header.replication_base_url_idx, .osm.Osm.stringtable )
2418 header : .osm.Header;
2419 @explicit_reference( .osm.Node.tag_first_idx, .osm.Osm.tags_index )
2420 nodes : vector< .osm.Node >;
2421 @explicit_reference( .osm.Way.tag_first_idx, .osm.Osm.tags_index )
2422 @explicit_reference( .osm.Way.ref_first_idx, .osm.Osm.nodes_index )
2423 ways : vector< .osm.Way >;
2424 @explicit_reference( .osm.Relation.tag_first_idx, .osm.Osm.tags_index )
2425 relations : vector< .osm.Relation >;
2426 @explicit_reference( .osm.NodeMember.node_idx, .osm.Osm.nodes )
2427 @explicit_reference( .osm.NodeMember.role_idx, .osm.Osm.stringtable )
2428 @explicit_reference( .osm.WayMember.way_idx, .osm.Osm.ways )
2429 @explicit_reference( .osm.WayMember.role_idx, .osm.Osm.stringtable )
2430 @explicit_reference( .osm.RelationMember.relation_idx, .osm.Osm.relations )
2431 @explicit_reference( .osm.RelationMember.role_idx, .osm.Osm.stringtable )
2432 relation_members : multivector< 40, .osm.NodeMember, .osm.WayMember, .osm.RelationMember >;
2433 @explicit_reference( .osm.Tag.key_idx, .osm.Osm.stringtable )
2434 @explicit_reference( .osm.Tag.value_idx, .osm.Osm.stringtable )
2435 tags : vector< .osm.Tag >;
2436 @explicit_reference( .osm.TagIndex.value, .osm.Osm.tags )
2437 tags_index : vector< .osm.TagIndex >;
2438 @explicit_reference( .osm.NodeIndex.value, .osm.Osm.nodes )
2439 nodes_index : vector< .osm.NodeIndex >;
2440 stringtable : raw_data;
2441 @optional
2442 ids : archive .osm.Ids;
2443}
2444}
2445
2446"#;
2447
2448pub mod resources {
2449pub const HEADER: &str = r#"namespace osm {
2450struct Header
2451{
2452 coord_scale : i32 : 32;
2453 bbox_left : i32 : 32;
2454 bbox_right : i32 : 32;
2455 bbox_top : i32 : 32;
2456 bbox_bottom : i32 : 32;
2457 writingprogram_idx : u64 : 40;
2458 source_idx : u64 : 40;
2459 replication_timestamp : i64 : 64;
2460 replication_sequence_number : i64 : 64;
2461 replication_base_url_idx : u64 : 40;
2462}
2463}
2464
2465namespace osm {
2466archive Osm
2467{
2468 @explicit_reference( .osm.Header.writingprogram_idx, .osm.Osm.stringtable )
2469 @explicit_reference( .osm.Header.source_idx, .osm.Osm.stringtable )
2470 @explicit_reference( .osm.Header.replication_base_url_idx, .osm.Osm.stringtable )
2471 header : .osm.Header;
2472}
2473}
2474
2475"#;
2476pub const NODES: &str = r#"namespace osm {
2477struct Node
2478{
2479 lat : i32 : 32;
2480 lon : i32 : 32;
2481 @range( tags )
2482 tag_first_idx : u64 : 40;
2483}
2484}
2485
2486namespace osm {
2487archive Osm
2488{
2489 @explicit_reference( .osm.Node.tag_first_idx, .osm.Osm.tags_index )
2490 nodes : vector< .osm.Node >;
2491}
2492}
2493
2494"#;
2495pub const WAYS: &str = r#"namespace osm {
2496struct Way
2497{
2498 @range( tags )
2499 tag_first_idx : u64 : 40;
2500 @range( refs )
2501 ref_first_idx : u64 : 40;
2502}
2503}
2504
2505namespace osm {
2506archive Osm
2507{
2508 @explicit_reference( .osm.Way.tag_first_idx, .osm.Osm.tags_index )
2509 @explicit_reference( .osm.Way.ref_first_idx, .osm.Osm.nodes_index )
2510 ways : vector< .osm.Way >;
2511}
2512}
2513
2514"#;
2515pub const RELATIONS: &str = r#"namespace osm {
2516struct Relation
2517{
2518 @range( tags )
2519 tag_first_idx : u64 : 40;
2520}
2521}
2522
2523namespace osm {
2524archive Osm
2525{
2526 @explicit_reference( .osm.Relation.tag_first_idx, .osm.Osm.tags_index )
2527 relations : vector< .osm.Relation >;
2528}
2529}
2530
2531"#;
2532pub const RELATION_MEMBERS: &str = r#"namespace osm {
2533const u64 INVALID_IDX = 1099511627775;
2534}
2535
2536namespace osm {
2537struct NodeMember
2538{
2539 @optional( .osm.INVALID_IDX )
2540 node_idx : u64 : 40;
2541 role_idx : u64 : 40;
2542}
2543}
2544
2545namespace osm {
2546struct WayMember
2547{
2548 @optional( .osm.INVALID_IDX )
2549 way_idx : u64 : 40;
2550 role_idx : u64 : 40;
2551}
2552}
2553
2554namespace osm {
2555struct RelationMember
2556{
2557 @optional( .osm.INVALID_IDX )
2558 relation_idx : u64 : 40;
2559 role_idx : u64 : 40;
2560}
2561}
2562
2563namespace osm {
2564archive Osm
2565{
2566 @explicit_reference( .osm.NodeMember.node_idx, .osm.Osm.nodes )
2567 @explicit_reference( .osm.NodeMember.role_idx, .osm.Osm.stringtable )
2568 @explicit_reference( .osm.WayMember.way_idx, .osm.Osm.ways )
2569 @explicit_reference( .osm.WayMember.role_idx, .osm.Osm.stringtable )
2570 @explicit_reference( .osm.RelationMember.relation_idx, .osm.Osm.relations )
2571 @explicit_reference( .osm.RelationMember.role_idx, .osm.Osm.stringtable )
2572 relation_members : multivector< 40, .osm.NodeMember, .osm.WayMember, .osm.RelationMember >;
2573}
2574}
2575
2576"#;
2577pub const TAGS: &str = r#"namespace osm {
2578struct Tag
2579{
2580 key_idx : u64 : 40;
2581 value_idx : u64 : 40;
2582}
2583}
2584
2585namespace osm {
2586archive Osm
2587{
2588 @explicit_reference( .osm.Tag.key_idx, .osm.Osm.stringtable )
2589 @explicit_reference( .osm.Tag.value_idx, .osm.Osm.stringtable )
2590 tags : vector< .osm.Tag >;
2591}
2592}
2593
2594"#;
2595pub const TAGS_INDEX: &str = r#"namespace osm {
2596struct TagIndex
2597{
2598 value : u64 : 40;
2599}
2600}
2601
2602namespace osm {
2603archive Osm
2604{
2605 @explicit_reference( .osm.TagIndex.value, .osm.Osm.tags )
2606 tags_index : vector< .osm.TagIndex >;
2607}
2608}
2609
2610"#;
2611pub const NODES_INDEX: &str = r#"namespace osm {
2612const u64 INVALID_IDX = 1099511627775;
2613}
2614
2615namespace osm {
2616struct NodeIndex
2617{
2618 @optional( .osm.INVALID_IDX )
2619 value : u64 : 40;
2620}
2621}
2622
2623namespace osm {
2624archive Osm
2625{
2626 @explicit_reference( .osm.NodeIndex.value, .osm.Osm.nodes )
2627 nodes_index : vector< .osm.NodeIndex >;
2628}
2629}
2630
2631"#;
2632pub const STRINGTABLE: &str = r#"namespace osm {
2633archive Osm
2634{
2635 stringtable : raw_data;
2636}
2637}
2638
2639"#;
2640pub const IDS: &str = r#"namespace osm {
2641struct Id
2642{
2643 value : u64 : 40;
2644}
2645}
2646
2647namespace osm {
2648archive Ids
2649{
2650 nodes : vector< .osm.Id >;
2651 ways : vector< .osm.Id >;
2652 relations : vector< .osm.Id >;
2653}
2654}
2655
2656namespace osm {
2657archive Osm
2658{
2659 @optional
2660 ids : archive .osm.Ids;
2661}
2662}
2663
2664"#;
2665}
2666}
2667}
2668}
2669
2670#[doc(hidden)]
2671pub mod _builtin {
2672#[allow(unused_imports)]
2673use flatdata::{flatdata_read_bytes, flatdata_write_bytes};
2674
2675
2676#[allow(missing_docs)]
2677pub mod multivector {
2678#[allow(unused_imports)]
2679use flatdata::{flatdata_read_bytes, flatdata_write_bytes};
2680
2681
2682#[repr(transparent)]
2684pub struct IndexType40 {
2685 data: [u8; 5],
2686}
2687
2688impl IndexType40 {
2689 pub unsafe fn new_unchecked( ) -> Self {
2691 Self{data : [0; 5]}
2692 }
2693}
2694
2695impl flatdata::Struct for IndexType40 {
2696 unsafe fn create_unchecked( ) -> Self {
2697 Self{data : [0; 5]}
2698 }
2699
2700 const SIZE_IN_BYTES: usize = 5;
2701 const IS_OVERLAPPING_WITH_NEXT : bool = true;
2702}
2703
2704impl flatdata::Overlap for IndexType40 {}
2705
2706impl IndexType40 {
2707 #[inline]
2711 pub fn value(&self) -> u64 {
2712 let value = flatdata_read_bytes!(u64, self.data.as_ptr(), 0, 40);
2713 unsafe { std::mem::transmute::<u64, u64>(value) }
2714 }
2715
2716 #[inline]
2717 pub fn range(&self) -> std::ops::Range<u64> {
2718 let start = flatdata_read_bytes!(u64, self.data.as_ptr(), 0, 40);
2719 let end = flatdata_read_bytes!(u64, self.data.as_ptr(), 0 + 5 * 8, 40);
2720 start..end
2721 }
2722
2723}
2724
2725impl std::fmt::Debug for IndexType40 {
2726 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2727 f.debug_struct("IndexType40")
2728 .field("value", &self.value())
2729 .finish()
2730 }
2731}
2732
2733impl std::cmp::PartialEq for IndexType40 {
2734 #[inline]
2735 fn eq(&self, other: &Self) -> bool {
2736 self.value() == other.value() }
2737}
2738
2739impl IndexType40 {
2740 #[inline]
2744 #[allow(missing_docs)]
2745 pub fn set_value(&mut self, value: u64) {
2746 flatdata_write_bytes!(u64; value, self.data, 0, 40)
2747 }
2748
2749
2750 #[inline]
2752 pub fn fill_from(&mut self, other: &IndexType40) {
2753 self.set_value(other.value());
2754 }
2755}
2756
2757impl flatdata::IndexStruct for IndexType40 {
2758 #[inline]
2759 fn range(&self) -> std::ops::Range<usize> {
2760 let range = self.range();
2761 range.start as usize..range.end as usize
2762 }
2763
2764 #[inline]
2765 fn set_index(&mut self, value: usize) {
2766 self.set_value(value as u64);
2767 }
2768}
2769
2770
2771#[doc(hidden)]
2772pub mod schema {
2773}
2774}
2775
2776#[doc(hidden)]
2777pub mod schema {
2778}
2779}