-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Project bounding box #96
Labels
Comments
navispatial
added
enhancement
New feature or request
🌐 geobase
Related to the code package "geobase"
labels
Feb 20, 2022
Consider also bbox factory function: /// Creates a new bounding box from [minX], [minY], [maxX] and [maxY] values.
///
/// Optional [minZ] and [maxZ] for 3D boxes, and [minM] and [maxM] for
/// measured boxes can be provided too.
///
/// For projected or cartesian bounding boxes (`ProjBox`), coordinates axis are
/// applied as is.
///
/// For geographic bounding boxes (`GeoBox`), coordinates are applied as:
/// `minX` => `west`, `minY` => `south`, `minZ` => `minElev`, `minM` => `minM`,
/// `maxX` => `east`, `maxY` => `north`, `maxZ` => `maxElev`, `maxM` => `maxM`
typedef CreateBox<T extends Box> = T Function({
required num minX,
required num minY,
num? minZ,
num? minM,
required num maxX,
required num maxY,
num? maxZ,
num? maxM,
}); |
Implementatins on
/// A bounding box from parameters compatible with `CreateBox` function type.
const ProjBox.create({
required num minX,
required num minY,
num? minZ,
num? minM,
required num maxX,
required num maxY,
num? maxZ,
num? maxM,
}) : _minX = minX,
_minY = minY,
_minZ = minZ,
_minM = minM,
_maxX = maxX,
_maxY = maxY,
_maxZ = maxZ,
_maxM = maxM;
/// A bounding box from parameters compatible with `CreateBox` function type.
GeoBox.create({
required num minX,
required num minY,
num? minZ,
num? minM,
required num maxX,
required num maxY,
num? maxZ,
num? maxM,
}) : _west = minX.toDouble(),
_south = minY.toDouble(),
_minElev = minZ?.toDouble(),
_minM = minM?.toDouble(),
_east = maxX.toDouble(),
_north = maxY.toDouble(),
_maxElev = maxZ?.toDouble(),
_maxM = maxM?.toDouble(); |
navispatial
added a commit
that referenced
this issue
Mar 9, 2022
Implementation not quite as previously planned.
/// Projects this geographic bounding box to a projected box using
/// the forward [projection].
@override
ProjBox project(Projection projection) {
// get distinct corners (one, two or four) in 2D for the geographic bbox
final corners = corners2D;
// project all corner positions (using the forward projection)
final projected = corners.map((pos) => pos.project(projection));
// create a projected bbox
// (calculating min and max coords in all axes from corner positions)
return ProjBox.from(projected);
}
/// Projects this projected bounding box to a geographic box using
/// the inverse [projection].
@override
GeoBox project(Projection projection) {
// get distinct corners (one, two or four) in 2D for the projected bbox
final corners = corners2D;
// unproject all corner positions (using the inverse projection)
final unprojected = corners.map((pos) => pos.project(projection));
// create an unprojected (geographic) bbox
// (calculating min and max coords in all axes from corner positions)
return GeoBox.from(unprojected);
} NOT handling the special case of geographic coordinates when longitude west and east coordinates span anti-meridian, this might need a separate issue. |
Implemented in geobase 0.5.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add method like following to
Projection
mixin:Plan to calculate:
The text was updated successfully, but these errors were encountered: