Skip to content

Commit

Permalink
[tech] Upgrade PROJ dependency to 6.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
woshilapin committed Jan 23, 2020
1 parent 1767f86 commit cd1a7a5
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ addons:
- sourceline: "deb [arch=amd64] https://kisiodigital.jfrog.io/kisiodigital/debian-local stretch main"
key_url: "https://kisiodigital.jfrog.io/kisiodigital/api/gpg/key/public"
packages:
- proj=6.1.0
- proj=6.3.0
matrix:
include:
- rust: stable
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ log = "0.4"
minidom = "0.11"
num-traits = "0.2"
pretty_assertions = "0.6"
proj = { version = "0.10", optional = true }
proj = { version = "0.14", optional = true }
rust_decimal = "1.0"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ This repository also provides :
cargo build --release
```

### Compile for KV1
### Compile for KV1, NeTEx IDF and TransXChange
The KV1 format needs a additional dependency called [PROJ](https://proj.org/)
which allows the transformation of localization coordinates.
[crates.io](https://crates.io/) provides a
[`proj`](https://crates.io/crates/proj) crate which is a binding to the C
library (version 6.1.0). This means you need [PROJ](https://proj.org/) version
6.1.0 installed on your system. See [PROJ installation
library (version 6.3.0). This means you need [PROJ](https://proj.org/) version
6.3.0 installed on your system. See [PROJ installation
instructions](https://github.com/OSGeo/PROJ#installation).

[PROJ](https://proj.org/) is configured as a `feature` of the `transit_model`
Expand All @@ -34,7 +34,8 @@ apt install -y clang libssl-dev
cargo build --features=proj
```

Now, you should be able to use the converter `kv12ntfs`. Enjoy!
Now, you should be able to use the readers `kv1::read`, `netex_idf::read` and
`transxchange::read`. Enjoy!

