13 #include <QScopedPointer>
15 #include <geos/geom/CoordinateArraySequence.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"
33 PixelFOV::PixelFOV() {
41 PixelFOV::~PixelFOV() {
70 const int numIfovs)
const {
82 QString msg =
"The number of instantaneous field of views must be a positive integer.";
83 throw IException(IException::Programmer, msg, _FILEINFO_);
90 boundaryVertices.append(instantaneousFov(camera));
91 return boundaryVertices;
98 double timeStep = 0.0;
103 throw IException(e, IException::Unknown,
"Unable to get FOV for full exposure.", _FILEINFO_);
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) {
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;
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::CoordinateArraySequence());
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());
246 geos::geom::CoordinateSequence *boundingPoints = boundingHull->getCoordinates();
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;
273 QScopedPointer<geos::geom::CoordinateSequence> pts(
new geos::geom::CoordinateArraySequence());
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.take()),
283 QScopedPointer<geos::geom::MultiPolygon> splitPolygons(
284 PolygonTools::SplitPolygonOn360(originalPoly.data()));
288 for (
unsigned int i = 0; i < splitPolygons->getNumGeometries(); i++) {
292 const geos::geom::Polygon *subPolygon =
293 dynamic_cast<const geos::geom::Polygon *
>(splitPolygons->getGeometryN(i));
294 geos::geom::CoordinateSequence *subCoordinates = subPolygon->
295 getExteriorRing()->getCoordinates();
296 for (
unsigned int j = 0; j < subCoordinates->getSize(); j++) {
297 subVertices.append(QPointF(subCoordinates->getAt(j).y,subCoordinates->getAt(j).x));
301 splitPoints.append(subVertices);