|
|
@@ -2,6 +2,8 @@ use osmpbf::{Element, ElementReader};
|
|
2
|
2
|
use regex::Regex;
|
|
3
|
3
|
use std::path::{Path, PathBuf};
|
|
4
|
4
|
use std::thread;
|
|
|
5
|
+use coord::LatLon;
|
|
|
6
|
+
|
|
5
|
7
|
|
|
6
|
8
|
#[derive(Debug, Eq, PartialEq)]
|
|
7
|
9
|
pub enum ControlFlow {
|
|
|
@@ -26,7 +28,7 @@ pub fn search_pbf<P, F>(
|
|
26
|
28
|
update_func: F,
|
|
27
|
29
|
) -> Result<thread::JoinHandle<()>, String>
|
|
28
|
30
|
where P: AsRef<Path>,
|
|
29
|
|
- F: Fn(f64, f64) -> ControlFlow + Send + 'static,
|
|
|
31
|
+ F: Fn(LatLon) -> ControlFlow + Send + 'static,
|
|
30
|
32
|
{
|
|
31
|
33
|
let pathbuf = PathBuf::from(pbf_path.as_ref());
|
|
32
|
34
|
let re = Regex::new(search_pattern)
|
|
|
@@ -40,17 +42,19 @@ where P: AsRef<Path>,
|
|
40
|
42
|
Element::Node(node) => {
|
|
41
|
43
|
for (_key, val) in node.tags() {
|
|
42
|
44
|
if re.is_match(val) {
|
|
43
|
|
- if update_func(node.lat(), node.lon()) == ControlFlow::Break {
|
|
|
45
|
+ let pos = LatLon::new(node.lat(), node.lon());
|
|
|
46
|
+ if update_func(pos) == ControlFlow::Break {
|
|
44
|
47
|
return;
|
|
45
|
48
|
}
|
|
46
|
49
|
break;
|
|
47
|
50
|
}
|
|
48
|
51
|
}
|
|
49
|
52
|
},
|
|
50
|
|
- Element::DenseNode(dnode) => {
|
|
51
|
|
- for (_key, val) in dnode.tags() {
|
|
|
53
|
+ Element::DenseNode(node) => {
|
|
|
54
|
+ for (_key, val) in node.tags() {
|
|
52
|
55
|
if re.is_match(val) {
|
|
53
|
|
- if update_func(dnode.lat(), dnode.lon()) == ControlFlow::Break {
|
|
|
56
|
+ let pos = LatLon::new(node.lat(), node.lon());
|
|
|
57
|
+ if update_func(pos) == ControlFlow::Break {
|
|
54
|
58
|
return;
|
|
55
|
59
|
}
|
|
56
|
60
|
break;
|