-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
605 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
fn main() { | ||
#[cfg(feature = "gdal")] | ||
{ | ||
use std::str::FromStr; | ||
let gdal_version_string = std::env::var("DEP_GDAL_VERSION_NUMBER").unwrap(); | ||
let gdal_version = i64::from_str(&gdal_version_string) | ||
.expect("Could not convert gdal version string into number."); | ||
let major = gdal_version / 1000000; | ||
let minor = (gdal_version - major * 1000000) / 10000; | ||
let patch = (gdal_version - major * 1000000 - minor * 10000) / 100; | ||
|
||
if major != 3 { | ||
panic!("This crate requires a GDAL version = 3. Found {major}.{minor}.{patch}"); | ||
} | ||
if minor >= 5 { | ||
println!("cargo:rustc-cfg=gdal_has_int64"); | ||
println!("cargo:rustc-cfg=gdal_has_uint64"); | ||
} | ||
if minor >= 7 { | ||
println!("cargo:rustc-cfg=gdal_has_int8"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/// Two-dimensional bounds. | ||
#[derive(Debug, Clone, Copy, PartialEq)] | ||
pub struct Bounds { | ||
/// Minimum x value. | ||
pub xmin: f64, | ||
/// Minimum y value. | ||
pub ymin: f64, | ||
/// Maximum x value. | ||
pub xmax: f64, | ||
/// Maximum y value. | ||
pub ymax: f64, | ||
} | ||
|
||
impl Bounds { | ||
/// Creates a new bounds object. | ||
/// | ||
/// # Examples | ||
/// | ||
/// ``` | ||
/// use stac::Bounds; | ||
/// let bounds = Bounds::new(1., 2., 3., 4.); | ||
/// ``` | ||
pub fn new(xmin: f64, ymin: f64, xmax: f64, ymax: f64) -> Bounds { | ||
Bounds { | ||
xmin, | ||
ymin, | ||
xmax, | ||
ymax, | ||
} | ||
} | ||
|
||
/// Returns true if the minimum bound values are smaller than the maximum. | ||
/// | ||
/// This doesn't currently handle antimeridian-crossing bounds. | ||
/// | ||
/// # Examples | ||
/// | ||
/// ``` | ||
/// use stac::Bounds; | ||
/// let bounds = Bounds::default(); | ||
/// assert!(!bounds.is_valid()); | ||
/// let bounds = Bounds::new(1., 2., 3., 4.); | ||
/// assert!(bounds.is_valid()); | ||
/// ``` | ||
pub fn is_valid(&self) -> bool { | ||
self.xmin < self.xmax && self.ymin < self.ymax | ||
} | ||
|
||
/// Updates these bounds with another bounds' values. | ||
/// | ||
/// # Examples | ||
/// | ||
/// ``` | ||
/// use stac::Bounds; | ||
/// let mut bounds = Bounds::new(1., 1., 2., 2.); | ||
/// bounds.update(Bounds::new(0., 0., 1.5, 1.5)); | ||
/// assert_eq!(bounds, Bounds::new(0., 0., 2., 2.)); | ||
/// ``` | ||
pub fn update(&mut self, other: Bounds) { | ||
self.xmin = self.xmin.min(other.xmin); | ||
self.ymin = self.ymin.min(other.ymin); | ||
self.xmax = self.xmax.max(other.xmax); | ||
self.ymax = self.ymax.max(other.ymax); | ||
} | ||
} | ||
|
||
impl Default for Bounds { | ||
fn default() -> Self { | ||
Bounds { | ||
xmin: f64::MAX, | ||
ymin: f64::MAX, | ||
xmax: f64::MIN, | ||
ymax: f64::MIN, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.