13#include <QScopedPointer>
15#include <geos/geom/CoordinateSequence.h>
16#include <geos/geom/CoordinateSequence.h>
17#include <geos/geom/LineString.h>
18#include <geos/geom/MultiPolygon.h>
19#include <geos/geom/Polygon.h>
22#include "CameraDistortionMap.h"
23#include "PolygonTools.h"
70 const int numIfovs)
const {
73 QList< QList<QPointF> > boundaryVertices;
77 QList<QPointF> lowerVertices;
78 QList<QPointF> upperVertices;
82 QString msg =
"The number of instantaneous field of views must be a positive integer.";
91 return boundaryVertices;
98 double timeStep = 0.0;
105 for (
int i = 0; i < numIfovs; i++) {
111 if (iFov.isEmpty()) {
116 bool crosses =
false;
117 int numVerts = iFov.size();
118 for (
int j = 0; j < numVerts - 1; j++) {
119 if (fabs(iFov[j].y() - iFov[j+1].y()) > 180.0) {
126 QList< QList<QPointF> > splitIFov =
splitIfov(iFov);
129 for (
int j = 0; j < splitIFov.size(); j++) {
130 double averageLong = 0;
131 int numSubVerts = splitIFov[j].size();
132 for (
int k = 0; k < numSubVerts; k++) {
133 averageLong += splitIFov[j][k].y();
135 averageLong = averageLong / numSubVerts;
136 if (averageLong < 180) {
137 lowerVertices.append(splitIFov[j]);
140 upperVertices.append(splitIFov[j]);
148 double averageLong = 0;
149 for (
int j = 0; j < numVerts; j++) {
150 averageLong += iFov[j].y();
152 averageLong = averageLong / numVerts;
153 if (averageLong < 180) {
154 lowerVertices.append(iFov);
157 upperVertices.append(iFov);
165 if (!lowerVertices.isEmpty()) {
166 boundaryVertices.append(
envelope(lowerVertices));
168 if (!upperVertices.isEmpty()) {
169 boundaryVertices.append(
envelope(upperVertices));
172 return boundaryVertices;
190 QList<QPointF> vertices;
193 int numVertices = offsets.size();
197 double unitNewLook[3];
204 double scale = focalLength / saveLook[2];
205 for (
int i = 0; i < numVertices; i++) {
206 double focalPlaneX = saveLook[0] * scale;
207 double focalPlaneY = saveLook[1] * scale;
208 focalPlaneX += offsets[i].x();
209 focalPlaneY += offsets[i].y();
210 newLook[0] = focalPlaneX;
211 newLook[1] = focalPlaneY;
213 vhat_c(newLook, unitNewLook);
234 QScopedPointer<geos::geom::CoordinateSequence> points(
new geos::geom::CoordinateSequence());
236 for (
int i = 0; i < vertices.size(); i++) {
237 points->add(geos::geom::Coordinate(vertices[i].x(), vertices[i].y()));
239 QScopedPointer<geos::geom::LineString> pointString(Isis::globalFactory->createLineString(
243 QScopedPointer<geos::geom::Geometry> boundingHull(pointString->convexHull().release());
246 geos::geom::CoordinateSequence *boundingPoints = boundingHull->getCoordinates().release();
248 QList<QPointF> boundingVertices;
249 for (
unsigned int i = 0; i < boundingPoints->getSize(); i++) {
250 boundingVertices.append(QPointF(boundingPoints->getAt(i).x,boundingPoints->getAt(i).y));
253 return boundingVertices;
270 QList< QList<QPointF> > splitPoints;
273 QScopedPointer<geos::geom::CoordinateSequence> pts(
new geos::geom::CoordinateSequence());
274 for (
int i = 0; i < vertices.size(); i++) {
275 pts->add(geos::geom::Coordinate(vertices[i].y(), vertices[i].x()));
277 pts->add(geos::geom::Coordinate(vertices[0].y(), vertices[0].x()));
278 QScopedPointer<geos::geom::Polygon> originalPoly(Isis::globalFactory->createPolygon(
279 globalFactory->createLinearRing(*pts)).release());
282 QScopedPointer<geos::geom::MultiPolygon> splitPolygons(
286 QList< QList<QPointF> > splitVertices;
287 for (
unsigned int i = 0; i < splitPolygons->getNumGeometries(); i++) {
288 QList<QPointF> subVertices;
291 const geos::geom::Polygon *subPolygon =
292 dynamic_cast<const geos::geom::Polygon *
>(splitPolygons->getGeometryN(i));
293 geos::geom::CoordinateSequence *subCoordinates = subPolygon->getExteriorRing()->getCoordinates().release();
294 for (
unsigned int j = 0; j < subCoordinates->getSize(); j++) {
295 subVertices.append(QPointF(subCoordinates->getAt(j).y,subCoordinates->getAt(j).x));
299 splitPoints.append(subVertices);
double UndistortedFocalPlaneZ() const
Gets the z-value in the undistorted focal plane coordinate system.
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
virtual bool SetImage(const double sample, const double line)
Sets the sample/line values of the image to get the lat/lon values.
double FocalLength() const
Returns the focal length.
CameraDistortionMap * DistortionMap()
Returns a pointer to the CameraDistortionMap object.
virtual QList< QPointF > PixelIfovOffsets()
Returns the pixel ifov offsets from center of pixel, which defaults to the (pixel pitch * summing mod...
@ Unknown
A type of error that cannot be classified as any of the other error types.
@ Programmer
This error is for when a programmer made an API call that was illegal.
~PixelFOV()
Destroys a PixelFOV object/.
QList< QPointF > instantaneousFov(Camera &camera) const
Compute the instantaneous fov for the pixel and time that the input camera is set to.
QList< QList< QPointF > > splitIfov(QList< QPointF > vertices) const
Split an instantaneous field of view across the 360/0 boundary.
QList< QList< QPointF > > latLonVertices(Camera &camera, const double sample, const double line, const int numIfovs=1) const
Produces an fov for the given line sample.
PixelFOV()
Constructs an empty PixelFOV object.
QList< QPointF > envelope(QList< QPointF > vertices) const
Produces a list of boundary points for the convex hull containing the input vertices.
virtual double UniversalLatitude() const
Returns the planetocentric latitude, in degrees, at the surface intersection point in the body fixed ...
virtual double UniversalLongitude() const
Returns the positive east, 0-360 domain longitude, in degrees, at the surface intersection point in t...
void LookDirection(double v[3]) const
Returns the look direction in the camera coordinate system.
bool SetLookDirection(const double v[3])
Sets the look direction of the spacecraft.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.