Skip to main content

Crate use_geography

Crate use_geography 

Source
Expand description

§use-geography

Facade crate for RustUse geography primitives.

use-geography reexports focused child crates for descriptive Earth-oriented vocabulary. It is not a GIS engine, mapping framework, geocoder, routing engine, map renderer, spatial database, projection engine, or address parser.

§Scope

  • thin facade over focused geography child crates
  • descriptive geographic coordinates, places, regions, boundaries, projections, spatial references, elevation, address components, and map scale
  • composition-friendly exports for downstream crates

§Non-goals

  • geodesic calculations
  • projection math
  • coordinate transformation
  • geocoding or reverse geocoding
  • address parsing or postal-service validation
  • routing or route planning
  • map rendering or tile behavior
  • network access or data fetching

§Example

use use_geography::{
	boundary, elevation, geo_coordinate, geographic_region, map_scale, place, projection,
	spatial_reference, Address, AddressCountryCode, AddressLine,
};

let latitude = geo_coordinate::Latitude::new(37.7749)?;
let longitude = geo_coordinate::Longitude::new(-122.4194)?;
let pair = geo_coordinate::CoordinatePair::new(latitude, longitude);
let coordinate = geo_coordinate::GeoCoordinate::from(pair);
let place_name = place::PlaceName::new("San Francisco")?;
let region_name = geographic_region::GeographicRegionName::new("Northern California")?;
let boundary_kind = boundary::BoundaryKind::Political;
let projection_kind = projection::ProjectionKind::WebMercator;
let epsg = spatial_reference::EpsgCode::new(4326)?;
let elevation = elevation::Elevation::new(16.0)?;
let scale = map_scale::MapScale::new(map_scale::ScaleRatio::new(25_000)?);
let address = Address::new().with_line(AddressLine::new("1 Rue de Rivoli")?);
let address = Address {
	country_code: Some(AddressCountryCode::new("fr")?),
	..address
};

assert_eq!(coordinate.latitude(), latitude);
assert_eq!(coordinate.longitude(), longitude);
assert_eq!(place_name.as_str(), "San Francisco");
assert_eq!(region_name.as_str(), "Northern California");
assert_eq!(boundary_kind.to_string(), "political");
assert_eq!(projection_kind.to_string(), "web-mercator");
assert_eq!(epsg.to_string(), "EPSG:4326");
assert_eq!(elevation.meters(), 16.0);
assert_eq!(scale.to_string(), "1:25000");
assert!(address.has_country());

Re-exports§

pub use use_boundary as boundary;
pub use use_elevation as elevation;
pub use use_geo_coordinate as geo_coordinate;
pub use use_geographic_region as geographic_region;
pub use use_map_scale as map_scale;
pub use use_place as place;
pub use use_projection as projection;
pub use use_spatial_reference as spatial_reference;

Structs§

Address
AddressCountryCode
AddressLine
AddressLine1
AddressLine2
AdministrativeArea
CountrySubdivision
Locality
PostalCode
StreetAddress
StreetName
StreetNumber
UnitDesignator
UnitNumber

Enums§

AddressComponentKind
AddressCountryCodeError
AddressError
AddressFormatHint
AddressKind
AddressLine1Error
AddressLine2Error
AddressLineError
AddressPrecision
AddressUsageKind
AddressValidationLevel
AdministrativeAreaError
CountrySubdivisionError
LocalityError
PostalCodeError
StreetNameError
StreetNumberError
UnitDesignatorError
UnitNumberError