7#include "UniversalGroundMap.h"
12#include "CameraFactory.h"
13#include "ImagePolygon.h"
18#include "PolygonTools.h"
19#include "Projection.h"
20#include "RingPlaneProjection.h"
21#include "TProjection.h"
22#include "ProjectionFactory.h"
23#include "SurfacePoint.h"
36 p_priority = priority;
38 Pvl &pvl = *cube.
label();
42 catch (IException &e) {
52 catch (IException &e) {
60 QString msg =
"Could not create camera or projection for [" +
62 IException realError(IException::Unknown, msg, _FILEINFO_);
105 if (
p_camera->SetUniversalGround(lat, lon)) {
138 double universalLat = lat.
degrees();
139 double universalLon = lon.
degrees();
140 return p_projection->SetUniversalGround(universalLat, universalLon);
165 double universalLat = lat.
degrees();
166 double universalLon = lon.
degrees();
167 return p_projection->SetUnboundUniversalGround(universalLat, universalLon);
236 return p_camera->SetImage(sample, line);
250 return p_camera->UniversalLatitude();
273 return p_camera->UniversalLongitude();
297 return p_camera->LocalRadius().meters();
337 bool allowEstimation) {
341 if (
p_camera->target()->shape()->name() ==
"Plane")
return false;
355 poly.
Polys()->clone().release());
357 geos::geom::Geometry *envelope = footprint->getEnvelope().release();
358 geos::geom::CoordinateSequence *coords = envelope->getCoordinates().release();
360 for (
unsigned int i = 0; i < coords->getSize(); i++) {
361 const geos::geom::Coordinate &coord = coords->getAt(i);
366 if (!minLat.
isValid() || minLat > coordLat)
368 if (!maxLat.
isValid() || maxLat < coordLat)
371 if (!minLon.
isValid() || minLon > coordLon)
373 if (!maxLon.
isValid() || maxLon < coordLon)
387 catch (IException &) {
394 PvlGroup mappingGrp(
"Mapping");
395 mappingGrp += PvlKeyword(
"LatitudeType",
"Planetocentric");
396 mappingGrp += PvlKeyword(
"LongitudeDomain",
"360");
397 mappingGrp += PvlKeyword(
"LongitudeDirection",
"PositiveEast");
400 mappingPvl += mappingGrp;
406 minLatDouble, maxLatDouble,
407 minLonDouble, maxLonDouble, mappingPvl);
416 if (mappingGrp.hasKeyword(
"MinimumLatitude") &&
417 mappingGrp.hasKeyword(
"MaximumLatitude") &&
418 mappingGrp.hasKeyword(
"MinimumLongitude") &&
419 mappingGrp.hasKeyword(
"MaximumLongitude")) {
421 minLat =
Latitude(mappingGrp[
"MinimumLatitude"],
423 maxLat =
Latitude(mappingGrp[
"MaximumLatitude"],
425 minLon =
Longitude(mappingGrp[
"MinimumLongitude"],
427 maxLon =
Longitude(mappingGrp[
"MaximumLongitude"],
431 else if (allowEstimation && cube) {
461 int stepsPerLength = 20;
462 double aspectRatio = (double)lineCount / (
double)sampleCount;
463 double xStepSize = sampleCount / stepsPerLength;
464 double yStepSize = xStepSize * aspectRatio;
466 if (lineCount > sampleCount) {
467 aspectRatio = (double)sampleCount / (
double)lineCount;
468 yStepSize = lineCount / stepsPerLength;
469 xStepSize = yStepSize * aspectRatio;
472 double yWalked = 0.5;
475 for (
int i = 0; i < 3; i++) {
476 double xValue = 0.5 + ( i * (sampleCount / 2) );
478 while (yWalked <= lineCount) {
479 imagePoints.append( QPointF(xValue, yWalked) );
480 yWalked += yStepSize;
486 double xWalked = 0.5;
489 for (
int i = 0; i < 3; i++) {
490 double yValue = 0.5 + ( i * (lineCount / 2) );
492 while (xWalked <= sampleCount) {
493 imagePoints.append( QPointF(xWalked, yValue) );
494 xWalked += xStepSize;
500 double xDiagonalWalked = 0.5;
501 double yDiagonalWalked = 0.5;
502 xStepSize = sampleCount / stepsPerLength;
503 yStepSize = lineCount / stepsPerLength;
506 while ( (xDiagonalWalked <= sampleCount) && (yDiagonalWalked <= lineCount) ) {
507 imagePoints.append( QPointF(xDiagonalWalked, yDiagonalWalked) );
508 xDiagonalWalked += xStepSize;
509 yDiagonalWalked += yStepSize;
512 xDiagonalWalked = 0.5;
515 while ( (xDiagonalWalked <= sampleCount) && (yDiagonalWalked >= 0) ) {
516 imagePoints.append( QPointF(xDiagonalWalked, yDiagonalWalked) );
517 xDiagonalWalked += xStepSize;
518 yDiagonalWalked -= yStepSize;
521 foreach (QPointF imagePoint, imagePoints) {
522 if (tproj->
SetWorld(imagePoint.x(), imagePoint.y())) {
528 minLat = qMin(minLat, latResult);
533 maxLat = qMax(maxLat, latResult);
538 minLon = qMin(minLon, lonResult);
543 maxLon = qMax(maxLon, lonResult);
554 minLat < maxLat && minLon < maxLon);
557 void UniversalGroundMap::setPriority(
int priority) {
559 p_priority = (CameraPriority) priority;
562 p_priority = (CameraPriority) priority;
bool isValid() const
This indicates whether we have a legitimate angle stored or are in an unset, or invalid,...
double degrees() const
Get the angle in units of Degrees.
@ Degrees
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
static Camera * Create(Cube &cube)
Creates a Camera object using Pvl Specifications.
IO Handler for Isis Cubes.
ImagePolygon readFootprint() const
Read the footprint polygon for the Cube.
virtual QString fileName() const
Returns the opened cube's filename.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Create cube polygons, read/write polygons to blobs.
geos::geom::MultiPolygon * Polys()
Return a geos Multipolygon.
This class is designed to encapsulate the concept of a Latitude.
This class is designed to encapsulate the concept of a Longitude.
static Isis::Projection * CreateFromCube(Isis::Cube &cube)
This method is a helper method.
ProjectionType
This enum defines the subclasses of Projection supported in Isis.
@ Triaxial
These projections are used to map triaxial and irregular-shaped bodies.
@ RingPlane
These projections are used to map ring planes.
virtual bool SetWorld(const double x, const double y)
This method is used to set a world coordinate.
Base class for Map Projections of plane shapes.
double RingRadius() const
This returns a radius.
double RingLongitude() const
This returns a ring longitude with correct ring longitude direction and domain as specified in the la...
This class defines a body-fixed surface point.
Latitude GetLatitude() const
Return the body-fixed latitude for the surface point.
Longitude GetLongitude() const
Return the body-fixed longitude for the surface point.
Base class for Map TProjections.
virtual double UniversalLongitude()
This returns a universal longitude (positive east in 0 to 360 domain).
virtual double UniversalLatitude()
This returns a universal latitude (planetocentric).
Isis::Projection * p_projection
The projection (if the image is projected)
double Sample() const
Returns the current line value of the camera model or projection.
double UniversalLongitude() const
Returns the universal longitude of the camera model or projection.
bool SetImage(double sample, double line)
Returns whether the sample/line postion was set successfully in the camera model or projection.
double Resolution() const
Returns the resolution of the camera model or projection.
~UniversalGroundMap()
Destroys the UniversalGroundMap object.
void SetBand(const int band)
Set the image band number.
Isis::Camera * p_camera
The camera (if the image has a camera)
double UniversalLatitude() const
Returns the universal latitude of the camera model or projection.
bool SetUnboundGround(Latitude lat, Longitude lon)
Returns whether the lat/lon position was set successfully in the camera model or projection.
double Line() const
Returns the current line value of the camera model or projection.
bool HasProjection()
Returns whether the ground map has a projection or not.
CameraPriority
This enum is used to define whether to use a camera or projection primarily, and which to fall back o...
@ ProjectionFirst
Use the projection for functionality well outside the original image if available,...
@ CameraFirst
This is the default because cameras are projection-aware.
double LocalRadius() const
Returns the radius of the camera model or projection.
bool HasCamera()
Returns whether the ground map has a camera or not.
UniversalGroundMap(Cube &cube, CameraPriority priority=CameraFirst)
Constructs a UniversalGroundMap object from a cube.
bool SetUniversalGround(double lat, double lon)
Returns whether the lat/lon position was set successfully in the camera model or projection.
bool SetGround(Latitude lat, Longitude lon)
Returns whether the lat/lon position was set successfully in the camera model or projection.
bool GroundRange(Cube *cube, Latitude &minLat, Latitude &maxLat, Longitude &minLon, Longitude &maxLon, bool allowEstimation=true)
Find the lat/lon range of the image.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.