From 0fbd95ba9654e767aaf22404dde79596549856ba Mon Sep 17 00:00:00 2001 From: Andreas Date: Tue, 3 May 2022 21:06:19 +0200 Subject: [PATCH] dependency version bump may 2022 (#29) --- Cargo.lock | 257 ++++++++++++++++++++++++++++++++++++++++------ Cargo.toml | 11 +- src/converter.rs | 16 ++- src/osm_reader.rs | 19 ++-- 4 files changed, 258 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f56a62..eb7556c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,6 +34,21 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "bit-set" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bitflags" version = "1.2.1" @@ -76,11 +91,20 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "fastrand" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +dependencies = [ + "instant", +] + [[package]] name = "flat_map" -version = "0.0.9" +version = "0.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbb562ef75bc322a6d4b5860794457438b89079f23471fb2ba876c2f39b24e5" +checksum = "e4fa2a56a33c493fc81acbad4676c599cf2b128f21462a020043ea1eee46244f" dependencies = [ "serde", "serde_derive", @@ -98,6 +122,12 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "futures" version = "0.1.31" @@ -116,25 +146,37 @@ dependencies = [ [[package]] name = "geo-types" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8bd2e95dd9f5c8ff74159ed9205ad7fd239a9569173a550863976421b45d2bb" +checksum = "a9537881a3d2941ff3fe901e744c45f0fa4c142334f499f27d26be1d72299ba8" dependencies = [ "num-traits", ] [[package]] name = "geojson" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c209e446d28d9142fb23127808bef2a1485924e7b42cd8c9407ea7cbfe09ccc" +checksum = "72d90a7b840bb94d82b66d15bc5f28bc6f9ac017a32a72610a26dc98314ebf5d" dependencies = [ "geo-types", "serde", + "serde_derive", "serde_json", "thiserror", ] +[[package]] +name = "getrandom" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "hermit-abi" version = "0.1.18" @@ -144,11 +186,26 @@ dependencies = [ "libc", ] +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + [[package]] name = "itoa" -version = "0.4.7" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" + +[[package]] +name = "lazy_static" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" @@ -187,7 +244,7 @@ dependencies = [ [[package]] name = "osm_extract_polygon" -version = "0.3.3" +version = "0.4.0" dependencies = [ "clap", "geo-types", @@ -195,13 +252,14 @@ dependencies = [ "osmpbfreader", "protobuf-codegen-pure", "serde_json", + "smartstring", ] [[package]] name = "osmpbfreader" -version = "0.13.4" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3562dde01d2f01e5315d270a1be25ec09eaf71de4d9b14e7be3caef217d8826" +checksum = "b322df744f061ec02182f59e3e4c8b429c54ad39acbdca8da271aba951ef8539" dependencies = [ "byteorder", "flat_map", @@ -210,9 +268,9 @@ dependencies = [ "protobuf", "protobuf-codegen-pure", "pub-iterator-type", - "rental", + "self_cell", "serde", - "serde_derive", + "smartstring", ] [[package]] @@ -227,6 +285,12 @@ dependencies = [ "pub-iterator-type", ] +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + [[package]] name = "proc-macro2" version = "1.0.24" @@ -236,6 +300,26 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "proptest" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0d9cc07f18492d879586c92b485def06bc850da3118075cd45d50e9c95b0e5" +dependencies = [ + "bit-set", + "bitflags", + "byteorder", + "lazy_static", + "num-traits", + "quick-error 2.0.1", + "rand", + "rand_chacha", + "rand_xorshift", + "regex-syntax", + "rusty-fork", + "tempfile", +] + [[package]] name = "protobuf" version = "2.22.1" @@ -267,6 +351,18 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "858afdbecdce657c6e32031348cf7326da7700c869c368a136d31565972f7018" +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + [[package]] name = "quote" version = "1.0.9" @@ -277,24 +373,78 @@ dependencies = [ ] [[package]] -name = "rental" -version = "0.5.5" +name = "rand" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8545debe98b2b139fb04cad8618b530e9b07c152d99a5de83c860b877d67847f" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "rental-impl", - "stable_deref_trait", + "libc", + "rand_chacha", + "rand_core", ] [[package]] -name = "rental-impl" -version = "0.5.5" +name = "rand_chacha" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475e68978dc5b743f2f40d8e0a8fdc83f1c5e78cbf4b8fa5e74e73beebc340de" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ - "proc-macro2", - "quote", - "syn", + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core", +] + +[[package]] +name = "redox_syscall" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "rusty-fork" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" +dependencies = [ + "fnv", + "quick-error 1.2.3", + "tempfile", + "wait-timeout", ] [[package]] @@ -303,11 +453,20 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +[[package]] +name = "self_cell" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ef965a420fe14fdac7dd018862966a4c14094f900e1650bbc71ddd7d580c8af" + [[package]] name = "serde" version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +dependencies = [ + "serde_derive", +] [[package]] name = "serde_derive" @@ -322,9 +481,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "f972498cf015f7c0746cac89ebe1d6ef10c293b94175a243a2d9442c163d9944" dependencies = [ "itoa", "ryu", @@ -332,10 +491,21 @@ dependencies = [ ] [[package]] -name = "stable_deref_trait" -version = "1.2.0" +name = "smartstring" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "e714dff2b33f2321fdcd475b71cec79781a692d846f37f415fb395a1d2bcd48e" +dependencies = [ + "proptest", + "serde", + "static_assertions", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strsim" @@ -354,6 +524,20 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -401,6 +585,21 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 9794d69..e3ac277 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,17 @@ [package] name = "osm_extract_polygon" -version = "0.3.3" +version = "0.4.0" authors = ["Andreas "] edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] clap = "2.33.3" -geojson = { version = "0.22.0", features=["geo-types"] } -geo-types = "0.7.0" -osmpbfreader = "0.13.4" -serde_json = "1.0" +geojson = { version = "0.22.3", features=["geo-types"] } +geo-types = "0.7.4" +osmpbfreader = "0.15.1" +serde_json = "1.0.80" +smartstring = { version = "*", features = ["proptest", "serde"] } [build-dependencies] protobuf-codegen-pure = "2" diff --git a/src/converter.rs b/src/converter.rs index 07ea65c..17f0b9d 100644 --- a/src/converter.rs +++ b/src/converter.rs @@ -109,14 +109,24 @@ fn find_match(node_id: NodeId, nodes: &mut Vec>) -> Option> fn convert_to_poly(rn: RelationNodes) -> Polygon { let points = rn.nodes.iter().map(|x| convert_nodes_to_points(x)).collect(); - let name: String = rn + let unknown_name = String::from("UNKNOWN_NAME"); + let empty_string = String::from(""); + + let name = rn .relation .tags .get("name") - .unwrap_or(&"UNKNOWN_NAME".to_string()) + .map(|x| x.to_string()) + .unwrap_or(unknown_name) .clone(); - let name_prefix = rn.relation.tags.get("name:prefix").unwrap_or(&"".to_string()).clone(); + let name_prefix = rn + .relation + .tags + .get("name:prefix") + .map(|x| x.to_string()) + .unwrap_or(empty_string) + .clone(); let fullname = if rn.relation.tags.contains_key("name:prefix") { format!("{}_{}", name_prefix, name) diff --git a/src/osm_reader.rs b/src/osm_reader.rs index 7b598b0..3bc7db0 100644 --- a/src/osm_reader.rs +++ b/src/osm_reader.rs @@ -1,8 +1,11 @@ -use osmpbfreader::{Node, NodeId, OsmPbfReader, Relation, RelationId, WayId}; +use osmpbfreader::{Node, NodeId, OsmPbfReader, Relation, RelationId, WayId, Tags}; use std::collections::{HashMap, HashSet}; use std::i8::MAX; use std::time::Instant; +use std::iter::FromIterator; + +use smartstring::alias::String; use crate::utils::hashmap_values_to_set; @@ -165,21 +168,21 @@ mod tests { #[test] fn test_admin_level_too_high_is_not_valid() { let max_admin_level = 8; - let relation = create_relation(vec![("admin_level".to_string(), (max_admin_level + 1).to_string())]); + let relation = create_relation(vec![(String::from("admin_level"), String::from((max_admin_level + 1).to_string()))]); assert_eq!(has_proper_admin_level(&relation, &1, &max_admin_level), false); } #[test] fn test_admin_level_is_max_level_is_valid() { let max_admin_level = 8; - let relation = create_relation(vec![("admin_level".to_string(), (max_admin_level).to_string())]); + let relation = create_relation(vec![(String::from("admin_level"), String::from((max_admin_level).to_string()))]); assert_eq!(has_proper_admin_level(&relation, &1, &max_admin_level), true); } #[test] fn test_min_admin_level_filters_out() { let min_admin_level = 1; - let relation = create_relation(vec![("admin_level".to_string(), "0".to_string())]); + let relation = create_relation(vec![(String::from("admin_level"), String::from((0).to_string()))]); assert_eq!(has_proper_admin_level(&relation, &min_admin_level, &8), false); } @@ -188,9 +191,9 @@ mod tests { let min_admin_level = 3; let max_admin_level = min_admin_level; - let relation_too_little = create_relation(vec![("admin_level".to_string(), (min_admin_level - 1).to_string())]); - let relation_exact = create_relation(vec![("admin_level".to_string(), min_admin_level.to_string())]); - let relation_too_big = create_relation(vec![("admin_level".to_string(), (max_admin_level + 1).to_string())]); + let relation_too_little = create_relation(vec![(String::from("admin_level"), String::from((min_admin_level - 1).to_string()))]); + let relation_exact = create_relation(vec![(String::from("admin_level"), String::from((min_admin_level).to_string()))]); + let relation_too_big = create_relation(vec![(String::from("admin_level"), String::from((min_admin_level + 1).to_string()))]); assert_eq!( has_proper_admin_level(&relation_too_little, &min_admin_level, &max_admin_level), @@ -209,7 +212,7 @@ mod tests { fn create_relation(tags_pairs: Vec<(String, String)>) -> Relation { Relation { id: RelationId(123), - tags: tags_pairs.into_iter().collect(), + tags: Tags::from_iter(tags_pairs), refs: Vec::new(), } }