Loading isis/src/base/objs/ImagePolygon/ImagePolygon.cpp +25 −17 Original line number Diff line number Diff line Loading @@ -67,11 +67,14 @@ namespace Isis { p_polyStr = string(blob.getBuffer(), blob.Size()); geos::io::WKTReader *wkt = new geos::io::WKTReader(&(*globalFactory)); p_polygons = PolygonTools::MakeMultiPolygon(wkt->read(p_polyStr)); p_polygons = PolygonTools::MakeMultiPolygon(wkt->read(p_polyStr).release()); p_pts = new geos::geom::CoordinateArraySequence; for (auto poly : *p_polygons) { // for (auto poly : *p_polygons) { for(unsigned int g = 0; g < p_polygons->getNumGeometries(); ++g) { const geos::geom::Polygon *poly = dynamic_cast<const geos::geom::Polygon *>(p_polygons->getGeometryN(g)); geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(poly->getCoordinates())); for (size_t i = 0; i < coordArray.getSize(); i++) { p_pts->add(geos::geom::Coordinate(coordArray.getAt(i))); Loading Loading @@ -288,7 +291,7 @@ namespace Isis { std::vector<geos::geom::Geometry *> *polys = new std::vector<geos::geom::Geometry *>; geos::geom::Polygon *poly = globalFactory->createPolygon(globalFactory->createLinearRing(p_pts), nullptr); polys->push_back(poly->clone()); polys->push_back(poly->clone().release()); p_polygons = globalFactory->createMultiPolygon(polys); delete polys; Loading Loading @@ -798,7 +801,7 @@ namespace Isis { // Checks for self-intersection and attempts to correct geos::geom::CoordinateSequence *tempPts = new geos::geom::CoordinateArraySequence(); geos::geom::CoordinateArraySequence *tempPts = new geos::geom::CoordinateArraySequence(); // Gets the starting, second, second to last, and last points to check for validity tempPts->add(geos::geom::Coordinate((*p_pts)[0].x, (*p_pts)[0].y)); Loading @@ -812,7 +815,11 @@ namespace Isis { // Remove the last point of the sequence if it produces invalid polygons if (!tempPoly->isValid()) { p_pts->deleteAt(p_pts->size() - 2); std::vector<geos::geom::Coordinate> coords; p_pts->toVector(coords); coords.erase(coords.begin() + p_pts->size() - 2); p_pts->setPoints(coords); //p_pts->deleteAt(p_pts->size() - 2); } delete tempPts; Loading Loading @@ -985,7 +992,7 @@ namespace Isis { } // split image at the pole geos::geom::CoordinateSequence *new_points = new geos::geom::CoordinateArraySequence(); geos::geom::CoordinateArraySequence *new_points = new geos::geom::CoordinateArraySequence(); for (unsigned int i = 0; i < p_pts->size(); i++) { geos::geom::Coordinate temp = p_pts->getAt(i); new_points->add(temp); Loading Loading @@ -1142,7 +1149,7 @@ namespace Isis { bool convertLon = false; bool negAdjust = false; bool newCoords = false; // coordinates have been adjusted geos::geom::CoordinateSequence *newLonLatPts = new geos::geom::CoordinateArraySequence(); geos::geom::CoordinateArraySequence *newLonLatPts = new geos::geom::CoordinateArraySequence(); double lon, lat; double lonOffset = 0; double prevLon = p_pts->getAt(0).x; Loading Loading @@ -1205,8 +1212,8 @@ namespace Isis { geos::geom::Polygon *newPoly = globalFactory->createPolygon (globalFactory->createLinearRing(newLonLatPts), NULL); geos::geom::CoordinateSequence *pts = new geos::geom::CoordinateArraySequence(); geos::geom::CoordinateSequence *pts2 = new geos::geom::CoordinateArraySequence(); geos::geom::CoordinateArraySequence *pts = new geos::geom::CoordinateArraySequence(); geos::geom::CoordinateArraySequence *pts2 = new geos::geom::CoordinateArraySequence(); // Depending on direction of compensation bound accordingly //*************************************************** Loading Loading @@ -1276,14 +1283,14 @@ namespace Isis { geos::geom::Geometry *newGeom = NULL; for (unsigned int i = 0; i < convertPoly->getNumGeometries(); i++) { newGeom = (convertPoly->getGeometryN(i))->clone(); pts = convertPoly->getGeometryN(i)->getCoordinates(); geos::geom::CoordinateSequence *newLonLatPts = new geos::geom::CoordinateArraySequence(); newGeom = (convertPoly->getGeometryN(i))->clone().release(); geos::geom::CoordinateSequence *pts3 = convertPoly->getGeometryN(i)->getCoordinates().release(); geos::geom::CoordinateArraySequence *newLonLatPts = new geos::geom::CoordinateArraySequence(); // fix the points for (unsigned int k = 0; k < pts->getSize() ; k++) { double lon = pts->getAt(k).x; double lat = pts->getAt(k).y; for (unsigned int k = 0; k < pts3->getSize() ; k++) { double lon = pts3->getAt(k).x; double lat = pts3->getAt(k).y; if (negAdjust) { lon = lon + 360; } Loading @@ -1296,15 +1303,16 @@ namespace Isis { // Add the points to polys finalpolys->push_back(globalFactory->createPolygon (globalFactory->createLinearRing(newLonLatPts), NULL)); delete pts3; } // This loop is over polygons that will always be in 0-360 space no need to convert for (unsigned int i = 0; i < convertPoly2->getNumGeometries(); i++) { newGeom = (convertPoly2->getGeometryN(i))->clone(); newGeom = (convertPoly2->getGeometryN(i))->clone().release(); finalpolys->push_back(newGeom); } p_polygons = globalFactory->createMultiPolygon(*finalpolys); p_polygons = globalFactory->createMultiPolygon(finalpolys); delete finalpolys; delete newGeom; Loading isis/src/base/objs/ImagePolygon/ImagePolygon.h +1 −1 Original line number Diff line number Diff line Loading @@ -269,7 +269,7 @@ namespace Isis { Brick *p_brick; //!< Used to check for valid DNs geos::geom::CoordinateSequence *p_pts; //!< The sequence of coordinates that compose the boundry of the image geos::geom::CoordinateArraySequence *p_pts; //!< The sequence of coordinates that compose the boundary of the image geos::geom::MultiPolygon *p_polygons; //!< The multipolygon of the image Loading Loading
isis/src/base/objs/ImagePolygon/ImagePolygon.cpp +25 −17 Original line number Diff line number Diff line Loading @@ -67,11 +67,14 @@ namespace Isis { p_polyStr = string(blob.getBuffer(), blob.Size()); geos::io::WKTReader *wkt = new geos::io::WKTReader(&(*globalFactory)); p_polygons = PolygonTools::MakeMultiPolygon(wkt->read(p_polyStr)); p_polygons = PolygonTools::MakeMultiPolygon(wkt->read(p_polyStr).release()); p_pts = new geos::geom::CoordinateArraySequence; for (auto poly : *p_polygons) { // for (auto poly : *p_polygons) { for(unsigned int g = 0; g < p_polygons->getNumGeometries(); ++g) { const geos::geom::Polygon *poly = dynamic_cast<const geos::geom::Polygon *>(p_polygons->getGeometryN(g)); geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(poly->getCoordinates())); for (size_t i = 0; i < coordArray.getSize(); i++) { p_pts->add(geos::geom::Coordinate(coordArray.getAt(i))); Loading Loading @@ -288,7 +291,7 @@ namespace Isis { std::vector<geos::geom::Geometry *> *polys = new std::vector<geos::geom::Geometry *>; geos::geom::Polygon *poly = globalFactory->createPolygon(globalFactory->createLinearRing(p_pts), nullptr); polys->push_back(poly->clone()); polys->push_back(poly->clone().release()); p_polygons = globalFactory->createMultiPolygon(polys); delete polys; Loading Loading @@ -798,7 +801,7 @@ namespace Isis { // Checks for self-intersection and attempts to correct geos::geom::CoordinateSequence *tempPts = new geos::geom::CoordinateArraySequence(); geos::geom::CoordinateArraySequence *tempPts = new geos::geom::CoordinateArraySequence(); // Gets the starting, second, second to last, and last points to check for validity tempPts->add(geos::geom::Coordinate((*p_pts)[0].x, (*p_pts)[0].y)); Loading @@ -812,7 +815,11 @@ namespace Isis { // Remove the last point of the sequence if it produces invalid polygons if (!tempPoly->isValid()) { p_pts->deleteAt(p_pts->size() - 2); std::vector<geos::geom::Coordinate> coords; p_pts->toVector(coords); coords.erase(coords.begin() + p_pts->size() - 2); p_pts->setPoints(coords); //p_pts->deleteAt(p_pts->size() - 2); } delete tempPts; Loading Loading @@ -985,7 +992,7 @@ namespace Isis { } // split image at the pole geos::geom::CoordinateSequence *new_points = new geos::geom::CoordinateArraySequence(); geos::geom::CoordinateArraySequence *new_points = new geos::geom::CoordinateArraySequence(); for (unsigned int i = 0; i < p_pts->size(); i++) { geos::geom::Coordinate temp = p_pts->getAt(i); new_points->add(temp); Loading Loading @@ -1142,7 +1149,7 @@ namespace Isis { bool convertLon = false; bool negAdjust = false; bool newCoords = false; // coordinates have been adjusted geos::geom::CoordinateSequence *newLonLatPts = new geos::geom::CoordinateArraySequence(); geos::geom::CoordinateArraySequence *newLonLatPts = new geos::geom::CoordinateArraySequence(); double lon, lat; double lonOffset = 0; double prevLon = p_pts->getAt(0).x; Loading Loading @@ -1205,8 +1212,8 @@ namespace Isis { geos::geom::Polygon *newPoly = globalFactory->createPolygon (globalFactory->createLinearRing(newLonLatPts), NULL); geos::geom::CoordinateSequence *pts = new geos::geom::CoordinateArraySequence(); geos::geom::CoordinateSequence *pts2 = new geos::geom::CoordinateArraySequence(); geos::geom::CoordinateArraySequence *pts = new geos::geom::CoordinateArraySequence(); geos::geom::CoordinateArraySequence *pts2 = new geos::geom::CoordinateArraySequence(); // Depending on direction of compensation bound accordingly //*************************************************** Loading Loading @@ -1276,14 +1283,14 @@ namespace Isis { geos::geom::Geometry *newGeom = NULL; for (unsigned int i = 0; i < convertPoly->getNumGeometries(); i++) { newGeom = (convertPoly->getGeometryN(i))->clone(); pts = convertPoly->getGeometryN(i)->getCoordinates(); geos::geom::CoordinateSequence *newLonLatPts = new geos::geom::CoordinateArraySequence(); newGeom = (convertPoly->getGeometryN(i))->clone().release(); geos::geom::CoordinateSequence *pts3 = convertPoly->getGeometryN(i)->getCoordinates().release(); geos::geom::CoordinateArraySequence *newLonLatPts = new geos::geom::CoordinateArraySequence(); // fix the points for (unsigned int k = 0; k < pts->getSize() ; k++) { double lon = pts->getAt(k).x; double lat = pts->getAt(k).y; for (unsigned int k = 0; k < pts3->getSize() ; k++) { double lon = pts3->getAt(k).x; double lat = pts3->getAt(k).y; if (negAdjust) { lon = lon + 360; } Loading @@ -1296,15 +1303,16 @@ namespace Isis { // Add the points to polys finalpolys->push_back(globalFactory->createPolygon (globalFactory->createLinearRing(newLonLatPts), NULL)); delete pts3; } // This loop is over polygons that will always be in 0-360 space no need to convert for (unsigned int i = 0; i < convertPoly2->getNumGeometries(); i++) { newGeom = (convertPoly2->getGeometryN(i))->clone(); newGeom = (convertPoly2->getGeometryN(i))->clone().release(); finalpolys->push_back(newGeom); } p_polygons = globalFactory->createMultiPolygon(*finalpolys); p_polygons = globalFactory->createMultiPolygon(finalpolys); delete finalpolys; delete newGeom; Loading
isis/src/base/objs/ImagePolygon/ImagePolygon.h +1 −1 Original line number Diff line number Diff line Loading @@ -269,7 +269,7 @@ namespace Isis { Brick *p_brick; //!< Used to check for valid DNs geos::geom::CoordinateSequence *p_pts; //!< The sequence of coordinates that compose the boundry of the image geos::geom::CoordinateArraySequence *p_pts; //!< The sequence of coordinates that compose the boundary of the image geos::geom::MultiPolygon *p_polygons; //!< The multipolygon of the image Loading