Skip to content

Commit 6ca8333

Browse files
authored
Merge pull request #87 from antoine-de/split_crates
split the crate in 2 separate crates
2 parents d45f379 + e37e1ac commit 6ca8333

21 files changed

+607
-560
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*
22
!src/
3+
!cosmogony/
34
!tests/
45
!Cargo*
56
!build.rs

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generated by Cargo
22
# will have compiled files and executables
3-
/target/
3+
target/
44

55
# These are backup files generated by rustfmt
66
**/*.rs.bk

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ matrix:
88
- rustup component add rustfmt
99
script:
1010
- cargo fmt --all -- --check
11-
- cargo test
11+
- cargo test --all
1212
after_success:
1313
- |-
1414
[ "$TRAVIS_TAG" = v$(cargo run -- --version | awk '{print $2}') ] &&
15+
cd cosmogony &&
1516
cargo publish --token ${CRATESIO_TOKEN}
1617
env:
1718
global:

Cargo.lock

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
[package]
2-
name = "cosmogony"
3-
version = "0.5.3"
2+
name = "cosmogony_builder"
3+
version = "0.6.0"
44
authors = ["Adrien Matissart <[email protected]>", "Antoine Desbordes <[email protected]>"]
55
license = "Apache-2.0"
66
repository = "https://github.com/osm-without-borders/cosmogony"
7-
homepage = "http://cosmogony.world"
8-
keywords = ["osm", "boundary", "geography"]
9-
categories = ["science", "algorithms"]
10-
description = "Provides geographical zones with a structured hierarchy"
11-
readme = "README.md"
127
edition = "2018"
138

14-
15-
[badges]
16-
travis-ci = { repository = "osm-without-borders/cosmogony" }
17-
189
[dependencies]
10+
cosmogony = { path = "cosmogony" }
1911
log = "0.4"
2012
env_logger = "0.6"
2113
geo = "0.12"
2214
geo-types = { version = "0.4", features = ["rstar"] }
2315
structopt = "0.2"
2416
structopt-derive = "0.1"
2517
osmpbfreader = "0.13"
18+
lazy_static = "1"
2619
serde = {version = "1", features = ["rc"]}
2720
serde_derive = "1"
2821
serde_json = "1"
@@ -34,7 +27,6 @@ failure_derive = "0.1"
3427
osm_boundaries_utils = "0.4"
3528
geos = { version = "5.0", features= ["geo"] }
3629
regex = "1"
37-
lazy_static = "1"
3830
ordered-float = "0.0.2"
3931
flate2 = "1.0"
4032
rayon = "1.0"

cosmogony/Cargo.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[package]
2+
name = "cosmogony"
3+
version = "0.6.0"
4+
authors = ["Adrien Matissart <[email protected]>", "Antoine Desbordes <[email protected]>"]
5+
license = "Apache-2.0"
6+
repository = "https://github.com/osm-without-borders/cosmogony"
7+
homepage = "http://cosmogony.world"
8+
keywords = ["osm", "boundary", "geography"]
9+
categories = ["science", "algorithms"]
10+
description = "Provides geographical zones with a structured hierarchy"
11+
readme = "README.md"
12+
edition = "2018"
13+
14+
[badges]
15+
travis-ci = { repository = "osm-without-borders/cosmogony" }
16+
17+
[dependencies]
18+
log = "0.4"
19+
env_logger = "0.6"
20+
geo = "0.12"
21+
geo-types = { version = "0.4", features = ["rstar"] }
22+
serde = {version = "1", features = ["rc"]}
23+
serde_derive = "1"
24+
serde_json = "1"
25+
geojson = "0.15"
26+
failure = "0.1"
27+
failure_derive = "0.1"
28+
flate2 = "1.0"
29+
osmpbfreader = "0.13"

cosmogony/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Object model for [Cosmogony](https://github.com/osm-without-borders/cosmogony/)
2+
3+
Provides some (de)serializable objects representing the cosmogony hierarchy

src/file_format.rs renamed to cosmogony/src/file_format.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use failure::Error;
2+
use std::path::Path;
23

34
#[derive(PartialEq, Clone)]
45
pub enum OutputFormat {
@@ -8,29 +9,36 @@ pub enum OutputFormat {
89
JsonStreamGz,
910
}
1011

11-
static ALL_EXTENTIONS: [(&str, OutputFormat); 4] = [
12+
static ALL_EXTENSIONS: [(&str, OutputFormat); 4] = [
1213
(".json", OutputFormat::Json),
1314
(".jsonl", OutputFormat::JsonStream),
1415
(".json.gz", OutputFormat::JsonGz),
1516
(".jsonl.gz", OutputFormat::JsonStreamGz),
1617
];
1718

1819
impl OutputFormat {
19-
pub fn from_filename(filename: &str) -> Result<OutputFormat, Error> {
20-
ALL_EXTENTIONS
20+
pub fn from_filename(filename: impl AsRef<Path>) -> Result<OutputFormat, Error> {
21+
ALL_EXTENSIONS
2122
.iter()
22-
.find(|&&(ref e, _)| filename.ends_with(e))
23+
.find(|&&(ref e, _)| {
24+
filename
25+
.as_ref()
26+
.file_name()
27+
.and_then(|f| f.to_str())
28+
.map_or(false, |f| f.ends_with(e))
29+
})
2330
.map(|&(_, ref f)| f.clone())
2431
.ok_or_else(|| {
25-
let extensions_str = ALL_EXTENTIONS
32+
let extensions_str = ALL_EXTENSIONS
2633
.into_iter()
2734
.map(|(e, _)| *e)
2835
.collect::<Vec<_>>()
2936
.join(", ");
3037
failure::err_msg(format!(
3138
"Unable to detect the file format from filename '{}'. \
3239
Accepted extensions are: {}",
33-
filename, extensions_str
40+
filename.as_ref().display(),
41+
extensions_str
3442
))
3543
})
3644
}

cosmogony/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub mod file_format;
2+
mod model;
3+
pub mod mutable_slice;
4+
mod read;
5+
mod zone;
6+
7+
pub use model::{Cosmogony, CosmogonyMetadata, CosmogonyStats};
8+
pub use read::{load_cosmogony_from_file, read_zones_from_file};
9+
pub use zone::{Coord, Zone, ZoneIndex, ZoneType};
File renamed without changes.

0 commit comments

Comments
 (0)