### Using PROJ
If you want to use [PROJ](https://proj.org/) in your code, you can if you
Expand Down
4 changes: 1 addition & 3 deletions src/kv1/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,7 @@ where
for point in rdr.deserialize() {
let point: Point = point.with_context(ctx_from_path!(path))?;
if point.category == "SP" {
let coords = proj
.convert((point.lon, point.lat).into())
.map(Coord::from)?;
let coords = proj.convert((point.lon, point.lat)).map(Coord::from)?;
point_map.insert(point.code, coords);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/netex_idf/stops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use transit_model_collection::CollectionWithId;
fn load_stop_area(stop_place_elem: &Element, proj: &Proj) -> Result<StopArea> {
let id: String = stop_place_elem.try_attribute("id")?;
let coord: Coord = load_coords(stop_place_elem)
.and_then(|coords| proj.convert(coords.into()))
.and_then(|coords| proj.convert(coords).map_err(|e| format_err!("{}", e)))
.map(Coord::from)
.unwrap_or_else(|e| {
warn!("unable to parse coordinates of stop place {}: {}", id, e);
Expand Down Expand Up @@ -192,7 +192,7 @@ fn load_stop_points<'a>(
id: quay.try_attribute("id")?,
name: quay.try_only_child("Name")?.text().trim().to_string(),
visible: true,
coord: proj.convert(coords.into()).map(Coord::from)?,
coord: proj.convert(coords).map(Coord::from)?,
stop_area_id: "default_id".to_string(),
timezone: Some(EUROPE_PARIS_TIMEZONE.to_string()),
stop_type: StopType::Point,
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/kv12ntfs/output/stops.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
stop_id,stop_name,visible,fare_zone_id,stop_lon,stop_lat,location_type,parent_station,stop_timezone,geometry_id,equipment_id,level_id,platform_code
prefix:19480230,"Dedemsvaart, Adelaarweg",1,,6.457907070063898,52.59530085423737,0,prefix:20361,,,,,
prefix:19480250,"Dedemsvaart, Sportlaan",1,,6.452120474490927,52.59648534466884,0,prefix:20362,,,,,
prefix:19480290,"Dedemsvaart, Busstation",1,,6.449186190836316,52.59905516530855,0,prefix:20363,,,,,
prefix:19480290,"Dedemsvaart, Busstation",1,,6.449186190836316,52.59905516530854,0,prefix:20363,,,,,
prefix:17000040,"Hoogeveen, Station",1,,6.473556233092426,52.733020858848604,0,prefix:20570,,,,,
prefix:17003020,"Hoogeveen, Brinkstraat",1,,6.477214425648108,52.73127978317494,0,prefix:20717,,,,,
prefix:17001660,"Hoogeveen, Willemskade",1,,6.477303204010278,52.72949044898821,0,prefix:20718,,,,,
prefix:47552005,"Epe, Centrum",1,,5.985359746795904,52.35122872110869,0,prefix:31215,,,,,
prefix:47552021,"Epe, Lohuizerweg",1,,5.979506669211143,52.34927186607629,0,prefix:32705,,,,,
prefix:47552019,"Epe, Sint Jorisweg",1,,5.987248253645743,52.34652751382206,0,prefix:32704,,,,,
prefix:19380313,"Slagharen, Centrum",1,,6.558561770013159,52.6256017584982,0,prefix:20718,,,,,
prefix:19380313,"Slagharen, Centrum",1,,6.558561770013159,52.625601758498206,0,prefix:20718,,,,,
prefix:19380320,"Slagharen, Attractiepark",1,,6.563244354682038,52.62064811262386,0,prefix:20718,,,,,
prefix:20361,"Dedemsvaart, Adelaarweg",1,,6.457907070063898,52.59530085423737,1,,,,,,
prefix:20362,"Dedemsvaart, Sportlaan",1,,6.452120474490927,52.59648534466884,1,,,,,,
prefix:20363,"Dedemsvaart, Busstation",1,,6.449186190836316,52.59905516530855,1,,,,,,
prefix:20363,"Dedemsvaart, Busstation",1,,6.449186190836316,52.59905516530854,1,,,,,,
prefix:20570,"Hoogeveen, Station",1,,6.473556233092426,52.733020858848604,1,,,,,,
prefix:20717,"Hoogeveen, Brinkstraat",1,,6.477214425648108,52.73127978317494,1,,,,,,
prefix:20718,"Hoogeveen, Willemskade",1,,6.533036442901825,52.658580106703425,1,,,,,,
Expand Down
12 changes: 6 additions & 6 deletions tests/fixtures/netexidf2ntfs/output/stops.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
stop_id,stop_name,visible,fare_zone_id,stop_lon,stop_lat,location_type,parent_station,stop_timezone,geometry_id,equipment_id,level_id,platform_code
prefix:FR::Quay:50144192:FR1,MAISON DU CITOYEN,1,3,2.476489952100393,48.84657571536898,0,prefix:FR::multimodalStopPlace:stop_area_1:FR1,Europe/Paris,,,,
prefix:FR::Quay:with_zder_not_found:FR1,République,1,,2.3633222823037054,48.86766535188486,0,prefix:Navitia:FR::Quay:with_zder_not_found:FR1,Europe/Paris,,prefix:1,,
prefix:FR::Quay:50144192:FR1,MAISON DU CITOYEN,1,3,2.476489952100393,48.846575715368985,0,prefix:FR::multimodalStopPlace:stop_area_1:FR1,Europe/Paris,,,,
prefix:FR::Quay:with_zder_not_found:FR1,République,1,,2.3633222823037054,48.86766535188487,0,prefix:Navitia:FR::Quay:with_zder_not_found:FR1,Europe/Paris,,prefix:1,,
prefix:FR::Quay:50068421:FR1,Avenue de la Gare,1,,2.695967813434811,49.03392183291665,0,prefix:FR::monomodalStopPlace:sp_with_parent_not_found:FR1,Europe/Paris,,prefix:2,,
prefix:FR::Quay:50013706:FR1,Roger Genty,1,5,2.767274238725237,48.34061261273478,0,prefix:FR::multimodalStopPlace:stop_area_2:FR1,Europe/Paris,,prefix:4,,
prefix:Navitia:FR::Quay:50114580:FR1,BIBLIOTHEQUE NATIONALE,1,,2.337949003337833,48.8679593749302,1,,Europe/Paris,,,,
prefix:FR::Quay:with_zder_but_no_stopplace:FR1,DIDEROT,1,2,2.287023483401608,48.81879517331899,0,prefix:Navitia:FR::Quay:with_zder_but_no_stopplace:FR1,Europe/Paris,,prefix:3,,
prefix:FR::multimodalStopPlace:stop_area_1:FR1,Maison du citoyen,1,,2.476489952100393,48.84657571536898,1,,,,,,
prefix:FR::Quay:with_zder_but_no_stopplace:FR1,DIDEROT,1,2,2.287023483401608,48.818795173318996,0,prefix:Navitia:FR::Quay:with_zder_but_no_stopplace:FR1,Europe/Paris,,prefix:3,,
prefix:FR::multimodalStopPlace:stop_area_1:FR1,Maison du citoyen,1,,2.476489952100393,48.846575715368985,1,,,,,,
prefix:FR::multimodalStopPlace:stop_area_2:FR1,Roger Genty,1,,2.767274238725237,48.34061261273478,1,,,,,,
prefix:FR::monomodalStopPlace:sp_with_parent_not_found:FR1,Avenue de la Gare,1,,2.696063645783932,49.0339040919032,1,,,,,,
prefix:Navitia:FR::Quay:with_zder_not_found:FR1,République,1,,2.3633222823037054,48.86766535188486,1,,Europe/Paris,,,,
prefix:Navitia:FR::Quay:with_zder_but_no_stopplace:FR1,DIDEROT,1,,2.287023483401608,48.81879517331899,1,,Europe/Paris,,,,
prefix:Navitia:FR::Quay:with_zder_not_found:FR1,République,1,,2.3633222823037054,48.86766535188487,1,,Europe/Paris,,,,
prefix:Navitia:FR::Quay:with_zder_but_no_stopplace:FR1,DIDEROT,1,,2.287023483401608,48.818795173318996,1,,Europe/Paris,,,,
prefix:FR::Quay:50114580:FR1,BIBLIOTHEQUE NATIONALE,1,1,2.337949003337833,48.8679593749302,0,prefix:Navitia:FR::Quay:50114580:FR1,Europe/Paris,,prefix:3,,
4 changes: 2 additions & 2 deletions tests/fixtures/transxchange2ntfs/output/ntfs/stops.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
stop_id,stop_name,visible,fare_zone_id,stop_lon,stop_lat,location_type,parent_station,stop_timezone,geometry_id,equipment_id,level_id,platform_code
prefix:010G0006,Town Hall,1,,-2.5876177860791136,51.45583651828705,1,,,,,,
prefix:010G0006,Town Hall,1,,-2.5876177860791136,51.45583651828706,1,,,,,,
prefix:5340AWB30742,Town Hall,1,,-3.0390218087,51.7010920948,0,prefix:010G0006,,,,,Stand 1
prefix:5340AWB30747,Greenfield Place,1,,-3.0805995246,51.7704547813,0,prefix:Navitia:5340AWB30747,,,,,NW
prefix:5340AWB30904,Race Club,1,,-3.0458658158,51.6929120222,0,prefix:Navitia:5340AWB30904,,,,,opp
prefix:Navitia:5340AWB30747,Greenfield Place,1,,-3.0805995246,51.7704547813,1,,,,,,
prefix:Navitia:5340AWB30904,Race Club,1,,-3.0458658158,51.6929120222,1,,,,,,
prefix:Navitia:5340AWB30904,Race Club,1,,-3.0458658158,51.6929120222,1,,,,,,

0 comments on commit cd1a7a5

Please sign in to comment.