Skip to main content

use_geography/
lib.rs

1#![forbid(unsafe_code)]
2#![doc = include_str!("../README.md")]
3
4pub use use_boundary as boundary;
5pub use use_elevation as elevation;
6pub use use_geo_coordinate as geo_coordinate;
7pub use use_geographic_region as geographic_region;
8pub use use_map_scale as map_scale;
9pub use use_place as place;
10pub use use_projection as projection;
11pub use use_spatial_reference as spatial_reference;
12
13#[cfg(test)]
14mod tests {
15    use super::{
16        boundary, elevation, geo_coordinate, geographic_region, map_scale, place, projection,
17        spatial_reference,
18    };
19
20    #[test]
21    fn facade_reexports_geography_primitives() -> Result<(), Box<dyn std::error::Error>> {
22        let latitude = geo_coordinate::Latitude::new(48.8566)?;
23        let longitude = geo_coordinate::Longitude::new(2.3522)?;
24        let pair = geo_coordinate::CoordinatePair::new(latitude, longitude);
25        let coordinate = geo_coordinate::GeoCoordinate::from(pair);
26        let place_name = place::PlaceName::new("Paris")?;
27        let region_name = geographic_region::GeographicRegionName::new("Ile-de-France")?;
28        let epsg = spatial_reference::EpsgCode::new(4326)?;
29        let height = elevation::Elevation::new(35.0)?;
30        let scale = map_scale::MapScale::new(map_scale::ScaleRatio::new(10_000)?);
31
32        assert_eq!(coordinate.latitude(), latitude);
33        assert_eq!(coordinate.longitude(), longitude);
34        assert_eq!(place_name.as_str(), "Paris");
35        assert_eq!(region_name.as_str(), "Ile-de-France");
36        assert_eq!(
37            boundary::BoundaryKind::Administrative.to_string(),
38            "administrative"
39        );
40        assert_eq!(projection::ProjectionKind::Mercator.to_string(), "mercator");
41        assert_eq!(epsg.to_string(), "EPSG:4326");
42        assert!((height.meters() - 35.0).abs() < f64::EPSILON);
43        assert_eq!(scale.to_string(), "1:10000");
44        Ok(())
45    }
46}