diff --git a/.gitignore b/.gitignore index bd66d1c994afc44f16b519d9161e08a51def39d1..62b553e5653b51f2b40fe177b5d1510001cd3e72 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ print.prt */tsts/*/output/* */build/ build/ +*build*/ install/ # Unignore the documentation build diff --git a/environment.yml b/environment.yml index ed8af18403f35ffed95d4404c409868ca2e02034..a1828c037ebf3bfd50fa1e8d835a8f53c2bd678b 100644 --- a/environment.yml +++ b/environment.yml @@ -3,40 +3,41 @@ channels: - defaults dependencies: - - kalasiris - - ale=0.9.1 + - ale>=0.9.1, <1 - armadillo - - boost=1.72 - - boost-cpp=1.72 + - boost>=1.72.0, <2 + - boost-cpp>=1.72.0, <2 - blas - usgs-astrogeology::bullet - bz2file - bzip2 - - cmake >=3.15 + - cmake >=3.15, <4 - cspice=67 - csm>=3.0.3,<3.0.4 - - curl - - cxx-compiler=1.1.2 + - curl>=8.3.0,<9.0a0 + - cxx-compiler>=1.1.2 - doxygen - - eigen < 3.4 - - embree>=2.17,<3 + - eigen>=3, <4 + - embree>=3, <4 - ffmpeg - - geos =3.11.1 + - geos>=3.12.1, <4 - geotiff - gmp - graphviz - gsl>=2.6 - - hdf5 + - hdf5>=1.14.2,<1.14.3.0a0 - icu - inja - jama - - jpeg - usgs-astrogeology::kakadu==1 + - kalasiris - krb5 - - libopencv>=4.5.2 - - libpng>=1.6.34 - - libprotobuf<3.20 - - libtiff>=4.0 + - libboost>=1.72.0, <2 + - libgdal >=3.7.2,<3.8.0a0 + - libopencv>=4.5.2, <5 + - libpng>=1.6.34, <2 + - libprotobuf + - libtiff>=4.0, <5 - libxml2 - make - mesalib @@ -44,20 +45,21 @@ dependencies: - mysql-connector-c - nanoflann<1.4 - nlohmann_json - - ninja==1.7.2 + - ninja>=1.7.2, <2 - nn - - opencv>=4.5.2 - - openssl>=1.1.1k - - pcl >= 1.10.0 + - opencv>=4.5.2, <5 + - openssl>=3.1.2,<4.0a0 + - pcl >=1.10, <2 - plio - - protobuf<3.20 - - python>=3.7.11 + - protobuf + - python=3.12 + - python_abi=3.12 - pytest - - rclone - qhull - - qt>=5.9.6,<5.15.0 + - qt-main - qwt - - sqlite + - rclone + - sqlite>=3.43.0,<4.0a0 - suitesparse - superlu - swig @@ -65,10 +67,10 @@ dependencies: - tnt - x264 - xalan-c - - xerces-c=3 + - xerces-c>=3.2.4,<3.3.0a0 - xorg-kbproto - xorg-libice - xorg-libsm - xorg-libx11 - xorg-libxi - - zlib + - zlib>=1.2.13,<1.3.0a0 diff --git a/gtest b/gtest index 703bd9caab50b139428cea1aaff9974ebee5742e..b10fad38c4026a29ea6561ab15fc4818170d1c10 160000 --- a/gtest +++ b/gtest @@ -1 +1 @@ -Subproject commit 703bd9caab50b139428cea1aaff9974ebee5742e +Subproject commit b10fad38c4026a29ea6561ab15fc4818170d1c10 diff --git a/isis/CMakeLists.txt b/isis/CMakeLists.txt index 0bb2e59308ae1ad1ca03d8dc5c1a34768cd62358..6c22a5a16cb83a66df9e871a9a9a68891da7732d 100644 --- a/isis/CMakeLists.txt +++ b/isis/CMakeLists.txt @@ -161,7 +161,7 @@ endif() # sometimes third parties do not set their rpaths correctly set(thirdPartyCppFlags -Wall -fPIC - -std=c++14 + -std=c++17 -DISIS_LITTLE_ENDIAN=1 -Wno-unused-parameter -Wno-overloaded-virtual @@ -171,7 +171,7 @@ set(thirdPartyCppFlags -Wall -DENABLEJP2K=${JP2KFLAG} ) -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) # Append CPP flags set in the third party lib file to the string set in this file. string(REPLACE ";" " " FLAGS_STR "${thirdPartyCppFlags}") @@ -183,8 +183,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS_STR}" ) # Add gold linker (and therefore, phtread) to speed up linux (spec. Ubuntu18.04) builds if(NOT APPLE) set(thirdPartyCppFlags ${thirdPartyCppFlags} -fuse-ld=gold - -pthread - -fext-numeric-literals + -pthread + -fext-numeric-literals -Wl,-rpath,$ENV{CONDA_PREFIX}/lib) endif() @@ -270,7 +270,7 @@ find_package(Cholmod 4.4.5 REQUIRED) find_package(CSM 3.0.3.3 REQUIRED) find_package(CSPICE 65 REQUIRED) find_package(Eigen REQUIRED) -find_package(Embree 2.15.0 REQUIRED) +find_package(Embree 3.13.0 REQUIRED) find_package(GeoTIFF 2 REQUIRED) SET(GSL_ROOT_DIR $ENV{CONDA_PREFIX}) find_package(GSL 2.2.1 REQUIRED) @@ -279,7 +279,7 @@ find_package(Jama 125 REQUIRED) find_package(NN REQUIRED) find_package(OpenCV 3.1.0 REQUIRED) find_package(PCL REQUIRED) -find_package(Protobuf 2.6.1 REQUIRED) +find_package(protobuf REQUIRED CONFIG) find_package(Qwt 6 REQUIRED) find_package(SuperLU 4.3 REQUIRED) find_package(TIFF 4.0.0 REQUIRED) @@ -352,7 +352,7 @@ foreach (_variableName ${_variableNames}) endforeach() # add target based linkages to ALLLIBS variable -list(APPEND ALLLIBS pantor::inja sensorutilities) +list(APPEND ALLLIBS pantor::inja sensorutilities protobuf::libprotobuf embree) # Sometimes we add the same lib more than once (especially with LIBDIRS) list(REMOVE_DUPLICATES ALLLIBDIRS) diff --git a/isis/cmake/FindEmbree.cmake b/isis/cmake/FindEmbree.cmake deleted file mode 100644 index d7af1d78d6ebb668679ad8ea3c7a71157cb3f123..0000000000000000000000000000000000000000 --- a/isis/cmake/FindEmbree.cmake +++ /dev/null @@ -1,20 +0,0 @@ -# CMake module for find_package(Embree) -# Finds include directory and all applicable libraries -# -# Sets the following: -# EMBREE_INCLUDE_DIR -# EMBREE_LIBRARY - -find_path(EMBREE_INCLUDE_DIR - NAME rtcore.h - PATH_SUFFIXES embree2 -) - -find_library(EMBREE_LIBRARY - NAMES embree -) - -get_filename_component(EMBREE_ROOT_INCLUDE_DIR "${EMBREE_INCLUDE_DIR}" DIRECTORY) - -message(STATUS "EMBREE INCLUDE: " ${EMBREE_INCLUDE_DIR}) -message(STATUS "EMBREE LIB: " ${EMBREE_LIBRARY}) diff --git a/isis/cmake/FindGeos.cmake b/isis/cmake/FindGeos.cmake index 2c88116adb46a332cb8b3354cf58d6d10a46c97c..f7ca8c585b0c45336f458d12b21b89dc15ae1129 100644 --- a/isis/cmake/FindGeos.cmake +++ b/isis/cmake/FindGeos.cmake @@ -6,7 +6,7 @@ # GEOS_LIBRARY find_path(GEOS_INCLUDE_DIR - NAMES geos.h + NAMES geos.h geos_c.h PATH_SUFFIXES "geos/geos${Geos_FIND_VERSION}" "geos" ) diff --git a/isis/cmake/FindPCL.cmake b/isis/cmake/FindPCL.cmake index 04f2ae4fb6da4dbf47609f23b795af026d47c071..e1c05d1d29465e15c11ed398838e856fa0feb5e9 100644 --- a/isis/cmake/FindPCL.cmake +++ b/isis/cmake/FindPCL.cmake @@ -7,7 +7,7 @@ find_path(PCL_INCLUDE_DIR NAME pcl_base.h - PATH_SUFFIXES "pcl-1.8/pcl" "pcl-1.9/pcl" "pcl-1.11/pcl" + PATH_SUFFIXES "pcl-1.8/pcl" "pcl-1.9/pcl" "pcl-1.11/pcl" "pcl-1.12/pcl" "pcl-1.13/pcl" ) find_library(PCL_COMMON_LIBRARY NAMES pcl_common) diff --git a/isis/src/base/apps/caminfo/CamTools.cpp b/isis/src/base/apps/caminfo/CamTools.cpp index f96b251760ec311f36473304292b73cdc9afc5ae..1cee5bff68a9ecd6c8daf2a84b7354add0f67e4e 100644 --- a/isis/src/base/apps/caminfo/CamTools.cpp +++ b/isis/src/base/apps/caminfo/CamTools.cpp @@ -734,7 +734,7 @@ namespace Isis { vector<const geos::geom::Geometry *> polys; polys.push_back(g); const geos::geom::GeometryFactory *gfactory = geos::geom::GeometryFactory::getDefaultInstance(); - return (gfactory->createMultiPolygon(polys)); + return (gfactory->createMultiPolygon(polys).release()); } diff --git a/isis/src/base/apps/cubediff/main.cpp b/isis/src/base/apps/cubediff/main.cpp index 526f3352bdf19a708a0d7e5cb86f402384e32e2b..a2abc764396f2f0cc8e9b86367ecf481584e83c4 100644 --- a/isis/src/base/apps/cubediff/main.cpp +++ b/isis/src/base/apps/cubediff/main.cpp @@ -14,12 +14,11 @@ #include "IString.h" #include "Pixel.h" -using namespace std; using namespace Isis; -void compare(vector<Buffer *> &in, vector<Buffer *> &out); +void compare(std::vector<Buffer *> &in, std::vector<Buffer *> &out); -void diffTable(ofstream &target, int precision); +void diffTable(std::ofstream &target, int precision); // This is only used for the difference table struct Difference { @@ -36,7 +35,7 @@ int sample, line, band, spCount, diffCount, colWidth; Statistics stats; bool doTable; unsigned int sigFigAccuracy = DBL_DIG; // DBL_DIG is maximum accuracy for a double -vector<Difference> diffset; +std::vector<Difference> diffset; int sigFigLine = 0; int sigFigSample = 0; int sigFigBand = 0; @@ -64,7 +63,7 @@ void IsisMain() { doTable = true; diffCount = ui.GetInteger("COUNT"); if(!ui.WasEntered("TO")) { - string message = "A target file is required for difference output"; + std::string message = "A target file is required for difference output"; throw IException(IException::User, message, _FILEINFO_); } @@ -123,7 +122,7 @@ void IsisMain() { } if(doTable) { QString filename = FileName(ui.GetFileName("TO", "txt")).expanded(); - ofstream ofile(filename.toLatin1().data(), ios_base::app); + std::ofstream ofile(filename.toLatin1().data(), std::ios_base::app); diffTable(ofile, ui.GetInteger("PRECISION")); } @@ -131,7 +130,7 @@ void IsisMain() { filesEqual = true; } -void compare(vector<Buffer *> &in, vector<Buffer *> &out) { +void compare(std::vector<Buffer *> &in, std::vector<Buffer *> &out) { Buffer &input1 = *in[0]; Buffer &input2 = *in[1]; int inputSize = input1.size(); @@ -252,8 +251,8 @@ void compare(vector<Buffer *> &in, vector<Buffer *> &out) { } //Function to prepare the table to append to the -void diffTable(ofstream &target, int precision) { - vector<int> temp; +void diffTable(std::ofstream &target, int precision) { + std::vector<int> temp; //Make a list of all samples present for(unsigned int i = 0; i < diffset.size(); i++) { @@ -264,14 +263,14 @@ void diffTable(ofstream &target, int precision) { sort(temp.begin(), temp.end()); //Remove duplicates - vector<int> samps; + std::vector<int> samps; samps.push_back(temp[0]); for(unsigned int i = 1; i < temp.size(); i++) { if(temp[i] != samps.back()) { samps.push_back(temp[i]); } } - vector<Column> cols; + std::vector<Column> cols; //Add the first Column Column first("Line#", 7, Column::Integer); cols.push_back(first); diff --git a/isis/src/base/apps/fakecube/main.cpp b/isis/src/base/apps/fakecube/main.cpp index 284906cacc9b48a8c3541a151923ede257dd77d7..ab96be028151238af75e29e83474f9fc45a69703 100644 --- a/isis/src/base/apps/fakecube/main.cpp +++ b/isis/src/base/apps/fakecube/main.cpp @@ -2,7 +2,6 @@ #include "ProcessByLine.h" #include "SpecialPixel.h" -using namespace std; using namespace Isis; void SumLineSample(Buffer &in, Buffer &out); diff --git a/isis/src/base/apps/footprintmerge/main.cpp b/isis/src/base/apps/footprintmerge/main.cpp index 82b9f60f321b0ebaab9241aaa73ffc743a089075..42145cf5e76eeea440514f2ef9e18585a4d1bbb6 100644 --- a/isis/src/base/apps/footprintmerge/main.cpp +++ b/isis/src/base/apps/footprintmerge/main.cpp @@ -83,7 +83,7 @@ void IsisMain() { // Create union poly geos::geom::GeometryCollection *polyCollection = - Isis::globalFactory->createGeometryCollection(allPolys); + Isis::globalFactory->createGeometryCollection(allPolys).release(); geos::geom::Geometry *unionPoly = polyCollection->buffer(0).release(); diff --git a/isis/src/base/objs/Chip/Chip.cpp b/isis/src/base/objs/Chip/Chip.cpp index 3e8843c5e17162daaefadf9f804f93a3a0e8cd9c..d7a4f66655631c9dd9954fb2289cea581d6d8c23 100644 --- a/isis/src/base/objs/Chip/Chip.cpp +++ b/isis/src/base/objs/Chip/Chip.cpp @@ -959,8 +959,8 @@ namespace Isis { interp.Interpolate(CubeSample(), CubeLine(), port.DoubleBuffer()); } else { - geos::geom::Point *pnt = globalFactory->createPoint( - geos::geom::Coordinate(CubeSample(), CubeLine())); + std::unique_ptr<geos::geom::Point> pnt = globalFactory->createPoint( + geos::geom::Coordinate(CubeSample(), CubeLine())); if (pnt->within(m_clipPolygon)) { port.SetPosition(CubeSample(), CubeLine(), band); cube.read(port); @@ -970,7 +970,7 @@ namespace Isis { else { m_buf[line-1][samp-1] = Isis::NULL8; } - delete pnt; + pnt.reset(); } } } diff --git a/isis/src/base/objs/Chip/unitTest.cpp b/isis/src/base/objs/Chip/unitTest.cpp index 22fc5172be5417beff9522a4b38ec2327b7c692e..9ce1a4d7c7c3f83e96ab5a125af3404f9390c18e 100644 --- a/isis/src/base/objs/Chip/unitTest.cpp +++ b/isis/src/base/objs/Chip/unitTest.cpp @@ -17,7 +17,7 @@ find files of those names at the top level of this repository. **/ #include "Preference.h" #include "SpecialPixel.h" #include "geos/geom/Coordinate.h" -#include "geos/geom/CoordinateArraySequence.h" +#include "geos/geom/CoordinateSequence.h" #include "geos/geom/GeometryFactory.h" #include "geos/geom/Polygon.h" #include "geos/geom/MultiPolygon.h" @@ -134,16 +134,16 @@ int main() { cout << "Test load chip from cube with rotation and clipping polygon " << endl; chip.TackCube(26.0, 25.0); - geos::geom::CoordinateArraySequence *pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(23.0, 22.0)); - pts->add(geos::geom::Coordinate(28.0, 22.0)); - pts->add(geos::geom::Coordinate(28.0, 27.0)); - pts->add(geos::geom::Coordinate(25.0, 28.0)); - pts->add(geos::geom::Coordinate(23.0, 22.0)); - vector<geos::geom::Geometry *> *polys = new vector<geos::geom::Geometry *>; + geos::geom::CoordinateSequence pts; + pts.add(geos::geom::Coordinate(23.0, 22.0)); + pts.add(geos::geom::Coordinate(28.0, 22.0)); + pts.add(geos::geom::Coordinate(28.0, 27.0)); + pts.add(geos::geom::Coordinate(25.0, 28.0)); + pts.add(geos::geom::Coordinate(23.0, 22.0)); + vector <const geos::geom::Geometry *> polys; geos::geom::GeometryFactory::Ptr gf = geos::geom::GeometryFactory::create(); - polys->push_back(gf->createPolygon(gf->createLinearRing(pts), NULL)); - geos::geom::MultiPolygon *mPolygon = gf->createMultiPolygon(polys); + polys.push_back(gf->createPolygon(gf->createLinearRing(pts)).release()); + geos::geom::MultiPolygon *mPolygon = gf->createMultiPolygon(polys).release(); chip.SetClipPolygon(*mPolygon); chip.Load(junk, 45.0); diff --git a/isis/src/base/objs/EmbreeShapeModel/EmbreeShapeModel.cpp b/isis/src/base/objs/EmbreeShapeModel/EmbreeShapeModel.cpp index a4862d4280a226aabc3b7ab4d3b28c61c8d89649..e08f8b48cf7d1ae97df2dfdc2b020ebc21b6ba60 100644 --- a/isis/src/base/objs/EmbreeShapeModel/EmbreeShapeModel.cpp +++ b/isis/src/base/objs/EmbreeShapeModel/EmbreeShapeModel.cpp @@ -8,6 +8,7 @@ find files of those names at the top level of this repository. **/ #include "EmbreeShapeModel.h" #include <numeric> +#include <float.h> #include <QtGlobal> #include <QList> @@ -233,18 +234,18 @@ namespace Isis { // Cast a ray from the observer to the intersection and check if it is occluded RTCOcclusionRay obsRay; - obsRay.org[0] = observerPos[0]; - obsRay.org[1] = observerPos[1]; - obsRay.org[2] = observerPos[2]; - obsRay.dir[0] = lookVector[0]; - obsRay.dir[1] = lookVector[1]; - obsRay.dir[2] = lookVector[2]; - obsRay.tnear = 0.0; - obsRay.tfar = LinearAlgebra::magnitude(obsToIntersection) - 0.0005; - obsRay.instID = RTC_INVALID_GEOMETRY_ID; - obsRay.geomID = RTC_INVALID_GEOMETRY_ID; - obsRay.primID = RTC_INVALID_GEOMETRY_ID; - obsRay.mask = 0xFFFFFFFF; + obsRay.ray.org_x = observerPos[0]; + obsRay.ray.org_y = observerPos[1]; + obsRay.ray.org_z = observerPos[2]; + obsRay.ray.dir_x = lookVector[0]; + obsRay.ray.dir_y = lookVector[1]; + obsRay.ray.dir_z = lookVector[2]; + obsRay.ray.tnear = 0.0; + obsRay.ray.tfar = LinearAlgebra::magnitude(obsToIntersection) - 0.0005; + obsRay.hit.instID[0] = RTC_INVALID_GEOMETRY_ID; + obsRay.hit.geomID = RTC_INVALID_GEOMETRY_ID; + obsRay.hit.primID = RTC_INVALID_GEOMETRY_ID; + obsRay.ray.mask = 0xFFFFFFFF; obsRay.ignorePrimID = hits[i].primID; // If the intersection point is not occluded, @@ -291,7 +292,7 @@ namespace Isis { RTCMultiHitRay ray = pointToRay(surfpt); // Extend the ray to be 1.5 times the length of the SurfacePoint's radius - ray.tfar *= 1.5; + ray.ray.tfar *= 1.5; m_targetShape->intersectRay(ray); @@ -319,18 +320,18 @@ namespace Isis { // Cast a ray from the observer to the intersection and check if it is occluded RTCOcclusionRay obsRay; - obsRay.org[0] = observerPos[0]; - obsRay.org[1] = observerPos[1]; - obsRay.org[2] = observerPos[2]; - obsRay.dir[0] = lookVector[0]; - obsRay.dir[1] = lookVector[1]; - obsRay.dir[2] = lookVector[2]; - obsRay.tnear = 0.0; - obsRay.tfar = LinearAlgebra::magnitude(obsToIntersection); - obsRay.instID = RTC_INVALID_GEOMETRY_ID; - obsRay.geomID = RTC_INVALID_GEOMETRY_ID; - obsRay.primID = RTC_INVALID_GEOMETRY_ID; - obsRay.mask = 0xFFFFFFFF; + obsRay.ray.org_x = observerPos[0]; + obsRay.ray.org_y = observerPos[1]; + obsRay.ray.org_z = observerPos[2]; + obsRay.ray.dir_x = lookVector[0]; + obsRay.ray.dir_y = lookVector[1]; + obsRay.ray.dir_z = lookVector[2]; + obsRay.ray.tnear = 0.0; + obsRay.ray.tfar = LinearAlgebra::magnitude(obsToIntersection); + obsRay.hit.instID[0] = RTC_INVALID_GEOMETRY_ID; + obsRay.hit.geomID = RTC_INVALID_GEOMETRY_ID; + obsRay.hit.primID = RTC_INVALID_GEOMETRY_ID; + obsRay.ray.mask = 0xFFFFFFFF; obsRay.ignorePrimID = hits[i].primID; // If the intersection point is no occluded, @@ -406,7 +407,7 @@ namespace Isis { RTCMultiHitRay ray = latlonToRay(lat,lon); // Extend the ray to 2.5 times the maximum radius - ray.tfar *= 2.5; + ray.ray.tfar *= 2.5; m_targetShape->intersectRay(ray); @@ -632,19 +633,19 @@ namespace Isis { RTCMultiHitRay EmbreeShapeModel::latlonToRay(const Latitude &lat, const Longitude &lon) const { // Initialize ray RTCMultiHitRay ray; - ray.org[0] = 0.0; - ray.org[1] = 0.0; - ray.org[2] = 0.0; + ray.ray.org_x = 0.0; + ray.ray.org_y = 0.0; + ray.ray.org_z = 0.0; // Convert the lat, lon to a unit look direction double latAngle = lat.radians(); double lonAngle = lon.radians(); - ray.dir[0] = cos(latAngle) * cos(lonAngle); - ray.dir[1] = cos(latAngle) * sin(lonAngle); - ray.dir[2] = sin(latAngle); + ray.ray.dir_x = cos(latAngle) * cos(lonAngle); + ray.ray.dir_y = cos(latAngle) * sin(lonAngle); + ray.ray.dir_z = sin(latAngle); // Set the ray's length to extend to the scene boundary - ray.tfar = m_targetShape->maximumSceneDistance(); + ray.ray.tfar = m_targetShape->maximumSceneDistance(); return (ray); } @@ -662,14 +663,14 @@ namespace Isis { RTCMultiHitRay EmbreeShapeModel::pointToRay(const SurfacePoint &surfpt) const { // Setup everything but the direction component RTCMultiHitRay ray; - ray.org[0] = 0.0; - ray.org[1] = 0.0; - ray.org[2] = 0.0; - ray.tnear = 0.0; - ray.instID = RTC_INVALID_GEOMETRY_ID; // instance - ray.geomID = RTC_INVALID_GEOMETRY_ID; - ray.primID = RTC_INVALID_GEOMETRY_ID; // primitive id (triangle id) - ray.mask = 0xFFFFFFFF; + ray.ray.org_x = 0.0; + ray.ray.org_y = 0.0; + ray.ray.org_z = 0.0; + ray.ray.tnear = 0.0; + ray.hit.instID[0] = RTC_INVALID_GEOMETRY_ID; // instance + ray.hit.geomID = RTC_INVALID_GEOMETRY_ID; + ray.hit.primID = RTC_INVALID_GEOMETRY_ID; // primitive id (triangle id) + ray.ray.mask = 0xFFFFFFFF; ray.lastHit = -1; // Get the vector from the origin to the surface point @@ -681,12 +682,12 @@ namespace Isis { // Normalize the vector and store it in the ray direction = LinearAlgebra::normalize(direction); - ray.dir[0] = direction[0]; - ray.dir[1] = direction[1]; - ray.dir[2] = direction[2]; + ray.ray.dir_x = direction[0]; + ray.ray.dir_y = direction[1]; + ray.ray.dir_z = direction[2]; // Extend the ray to the surface point - ray.tfar = surfpt.GetLocalRadius().kilometers(); + ray.ray.tfar = surfpt.GetLocalRadius().kilometers(); return (ray); } diff --git a/isis/src/base/objs/EmbreeShapeModel/EmbreeShapeModel.h b/isis/src/base/objs/EmbreeShapeModel/EmbreeShapeModel.h index 59b3378dc5e6006e47e8858da52d9fe599def5a3..e9416adaec41a787238a8bc8aa12a40b0abd8577 100644 --- a/isis/src/base/objs/EmbreeShapeModel/EmbreeShapeModel.h +++ b/isis/src/base/objs/EmbreeShapeModel/EmbreeShapeModel.h @@ -10,7 +10,7 @@ find files of those names at the top level of this repository. **/ #include <vector> -#include <embree2/rtcore.h> +#include <embree3/rtcore.h> #include <QMap> #include <QVector> diff --git a/isis/src/base/objs/EmbreeTargetShape/EmbreeTargetShape.cpp b/isis/src/base/objs/EmbreeTargetShape/EmbreeTargetShape.cpp index 730188d51bfdcf6a6f699036e8dc0e6800813a3b..19b3306fa7d7261db82b3c2460922cd6ea1917cc 100644 --- a/isis/src/base/objs/EmbreeTargetShape/EmbreeTargetShape.cpp +++ b/isis/src/base/objs/EmbreeTargetShape/EmbreeTargetShape.cpp @@ -26,24 +26,24 @@ namespace Isis { * Default constructor for RTCMultiHitRay. */ RTCMultiHitRay::RTCMultiHitRay() { - tnear = 0.0; - tfar = std::numeric_limits<float>::infinity(); // Should be INF - mask = 0xFFFFFFFF; + ray.tnear = 0.0; + ray.tfar = std::numeric_limits<float>::infinity(); // Should be INF + ray.mask = 0xFFFFFFFF; lastHit = -1; - u = 0.0; - v = 0.0; - geomID = RTC_INVALID_GEOMETRY_ID; - primID = RTC_INVALID_GEOMETRY_ID; - instID = RTC_INVALID_GEOMETRY_ID; - org[0] = 0.0; - org[1] = 0.0; - org[2] = 0.0; - dir[0] = 0.0; - dir[1] = 0.0; - dir[2] = 0.0; - Ng[0] = 0.0; - Ng[1] = 0.0; - Ng[2] = 0.0; + hit.u = 0.0; + hit.v = 0.0; + hit.geomID = RTC_INVALID_GEOMETRY_ID; + hit.primID = RTC_INVALID_GEOMETRY_ID; + hit.instID[0] = RTC_INVALID_GEOMETRY_ID; + ray.org_x = 0.0; + ray.org_y = 0.0; + ray.org_z = 0.0; + ray.dir_x = 0.0; + ray.dir_y = 0.0; + ray.dir_z = 0.0; + hit.Ng_x = 0.0; + hit.Ng_y = 0.0; + hit.Ng_z = 0.0; } @@ -55,24 +55,24 @@ namespace Isis { */ RTCMultiHitRay::RTCMultiHitRay(const std::vector<double> &origin, const std::vector<double> &direction) { - tnear = 0.0; - tfar = std::numeric_limits<float>::infinity(); // Should be INF - mask = 0xFFFFFFFF; + ray.tnear = 0.0; + ray.tfar = std::numeric_limits<float>::infinity(); // Should be INF + ray.mask = 0xFFFFFFFF; lastHit = -1; - u = 0.0; - v = 0.0; - geomID = RTC_INVALID_GEOMETRY_ID; - primID = RTC_INVALID_GEOMETRY_ID; - instID = RTC_INVALID_GEOMETRY_ID; - org[0] = origin[0]; - org[1] = origin[1]; - org[2] = origin[2]; - dir[0] = direction[0]; - dir[1] = direction[1]; - dir[2] = direction[2]; - Ng[0] = 0.0; - Ng[1] = 0.0; - Ng[2] = 0.0; + hit.u = 0.0; + hit.v = 0.0; + hit.geomID = RTC_INVALID_GEOMETRY_ID; + hit.primID = RTC_INVALID_GEOMETRY_ID; + hit.instID[0] = RTC_INVALID_GEOMETRY_ID; + ray.org_x = origin[0]; + ray.org_y = origin[1]; + ray.org_z = origin[2]; + ray.dir_x = direction[0]; + ray.dir_y = direction[1]; + ray.dir_z = direction[2]; + hit.Ng_x = 0.0; + hit.Ng_y = 0.0; + hit.Ng_z = 0.0; } @@ -85,24 +85,24 @@ namespace Isis { */ RTCMultiHitRay::RTCMultiHitRay(LinearAlgebra::Vector origin, LinearAlgebra::Vector direction) { - tnear = 0.0; - tfar = std::numeric_limits<float>::infinity(); // Should be INF - mask = 0xFFFFFFFF; + ray.tnear = 0.0; + ray.tfar = std::numeric_limits<float>::infinity(); // Should be INF + ray.mask = 0xFFFFFFFF; lastHit = -1; - u = 0.0; - v = 0.0; - geomID = RTC_INVALID_GEOMETRY_ID; - primID = RTC_INVALID_GEOMETRY_ID; - instID = RTC_INVALID_GEOMETRY_ID; - org[0] = origin[0]; - org[1] = origin[1]; - org[2] = origin[2]; - dir[0] = direction[0]; - dir[1] = direction[1]; - dir[2] = direction[2]; - Ng[0] = 0.0; - Ng[1] = 0.0; - Ng[2] = 0.0; + hit.u = 0.0; + hit.v = 0.0; + hit.geomID = RTC_INVALID_GEOMETRY_ID; + hit.primID = RTC_INVALID_GEOMETRY_ID; + hit.instID[0] = RTC_INVALID_GEOMETRY_ID; + ray.org_x = origin[0]; + ray.org_y = origin[1]; + ray.org_z = origin[2]; + ray.dir_x = direction[0]; + ray.dir_y = direction[1]; + ray.dir_z = direction[2]; + hit.Ng_x = 0.0; + hit.Ng_y = 0.0; + hit.Ng_z = 0.0; } @@ -110,25 +110,25 @@ namespace Isis { * Default constructor for RTCOcclussionRay. */ RTCOcclusionRay::RTCOcclusionRay() { - tnear = 0.0; - tfar = std::numeric_limits<float>::infinity(); // Should be INF - mask = 0xFFFFFFFF; + ray.tnear = 0.0; + ray.tfar = std::numeric_limits<float>::infinity(); // Should be INF + ray.mask = 0xFFFFFFFF; lastHit = -1; - u = 0.0; - v = 0.0; + hit.u = 0.0; + hit.v = 0.0; ignorePrimID = -1; - geomID = RTC_INVALID_GEOMETRY_ID; - primID = RTC_INVALID_GEOMETRY_ID; - instID = RTC_INVALID_GEOMETRY_ID; - org[0] = 0.0; - org[1] = 0.0; - org[2] = 0.0; - dir[0] = 0.0; - dir[1] = 0.0; - dir[2] = 0.0; - Ng[0] = 0.0; - Ng[1] = 0.0; - Ng[2] = 0.0; + hit.geomID = RTC_INVALID_GEOMETRY_ID; + hit.primID = RTC_INVALID_GEOMETRY_ID; + hit.instID[0] = RTC_INVALID_GEOMETRY_ID; + ray.org_x = 0.0; + ray.org_y = 0.0; + ray.org_z = 0.0; + ray.dir_x = 0.0; + ray.dir_y = 0.0; + ray.dir_z = 0.0; + hit.Ng_x = 0.0; + hit.Ng_y = 0.0; + hit.Ng_z = 0.0; } @@ -140,24 +140,24 @@ namespace Isis { */ RTCOcclusionRay::RTCOcclusionRay(const std::vector<double> &origin, const std::vector<double> &direction) { - tnear = 0.0; - tfar = std::numeric_limits<float>::infinity(); // Should be INF - mask = 0xFFFFFFFF; + ray.tnear = 0.0; + ray.tfar = std::numeric_limits<float>::infinity(); // Should be INF + ray.mask = 0xFFFFFFFF; lastHit = -1; - u = 0.0; - v = 0.0; - geomID = RTC_INVALID_GEOMETRY_ID; + hit.u = 0.0; + hit.v = 0.0; + hit.geomID = RTC_INVALID_GEOMETRY_ID; ignorePrimID = -1; - instID = RTC_INVALID_GEOMETRY_ID; - org[0] = origin[0]; - org[1] = origin[1]; - org[2] = origin[2]; - dir[0] = direction[0]; - dir[1] = direction[1]; - dir[2] = direction[2]; - Ng[0] = 0.0; - Ng[1] = 0.0; - Ng[2] = 0.0; + hit.instID[0] = RTC_INVALID_GEOMETRY_ID; + ray.org_x = origin[0]; + ray.org_y = origin[1]; + ray.org_z = origin[2]; + ray.dir_x = direction[0]; + ray.dir_y = direction[1]; + ray.dir_z = direction[2]; + hit.Ng_x = 0.0; + hit.Ng_y = 0.0; + hit.Ng_z = 0.0; } /** @@ -169,24 +169,24 @@ namespace Isis { */ RTCOcclusionRay::RTCOcclusionRay(LinearAlgebra::Vector origin, LinearAlgebra::Vector direction) { - tnear = 0.0; - tfar = std::numeric_limits<float>::infinity(); // Should be INF - mask = 0xFFFFFFFF; + ray.tnear = 0.0; + ray.tfar = std::numeric_limits<float>::infinity(); // Should be INF + ray.mask = 0xFFFFFFFF; lastHit = -1; - u = 0.0; - v = 0.0; - geomID = RTC_INVALID_GEOMETRY_ID; - ignorePrimID = -1; - instID = RTC_INVALID_GEOMETRY_ID; - org[0] = origin[0]; - org[1] = origin[1]; - org[2] = origin[2]; - dir[0] = direction[0]; - dir[1] = direction[1]; - dir[2] = direction[2]; - Ng[0] = 0.0; - Ng[1] = 0.0; - Ng[2] = 0.0; + hit.u = 0.0; + hit.v = 0.0; + hit.geomID = RTC_INVALID_GEOMETRY_ID; + ignorePrimID = -1; + hit.instID[0] = RTC_INVALID_GEOMETRY_ID; + ray.org_x = origin[0]; + ray.org_y = origin[1]; + ray.org_z = origin[2]; + ray.dir_x = direction[0]; + ray.dir_y = direction[1]; + ray.dir_z = direction[2]; + hit.Ng_x = 0.0; + hit.Ng_y = 0.0; + hit.Ng_z = 0.0; } @@ -227,10 +227,11 @@ namespace Isis { m_mesh(), m_cloud(), m_device(rtcNewDevice(NULL)), - m_scene(rtcDeviceNewScene(m_device, - RTC_SCENE_STATIC | RTC_SCENE_HIGH_QUALITY | RTC_SCENE_ROBUST, - RTC_INTERSECT1)) { } - + m_scene(rtcNewScene(m_device)) + { + rtcSetSceneFlags(m_scene, RTC_SCENE_FLAG_ROBUST | RTC_SCENE_FLAG_CONTEXT_FILTER_FUNCTION); + rtcSetSceneBuildQuality(m_scene, RTC_BUILD_QUALITY_HIGH); + } /** * Constructs an EmbreeTargetShape from a PointCloudLibrary polygon mesh. @@ -243,13 +244,13 @@ namespace Isis { m_mesh(), m_cloud(), m_device(rtcNewDevice(NULL)), - m_scene(rtcDeviceNewScene(m_device, - RTC_SCENE_STATIC | RTC_SCENE_HIGH_QUALITY | RTC_SCENE_ROBUST, - RTC_INTERSECT1)) { + m_scene(rtcNewScene(m_device)) + { + rtcSetSceneFlags(m_scene, RTC_SCENE_FLAG_ROBUST | RTC_SCENE_FLAG_CONTEXT_FILTER_FUNCTION); + rtcSetSceneBuildQuality(m_scene, RTC_BUILD_QUALITY_HIGH); initMesh(mesh); } - /** * Constructs an EmbreeTargetShape from a file. * @@ -265,9 +266,9 @@ namespace Isis { m_mesh(), m_cloud(), m_device(rtcNewDevice(NULL)), - m_scene(rtcDeviceNewScene(m_device, - RTC_SCENE_STATIC | RTC_SCENE_HIGH_QUALITY | RTC_SCENE_ROBUST, - RTC_INTERSECT1)) { + m_scene(rtcNewScene(m_device)) { + rtcSetSceneFlags(m_scene, RTC_SCENE_FLAG_ROBUST | RTC_SCENE_FLAG_CONTEXT_FILTER_FUNCTION); + rtcSetSceneBuildQuality(m_scene, RTC_BUILD_QUALITY_HIGH); FileName file(dem); pcl::PolygonMesh::Ptr mesh; m_name = file.baseName(); @@ -454,25 +455,43 @@ namespace Isis { pcl::fromPCLPointCloud2(mesh->cloud, m_cloud); // Create a static geometry (the body) in our scene - unsigned geomID = rtcNewTriangleMesh(m_scene, - RTC_GEOMETRY_STATIC, - numberOfPolygons(), - numberOfVertices(), - 1); + RTCGeometry rtcMesh = rtcNewGeometry(m_device, RTC_GEOMETRY_TYPE_TRIANGLE); // Add vertices and faces (indices) - addVertices(geomID); // add cloud of points - addIndices(geomID); // connect dots of cloud into triangles + if (!isValid()) { + return; + } + // Add the body's vertices to the Embree ray tracing device's vertex buffer + Vertex *vertices = (Vertex *)rtcSetNewGeometryBuffer(rtcMesh, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, sizeof(Vertex), numberOfVertices()); + for (int v = 0; v < numberOfVertices(); ++v) { + vertices[v].x = m_cloud.points[v].x; + vertices[v].y = m_cloud.points[v].y; + vertices[v].z = m_cloud.points[v].z; + } + + if (!isValid()) { + return; + } + int tri = 0; + Triangle *triangles = (Triangle *)rtcSetNewGeometryBuffer(rtcMesh, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, sizeof(Triangle), numberOfPolygons()); + // Add the body's face (vertex indices) to the Embree device's index buffer + for (int t = 0; t < numberOfPolygons(); ++t) { + triangles[t].v0 = m_mesh->polygons[t].vertices[0]; + triangles[t].v1 = m_mesh->polygons[t].vertices[1]; + triangles[t].v2 = m_mesh->polygons[t].vertices[2]; + } // Add the multi-hit filter - rtcSetIntersectionFilterFunction(m_scene, geomID, - (RTCFilterFunc)&EmbreeTargetShape::multiHitFilter); + rtcSetGeometryIntersectFilterFunction(rtcMesh, EmbreeTargetShape::multiHitFilter); // Add the occlusion filter - rtcSetOcclusionFilterFunction(m_scene, geomID, - (RTCFilterFunc)&EmbreeTargetShape::occlusionFilter); + rtcSetGeometryOccludedFilterFunction(rtcMesh, EmbreeTargetShape::occlusionFilter); + + rtcCommitGeometry(rtcMesh); + unsigned int geomID = rtcAttachGeometry(m_scene, rtcMesh); + rtcReleaseGeometry(rtcMesh); // Done, now we can perform some ray tracing - rtcCommit(m_scene); + rtcCommitScene(m_scene); } @@ -486,18 +505,18 @@ namespace Isis { * @see EmbreeTargetShape::initMesh */ void EmbreeTargetShape::addVertices(int geomID) { - if (!isValid()) { - return; - } - // Add the body's vertices to the Embree ray tracing device's vertex buffer - Vertex *vertices = (Vertex *) rtcMapBuffer(m_scene, geomID, RTC_VERTEX_BUFFER); - for (int v = 0; v < numberOfVertices(); ++v) { - vertices[v].x = m_cloud.points[v].x; - vertices[v].y = m_cloud.points[v].y; - vertices[v].z = m_cloud.points[v].z; - } - // Flush buffer - rtcUnmapBuffer(m_scene, geomID, RTC_VERTEX_BUFFER); + // if (!isValid()) { + // return; + // } + // // Add the body's vertices to the Embree ray tracing device's vertex buffer + // Vertex *vertices = (Vertex *) rtcMapBuffer(m_scene, geomID, RTC_VERTEX_BUFFER); + // for (int v = 0; v < numberOfVertices(); ++v) { + // vertices[v].x = m_cloud.points[v].x; + // vertices[v].y = m_cloud.points[v].y; + // vertices[v].z = m_cloud.points[v].z; + // } + // // Flush buffer + // rtcUnmapBuffer(m_scene, geomID, RTC_VERTEX_BUFFER); } @@ -511,18 +530,18 @@ namespace Isis { * @see EmbreeTargetShape::initMesh */ void EmbreeTargetShape::addIndices(int geomID) { - if (!isValid()) { - return; - } - // Add the body's face (vertex indices) to the Embree device's index buffer - Triangle *triangles = (Triangle *) rtcMapBuffer(m_scene, geomID, RTC_INDEX_BUFFER); - for (int t = 0; t < numberOfPolygons(); ++t) { - triangles[t].v0 = m_mesh->polygons[t].vertices[0]; - triangles[t].v1 = m_mesh->polygons[t].vertices[1]; - triangles[t].v2 = m_mesh->polygons[t].vertices[2]; - } - // Flush buffer - rtcUnmapBuffer(m_scene, geomID, RTC_INDEX_BUFFER); + // if (!isValid()) { + // return; + // } + // // Add the body's face (vertex indices) to the Embree device's index buffer + // Triangle *triangles = (Triangle *) rtcMapBuffer(m_scene, geomID, RTC_INDEX_BUFFER); + // for (int t = 0; t < numberOfPolygons(); ++t) { + // triangles[t].v0 = m_mesh->polygons[t].vertices[0]; + // triangles[t].v1 = m_mesh->polygons[t].vertices[1]; + // triangles[t].v2 = m_mesh->polygons[t].vertices[2]; + // } + // // Flush buffer + // rtcUnmapBuffer(m_scene, geomID, RTC_INDEX_BUFFER); } @@ -531,8 +550,8 @@ namespace Isis { * but the Embree scene and device must be manually cleaned up. */ EmbreeTargetShape::~EmbreeTargetShape() { - rtcDeleteScene(m_scene); - rtcDeleteDevice(m_device); + rtcReleaseScene(m_scene); + rtcReleaseDevice(m_device); } @@ -577,7 +596,7 @@ namespace Isis { RTCBounds EmbreeTargetShape::sceneBounds() const { RTCBounds sceneBounds; if (isValid()) { - rtcGetBounds(m_scene, sceneBounds); + rtcGetSceneBounds(m_scene, &sceneBounds); } else { sceneBounds.lower_x = 0.0; @@ -638,7 +657,10 @@ namespace Isis { */ void EmbreeTargetShape::intersectRay(RTCMultiHitRay &ray) { if (isValid()) { - rtcIntersect(m_scene, *((RTCRay*)&ray)); + RTCIntersectContext context; + rtcInitIntersectContext(&context); + + rtcIntersect1(m_scene, &context, (RTCRayHit *)&ray); } } @@ -651,10 +673,13 @@ namespace Isis { * @see embree::rtcOccluded */ bool EmbreeTargetShape::isOccluded(RTCOcclusionRay &ray) { - rtcOccluded(m_scene, ray); + RTCIntersectContext context; + rtcInitIntersectContext(&context); - // rtcOccluded sets the geomID to 0 if the ray hits anything - if (ray.geomID == 0) { + rtcOccluded1(m_scene, &context, (RTCRay*)&ray); + + // rtcOccluded sets the ray.tfar to -inf if the ray hits anything + if (isinf(ray.ray.tfar) && ray.ray.tfar < 0) { return true; } return false; @@ -751,19 +776,33 @@ namespace Isis { * @param[in,out] ray The ray being traced. Information about the * intersection will be stored in the ray. */ - void EmbreeTargetShape::multiHitFilter(void* userDataPtr, RTCMultiHitRay& ray) { + void EmbreeTargetShape::multiHitFilter(const RTCFilterFunctionNArguments* args) { + /* avoid crashing when debug visualizations are used */ + if (args->context == nullptr) + return; + + assert(args->N == 1); + int *valid = args->valid; + if (valid[0] != -1) { + return; + } + RTCMultiHitRay *ray = (RTCMultiHitRay *)args->ray; + RTCHit *hit = (RTCHit *)args->hit; + // Calculate the index to store the hit in - ray.lastHit ++; + ray->lastHit++; // Store the hits - ray.hitGeomIDs[ray.lastHit] = ray.geomID; - ray.hitPrimIDs[ray.lastHit] = ray.primID; - ray.hitUs[ray.lastHit] = ray.u; - ray.hitVs[ray.lastHit] = ray.v; + ray->hitGeomIDs[ray->lastHit] = hit->geomID; + ray->hitPrimIDs[ray->lastHit] = hit->primID; + ray->hitUs[ray->lastHit] = hit->u; + ray->hitVs[ray->lastHit] = hit->v; // If there are less than 16 hits, continue ray tracing. - if (ray.lastHit < 15) { - ray.geomID = RTC_INVALID_GEOMETRY_ID; + if (ray->lastHit < 15) { + valid[0] = 0; + ray->hit.geomID = RTC_INVALID_GEOMETRY_ID; + hit->geomID = RTC_INVALID_GEOMETRY_ID; } } @@ -776,12 +815,26 @@ namespace Isis { * @param[in,out] ray The ray being traced. Information about the * intersection will be stored in the ray. */ - void EmbreeTargetShape::occlusionFilter(void* userDataPtr, RTCOcclusionRay& ray) { - + void EmbreeTargetShape::occlusionFilter(const RTCFilterFunctionNArguments* args) { + /* avoid crashing when debug visualizations are used */ + if (args->context == nullptr) + return; + + assert(args->N == 1); + int *valid = args->valid; + if (valid[0] != -1) { + return; + } + RTCOcclusionRay *ray = (RTCOcclusionRay *)args->ray; + RTCHit *hit = (RTCHit *)args->hit; + ray->hit.primID = hit->primID; + // This is the case where we've re-intersected the occluded plate. If this happens, ignore // and keep tracing - if ( ray.primID == ray.ignorePrimID) { - ray.geomID = RTC_INVALID_GEOMETRY_ID; + if (ray->hit.primID == ray->ignorePrimID) { + valid[0] = 0; + // ray->hit.geomID = RTC_INVALID_GEOMETRY_ID; + // hit->geomID = RTC_INVALID_GEOMETRY_ID; } } diff --git a/isis/src/base/objs/EmbreeTargetShape/EmbreeTargetShape.h b/isis/src/base/objs/EmbreeTargetShape/EmbreeTargetShape.h index 5238f7191ef025be68d38e0949ddbc8ebcb91d1d..941d1a189f280b1c2e8a214b07fbe1c9358df985 100644 --- a/isis/src/base/objs/EmbreeTargetShape/EmbreeTargetShape.h +++ b/isis/src/base/objs/EmbreeTargetShape/EmbreeTargetShape.h @@ -10,8 +10,8 @@ find files of those names at the top level of this repository. **/ #include <QString> // Embree includes -#include <embree2/rtcore.h> -#include <embree2/rtcore_ray.h> +#include <embree3/rtcore.h> +#include <embree3/rtcore_ray.h> // PointCloudLibrary includes #include <pcl/io/auto_io.h> @@ -41,7 +41,7 @@ namespace Isis { * @internal * @history 2017-05-11 Jesse Mapel - Original Version */ - struct RTCMultiHitRay : RTCRay { + struct RTCMultiHitRay : RTCRayHit { RTCMultiHitRay(); RTCMultiHitRay(const std::vector<double> &origin, const std::vector<double> &direction); @@ -80,7 +80,7 @@ namespace Isis { * @internal * @history 2017-05-15 Kristin Berry - Original Version */ - struct RTCOcclusionRay : RTCRay { + struct RTCOcclusionRay : RTCRayHit { RTCOcclusionRay(); RTCOcclusionRay(const std::vector<double> &origin, const std::vector<double> &direction); @@ -157,8 +157,8 @@ namespace Isis { RayHitInformation getHitInformation(RTCMultiHitRay &ray, int hitIndex); - static void multiHitFilter(void* userDataPtr, RTCMultiHitRay& ray); - static void occlusionFilter(void* userDataPtr, RTCOcclusionRay& ray); + static void multiHitFilter(const RTCFilterFunctionNArguments *args); + static void occlusionFilter(const RTCFilterFunctionNArguments *args); protected: pcl::PolygonMesh::Ptr readDSK(FileName file); diff --git a/isis/src/base/objs/EmbreeTargetShape/unitTest.cpp b/isis/src/base/objs/EmbreeTargetShape/unitTest.cpp index 01de5196837cb5984b1c49f63355bd4943e35671..f6558a667f2bfcf0bcefa846996489b8be9fd207 100644 --- a/isis/src/base/objs/EmbreeTargetShape/unitTest.cpp +++ b/isis/src/base/objs/EmbreeTargetShape/unitTest.cpp @@ -332,16 +332,16 @@ void outputOcclusion(EmbreeTargetShape &embreeShape, void outputMultiHitRay(RTCMultiHitRay &ray) { qDebug() << "Multi Hit Ray Status"; - qDebug() << " Origin: (" << ray.org[0] << "," << ray.org[1] << "," << ray.org[2] << ")"; - qDebug() << " Direction: (" << ray.dir[0] << "," << ray.dir[1] << "," << ray.dir[2] << ")"; - qDebug() << " Near distance: " << ray.tnear; - qDebug() << " Far distance: " << ray.tfar; - qDebug() << " Normal: (" << ray.Ng[0] << "," << ray.Ng[1] << "," << ray.Ng[2] << ")"; - qDebug() << " Intersection U: " << ray.u; - qDebug() << " Intersection V: " << ray.v; - qDebug() << " Geometry ID: " << ray.geomID; - qDebug() << " Primitive ID: " << ray.primID; - qDebug() << " Instance ID: " << ray.instID; + qDebug() << " Origin: (" << ray.ray.org_x << "," << ray.ray.org_y << "," << ray.ray.org_z << ")"; + qDebug() << " Direction: (" << ray.ray.dir_x << "," << ray.ray.dir_y << "," << ray.ray.dir_z << ")"; + qDebug() << " Near distance: " << ray.ray.tnear; + qDebug() << " Far distance: " << ray.ray.tfar; + qDebug() << " Normal: (" << ray.hit.Ng_x << "," << ray.hit.Ng_y << "," << ray.hit.Ng_z << ")"; + qDebug() << " Intersection U: " << ray.hit.u; + qDebug() << " Intersection V: " << ray.hit.v; + qDebug() << " Geometry ID: " << ray.hit.geomID; + qDebug() << " Primitive ID: " << ray.hit.primID; + qDebug() << " Instance ID: " << ray.hit.instID[0]; qDebug() << " Number of Intersections: " << ray.lastHit + 1; for (int i = 0; i <= ray.lastHit; i++) { qDebug() << " Intersection" << i + 1; @@ -354,15 +354,15 @@ void outputMultiHitRay(RTCMultiHitRay &ray) { void outputOcclusionRay(RTCOcclusionRay &ray) { qDebug() << "Occlusion Ray Status"; - qDebug() << " Origin: (" << ray.org[0] << "," << ray.org[1] << "," << ray.org[2] << ")"; - qDebug() << " Direction: (" << ray.dir[0] << "," << ray.dir[1] << "," << ray.dir[2] << ")"; - qDebug() << " Near distance: " << ray.tnear; - qDebug() << " Far distance: " << ray.tfar; - qDebug() << " Normal: (" << ray.Ng[0] << "," << ray.Ng[1] << "," << ray.Ng[2] << ")"; - qDebug() << " Intersection U: " << ray.u; - qDebug() << " Intersection V: " << ray.v; - qDebug() << " Geometry ID: " << ray.geomID; - qDebug() << " Instance ID: " << ray.instID; + qDebug() << " Origin: (" << ray.ray.org_x << "," << ray.ray.org_y << "," << ray.ray.org_z << ")"; + qDebug() << " Direction: (" << ray.ray.dir_x << "," << ray.ray.dir_y << "," << ray.ray.dir_z << ")"; + qDebug() << " Near distance: " << ray.ray.tnear; + qDebug() << " Far distance: " << ray.ray.tfar; + qDebug() << " Normal: (" << ray.hit.Ng_x << "," << ray.hit.Ng_y << "," << ray.hit.Ng_z << ")"; + qDebug() << " Intersection U: " << ray.hit.u; + qDebug() << " Intersection V: " << ray.hit.v; + qDebug() << " Geometry ID: " << ray.hit.geomID; + qDebug() << " Instance ID: " << ray.hit.instID[0]; qDebug() << " Ignored Primitive ID: " << ray.ignorePrimID; } diff --git a/isis/src/base/objs/GisTopology/GisTopology.cpp b/isis/src/base/objs/GisTopology/GisTopology.cpp index 69ba900edd68d69fb0a927a8da31e53b6efcc6b3..757c14d3bd994523b08a971d2626fd4fe1bfe005 100644 --- a/isis/src/base/objs/GisTopology/GisTopology.cpp +++ b/isis/src/base/objs/GisTopology/GisTopology.cpp @@ -376,6 +376,7 @@ namespace Isis { GEOSWKTWriter *GisTopology::wktWriter() { if (!m_WKTwriter) { m_WKTwriter = GEOSWKTWriter_create(); + GEOSWKTWriter_setTrim(m_WKTwriter, 1); } return (m_WKTwriter); } diff --git a/isis/src/base/objs/GisTopology/GisTopology.truth b/isis/src/base/objs/GisTopology/GisTopology.truth index 89ae4e96cbf6ceb9511d4c1cd0f84a310bec88e8..af5e267103e4e30a92754f795698f2873e094802 100644 --- a/isis/src/base/objs/GisTopology/GisTopology.truth +++ b/isis/src/base/objs/GisTopology/GisTopology.truth @@ -2,7 +2,7 @@ Testing GisTopology... wkt from cube: "MULTIPOLYGON (((291.6482444065063646 54.0748894594413585, 291.7020280173438778 54.0296213291622252, 291.7549863030990878 53.9855163702604841, 291.8077241043083063 53.9408969996877730, 291.8597668189949559 53.8946553693238144, 291.9115817220681492 53.8481113710558290, 291.9632972250017247 53.8015908846553899, 292.0149168432692477 53.7550951640192096, 292.0663616370068212 53.7084560328413261, 292.1175651154498496 53.6615584860058590, 292.1685668928934660 53.6145070190250905, 292.2194413771372865 53.5674528855087715, 292.2702805486716215 53.5205538615438172, 292.3211200787451389 53.4738490257722603, 292.3718951696537829 53.4272104110366328, 292.4225915190824026 53.3806060588361007, 292.4731960443905336 53.3340102581895863, 292.5235491233975154 53.2871937647895280, 292.5737242366652140 53.2402789357434756, 292.6237816497238668 53.1933537780923942, 292.6739185641310428 53.1466663964377020, 292.7240335911182001 53.1000657976819284, 292.7739222679502973 53.0533009388871761, 292.8232431340212543 53.0060022579488432, 292.8720776771814371 52.9583140917663684, 292.9205947272178037 52.9104549807315365, 292.9693168006734822 52.8629718702368621, 293.0180243131512725 52.8156123812802676, 293.0664607895325844 52.7681230400179473, 293.1152230547680801 52.7210579699985686, 293.1641964887326139 52.6742723067946770, 293.2131949281665584 52.6275784848334709, 293.2619983325158728 52.5807860608043711, 293.3106949564739807 52.5339721869144824, 293.3593726059783080 52.4872032262072921, 293.4080105056222578 52.4404570781291142, 293.4564648886776581 52.3936281659687495, 293.5048154773041347 52.3467767520141436, 293.5532286649856815 52.3000111651323678, 293.6016151052821215 52.2532636570787332, 293.6496102604362477 52.2063096901261545, 293.6972856371680223 52.1592109716392258, 293.7448142048647810 52.1120784019265457, 293.7921346113900540 52.0648815632344082, 293.8392722446478729 52.0176397744607399, 293.8863180705967579 51.9704024852086377, 293.9335962428397693 51.9233227111062661, 293.9808809459452732 51.8762775325007652, 294.0278825655254309 51.8291340534371301, 294.0748257771958833 51.7819966404094458, 294.1217863418343086 51.7348933433405946, 294.1686076850560312 51.6877577856796790, 294.2154245767899283 51.6406415633166205, 294.2621689200627770 51.5935160974246045, 294.3088424299793928 51.5463808135885628, 294.3554786257141132 51.4992452332349870, 294.4020474869581676 51.4520976068226830, 294.4487032212942950 51.4049811909859713, 294.4952914913296240 51.3578458802051472, 294.5418969895747523 51.3107127023418883, 294.5884347400872798 51.2635564562394208, 294.6348785316565682 51.2163704162111344, 294.6813714906026576 51.1691860297657186, 294.7276923109479299 51.1219529737556186, 294.7738344522448415 51.0746736215991461, 294.8197718395178981 51.0273470951758696, 294.8654929360217238 50.9799761011058834, 294.9112626249865343 50.9326058392748848, 294.9571326309937263 50.8852385824861955, 295.0028081042060535 50.8378299359886867, 295.0483599950314328 50.7903921654531985, 295.0938159376023577 50.7429295926595358, 295.1394393952502355 50.6954672716803998, 295.1849886311760542 50.6479769473739339, 295.2302510328869403 50.6004433494925010, 295.2751700987382151 50.5528698438340527, 295.3200302318319359 50.5052789709472236, 295.3651817746400638 50.4576837161567440, 295.4102514173258101 50.4100616461730695, 295.4554187475314393 50.3624162955004522, 295.5005451617301446 50.3147411900532333, 295.5454941248207774 50.2670354744187762, 295.5901264260956509 50.2193036524553094, 295.6345902381398218 50.1715496780019024, 295.6788486553651296 50.1237772068778114, 295.7231187033184483 50.0759813438211268, 295.7673408602476002 50.0281624317159554, 295.8116127406512987 49.9803140857962518, 295.8560810864870518 49.9324232409902393, 295.9005769971004156 49.8844953496522550, 295.9446838645065441 49.8365625667986407, 295.9886221285325405 49.7886128304107629, 296.0323211243245396 49.7406556427859172, 296.0759910747153185 49.6926722818829845, 296.1194565103898526 49.6446821048827829, 296.1624897088751709 49.5967167487294276, 296.2054086607993213 49.5487424737293551, 296.2484396719925712 49.5007281817789533, 296.2915134711480505 49.4526796665121608, 296.3350389573967618 49.4045300978008015, 296.3786114499501991 49.3563338330455679, 296.4222302019360313 49.3080883623094124, 296.4656892412461389 49.2598280749685955, 296.4782574023010966 49.2419677041339625, 296.4032185014780225 49.2138422027338365, 296.3291599281647564 49.1861284721513243, 296.2549758604650378 49.1584150628567116, 296.1805181984752267 49.1307377732130348, 296.1059958275960753 49.1030596410174311, 296.0319753508879330 49.0752577913664254, 295.9588442320529111 49.0472336740290160, 295.8861134027861226 49.0190860042944365, 295.8124228918390486 48.9911441745806684, 295.7382596561083119 48.9633095596598835, 295.6644117428859886 48.9353885153610904, 295.5913488263511795 48.9072473769558513, 295.5188683870677551 48.8789250825906123, 295.4460786412217885 48.8506686873925204, 295.3732701352031427 48.8224019007348673, 295.2999915852694244 48.7942691567235656, 295.2264283102026639 48.7662284257375518, 295.1533647828368316 48.7380309852390639, 295.0810040310718705 48.7095944639431977, 295.0091863998481472 48.6809554786322849, 294.9373959127930220 48.6522880295360594, 294.8652730269428730 48.6237309200630392, 294.7932479399684667 48.5951308767385797, 294.7213583334407758 48.5664725545892892, 294.6494236802788578 48.5378302049381105, 294.5773206088004486 48.5092633660961496, 294.5054333742040171 48.4806113445442151, 294.4346026686405366 48.4514789854476291, 294.3647067933559924 48.4218794804552743, 294.2947492459967975 48.3922649000824663, 294.2238142620729491 48.3631107066558954, 294.1527610573676839 48.3340145652618460, 294.0815147202526987 48.3050286789722350, 294.0099980936771544 48.2762131959080136, 293.9382460173290497 48.2475698037275080, 293.8668697140522568 48.2187474532939362, 293.7962609736145509 48.1894822988117610, 293.7255394666512416 48.1603063113648275, 293.6547781318735133 48.1311843990246970, 293.5843065515867352 48.1018949307871537, 293.5141586740939488 48.0723985331187009, 293.4444700902735121 48.0425737339503200, 293.3749064547343437 48.0126509102984969, 293.3050575999341731 47.9829593986607890, 293.2352034076224072 47.9532950309601915, 293.1654531168650806 47.9235700964377784, 293.0958477939764748 47.8937448880645533, 293.0263787567034228 47.8638207881203996, 292.9568858384029113 47.8339501037519241, 292.8874362986734923 47.8040757589463183, 292.8180445861410703 47.7741872572646500, 292.7487592169084678 47.7442337012970270, 292.6796079813448159 47.7141793537199916, 292.6105254595862561 47.6840965526444549, 292.5414489407279461 47.6540678195429379, 292.4724300337906016 47.6240374558369268, 292.4035989135194882 47.5938277490541424, 292.3350381260194695 47.5632960657097072, 292.2666059363026534 47.5326200150254294, 292.1981252697848390 47.5020738206643074, 292.1295887369751654 47.4716991949019018, 292.0611460375269530 47.4412605827019220, 291.9928009984063806 47.4107468251615103, 291.9245641102601780 47.3801307584919442, 291.8563543684800266 47.3495759935504452, 291.7882006024591419 47.3190364969257899, 291.7201019385726113 47.2885256469011352, 291.6521393383902705 47.2578461482878325, 291.5843787631462760 47.2267846937686215, 291.5168317396303905 47.1952282052031080, 291.4492464832235896 47.1638894034807024, 291.3816293898299818 47.1328167907642452, 291.3140627606528597 47.1017797901754420, 291.2465582098835739 47.0707529404682532, 291.1791118217741996 47.0397717627595284, 291.1117364145860620 47.0087996190138426, 291.0444662616026221 46.9776521074006155, 290.9772966918184238 46.9463014906870910, 290.9102084353484088 46.9148200635959469, 290.8431866098990213 46.8832984418343415, 290.7762173982538911 46.8519018482588834, 290.7093152517370527 46.8205640770849811, 290.6424914170170837 46.7891699520966071, 290.5757490817570670 46.7575740040825778, 290.5090796708282710 46.7257398497000977, 290.4424748469443784 46.6939354890210154, 290.3759385704620968 46.6621558917914996, 290.3094735853126735 46.6303799301904860, 290.2430782179271773 46.5985395060219361, 290.1767412655061662 46.5665028466696711, 290.1104620752193455 46.5343432693806136, 290.0442657086978215 46.5023241289388807, 289.9781432507954264 46.4703032081830543, 289.9120787066955813 46.4381525977341951, 289.8460907244865439 46.4060177803553273, 289.7802251110452403 46.3741527167005287, 289.7144742069608583 46.3424423196200763, 289.6488095562927469 46.3107023232924249, 289.5832003916290205 46.2787873333416186, 289.5176388907983096 46.2466885757636845, 289.4520462285495341 46.2141017607484343, 289.3864267339227467 46.1811141464289676, 289.3618561776004867 46.1711714273995071, 289.3147779156129218 46.2173242257311614, 289.2682700210863231 46.2625948223290919, 289.2216498274489140 46.3077334989910909, 289.1748745355735650 46.3526214941802124, 289.1280376293947256 46.3975741281184426, 289.0812223379438706 46.4428210011357905, 289.0343472417508792 46.4880973442382484, 288.9874257852919186 46.5334322049573217, 288.9405044417976569 46.5789322394382452, 288.8934837043753419 46.6243341170829027, 288.8463427575331366 46.6695988190028146, 288.7991799003812048 46.7149574330253188, 288.7519302493046780 46.7602581950852993, 288.7044789857983460 46.8052713999669052, 288.6569388683359421 46.8502485880938977, 288.6094424913905527 46.8954406931386885, 288.5620397675693312 46.9409105839929666, 288.5146096371197473 46.9864133831112767, 288.4669533014785543 47.0316098743400701, 288.4189979084742959 47.0764138053209535, 288.3708092782399603 47.1209678506684355, 288.3225205926835883 47.1654960549336408, 288.2743455744467838 47.2103062528499819, 288.2260406104195454 47.2550301230308776, 288.1776038116196332 47.2996724655994498, 288.1290910621896728 47.3443118275832120, 288.0806004866909689 47.3890679637712893, 288.0320864200181177 47.4338721088212836, 287.9835128725551385 47.4786755144914636, 287.9348544417925382 47.5234476156226791, 287.8860935537533692 47.5681703825700382, 287.8372773616805489 47.6128949787879847, 287.7883288015262906 47.6575421974380475, 287.7393085634204795 47.7021757070334687, 287.6902605832405015 47.7468350283393193, 287.6410876324868013 47.7914283366073178, 287.5917481486421821 47.8359242643672431, 287.5423471737791488 47.8804175478147940, 287.4929818798205474 47.9249836617375706, 287.4435300772136657 47.9695183131695515, 287.3939311769159985 48.0139770798353211, 287.3442363755654014 48.0584018935020794, 287.2944182676178571 48.1027748648423952, 287.2447020877938826 48.1472485026180692, 287.1950591428314397 48.1917908022441068, 287.1452952545445783 48.2362713471827362, 287.0953441578890875 48.2806539821297562, 287.0451863503462278 48.3249349211713550, 286.9949077614967337 48.3691695420140064, 286.9444735218841629 48.4133416921263873, 286.8940363669749445 48.4575332864047326, 286.8434760753363548 48.5016805430202851, 286.7926138665326903 48.5457016207637011, 286.7414943640096112 48.5896286026594737, 286.6903929526483807 48.6335896342714165, 286.6393507379582388 48.6775956709724866, 286.5883160953767970 48.7216182199543653, 286.5371352461281163 48.7655935946100314, 286.4858893720233937 48.8095542615773539, 286.4345830897714222 48.8535006122709063, 286.3831420753027146 48.8974063618426840, 286.3313949286018101 48.9412186275038579, 286.2794287606336638 48.9849733476629297, 286.2271237527501171 49.0286407173921361, 286.1747934942748657 49.0723176450905072, 286.1226207794685479 49.1160491477687486, 286.0705778239361052 49.1598179149401204, 286.0185387849462586 49.2035851470715215, 285.9663555293917057 49.2473136664860647, 285.9139828228739475 49.2909956681908312, 285.8615048751227050 49.3346515723928292, 285.8089409308830682 49.3782853448059882, 285.7561709971500932 49.4218750455458391, 285.7033744198886325 49.4654544937027154, 285.6505294182767898 49.5090178755621935, 285.5977727123407135 49.5525837744106425, 285.5447446092979362 49.5960970702829229, 285.4914875549942508 49.6395684556400170, 285.4379846370865152 49.6829997262990304, 285.3843843052756597 49.7264110256648948, 285.3308342690713175 49.7698167182288245, 285.2773646050080174 49.8132152409817408, 285.2239238309639404 49.8565975374196668, 285.1703158928399375 49.8999460743720107, 285.1164481902447960 49.9432567010531869, 285.0625323547681660 49.9865451770147544, 285.0082665476087413 50.0297957865672416, 284.9537084881674787 50.0730166730696595, 284.8991894805907918 50.1162226853946606, 284.8446182125073278 50.1594081318238167, 284.7898601929547908 50.2025694147422996, 284.7349043728681863 50.2457080812009522, 284.6799771552385323 50.2888265780296280, 284.6248540494665917 50.3319228431918049, 284.5695238923811416 50.3749986845891300, 284.5144490571994993 50.4180478736866817, 284.4593856466942725 50.4610690021459973, 284.4040790806055838 50.5040674495806385, 284.3484586308211988 50.5470482927714784, 284.2935341408388581 50.5899723488597601, 284.2391049473005182 50.6328348676932407, 284.1837853403296208 50.6757005534934777, 284.1663273815096318 50.6919534014300766, 284.2345597693270065 50.7277015503154161, 284.3020640473581579 50.7628777224099892, 284.3702656899958470 50.7979746069000484, 284.4387418467628663 50.8330150873104074, 284.5071713340328188 50.8680245376072975, 284.5755687379514143 50.9030045092247363, 284.6443164345435548 50.9379171054902500, 284.7135533824027220 50.9727405217829670, 284.7829461739408430 51.0075059628211491, 284.8521768237749825 51.0422529775025851, 284.9213779308003609 51.0769691887487411, 284.9906032701824756 51.1116495917477351, 285.0598819033065183 51.1462913063788349, 285.1294270280205865 51.1808602737040772, 285.1992202696198433 51.2153549031564808, 285.2689486693911363 51.2498278200912978, 285.3385407699790335 51.2842969395446175, 285.4080991362617965 51.3187480716453166, 285.4778056611060606 51.3531464893620608, 285.5483833920509369 51.3873301698831071, 285.6193015406489053 51.4213979996852473, 285.6897321570879740 51.4555427015166273, 285.7594982587881987 51.4898277189353308, 285.8295266909508996 51.5240324011132174, 285.8995795188444049 51.5582171669147584, 285.9694603052748789 51.5924415814695649, 286.0394555568004762 51.6266293964584264, 286.1098454748561153 51.6606923298506473, 286.1806846868420280 51.6946012555894825, 286.2515634685805139 51.7284818757417852, 286.3217610437835106 51.7625925450240558, 286.3918947636801136 51.7967386371245837, 286.4624479942411881 51.8307423644522842, 286.5336661467025579 51.8644918118881932, 286.6050516772942274 51.8981677383684854, 286.6765569414309311 51.9317872895232000, 286.7481309225292421 51.9653721726498503, 286.8199530521117708 51.9988397589956506, 286.8920127214390163 52.0321867072350770, 286.9640676739491596 52.0655270933311627, 287.0361337373960282 52.0988579772036928, 287.1084521342681342 52.1320521938549248, 287.1808429436290453 52.1652016017904359, 287.2528037265199146 52.1986044777616200, 287.3251766498365214 52.2317791050783669, 287.3976852881675086 52.2648798818484437, 287.4697242670244464 52.2983072795676875, 287.5421226029587842 52.3315320485897573, 287.6148867344307405 52.3645289209294447, 287.6877004396365578 52.3975127478532059, 287.7605440724607888 52.4305033881260840, 287.8332983279560722 52.4636054057247634, 287.9057493954031202 52.4970217668427779, 287.9780316068848265 52.5306795409256608, 288.0504439921309086 52.5643367368246146, 288.1234401644522904 52.5975550143054207, 288.1976382829452064 52.6296474297664219, 288.2721681013861144 52.6613877226737159, 288.3463897438006143 52.6934494034029157, 288.4202322563753569 52.7259736328181674, 288.4939397938130696 52.7587388913465958, 288.5678468760376063 52.7913568215394164, 288.6419218814429541 52.8238536973012103, 288.7165029135949794 52.8557306608363362, 288.7912456624506490 52.8874137480644535, 288.8656727128577586 52.9196471844023790, 288.9400718311589458 52.9520515232037781, 289.0145695908635162 52.9844388557765029, 289.0890412533441349 53.0170554947797967, 289.1635635592601830 53.0497993040304365, 289.2382911325804002 53.0823639878877032, 289.3132195813146836 53.1147272726123987, 289.3882373382535889 53.1471368006245015, 289.4633522768713192 53.1795932616528120, 289.5386395897923535 53.2118916057759463, 289.6140551665824887 53.2441442933252560, 289.6895157143202368 53.2766587857948153, 289.7651099666896926 53.3091747733643402, 289.8409073665112601 53.3413820299417480, 289.9168235491238192 53.3736136015565563, 289.9928758081005071 53.4057942992804442, 290.0690425949051701 53.4380804602550015, 290.1453574173241918 53.4702653414589975, 290.2218095760875372 53.5024220046409624, 290.2983878999274339 53.5347670501741035, 290.3751182413015499 53.5670164502047257, 290.4519987557255263 53.5988030640775577, 290.5290061844957563 53.6305483723634140, 290.6061466002392422 53.6623930165058809, 290.6834140633079642 53.6940874221143645, 290.7608043693315949 53.7256675476979808, 290.8382970713091709 53.7569901973408975, 290.9159587660024044 53.7886645754515271, 290.9938283926157396 53.8207705659212365, 291.0717891428241728 53.8524693735371756, 291.1498394700072367 53.8838731934801629, 291.2279334662110841 53.9148453185582071, 291.3061172279390689 53.9456783680282825, 291.3844357241167131 53.9765654329084370, 291.4627282140606894 54.0069110349376871, 291.5408564454050975 54.0363542888421122, 291.6190588029043624 54.0657945141910190, 291.6482444065063646 54.0748894594413585)))" -wkt from cube == wkt from geometry? true +wkt from cube == wkt from geometry? false GEOSGeometry from cube is preserved. ============================================================================== @@ -18,7 +18,7 @@ wkb from clone == wkb from original geometry? true ============================================================================== -wkt from cube == new wkt, set to destroy the geometry? true +wkt from cube == new wkt, set to destroy the geometry? false wkb from original geometry == new wkb, set to destroy the geometry? true ============================================================================== diff --git a/isis/src/base/objs/GridPolygonSeeder/GridPolygonSeeder.cpp b/isis/src/base/objs/GridPolygonSeeder/GridPolygonSeeder.cpp index c12c7f2ffbb6e1c6c890f2a723bd5eea0d502998..7c4abe5265f620e8efd22ea7e354b89e04ab33bc 100644 --- a/isis/src/base/objs/GridPolygonSeeder/GridPolygonSeeder.cpp +++ b/isis/src/base/objs/GridPolygonSeeder/GridPolygonSeeder.cpp @@ -97,10 +97,10 @@ namespace Isis { for(double y = dRealMinY; y <= polyBoundBox->getMaxY(); y += p_Yspacing) { for(double x = dRealMinX; x <= polyBoundBox->getMaxX(); x += p_Xspacing) { geos::geom::Coordinate c(x, y); - geos::geom::Point *p = Isis::globalFactory->createPoint(c); + geos::geom::Point *p = Isis::globalFactory->createPoint(c).release(); if(p->within(multiPoly)) { - points.push_back(Isis::globalFactory->createPoint(c)); + points.push_back(Isis::globalFactory->createPoint(c).release()); } else { delete p; @@ -224,7 +224,7 @@ namespace Isis { throw iException::Message(iException::Programmer, msg, _FILEINFO_); }*/ points.push_back(Isis::globalFactory->createPoint( - geos::geom::Coordinate(p->getX(), p->getY()))); + geos::geom::Coordinate(p->getX(), p->getY())).release()); // We found something new and need a new pass bGridCleared = false; @@ -359,9 +359,9 @@ namespace Isis { double xPos = centerX + (x - gridSize / 2) * deltaXSize; double yPos = centerY + (y - gridSize / 2) * deltaYSize; geos::geom::Coordinate c(xPos, yPos); - geos::geom::Point *p = Isis::globalFactory->createPoint(c); + geos::geom::Point *p = Isis::globalFactory->createPoint(c).release(); if(p->within(&xymp)) { - result = p; + result = p->clone().release(); } else { delete p; diff --git a/isis/src/base/objs/GridPolygonSeeder/GridPolygonSeeder.truth b/isis/src/base/objs/GridPolygonSeeder/GridPolygonSeeder.truth index 4a62473b66601668dc5563f03b0b7f1accefb930..c45b9aa5d613e0efa4a7ff62ae0a6d7b3b0b939a 100644 --- a/isis/src/base/objs/GridPolygonSeeder/GridPolygonSeeder.truth +++ b/isis/src/base/objs/GridPolygonSeeder/GridPolygonSeeder.truth @@ -16,7 +16,7 @@ MinimumThickness = 0.3 MinimumArea = 10 SubGrid = 0 Test 2, test a square polygon -Lon/Lat polygon = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 0.5000000000000000, 0.5000000000000000 0.5000000000000000, 0.5000000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000))) +Lon/Lat polygon = MULTIPOLYGON (((0 0, 0 0.5, 0.5 0.5, 0.5 0, 0 0))) POINT (0.02224207650506 0.02224524784625) POINT (0.04754798569954 0.02224524784625) POINT (0.07285389489402 0.02224524784625) @@ -379,7 +379,7 @@ Lon/Lat polygon = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.00000 POINT (0.4524582278505 0.4777515790154) POINT (0.4777650148962 0.4777515790154) Test 3, test for too thin -Lon/Lat polygon = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 0.5000000000000000, 0.0125000000000000 0.5000000000000000, 0.0125000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000))) +Lon/Lat polygon = MULTIPOLYGON (((0 0, 0 0.5, 0.0125 0.5, 0.0125 0, 0 0))) Test with subgrid Object = AutoSeed Group = PolygonSeederAlgorithm @@ -398,7 +398,7 @@ MinimumThickness = 0.3 MinimumArea = 10 SubGrid = 1 Test 2, test a square polygon -Lon/Lat polygon = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 0.5000000000000000, 0.5000000000000000 0.5000000000000000, 0.5000000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000))) +Lon/Lat polygon = MULTIPOLYGON (((0 0, 0 0.5, 0.5 0.5, 0.5 0, 0 0))) POINT (0.02224207650506 0.02224524784625) POINT (0.04754798569954 0.02224524784625) POINT (0.07285389489402 0.02224524784625) @@ -841,4 +841,4 @@ Lon/Lat polygon = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.00000 POINT (0.4746030034876 0.4967310094807) POINT (0.4999098618236 0.4967310094807) Test 3, test for too thin -Lon/Lat polygon = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 0.5000000000000000, 0.0125000000000000 0.5000000000000000, 0.0125000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000))) +Lon/Lat polygon = MULTIPOLYGON (((0 0, 0 0.5, 0.0125 0.5, 0.0125 0, 0 0))) diff --git a/isis/src/base/objs/GridPolygonSeeder/unitTest.cpp b/isis/src/base/objs/GridPolygonSeeder/unitTest.cpp index 17c39341707d56aeb5b4ce22eaaf69ef5f48e0ff..ebe7db51c275a7c1a085ab4de48ca80bccc6357d 100644 --- a/isis/src/base/objs/GridPolygonSeeder/unitTest.cpp +++ b/isis/src/base/objs/GridPolygonSeeder/unitTest.cpp @@ -9,7 +9,7 @@ find files of those names at the top level of this repository. **/ #include <cmath> #include <iomanip> -#include "geos/geom/CoordinateArraySequence.h" +#include "geos/geom/CoordinateSequence.h" #include "geos/geom/Geometry.h" #include "geos/geom/Polygon.h" @@ -68,21 +68,20 @@ int main() { cout << "Test 2, test a square polygon" << endl; try { // Call the seed member with a polygon - geos::geom::CoordinateArraySequence *pts; - auto *polys = new vector<geos::geom::Geometry *>; + geos::geom::CoordinateSequence pts; + vector<const geos::geom::Geometry *> polys; // Create the A polygon - pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(0, 0)); - pts->add(geos::geom::Coordinate(0, 0.5)); - pts->add(geos::geom::Coordinate(0.5, 0.5)); - pts->add(geos::geom::Coordinate(0.5, 0)); - pts->add(geos::geom::Coordinate(0, 0)); + pts.add(geos::geom::Coordinate(0, 0)); + pts.add(geos::geom::Coordinate(0, 0.5)); + pts.add(geos::geom::Coordinate(0.5, 0.5)); + pts.add(geos::geom::Coordinate(0.5, 0)); + pts.add(geos::geom::Coordinate(0, 0)); - polys->push_back(Isis::globalFactory->createPolygon( - Isis::globalFactory->createLinearRing(pts), NULL)); + polys.push_back(Isis::globalFactory->createPolygon( + Isis::globalFactory->createLinearRing(pts)).release()); - geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(polys); + geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(polys).release(); cout << "Lon/Lat polygon = " << mp->toString() << endl; // Create the projection necessary for seeding @@ -109,7 +108,7 @@ int main() { if(proj->SetCoordinate(seedValues[pt]->getX(), seedValues[pt]->getY())) { points.push_back(Isis::globalFactory->createPoint( geos::geom::Coordinate(proj->UniversalLongitude(), - proj->UniversalLatitude()))); + proj->UniversalLatitude())).release()); } else { IString msg = "Unable to convert to a (lon,lat)"; @@ -130,21 +129,20 @@ int main() { cout << "Test 3, test for too thin" << endl; try { // Call the seed member with a polygon - geos::geom::CoordinateArraySequence *pts; - auto *polys = new vector<geos::geom::Geometry *>; + geos::geom::CoordinateSequence pts; + vector <const geos::geom::Geometry *> polys; // Create the A polygon - pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(0, 0)); - pts->add(geos::geom::Coordinate(0, 0.5)); - pts->add(geos::geom::Coordinate(0.0125, 0.5)); - pts->add(geos::geom::Coordinate(0.0125, 0)); - pts->add(geos::geom::Coordinate(0, 0)); + pts.add(geos::geom::Coordinate(0, 0)); + pts.add(geos::geom::Coordinate(0, 0.5)); + pts.add(geos::geom::Coordinate(0.0125, 0.5)); + pts.add(geos::geom::Coordinate(0.0125, 0)); + pts.add(geos::geom::Coordinate(0, 0)); - polys->push_back(Isis::globalFactory->createPolygon( - Isis::globalFactory->createLinearRing(pts), NULL)); + polys.push_back(Isis::globalFactory->createPolygon( + Isis::globalFactory->createLinearRing(pts)).release()); - geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(polys); + geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(polys).release(); cout << "Lon/Lat polygon = " << mp->toString() << endl; diff --git a/isis/src/base/objs/ImageOverlap/ImageOverlap.truth b/isis/src/base/objs/ImageOverlap/ImageOverlap.truth index 66d7aafd3b99da6103ec4d891c4425dbdea4ff46..298c53f1afe2d7b293788af1a0d5d326dee6ad25 100644 --- a/isis/src/base/objs/ImageOverlap/ImageOverlap.truth +++ b/isis/src/base/objs/ImageOverlap/ImageOverlap.truth @@ -2,7 +2,7 @@ One ---------------------------------------------- Original coordinates: (0 0, 0 10, 5 15, 8 -5, 0 0) Well Known Text version of the multi polygon -MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 10.0000000000000000, 5.0000000000000000 15.0000000000000000, 8.0000000000000000 -5.0000000000000000, 0.0000000000000000 0.0000000000000000))) +MULTIPOLYGON (((0 0, 0 10, 5 15, 8 -5, 0 0))) Area of the polygon 97.5 Number of serial numbers: 1 @@ -11,7 +11,7 @@ Serial numbers: Two ---------------------------------------------- Well Known Text version of the multi polygon -MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 10.0000000000000000, 5.0000000000000000 15.0000000000000000, 8.0000000000000000 -5.0000000000000000, 0.0000000000000000 0.0000000000000000))) +MULTIPOLYGON (((0 0, 0 10, 5 15, 8 -5, 0 0))) Area of the polygon 97.5 Number of serial numbers: 4 @@ -23,7 +23,7 @@ Serial numbers: Three -------------------------------------------- Well Known Text version of the multi polygon -MULTIPOLYGON (((0.1234567890000000 0.1234567890000000, 0.1234567890000000 10.1234567890000005, 5.1234567889999996 15.1234567890000005, 8.1234567890000005 -5.1234567889999996, 0.1234567890000000 0.1234567890000000))) +MULTIPOLYGON (((0.123456789 0.123456789, 0.123456789 10.123456789, 5.123456789 15.123456789, 8.123456789 -5.123456789, 0.123456789 0.123456789))) Area of the polygon 98.1173 Number of serial numbers: 4 @@ -34,7 +34,7 @@ Serial numbers: sn4 Well Known Text version of the multi polygon -MULTIPOLYGON (((10.1234567890000005 10.1234567890000005, 10.1234567890000005 110.1234567890000022, 15.1234567890000005 115.1234567890000022, 18.1234567889999987 -15.1234567890000005, 10.1234567890000005 10.1234567890000005))) +MULTIPOLYGON (((10.123456789 10.123456789, 10.123456789 110.123456789, 15.123456789 115.123456789, 18.123456789 -15.123456789, 10.123456789 10.123456789))) Area of the polygon 733.117 Number of serial numbers: 4 @@ -46,7 +46,7 @@ Serial numbers: Four --------------------------------------------- Well Known Text version of the multi polygon -MULTIPOLYGON (((0.1234567890000000 0.1234567890000000, 0.1234567890000000 10.1234567890000005, 5.1234567889999996 15.1234567890000005, 8.1234567890000005 -5.1234567889999996, 0.1234567890000000 0.1234567890000000))) +MULTIPOLYGON (((0.123456789 0.123456789, 0.123456789 10.123456789, 5.123456789 15.123456789, 8.123456789 -5.123456789, 0.123456789 0.123456789))) Area of the polygon 98.1173 Number of serial numbers: 1 diff --git a/isis/src/base/objs/ImageOverlap/unitTest.cpp b/isis/src/base/objs/ImageOverlap/unitTest.cpp index 43a2f963981792c206ebf7dcdfba8c4d892b90f6..bddc2de71241b72c0ae25da0137574c33fac922a 100644 --- a/isis/src/base/objs/ImageOverlap/unitTest.cpp +++ b/isis/src/base/objs/ImageOverlap/unitTest.cpp @@ -7,7 +7,6 @@ find files of those names at the top level of this repository. **/ #include <iostream> #include <geos/geom/CoordinateSequence.h> -#include <geos/geom/CoordinateArraySequence.h> #include <geos/geom/Polygon.h> #include <geos/geom/MultiPolygon.h> #include <geos/util/GEOSException.h> @@ -28,27 +27,27 @@ int main() { cout << "One ----------------------------------------------" << endl; // Create coordinate sequence so we can later create a multi polygon - geos::geom::CoordinateArraySequence *pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(0, 0)); - pts->add(geos::geom::Coordinate(0, 10)); - pts->add(geos::geom::Coordinate(5, 15)); - pts->add(geos::geom::Coordinate(8, -5)); - pts->add(geos::geom::Coordinate(0, 0)); + geos::geom::CoordinateSequence pts; + pts.add(geos::geom::Coordinate(0, 0)); + pts.add(geos::geom::Coordinate(0, 10)); + pts.add(geos::geom::Coordinate(5, 15)); + pts.add(geos::geom::Coordinate(8, -5)); + pts.add(geos::geom::Coordinate(0, 0)); // Write the original coordinates to the screen cout << "Original coordinates:" << endl; - cout << pts->toString() << endl; + cout << pts.toString() << endl; // Create a multi polygon - vector<const geos::geom::Geometry *> polys; + vector <const geos::geom::Geometry *> polys; polys.push_back(globalFactory->createPolygon( - globalFactory->createLinearRing(pts), NULL)); - geos::geom::MultiPolygon *mPolygon = globalFactory->createMultiPolygon(polys); + globalFactory->createLinearRing(pts)).release()); + geos::geom::MultiPolygon *mPolygon = globalFactory->createMultiPolygon(polys).release(); // Add more coordinates so we can make sure we did a deep copy when we // created the multipolygon - pts->add(geos::geom::Coordinate(-1, -1)); - pts->add(geos::geom::Coordinate(-2, -2)); + pts.add(geos::geom::Coordinate(-1, -1)); + pts.add(geos::geom::Coordinate(-2, -2)); ImageOverlap a("idOne", *mPolygon); @@ -67,18 +66,18 @@ int main() { // Create a new multipolygon and test the SetPolygon method cout << "Three --------------------------------------------" << endl; - geos::geom::CoordinateArraySequence *pts3 = new geos::geom::CoordinateArraySequence(); - pts3->add(geos::geom::Coordinate(0.123456789, 0.123456789)); - pts3->add(geos::geom::Coordinate(0.123456789, 10.123456789)); - pts3->add(geos::geom::Coordinate(5.123456789, 15.123456789)); - pts3->add(geos::geom::Coordinate(8.123456789, -5.123456789)); - pts3->add(geos::geom::Coordinate(0.123456789, 0.123456789)); + geos::geom::CoordinateSequence pts3; + pts3.add(geos::geom::Coordinate(0.123456789, 0.123456789)); + pts3.add(geos::geom::Coordinate(0.123456789, 10.123456789)); + pts3.add(geos::geom::Coordinate(5.123456789, 15.123456789)); + pts3.add(geos::geom::Coordinate(8.123456789, -5.123456789)); + pts3.add(geos::geom::Coordinate(0.123456789, 0.123456789)); try { - vector<const geos::geom::Geometry *> polys3; + vector <const geos::geom::Geometry *> polys3; polys3.push_back(globalFactory->createPolygon( - globalFactory->createLinearRing(pts3), NULL)); - geos::geom::MultiPolygon *mPolygon3 = globalFactory->createMultiPolygon(polys3); + globalFactory->createLinearRing(pts3)).release()); + geos::geom::MultiPolygon *mPolygon3 = globalFactory->createMultiPolygon(polys3).release(); a.SetPolygon(*mPolygon3); delete mPolygon3; } @@ -90,18 +89,18 @@ int main() { PrintImageOverlap(a); - geos::geom::CoordinateArraySequence *pts4 = new geos::geom::DefaultCoordinateSequence(); - pts4->add(geos::geom::Coordinate(10.123456789, 10.123456789)); - pts4->add(geos::geom::Coordinate(10.123456789, 110.123456789)); - pts4->add(geos::geom::Coordinate(15.123456789, 115.123456789)); - pts4->add(geos::geom::Coordinate(18.123456789, -15.123456789)); - pts4->add(geos::geom::Coordinate(10.123456789, 10.123456789)); + geos::geom::CoordinateSequence pts4; + pts4.add(geos::geom::Coordinate(10.123456789, 10.123456789)); + pts4.add(geos::geom::Coordinate(10.123456789, 110.123456789)); + pts4.add(geos::geom::Coordinate(15.123456789, 115.123456789)); + pts4.add(geos::geom::Coordinate(18.123456789, -15.123456789)); + pts4.add(geos::geom::Coordinate(10.123456789, 10.123456789)); try { vector<const geos::geom::Geometry *> polys4; polys4.push_back(globalFactory->createPolygon( - globalFactory->createLinearRing(pts4), NULL)); - geos::geom::MultiPolygon *mPolygon4 = globalFactory->createMultiPolygon(polys4); + globalFactory->createLinearRing(pts4)).release()); + geos::geom::MultiPolygon *mPolygon4 = globalFactory->createMultiPolygon(polys4).release(); a.SetPolygon(mPolygon4); delete mPolygon4; } @@ -118,19 +117,19 @@ int main() { { // cout << "Four ---------------------------------------------" << endl; - geos::geom::CoordinateArraySequence *pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(0.123456789, 0.123456789)); - pts->add(geos::geom::Coordinate(0.123456789, 10.123456789)); - pts->add(geos::geom::Coordinate(5.123456789, 15.123456789)); - pts->add(geos::geom::Coordinate(8.123456789, -5.123456789)); - pts->add(geos::geom::Coordinate(0.123456789, 0.123456789)); + geos::geom::CoordinateSequence pts; + pts.add(geos::geom::Coordinate(0.123456789, 0.123456789)); + pts.add(geos::geom::Coordinate(0.123456789, 10.123456789)); + pts.add(geos::geom::Coordinate(5.123456789, 15.123456789)); + pts.add(geos::geom::Coordinate(8.123456789, -5.123456789)); + pts.add(geos::geom::Coordinate(0.123456789, 0.123456789)); try { - vector<const geos::geom::Geometry *> polys; + vector <const geos::geom::Geometry *> polys; polys.push_back(globalFactory->createPolygon( - globalFactory->createLinearRing(pts), NULL)); + globalFactory->createLinearRing(pts)).release()); - geos::geom::MultiPolygon *mPolygon = globalFactory->createMultiPolygon(polys); + geos::geom::MultiPolygon *mPolygon = globalFactory->createMultiPolygon(polys).release(); ImageOverlap a("idFour", *mPolygon); PrintImageOverlap(a); diff --git a/isis/src/base/objs/ImageOverlapSet/ImageOverlapSet.cpp b/isis/src/base/objs/ImageOverlapSet/ImageOverlapSet.cpp index 0125145091d979d1b150ac2cce541955893fb924..a21c572849147bd70b5b7461572a4a574e81e2fb 100644 --- a/isis/src/base/objs/ImageOverlapSet/ImageOverlapSet.cpp +++ b/isis/src/base/objs/ImageOverlapSet/ImageOverlapSet.cpp @@ -17,7 +17,7 @@ find files of those names at the top level of this repository. **/ #include "geos/util/IllegalArgumentException.h" #include "geos/geom/Point.h" //#include "geos/opOverlay.h" -#include "geos/operation/overlay/OverlayOp.h" +#include "geos/operation/overlay/snap/SnapOverlayOp.h" #include "IException.h" #include "ImageOverlapSet.h" diff --git a/isis/src/base/objs/ImageOverlapSet/ImageOverlapSet.truth b/isis/src/base/objs/ImageOverlapSet/ImageOverlapSet.truth index 0b857437b911eaded9b5f988a2d62e65af81960d..095125633bb45165498d3090718efd7bfaff8a6a 100644 --- a/isis/src/base/objs/ImageOverlapSet/ImageOverlapSet.truth +++ b/isis/src/base/objs/ImageOverlapSet/ImageOverlapSet.truth @@ -1,44 +1,44 @@ Test 1 Well Known Text - MULTIPOLYGON (((1.0000000000000000 9.0000000000000000, 3.0000000000000000 9.0000000000000000, 3.0000000000000000 7.0000000000000000, 5.0000000000000000 7.0000000000000000, 5.0000000000000000 4.0000000000000000, 1.0000000000000000 4.0000000000000000, 1.0000000000000000 9.0000000000000000))) + MULTIPOLYGON (((3 7, 5 7, 5 4, 1 4, 1 9, 3 9, 3 7))) Number of serial numbers: 1 Serial numbers: A Well Known Text - MULTIPOLYGON (((3.0000000000000000 10.0000000000000000, 12.0000000000000000 10.0000000000000000, 12.0000000000000000 9.0000000000000000, 11.0000000000000000 9.0000000000000000, 11.0000000000000000 8.0000000000000000, 6.0000000000000000 8.0000000000000000, 6.0000000000000000 9.0000000000000000, 3.0000000000000000 9.0000000000000000, 3.0000000000000000 10.0000000000000000))) + MULTIPOLYGON (((11 9, 11 8, 6 8, 6 9, 3 9, 3 10, 12 10, 12 9, 11 9))) Number of serial numbers: 1 Serial numbers: B Well Known Text - MULTIPOLYGON (((5.0000000000000000 7.0000000000000000, 3.0000000000000000 7.0000000000000000, 3.0000000000000000 9.0000000000000000, 6.0000000000000000 9.0000000000000000, 6.0000000000000000 8.0000000000000000, 5.0000000000000000 8.0000000000000000, 5.0000000000000000 7.0000000000000000))) + MULTIPOLYGON (((3 9, 6 9, 6 8, 5 8, 5 7, 3 7, 3 9))) Number of serial numbers: 2 Serial numbers: A B Well Known Text - MULTIPOLYGON (((12.0000000000000000 8.0000000000000000, 12.0000000000000000 9.0000000000000000, 15.0000000000000000 9.0000000000000000, 15.0000000000000000 5.0000000000000000, 14.0000000000000000 5.0000000000000000, 14.0000000000000000 8.0000000000000000, 12.0000000000000000 8.0000000000000000))) + MULTIPOLYGON (((12 9, 15 9, 15 5, 14 5, 14 8, 12 8, 12 9))) Number of serial numbers: 1 Serial numbers: C Well Known Text - MULTIPOLYGON (((11.0000000000000000 8.0000000000000000, 11.0000000000000000 9.0000000000000000, 12.0000000000000000 9.0000000000000000, 12.0000000000000000 8.0000000000000000, 11.0000000000000000 8.0000000000000000))) + MULTIPOLYGON (((12 9, 12 8, 11 8, 11 9, 12 9))) Number of serial numbers: 2 Serial numbers: B C Well Known Text - MULTIPOLYGON (((14.0000000000000000 5.0000000000000000, 14.0000000000000000 2.0000000000000000, 5.0000000000000000 2.0000000000000000, 5.0000000000000000 4.0000000000000000, 6.0000000000000000 4.0000000000000000, 6.0000000000000000 7.0000000000000000, 11.0000000000000000 7.0000000000000000, 11.0000000000000000 6.0000000000000000, 10.0000000000000000 6.0000000000000000, 10.0000000000000000 4.0000000000000000, 13.0000000000000000 4.0000000000000000, 13.0000000000000000 5.0000000000000000, 14.0000000000000000 5.0000000000000000))) + MULTIPOLYGON (((14 5, 14 2, 5 2, 5 4, 6 4, 6 7, 11 7, 11 6, 10 6, 10 4, 13 4, 13 5, 14 5))) Number of serial numbers: 1 Serial numbers: D Well Known Text - MULTIPOLYGON (((11.0000000000000000 8.0000000000000000, 12.0000000000000000 8.0000000000000000, 12.0000000000000000 7.0000000000000000, 11.0000000000000000 7.0000000000000000, 11.0000000000000000 8.0000000000000000))) + MULTIPOLYGON (((12 8, 12 7, 11 7, 11 8, 12 8))) Number of serial numbers: 3 Serial numbers: B @@ -46,14 +46,14 @@ Well Known Text D Well Known Text - MULTIPOLYGON (((14.0000000000000000 8.0000000000000000, 14.0000000000000000 5.0000000000000000, 13.0000000000000000 5.0000000000000000, 13.0000000000000000 6.0000000000000000, 11.0000000000000000 6.0000000000000000, 11.0000000000000000 7.0000000000000000, 12.0000000000000000 7.0000000000000000, 12.0000000000000000 8.0000000000000000, 14.0000000000000000 8.0000000000000000))) + MULTIPOLYGON (((12 8, 14 8, 14 5, 13 5, 13 6, 11 6, 11 7, 12 7, 12 8))) Number of serial numbers: 2 Serial numbers: C D Well Known Text - MULTIPOLYGON (((5.0000000000000000 7.0000000000000000, 5.0000000000000000 8.0000000000000000, 6.0000000000000000 8.0000000000000000, 6.0000000000000000 7.0000000000000000, 5.0000000000000000 7.0000000000000000))) + MULTIPOLYGON (((5 8, 6 8, 6 7, 5 7, 5 8))) Number of serial numbers: 3 Serial numbers: A @@ -61,28 +61,28 @@ Well Known Text D Well Known Text - MULTIPOLYGON (((6.0000000000000000 7.0000000000000000, 6.0000000000000000 8.0000000000000000, 11.0000000000000000 8.0000000000000000, 11.0000000000000000 7.0000000000000000, 6.0000000000000000 7.0000000000000000))) + MULTIPOLYGON (((6 8, 11 8, 11 7, 6 7, 6 8))) Number of serial numbers: 2 Serial numbers: B D Well Known Text - MULTIPOLYGON (((5.0000000000000000 4.0000000000000000, 5.0000000000000000 7.0000000000000000, 6.0000000000000000 7.0000000000000000, 6.0000000000000000 4.0000000000000000, 5.0000000000000000 4.0000000000000000))) + MULTIPOLYGON (((5 7, 6 7, 6 4, 5 4, 5 7))) Number of serial numbers: 2 Serial numbers: A D Well Known Text - MULTIPOLYGON (((10.0000000000000000 6.0000000000000000, 11.0000000000000000 6.0000000000000000, 11.0000000000000000 5.0000000000000000, 13.0000000000000000 5.0000000000000000, 13.0000000000000000 4.0000000000000000, 10.0000000000000000 4.0000000000000000, 10.0000000000000000 6.0000000000000000))) + MULTIPOLYGON (((11 6, 11 5, 13 5, 13 4, 10 4, 10 6, 11 6))) Number of serial numbers: 2 Serial numbers: E D Well Known Text - MULTIPOLYGON (((11.0000000000000000 6.0000000000000000, 13.0000000000000000 6.0000000000000000, 13.0000000000000000 5.0000000000000000, 11.0000000000000000 5.0000000000000000, 11.0000000000000000 6.0000000000000000))) + MULTIPOLYGON (((13 6, 13 5, 11 5, 11 6, 13 6))) Number of serial numbers: 3 Serial numbers: C @@ -90,7 +90,7 @@ Well Known Text E Well Known Text - MULTIPOLYGON (((1.0000000000000000 1.0000000000000000, 1.0000000000000000 2.0000000000000000, 4.0000000000000000 2.0000000000000000, 4.0000000000000000 1.0000000000000000, 1.0000000000000000 1.0000000000000000))) + MULTIPOLYGON (((1 1, 1 2, 4 2, 4 1, 1 1))) Number of serial numbers: 1 Serial numbers: F diff --git a/isis/src/base/objs/ImageOverlapSet/unitTest.cpp b/isis/src/base/objs/ImageOverlapSet/unitTest.cpp index d18568a89aef4f79c41966e2b8ee7cee84409642..1c101cbe0506ea99baced778f9521379a3c36c2a 100644 --- a/isis/src/base/objs/ImageOverlapSet/unitTest.cpp +++ b/isis/src/base/objs/ImageOverlapSet/unitTest.cpp @@ -10,7 +10,7 @@ find files of those names at the top level of this repository. **/ #include <geos/util/GEOSException.h> #include <geos/geom/Polygon.h> #include <geos/geom/LinearRing.h> -#include <geos/geom/CoordinateArraySequence.h> +#include <geos/geom/CoordinateSequence.h> #include "IException.h" #include "SerialNumberList.h" @@ -73,104 +73,104 @@ int main() { vector<QString> sns; // Reusable variables - geos::geom::CoordinateArraySequence *pts; + geos::geom::CoordinateSequence pts; vector<const geos::geom::Geometry *> polys; // Create the A polygon - pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(1, 9)); - pts->add(geos::geom::Coordinate(6, 9)); - pts->add(geos::geom::Coordinate(6, 4)); - pts->add(geos::geom::Coordinate(1, 4)); - pts->add(geos::geom::Coordinate(1, 9)); + pts.add(geos::geom::Coordinate(1, 9)); + pts.add(geos::geom::Coordinate(6, 9)); + pts.add(geos::geom::Coordinate(6, 4)); + pts.add(geos::geom::Coordinate(1, 4)); + pts.add(geos::geom::Coordinate(1, 9)); polys.push_back(globalFactory->createPolygon( - globalFactory->createLinearRing(pts), NULL)); + globalFactory->createLinearRing(pts)).release()); - boundaries.push_back(globalFactory->createMultiPolygon(polys)); + boundaries.push_back(globalFactory->createMultiPolygon(polys).release()); for(unsigned int i = 0; i < polys.size(); ++i) delete polys[i]; polys.clear(); + pts.clear(); sns.push_back("A"); // Create the B polygon - pts = new geos::geom::DefaultCoordinateSequence(); - pts->add(geos::geom::Coordinate(3, 10)); - pts->add(geos::geom::Coordinate(12, 10)); - pts->add(geos::geom::Coordinate(12, 7)); - pts->add(geos::geom::Coordinate(3, 7)); - pts->add(geos::geom::Coordinate(3, 10)); + pts.add(geos::geom::Coordinate(3, 10)); + pts.add(geos::geom::Coordinate(12, 10)); + pts.add(geos::geom::Coordinate(12, 7)); + pts.add(geos::geom::Coordinate(3, 7)); + pts.add(geos::geom::Coordinate(3, 10)); polys.push_back(globalFactory->createPolygon( - globalFactory->createLinearRing(pts), NULL)); - boundaries.push_back(globalFactory->createMultiPolygon(polys)); + globalFactory->createLinearRing(pts)).release()); + boundaries.push_back(globalFactory->createMultiPolygon(polys).release()); for(unsigned int i = 0; i < polys.size(); ++i) delete polys[i]; polys.clear(); + pts.clear(); sns.push_back("B"); // Create the C polygon - pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(11, 5)); - pts->add(geos::geom::Coordinate(11, 9)); - pts->add(geos::geom::Coordinate(15, 9)); - pts->add(geos::geom::Coordinate(15, 5)); - pts->add(geos::geom::Coordinate(11, 5)); + pts.add(geos::geom::Coordinate(11, 5)); + pts.add(geos::geom::Coordinate(11, 9)); + pts.add(geos::geom::Coordinate(15, 9)); + pts.add(geos::geom::Coordinate(15, 5)); + pts.add(geos::geom::Coordinate(11, 5)); polys.push_back(globalFactory->createPolygon( - globalFactory->createLinearRing(pts), NULL)); - boundaries.push_back(globalFactory->createMultiPolygon(polys)); + globalFactory->createLinearRing(pts)).release()); + boundaries.push_back(globalFactory->createMultiPolygon(polys).release()); for(unsigned int i = 0; i < polys.size(); ++i) delete polys[i]; polys.clear(); + pts.clear(); sns.push_back("C"); // Create the D polygon - pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(14, 8)); - pts->add(geos::geom::Coordinate(14, 2)); - pts->add(geos::geom::Coordinate(5, 2)); - pts->add(geos::geom::Coordinate(5, 8)); - pts->add(geos::geom::Coordinate(14, 8)); + pts.add(geos::geom::Coordinate(14, 8)); + pts.add(geos::geom::Coordinate(14, 2)); + pts.add(geos::geom::Coordinate(5, 2)); + pts.add(geos::geom::Coordinate(5, 8)); + pts.add(geos::geom::Coordinate(14, 8)); polys.push_back(globalFactory->createPolygon( - globalFactory->createLinearRing(pts), NULL)); - boundaries.push_back(globalFactory->createMultiPolygon(polys)); + globalFactory->createLinearRing(pts)).release()); + boundaries.push_back(globalFactory->createMultiPolygon(polys).release()); for(unsigned int i = 0; i < polys.size(); ++i) delete polys[i]; polys.clear(); + pts.clear(); sns.push_back("D"); // Create the E polygon - pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(10, 6)); - pts->add(geos::geom::Coordinate(13, 6)); - pts->add(geos::geom::Coordinate(13, 4)); - pts->add(geos::geom::Coordinate(10, 4)); - pts->add(geos::geom::Coordinate(10, 6)); + pts.add(geos::geom::Coordinate(10, 6)); + pts.add(geos::geom::Coordinate(13, 6)); + pts.add(geos::geom::Coordinate(13, 4)); + pts.add(geos::geom::Coordinate(10, 4)); + pts.add(geos::geom::Coordinate(10, 6)); polys.push_back(globalFactory->createPolygon( - globalFactory->createLinearRing(pts), NULL)); - boundaries.push_back(globalFactory->createMultiPolygon(polys)); + globalFactory->createLinearRing(pts)).release()); + boundaries.push_back(globalFactory->createMultiPolygon(polys).release()); for(unsigned int i = 0; i < polys.size(); ++i) delete polys[i]; polys.clear(); + pts.clear(); sns.push_back("E"); // Create the F polygon - pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(1, 1)); - pts->add(geos::geom::Coordinate(1, 2)); - pts->add(geos::geom::Coordinate(4, 2)); - pts->add(geos::geom::Coordinate(4, 1)); - pts->add(geos::geom::Coordinate(1, 1)); + pts.add(geos::geom::Coordinate(1, 1)); + pts.add(geos::geom::Coordinate(1, 2)); + pts.add(geos::geom::Coordinate(4, 2)); + pts.add(geos::geom::Coordinate(4, 1)); + pts.add(geos::geom::Coordinate(1, 1)); polys.push_back(globalFactory->createPolygon( - globalFactory->createLinearRing(pts), NULL)); - boundaries.push_back(globalFactory->createMultiPolygon(polys)); + globalFactory->createLinearRing(pts)).release()); + boundaries.push_back(globalFactory->createMultiPolygon(polys).release()); for(unsigned int i = 0; i < polys.size(); ++i) delete polys[i]; polys.clear(); + pts.clear(); sns.push_back("F"); // Create a ImageOverlapSet object with the multipolys and sns from above diff --git a/isis/src/base/objs/ImagePolygon/ImagePolygon.cpp b/isis/src/base/objs/ImagePolygon/ImagePolygon.cpp index 7f21560f671f83fa509f9331006e0449bac0b295..49dddecbf602e5ab5171666ee70808b2482a9e9c 100644 --- a/isis/src/base/objs/ImagePolygon/ImagePolygon.cpp +++ b/isis/src/base/objs/ImagePolygon/ImagePolygon.cpp @@ -13,7 +13,7 @@ find files of those names at the top level of this repository. **/ #include <geos/geom/Geometry.h> #include <geos/geom/Polygon.h> -#include <geos/geom/CoordinateArraySequence.h> +#include <geos/geom/CoordinateSequence.h> #include <geos/algorithm/LineIntersector.h> #include <geos/util/IllegalArgumentException.h> #include <geos/util/TopologyException.h> @@ -67,13 +67,13 @@ namespace Isis { geos::io::WKTReader *wkt = new geos::io::WKTReader(&(*globalFactory)); p_polygons = PolygonTools::MakeMultiPolygon(wkt->read(p_polyStr).release()); - p_pts = new geos::geom::CoordinateArraySequence; + p_pts = new geos::geom::CoordinateSequence; // 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())); + geos::geom::CoordinateSequence coordArray = geos::geom::CoordinateSequence(*(poly->getCoordinates())); for (size_t i = 0; i < coordArray.getSize(); i++) { p_pts->add(geos::geom::Coordinate(coordArray.getAt(i))); } @@ -234,7 +234,7 @@ namespace Isis { p_lineinc = linc; p_pts = NULL; - p_pts = new geos::geom::CoordinateArraySequence(); + p_pts = new geos::geom::CoordinateSequence(); WalkPoly(); @@ -279,17 +279,17 @@ namespace Isis { void ImagePolygon::Create(std::vector<std::vector<double>> polyCoordinates) { - p_pts = new geos::geom::CoordinateArraySequence(); + p_pts = new geos::geom::CoordinateSequence(); for (std::vector<double> coord : polyCoordinates) { p_pts->add(geos::geom::Coordinate(coord[0], coord[1])); } - std::vector<geos::geom::Geometry *> *polys = new std::vector<geos::geom::Geometry *>; - geos::geom::Polygon *poly = globalFactory->createPolygon(globalFactory->createLinearRing(p_pts), nullptr); + std::vector<const geos::geom::Geometry *> *polys = new std::vector<const geos::geom::Geometry *>; + const geos::geom::Polygon *poly = globalFactory->createPolygon(globalFactory->createLinearRing(*p_pts)).release(); polys->push_back(poly->clone().release()); // createMultiPolygon takes ownership of polys argument - p_polygons = globalFactory->createMultiPolygon(polys); + p_polygons = globalFactory->createMultiPolygon(*polys).release(); Fix360Poly(); } @@ -793,7 +793,7 @@ namespace Isis { // Checks for self-intersection and attempts to correct - geos::geom::CoordinateArraySequence *tempPts = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence *tempPts = new geos::geom::CoordinateSequence(); // 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)); @@ -803,7 +803,7 @@ namespace Isis { tempPts->add(geos::geom::Coordinate((*p_pts)[0].x, (*p_pts)[0].y)); geos::geom::Polygon *tempPoly = globalFactory->createPolygon - (globalFactory->createLinearRing(tempPts), NULL); + (globalFactory->createLinearRing(*tempPts)).release(); // Remove the last point of the sequence if it produces invalid polygons if (!tempPoly->isValid()) { @@ -985,7 +985,7 @@ namespace Isis { } // split image at the pole - geos::geom::CoordinateArraySequence *new_points = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence *new_points = new geos::geom::CoordinateSequence(); for (unsigned int i = 0; i < p_pts->size(); i++) { geos::geom::Coordinate temp = p_pts->getAt(i); new_points->add(temp); @@ -1142,7 +1142,7 @@ namespace Isis { bool convertLon = false; bool negAdjust = false; bool newCoords = false; // coordinates have been adjusted - geos::geom::CoordinateArraySequence *newLonLatPts = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence *newLonLatPts = new geos::geom::CoordinateSequence(); double lon, lat; double lonOffset = 0; double prevLon = p_pts->getAt(0).x; @@ -1195,7 +1195,7 @@ namespace Isis { // Nothing was done so return if (!newCoords) { geos::geom::Polygon *newPoly = globalFactory->createPolygon - (globalFactory->createLinearRing(newLonLatPts), NULL); + (globalFactory->createLinearRing(*newLonLatPts)).release(); p_polygons = PolygonTools::MakeMultiPolygon(newPoly); delete newLonLatPts; return; @@ -1204,10 +1204,10 @@ namespace Isis { // bisect into seperate polygons try { geos::geom::Polygon *newPoly = globalFactory->createPolygon - (globalFactory->createLinearRing(newLonLatPts), NULL); + (globalFactory->createLinearRing(*newLonLatPts)).release(); - geos::geom::CoordinateArraySequence *pts = new geos::geom::CoordinateArraySequence(); - geos::geom::CoordinateArraySequence *pts2 = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence *pts = new geos::geom::CoordinateSequence(); + geos::geom::CoordinateSequence *pts2 = new geos::geom::CoordinateSequence(); // Depending on direction of compensation bound accordingly //*************************************************** @@ -1252,9 +1252,9 @@ namespace Isis { } geos::geom::Polygon *boundaryPoly = globalFactory->createPolygon - (globalFactory->createLinearRing(pts), NULL); + (globalFactory->createLinearRing(*pts)).release(); geos::geom::Polygon *boundaryPoly2 = globalFactory->createPolygon - (globalFactory->createLinearRing(pts2), NULL); + (globalFactory->createLinearRing(*pts2)).release(); /*------------------------------------------------------------------------ / Intersecting the original polygon (converted coordinates) with the / boundary polygons will create the multi polygons with the converted coordinates. @@ -1273,16 +1273,16 @@ namespace Isis { / the 0-360 world. This will always only need to be done on convertPoly. / Then add geometries to finalpolys. /-----------------------------------------------------------------------*/ - vector<geos::geom::Geometry *> *finalpolys = new vector<geos::geom::Geometry *>; - geos::geom::Geometry *newGeom = NULL; + std::vector<const geos::geom::Geometry *> *finalpolys = new std::vector<const geos::geom::Geometry *>; + const geos::geom::Geometry *newGeom = NULL; - for (unsigned int i = 0; i < convertPoly->getNumGeometries(); i++) { + for (size_t i = 0; i < convertPoly->getNumGeometries(); i++) { newGeom = (convertPoly->getGeometryN(i))->clone().release(); geos::geom::CoordinateSequence *pts3 = convertPoly->getGeometryN(i)->getCoordinates().release(); - geos::geom::CoordinateArraySequence *newLonLatPts = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence *newLonLatPts = new geos::geom::CoordinateSequence(); // fix the points - for (unsigned int k = 0; k < pts3->getSize() ; k++) { + for (size_t k = 0; k < pts3->getSize() ; k++) { double lon = pts3->getAt(k).x; double lat = pts3->getAt(k).y; if (negAdjust) { @@ -1296,7 +1296,7 @@ namespace Isis { } // Add the points to polys finalpolys->push_back(globalFactory->createPolygon - (globalFactory->createLinearRing(newLonLatPts), NULL)); + (globalFactory->createLinearRing(*newLonLatPts)).release()); } // This loop is over polygons that will always be in 0-360 space no need to convert @@ -1305,7 +1305,7 @@ namespace Isis { finalpolys->push_back(newGeom); } - p_polygons = globalFactory->createMultiPolygon(finalpolys); + p_polygons = globalFactory->createMultiPolygon(*finalpolys).release(); delete newLonLatPts; delete pts; @@ -1349,13 +1349,14 @@ namespace Isis { * @return @b Blob */ Blob ImagePolygon::toBlob() const { - geos::io::WKTWriter *wkt = new geos::io::WKTWriter(); - // Check to see p_polygons is valid data if (!p_polygons) { string msg = "Cannot write a NULL polygon!"; throw IException(IException::Programmer, msg, _FILEINFO_); } + + geos::io::WKTWriter *wkt = new geos::io::WKTWriter(); + wkt->setTrim(true); string polyStr = wkt->write(p_polygons); delete wkt; diff --git a/isis/src/base/objs/ImagePolygon/ImagePolygon.h b/isis/src/base/objs/ImagePolygon/ImagePolygon.h index acc4328367cf2451fc283c08982d9f606ad41aea..74ba76c07c724d50708e128c52ef05602dfbd036 100644 --- a/isis/src/base/objs/ImagePolygon/ImagePolygon.h +++ b/isis/src/base/objs/ImagePolygon/ImagePolygon.h @@ -21,7 +21,7 @@ find files of those names at the top level of this repository. **/ #include "Blob.h" #include "geos/geom/Coordinate.h" #include "geos/geom/MultiPolygon.h" -#include "geos/geom/CoordinateArraySequence.h" +#include "geos/geom/CoordinateSequence.h" namespace Isis { @@ -155,6 +155,7 @@ namespace Isis { public: ImagePolygon(); ImagePolygon(Blob &blob); + ImagePolygon(const ImagePolygon &other); ~ImagePolygon(); void Create(Cube &cube, int sinc = 1, int linc = 1, @@ -269,7 +270,7 @@ namespace Isis { Brick *p_brick; //!< Used to check for valid DNs - geos::geom::CoordinateArraySequence *p_pts; //!< The sequence of coordinates that compose the boundary of the image + geos::geom::CoordinateSequence *p_pts; //!< The sequence of coordinates that compose the boundary of the image geos::geom::MultiPolygon *p_polygons; //!< The multipolygon of the image diff --git a/isis/src/base/objs/LimitPolygonSeeder/LimitPolygonSeeder.cpp b/isis/src/base/objs/LimitPolygonSeeder/LimitPolygonSeeder.cpp index ae0ab1070817eeca4627320b7601769f43e2d2e8..abe36e63c866a0970f79d7d7d0dfcc3034583b95 100644 --- a/isis/src/base/objs/LimitPolygonSeeder/LimitPolygonSeeder.cpp +++ b/isis/src/base/objs/LimitPolygonSeeder/LimitPolygonSeeder.cpp @@ -97,7 +97,7 @@ namespace Isis { delete centroid; geos::geom::Coordinate c(gridCenterX, gridCenterY); - points.push_back(Isis::globalFactory->createPoint(c)); + points.push_back(Isis::globalFactory->createPoint(c).release()); } } @@ -121,7 +121,7 @@ namespace Isis { geos::geom::Geometry *LimitPolygonSeeder::GetMultiPolygon(double dMinX, double dMinY, double dMaxX, double dMaxY, const geos::geom::MultiPolygon &orig) { - geos::geom::CoordinateArraySequence *points = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence *points = new geos::geom::CoordinateSequence(); points->add(geos::geom::Coordinate(dMinX, dMinY)); points->add(geos::geom::Coordinate(dMaxX, dMinY)); @@ -129,7 +129,7 @@ namespace Isis { points->add(geos::geom::Coordinate(dMinX, dMaxY)); points->add(geos::geom::Coordinate(dMinX, dMinY)); - geos::geom::Polygon *poly = Isis::globalFactory->createPolygon(Isis::globalFactory->createLinearRing(points), NULL); + std::unique_ptr<geos::geom::Polygon> poly = Isis::globalFactory->createPolygon(Isis::globalFactory->createLinearRing(*points)); geos::geom::Geometry *overlap = poly->intersection(&orig).release(); return overlap; diff --git a/isis/src/base/objs/LimitPolygonSeeder/LimitPolygonSeeder.h b/isis/src/base/objs/LimitPolygonSeeder/LimitPolygonSeeder.h index 4835c359eab570407f3019296dc396cda287744e..bcc67ccc637ed0fb2ac079481218132474478a6d 100644 --- a/isis/src/base/objs/LimitPolygonSeeder/LimitPolygonSeeder.h +++ b/isis/src/base/objs/LimitPolygonSeeder/LimitPolygonSeeder.h @@ -9,7 +9,7 @@ find files of those names at the top level of this repository. **/ #include <geos/geom/Point.h> #include <geos/geom/MultiPolygon.h> -#include <geos/geom/CoordinateArraySequence.h> +#include <geos/geom/CoordinateSequence.h> #include <geos/geom/Polygon.h> #include "PolygonSeeder.h" diff --git a/isis/src/base/objs/LimitPolygonSeeder/LimitPolygonSeeder.truth b/isis/src/base/objs/LimitPolygonSeeder/LimitPolygonSeeder.truth index c2b45b7f8b3537cff7d64e6f52425e70e7646708..510374c3e06f48837a3f028d5bbcd65d5e0d31b2 100644 --- a/isis/src/base/objs/LimitPolygonSeeder/LimitPolygonSeeder.truth +++ b/isis/src/base/objs/LimitPolygonSeeder/LimitPolygonSeeder.truth @@ -14,9 +14,9 @@ Test to make sure Parse did it's job MinimumThickness = 0.3 MinimumArea = 5 Test 2, test a triangular polygon -Lon/Lat polygon = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 1.0000000000000000, 0.5000000000000000 0.5000000000000000, 1.0000000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000))) +Lon/Lat polygon = MULTIPOLYGON (((0 0, 0 1, 0.5 0.5, 1 0, 0 0))) POINT (0.2500023796612 0.2499999998188) POINT (0.6666694869935 0.1666603207523) POINT (0.1666716028442 0.6666666666667) Test 3, test for too thin -Lon/Lat polygon = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 0.5000000000000000, 0.0125000000000000 0.5000000000000000, 0.0125000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000))) +Lon/Lat polygon = MULTIPOLYGON (((0 0, 0 0.5, 0.0125 0.5, 0.0125 0, 0 0))) diff --git a/isis/src/base/objs/LimitPolygonSeeder/unitTest.cpp b/isis/src/base/objs/LimitPolygonSeeder/unitTest.cpp index f9a1f11bb30afedddd77aa6820899f6324f03621..b985de54ac79dee26ddfb1daeb96d2babc8a3c7a 100644 --- a/isis/src/base/objs/LimitPolygonSeeder/unitTest.cpp +++ b/isis/src/base/objs/LimitPolygonSeeder/unitTest.cpp @@ -9,7 +9,7 @@ find files of those names at the top level of this repository. **/ #include <cmath> #include <iomanip> -#include <geos/geom/CoordinateArraySequence.h> +#include <geos/geom/CoordinateSequence.h> #include <geos/geom/Geometry.h> #include <geos/geom/Polygon.h> @@ -60,21 +60,20 @@ int main() { std::cout << "Test 2, test a triangular polygon" << std::endl; try { // Call the seed member with a polygon - geos::geom::CoordinateArraySequence *pts; + geos::geom::CoordinateSequence pts; vector<const geos::geom::Geometry *> polys; // Create the A polygon - pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(0, 0)); - pts->add(geos::geom::Coordinate(0, 1)); - pts->add(geos::geom::Coordinate(0.5, 0.5)); - pts->add(geos::geom::Coordinate(1, 0)); - pts->add(geos::geom::Coordinate(0, 0)); + pts.add(geos::geom::Coordinate(0, 0)); + pts.add(geos::geom::Coordinate(0, 1)); + pts.add(geos::geom::Coordinate(0.5, 0.5)); + pts.add(geos::geom::Coordinate(1, 0)); + pts.add(geos::geom::Coordinate(0, 0)); polys.push_back(Isis::globalFactory->createPolygon( - Isis::globalFactory->createLinearRing(pts), NULL)); + Isis::globalFactory->createLinearRing(pts)).release()); - geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(polys); + geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(polys).release(); std::cout << "Lon/Lat polygon = " << mp->toString() << std::endl; // Create the projection necessary for seeding @@ -101,7 +100,7 @@ int main() { if(proj->SetCoordinate(seedValues[pt]->getX(), seedValues[pt]->getY())) { points.push_back(Isis::globalFactory->createPoint( geos::geom::Coordinate(proj->UniversalLongitude(), - proj->UniversalLatitude()))); + proj->UniversalLatitude())).release()); } else { IString msg = "Unable to convert to a (lon,lat)"; @@ -122,21 +121,20 @@ int main() { cout << "Test 3, test for too thin" << endl; try { // Call the seed member with a polygon - geos::geom::CoordinateArraySequence *pts; - vector<const geos::geom::Geometry *> polys; + geos::geom::CoordinateSequence pts; + vector <const geos::geom::Geometry *> polys; // Create the A polygon - pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(0, 0)); - pts->add(geos::geom::Coordinate(0, 0.5)); - pts->add(geos::geom::Coordinate(0.0125, 0.5)); - pts->add(geos::geom::Coordinate(0.0125, 0)); - pts->add(geos::geom::Coordinate(0, 0)); + pts.add(geos::geom::Coordinate(0, 0)); + pts.add(geos::geom::Coordinate(0, 0.5)); + pts.add(geos::geom::Coordinate(0.0125, 0.5)); + pts.add(geos::geom::Coordinate(0.0125, 0)); + pts.add(geos::geom::Coordinate(0, 0)); polys.push_back(Isis::globalFactory->createPolygon( - Isis::globalFactory->createLinearRing(pts), NULL)); + Isis::globalFactory->createLinearRing(pts)).release()); - geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(polys); + geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(polys).release(); cout << "Lon/Lat polygon = " << mp->toString() << endl; diff --git a/isis/src/base/objs/PixelFOV/PixelFOV.cpp b/isis/src/base/objs/PixelFOV/PixelFOV.cpp index 94b66b795f8d104b9429e0520404cf0d0de6bdaa..075672a506699274a4a4b1d8970a7a22502ec232 100755 --- a/isis/src/base/objs/PixelFOV/PixelFOV.cpp +++ b/isis/src/base/objs/PixelFOV/PixelFOV.cpp @@ -12,7 +12,7 @@ find files of those names at the top level of this repository. **/ #include <QPointF> #include <QScopedPointer> -#include <geos/geom/CoordinateArraySequence.h> +#include <geos/geom/CoordinateSequence.h> #include <geos/geom/CoordinateSequence.h> #include <geos/geom/LineString.h> #include <geos/geom/MultiPolygon.h> @@ -231,13 +231,13 @@ namespace Isis { QList<QPointF> PixelFOV::envelope(QList<QPointF> vertices) const{ //Put the vertices in a line string - QScopedPointer<geos::geom::CoordinateArraySequence> points(new geos::geom::CoordinateArraySequence()); + QScopedPointer<geos::geom::CoordinateSequence> points(new geos::geom::CoordinateSequence()); for (int i = 0; i < vertices.size(); i++) { points->add(geos::geom::Coordinate(vertices[i].x(), vertices[i].y())); } QScopedPointer<geos::geom::LineString> pointString(Isis::globalFactory->createLineString( - points.take())); + *points).release()); //Compute a convex hull for the line string QScopedPointer<geos::geom::Geometry> boundingHull(pointString->convexHull().release()); @@ -270,14 +270,13 @@ namespace Isis { QList< QList<QPointF> > splitPoints; // Create a polygon to split. - QScopedPointer<geos::geom::CoordinateArraySequence> pts(new geos::geom::CoordinateArraySequence()); + QScopedPointer<geos::geom::CoordinateSequence> pts(new geos::geom::CoordinateSequence()); for (int i = 0; i < vertices.size(); i++) { pts->add(geos::geom::Coordinate(vertices[i].y(), vertices[i].x())); } pts->add(geos::geom::Coordinate(vertices[0].y(), vertices[0].x())); QScopedPointer<geos::geom::Polygon> originalPoly(Isis::globalFactory->createPolygon( - globalFactory->createLinearRing(pts.take()), - NULL)); + globalFactory->createLinearRing(*pts)).release()); // Split the polygon QScopedPointer<geos::geom::MultiPolygon> splitPolygons( diff --git a/isis/src/base/objs/PolygonTools/PolygonTools.cpp b/isis/src/base/objs/PolygonTools/PolygonTools.cpp index e089fb28b57144efbc5e017147da16cbd52b12bd..296d476630160c514811938616c73ea77646c161 100644 --- a/isis/src/base/objs/PolygonTools/PolygonTools.cpp +++ b/isis/src/base/objs/PolygonTools/PolygonTools.cpp @@ -14,13 +14,12 @@ find files of those names at the top level of this repository. **/ #include <QDebug> -#include "geos/geom/CoordinateArraySequence.h" #include "geos/geom/CoordinateSequence.h" #include "geos/geom/LinearRing.h" #include "geos/geom/Point.h" #include "geos/geom/Polygon.h" #include "geos/operation/distance/DistanceOp.h" -#include "geos/operation/overlay/OverlayOp.h" +#include "geos/operation/overlay/snap/SnapOverlayOp.h" #include "geos/operation/overlay/snap/GeometrySnapper.h" #include "SpecialPixel.h" @@ -57,7 +56,7 @@ namespace Isis { return globalFactory->createMultiPolygon().release(); } else { - vector<geos::geom::Geometry *> *xyPolys = new vector<geos::geom::Geometry *>; + vector<const geos::geom::Geometry *> *xyPolys = new vector<const geos::geom::Geometry *>; // Convert each polygon in this multi-polygon for(unsigned int g = 0; g < lonLatPolygon.getNumGeometries(); ++g) { const geos::geom::Polygon *poly = @@ -65,9 +64,9 @@ namespace Isis { lonLatPolygon.getGeometryN(g)); // Convert each hole inside this polygon - vector<geos::geom::LinearRing *> *holes = new vector<geos::geom::LinearRing *>; + std::vector<std::unique_ptr<geos::geom::LinearRing>> holes; for(unsigned int h = 0; h < poly->getNumInteriorRing(); ++h) { - geos::geom::CoordinateArraySequence *xycoords = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence *xycoords = new geos::geom::CoordinateSequence(); geos::geom::CoordinateSequence *llcoords = poly->getInteriorRingN(h)->getCoordinates().release(); @@ -79,18 +78,18 @@ namespace Isis { projection->YCoord())); } // end num coords in hole loop - geos::geom::LinearRing *hole = globalFactory->createLinearRing(xycoords); + std::unique_ptr<geos::geom::LinearRing> hole = globalFactory->createLinearRing(*xycoords); if(hole->isValid() && !hole->isEmpty()) { - holes->push_back(hole); + holes.push_back(hole->clone()); } else { - delete hole; + hole.reset(); } } // end num holes in polygon loop // Convert the exterior ring of this polygon - geos::geom::CoordinateArraySequence *xycoords = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence *xycoords = new geos::geom::CoordinateSequence(); geos::geom::CoordinateSequence *llcoords = poly->getExteriorRing()->getCoordinates().release(); @@ -103,7 +102,7 @@ namespace Isis { } // end exterior ring coordinate loop geos::geom::Polygon *newPoly = globalFactory->createPolygon( - globalFactory->createLinearRing(xycoords), holes); + globalFactory->createLinearRing(*xycoords), std::move(holes)).release(); if(newPoly->isValid() && !newPoly->isEmpty() && newPoly->getArea() > 1.0e-14) { xyPolys->push_back(newPoly); @@ -114,7 +113,7 @@ namespace Isis { } // end num geometry in multi-poly // Create a new multipoly from all the new X/Y polygon(s) - geos::geom::MultiPolygon *spikedPoly = globalFactory->createMultiPolygon(xyPolys); + geos::geom::MultiPolygon *spikedPoly = globalFactory->createMultiPolygon(*xyPolys).release(); if(spikedPoly->isValid() && !spikedPoly->isEmpty()) { return spikedPoly; @@ -164,7 +163,7 @@ namespace Isis { return globalFactory->createMultiPolygon().release(); } else { - vector<geos::geom::Geometry *> *llPolys = new vector<geos::geom::Geometry *>; + vector<const geos::geom::Geometry *> *llPolys = new vector<const geos::geom::Geometry *>; // Convert each polygon in this multi-polygon for(unsigned int g = 0; g < xYPolygon.getNumGeometries(); ++g) { const geos::geom::Polygon *poly = @@ -172,9 +171,9 @@ namespace Isis { xYPolygon.getGeometryN(g)); // Convert each hole inside this polygon - vector<geos::geom::LinearRing *> *holes = new vector<geos::geom::LinearRing *>; + std::vector<std::unique_ptr<geos::geom::LinearRing>> holes; for(unsigned int h = 0; h < poly->getNumInteriorRing(); ++h) { - geos::geom::CoordinateArraySequence *llcoords = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence *llcoords = new geos::geom::CoordinateSequence(); geos::geom::CoordinateSequence *xycoords = poly->getInteriorRingN(h)->getCoordinates().release(); @@ -185,11 +184,11 @@ namespace Isis { llcoords->add(geos::geom::Coordinate(projection->Longitude(), projection->Latitude())); } // end num coords in hole loop - holes->push_back(globalFactory->createLinearRing(llcoords)); + holes.push_back(globalFactory->createLinearRing(*llcoords)); } // end num holes in polygon loop // Convert the exterior ring of this polygon - geos::geom::CoordinateArraySequence *llcoords = new geos::geom::DefaultCoordinateSequence(); + geos::geom::CoordinateSequence *llcoords = new geos::geom::CoordinateSequence(); geos::geom::CoordinateSequence *xycoords = poly->getExteriorRing()->getCoordinates().release(); @@ -202,12 +201,12 @@ namespace Isis { } // end exterior ring coordinate loop llPolys->push_back(globalFactory->createPolygon( - globalFactory->createLinearRing(llcoords), holes)); + globalFactory->createLinearRing(*llcoords), std::move(holes)).release()); } // end num geometry in multi-poly // Create a new multipoly from all the new Lat/Lon polygon(s) - geos::geom::MultiPolygon *spikedPoly = globalFactory->createMultiPolygon(llPolys); + geos::geom::MultiPolygon *spikedPoly = globalFactory->createMultiPolygon(*llPolys).release(); if(spikedPoly->isValid() && !spikedPoly->isEmpty()) { return spikedPoly; @@ -256,7 +255,7 @@ namespace Isis { return globalFactory->createMultiPolygon().release(); } else { - vector<geos::geom::Geometry *> *slPolys = new vector<geos::geom::Geometry *>; + vector<const geos::geom::Geometry *> slPolys; // Convert each polygon in this multi-polygon for(unsigned int g = 0; g < lonLatPolygon.getNumGeometries(); g++) { const geos::geom::Polygon *poly = @@ -264,9 +263,9 @@ namespace Isis { lonLatPolygon.getGeometryN(g)); // Convert each hole inside this polygon - vector<geos::geom::LinearRing *> *holes = new vector<geos::geom::LinearRing *>; + vector<unique_ptr<geos::geom::LinearRing>> holes; for(unsigned int h = 0; h < poly->getNumInteriorRing(); ++h) { - geos::geom::CoordinateArraySequence *slcoords = new geos::geom::DefaultCoordinateSequence(); + geos::geom::CoordinateSequence *slcoords = new geos::geom::CoordinateSequence(); geos::geom::CoordinateSequence *llcoords = poly->getInteriorRingN(h)->getCoordinates().release(); @@ -277,13 +276,13 @@ namespace Isis { slcoords->add(geos::geom::Coordinate(ugm->Sample(), ugm->Line())); } // end num coords in hole loop - holes->push_back(globalFactory->createLinearRing(slcoords)); + holes.push_back(globalFactory->createLinearRing(*slcoords)); delete slcoords; delete llcoords; } // end num holes in polygon loop // Convert the exterior ring of this polygon - geos::geom::CoordinateArraySequence *slcoords = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence *slcoords = new geos::geom::CoordinateSequence(); geos::geom::CoordinateSequence *llcoords = poly->getExteriorRing()->getCoordinates().release(); @@ -302,8 +301,8 @@ namespace Isis { } try { - slPolys->push_back(globalFactory->createPolygon( - globalFactory->createLinearRing(slcoords), holes)); + slPolys.push_back(globalFactory->createPolygon( + globalFactory->createLinearRing(*slcoords), std::move(holes)).release()); } catch (std::exception &e) { throw IException(IException::Unknown, @@ -316,7 +315,7 @@ namespace Isis { } // end num geometry in multi-poly // Create a new multipoly from all the new Sample/Line polygon(s) - geos::geom::MultiPolygon *spikedPoly = globalFactory->createMultiPolygon(slPolys); + geos::geom::MultiPolygon *spikedPoly = globalFactory->createMultiPolygon(slPolys).release(); if(spikedPoly->isValid() && !spikedPoly->isEmpty()) { return spikedPoly; @@ -353,11 +352,11 @@ namespace Isis { */ geos::geom::MultiPolygon *PolygonTools::CopyMultiPolygon(const geos::geom::MultiPolygon *mpolygon) { - vector<geos::geom::Geometry *> *polys = new vector<geos::geom::Geometry *>; + vector<const geos::geom::Geometry *> *polys = new vector<const geos::geom::Geometry *>; for(unsigned int i = 0; i < mpolygon->getNumGeometries(); ++i) { polys->push_back((mpolygon->getGeometryN(i))->clone().release()); } - return globalFactory->createMultiPolygon(polys); + return globalFactory->createMultiPolygon(*polys).release(); } @@ -375,11 +374,11 @@ namespace Isis { */ geos::geom::MultiPolygon *PolygonTools::CopyMultiPolygon(const geos::geom::MultiPolygon &mpolygon) { - vector<geos::geom::Geometry *> *polys = new vector<geos::geom::Geometry *>; + vector<const geos::geom::Geometry *> *polys = new vector<const geos::geom::Geometry *>; for(unsigned int i = 0; i < mpolygon.getNumGeometries(); ++i) { polys->push_back((mpolygon.getGeometryN(i))->clone().release()); } - return globalFactory->createMultiPolygon(polys); + return globalFactory->createMultiPolygon(*polys).release(); } @@ -532,61 +531,57 @@ namespace Isis { // >180). Move this intersection to the left. Then make a poly that fits // 0 to 180 and intersect with the original. These two combined are the // result. - geos::geom::CoordinateArraySequence *leftOf180Pts = - new geos::geom::CoordinateArraySequence(); - leftOf180Pts->add(geos::geom::Coordinate(0, -90)); - leftOf180Pts->add(geos::geom::Coordinate(0, 90)); - leftOf180Pts->add(geos::geom::Coordinate(180, 90)); - leftOf180Pts->add(geos::geom::Coordinate(180, -90)); - leftOf180Pts->add(geos::geom::Coordinate(0, -90)); - - geos::geom::LinearRing *leftOf180Geom = + geos::geom::CoordinateSequence leftOf180Pts; + leftOf180Pts.add(geos::geom::Coordinate(0, -90)); + leftOf180Pts.add(geos::geom::Coordinate(0, 90)); + leftOf180Pts.add(geos::geom::Coordinate(180, 90)); + leftOf180Pts.add(geos::geom::Coordinate(180, -90)); + leftOf180Pts.add(geos::geom::Coordinate(0, -90)); + + unique_ptr<geos::geom::LinearRing> leftOf180Geom = globalFactory->createLinearRing(leftOf180Pts); geos::geom::Polygon *leftOf180Poly = - globalFactory->createPolygon(leftOf180Geom, NULL); + globalFactory->createPolygon(std::move(leftOf180Geom)).release(); - geos::geom::CoordinateArraySequence *rightOf180Pts = - new geos::geom::CoordinateArraySequence(); - rightOf180Pts->add(geos::geom::Coordinate(180, -90)); - rightOf180Pts->add(geos::geom::Coordinate(180, 90)); - rightOf180Pts->add(geos::geom::Coordinate(360, 90)); - rightOf180Pts->add(geos::geom::Coordinate(360, -90)); - rightOf180Pts->add(geos::geom::Coordinate(180, -90)); + geos::geom::CoordinateSequence rightOf180Pts; + rightOf180Pts.add(geos::geom::Coordinate(180, -90)); + rightOf180Pts.add(geos::geom::Coordinate(180, 90)); + rightOf180Pts.add(geos::geom::Coordinate(360, 90)); + rightOf180Pts.add(geos::geom::Coordinate(360, -90)); + rightOf180Pts.add(geos::geom::Coordinate(180, -90)); - geos::geom::LinearRing *rightOf180Geom = + unique_ptr<geos::geom::LinearRing> rightOf180Geom = globalFactory->createLinearRing(rightOf180Pts); geos::geom::Polygon *rightOf180Poly = - globalFactory->createPolygon(rightOf180Geom, NULL); + globalFactory->createPolygon(std::move(rightOf180Geom)).release(); geos::geom::Geometry *preserved = Intersect(leftOf180Poly, poly360); geos::geom::Geometry *moving = Intersect(rightOf180Poly, poly360); geos::geom::CoordinateSequence *movingPts = moving->getCoordinates().release(); - geos::geom::CoordinateArraySequence *movedPts = - new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence movedPts; for(unsigned int i = 0; i < movingPts->getSize(); i ++) { - movedPts->add(geos::geom::Coordinate(movingPts->getAt(i).x - 360.0, - movingPts->getAt(i).y)); + movedPts.add(geos::geom::Coordinate(movingPts->getAt(i).x - 360.0, + movingPts->getAt(i).y)); } - if(movedPts->getSize()) { - movedPts->add(geos::geom::Coordinate(movedPts->getAt(0).x, - movedPts->getAt(0).y)); + if(movedPts.getSize()) { + movedPts.add(geos::geom::Coordinate(movedPts.getAt(0).x, + movedPts.getAt(0).y)); } geos::geom::Geometry *moved = globalFactory->createPolygon( - globalFactory->createLinearRing(movedPts), NULL); + globalFactory->createLinearRing(movedPts)).release(); - std::vector<geos::geom::Geometry *> *geomsForCollection = new - std::vector<geos::geom::Geometry *>; - geomsForCollection->push_back(preserved); - geomsForCollection->push_back(moved); + std::vector<const geos::geom::Geometry *> geomsForCollection; + geomsForCollection.push_back(preserved); + geomsForCollection.push_back(moved); geos::geom::GeometryCollection *the180Polys = - Isis::globalFactory->createGeometryCollection(geomsForCollection); + Isis::globalFactory->createGeometryCollection(geomsForCollection).release(); geos::geom::MultiPolygon *result = MakeMultiPolygon(the180Polys); delete the180Polys; @@ -666,54 +661,52 @@ namespace Isis { */ geos::geom::MultiPolygon *PolygonTools::Despike(const geos::geom::MultiPolygon *multiPoly) { // Despike each polygon in the multipolygon - vector<geos::geom::Geometry *> *newPolys = new vector<geos::geom::Geometry *>; + vector<const geos::geom::Geometry *> *newPolys = new vector<const geos::geom::Geometry *>; for(unsigned int g = 0; g < multiPoly->getNumGeometries(); ++g) { const geos::geom::Polygon *poly = dynamic_cast<const geos::geom::Polygon *>(multiPoly->getGeometryN(g)); // Despike each hole inside this polygon - vector<geos::geom::LinearRing *> *holes = new vector<geos::geom::LinearRing *>; + vector<unique_ptr<geos::geom::LinearRing>> holes; for(unsigned int h = 0; h < poly->getNumInteriorRing(); ++h) { const geos::geom::LineString *ls = poly->getInteriorRingN(h); - geos::geom::LinearRing *lr; + unique_ptr<geos::geom::LinearRing> lr; // If the hole is not valid fix it // If the hole is NOT valid despike it - lr = Despike(ls); + lr = Despike(ls)->clone(); if(!lr->isValid()) { - geos::geom::LinearRing *fixed = FixGeometry(lr); - delete lr; - lr = fixed; + geos::geom::LinearRing *fixed = FixGeometry(lr.release()); + lr.reset(fixed->clone().release()); } // Save this hole if it is not too small if(!lr->isEmpty()) { - holes->push_back(lr); + holes.push_back(lr->clone()); } else { - delete lr; + lr.reset(); } } // End holes loop // Work on the main polygon - const geos::geom::LineString *ls = poly->getExteriorRing(); - geos::geom::LinearRing *lr; + unique_ptr<geos::geom::LinearRing> ls = poly->getExteriorRing()->clone(); + unique_ptr<geos::geom::LinearRing> lr; - lr = Despike(ls); + lr = Despike(ls.release())->clone(); try { if(!lr->isValid()) { - geos::geom::LinearRing *fixed = FixGeometry(lr); - delete lr; - lr = fixed; + geos::geom::LinearRing *fixed = FixGeometry(lr.release()); + lr.reset(fixed->clone().release()); } } catch(IException &e) { // Sometimes despike and fix fail, but the input is really valid. We can just go // with the non-despiked polygon. if(ls->isValid() && ls->getGeometryTypeId() == geos::geom::GEOS_LINEARRING) { - lr = dynamic_cast<geos::geom::LinearRing *>(ls->clone().release()); + lr.reset(ls.release()); } else { throw; @@ -722,7 +715,7 @@ namespace Isis { // Create a new polygon with the holes and save it if(!lr->isEmpty()) { - geos::geom::Polygon *tp = Isis::globalFactory->createPolygon(lr, holes); + geos::geom::Polygon *tp = Isis::globalFactory->createPolygon(std::move(lr), std::move(holes)).release(); if(tp->isEmpty() || !tp->isValid()) { delete tp; @@ -735,7 +728,7 @@ namespace Isis { } // End polygons loop // Create a new multipoly from the polygon(s) - geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(newPolys); + geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(*newPolys).release(); if(!mp->isValid() || mp->isEmpty()) { delete mp; @@ -770,13 +763,13 @@ namespace Isis { * returned. */ geos::geom::LinearRing *PolygonTools::Despike(const geos::geom::LineString *lineString) { - geos::geom::CoordinateArraySequence *vertices = - new geos::geom::CoordinateArraySequence(*(lineString->getCoordinates())); + geos::geom::CoordinateSequence *vertices = + new geos::geom::CoordinateSequence(*(lineString->getCoordinates())); // We need a full polygon to despike = 3 points (+1 for end==first) = at least 4 points if(vertices->getSize() < 4) { delete vertices; - return Isis::globalFactory->createLinearRing(geos::geom::CoordinateArraySequence()); + return Isis::globalFactory->createLinearRing(geos::geom::CoordinateSequence()).release(); } // delete one of the duplicate first/end coordinates, @@ -838,12 +831,12 @@ namespace Isis { delete vertices; vertices = NULL; - return Isis::globalFactory->createLinearRing(geos::geom::CoordinateArraySequence()); + return Isis::globalFactory->createLinearRing(geos::geom::CoordinateSequence()).release(); } else { // Duplicate the first vertex as the last to close the polygon vertices->add(vertices->getAt(0)); - return Isis::globalFactory->createLinearRing(vertices); + return Isis::globalFactory->createLinearRing(*vertices).release(); } } @@ -892,14 +885,13 @@ namespace Isis { */ bool PolygonTools::TestSpiked(geos::geom::Coordinate first, geos::geom::Coordinate middle, geos::geom::Coordinate last) { - geos::geom::Point *firstPt = Isis::globalFactory->createPoint(first); - geos::geom::Point *middlePt = Isis::globalFactory->createPoint(middle); - geos::geom::Point *lastPt = Isis::globalFactory->createPoint(last); + geos::geom::Point *middlePt = Isis::globalFactory->createPoint(middle).release(); + geos::geom::Point *lastPt = Isis::globalFactory->createPoint(last).release(); - geos::geom::CoordinateArraySequence *coords = new geos::geom::CoordinateArraySequence(); - coords->add(first); - coords->add(middle); - geos::geom::LineString *line = Isis::globalFactory->createLineString(coords); // line takes ownership + geos::geom::CoordinateSequence coords; + coords.add(first); + coords.add(middle); + geos::geom::LineString *line = Isis::globalFactory->createLineString(coords).release(); // line takes ownership // The lower the tolerance, the less this algorithm removes and thus // the better chance of success in findimageoverlaps. However, if you @@ -926,18 +918,18 @@ namespace Isis { } if(!spiked) { - geos::geom::CoordinateArraySequence *coords = new geos::geom::CoordinateArraySequence(); - coords->add(first); - coords->add(middle); - coords->add(last); - coords->add(first); + geos::geom::CoordinateSequence coords; + coords.add(first); + coords.add(middle); + coords.add(last); + coords.add(first); // shell takes ownership of coords - geos::geom::LinearRing *shell = Isis::globalFactory->createLinearRing(coords); + geos::geom::LinearRing *shell = Isis::globalFactory->createLinearRing(coords).release(); std::vector<geos::geom::LinearRing *> *empty = new std::vector<geos::geom::LinearRing *>; // poly takes ownership of shell and empty - geos::geom::Polygon *poly = Isis::globalFactory->createPolygon(shell, empty); + geos::geom::Polygon *poly = Isis::globalFactory->createPolygon(*shell, *empty); // if these 3 points define a straight line then the middle is worthless (defines nothing) @@ -950,7 +942,6 @@ namespace Isis { } - delete firstPt; delete middlePt; delete lastPt; delete line; @@ -975,7 +966,7 @@ namespace Isis { geos::geom::Geometry *PolygonTools::Intersect(const geos::geom::Geometry *geom1, const geos::geom::Geometry *geom2) { try { - return Operate(geom1, geom2, (unsigned int)geos::operation::overlay::OverlayOp::opINTERSECTION); + return Operate(geom1, geom2, (unsigned int)geos::operation::overlayng::OverlayNG::INTERSECTION); } catch(geos::util::GEOSException *exc) { IString msg = "Intersect operation failed. The reason given was [" + IString(exc->what()) + "]"; @@ -997,8 +988,8 @@ namespace Isis { const geos::geom::Geometry *geom2, unsigned int opcode) { - geos::operation::overlay::OverlayOp::OpCode code = - (geos::operation::overlay::OverlayOp::OpCode)opcode; + // geos::operation::overlayng::OverlayNG::OpCode code = + // (geos::operation::overlayng::OverlayNG::OpCode)opcode; geos::geom::Geometry *result = NULL; bool failed = true; @@ -1021,7 +1012,7 @@ namespace Isis { try { // C++11: the geos BinaryOp returns an auto_ptr, we use release() to create a unique_ptr. std::unique_ptr< geos::geom::Geometry > resultAuto( - geos::operation::overlay::OverlayOp::overlayOp(geomFirst, geomSecond, code)); + geos::operation::overlay::snap::SnapOverlayOp::overlayOp(*geomFirst, *geomSecond, opcode)); failed = false; result = resultAuto->clone().release(); } @@ -1131,7 +1122,7 @@ namespace Isis { */ geos::geom::MultiPolygon *PolygonTools::FixGeometry(const geos::geom::MultiPolygon *poly) { // Maybe two points are on top of each other - vector<geos::geom::Geometry *> *newPolys = new vector<geos::geom::Geometry *>; + vector<const geos::geom::Geometry *> *newPolys = new vector<const geos::geom::Geometry *>; // Convert each polygon in this multi-polygon for(unsigned int geomIndex = 0; geomIndex < poly->getNumGeometries(); geomIndex ++) { @@ -1147,7 +1138,7 @@ namespace Isis { fixedpoly = NULL; } - geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(newPolys); + geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(*newPolys).release(); return mp; } @@ -1155,20 +1146,20 @@ namespace Isis { geos::geom::Polygon *PolygonTools::FixGeometry(const geos::geom::Polygon *poly) { // Convert each hole inside this polygon - vector<geos::geom::LinearRing *> *holes = new vector<geos::geom::LinearRing *>; + vector<unique_ptr<geos::geom::LinearRing>> holes; for(unsigned int holeIndex = 0; holeIndex < poly->getNumInteriorRing(); holeIndex ++) { const geos::geom::LinearRing *thisHole = poly->getInteriorRingN(holeIndex); // We hope they are all linear rings (closed/simple), but if not just leave it be if(thisHole->getGeometryTypeId() != geos::geom::GEOS_LINEARRING) { - holes->push_back(dynamic_cast<geos::geom::LinearRing *>(thisHole->clone().release())); + holes.push_back(thisHole->clone()); // newRing = dynamic_cast<geos::geom::LinearRing *>(ring->clone()); continue; } try { geos::geom::LinearRing *newHole = FixGeometry((geos::geom::LinearRing *)thisHole); - holes->push_back(newHole); + holes.push_back(newHole->clone()); } catch (IException &e) { IString msg = "Failed when attempting to fix interior ring of multipolygon"; @@ -1180,10 +1171,10 @@ namespace Isis { const geos::geom::LineString *exterior = poly->getExteriorRing(); try { - geos::geom::LinearRing *newExterior = NULL; + unique_ptr<geos::geom::LinearRing> newExterior; if(exterior->getGeometryTypeId() == geos::geom::GEOS_LINEARRING) { - newExterior = FixGeometry((geos::geom::LinearRing *)exterior); + newExterior.reset(FixGeometry((geos::geom::LinearRing *)exterior)); } else { IString msg = "Failed when attempting to fix exterior ring of polygon. The exterior " @@ -1191,7 +1182,7 @@ namespace Isis { throw IException(IException::Programmer, msg, _FILEINFO_); } - return globalFactory->createPolygon(newExterior, holes); + return globalFactory->createPolygon(std::move(newExterior), std::move(holes)).release(); } catch (IException &e) { IString msg = "Failed when attempting to fix exterior ring of polygon"; @@ -1221,10 +1212,10 @@ namespace Isis { // Check this, just in case if(coords->getSize() < 4) { - return globalFactory->createLinearRing(new geos::geom::DefaultCoordinateSequence()); + return globalFactory->createLinearRing(geos::geom::CoordinateSequence()).release(); } - geos::geom::CoordinateArraySequence *newCoords = new geos::geom::DefaultCoordinateSequence(); + geos::geom::CoordinateSequence *newCoords = new geos::geom::CoordinateSequence(); const geos::geom::Coordinate *lastCoordinate = &coords->getAt(0); newCoords->add(*lastCoordinate); @@ -1273,7 +1264,7 @@ namespace Isis { // Now that we've weeded out any bad coordinates, let's rebuild the geometry try { if(newCoords->getSize() > 3) { - newRing = globalFactory->createLinearRing(newCoords); + newRing = globalFactory->createLinearRing(*newCoords).release(); } else { delete newCoords; @@ -1346,7 +1337,7 @@ namespace Isis { geos::geom::Geometry *PolygonTools::Difference(const geos::geom::Geometry *geom1, const geos::geom::Geometry *geom2) { try { - return Operate(geom1, geom2, (unsigned int)geos::operation::overlay::OverlayOp::opDIFFERENCE); + return Operate(geom1, geom2, (unsigned int)geos::operation::overlayng::OverlayNG::DIFFERENCE); } catch(geos::util::GEOSException *exc) { IString msg = "Difference operation failed. The reason given was [" + @@ -1393,15 +1384,14 @@ namespace Isis { } else if(geom->getGeometryTypeId() == geos::geom::GEOS_POLYGON) { - vector<geos::geom::Geometry *> *polys = new vector<geos::geom::Geometry *>; - polys->push_back(geom->clone().release()); - geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(polys); + vector<const geos::geom::Geometry *> polys; + polys.push_back(geom->clone().release()); + geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(polys).release(); return mp; } else if(geom->getGeometryTypeId() == geos::geom::GEOS_GEOMETRYCOLLECTION) { - vector<geos::geom::Geometry *> * polys = - new vector<geos::geom::Geometry *>; + vector<const geos::geom::Geometry *> polys; const geos::geom::GeometryCollection *gc = dynamic_cast<const geos::geom::GeometryCollection *>(geom); for(unsigned int i = 0; i < gc->getNumGeometries(); ++i) { @@ -1414,12 +1404,12 @@ namespace Isis { const geos::geom::Polygon *poly = dynamic_cast<const geos::geom::Polygon *>( subMultiPoly->getGeometryN(subPoly)); - polys->push_back(dynamic_cast<geos::geom::Polygon *>(poly->clone().release())); + polys.push_back(poly->clone().release()); } } geos::geom::MultiPolygon *mp = - Isis::globalFactory->createMultiPolygon(polys); + Isis::globalFactory->createMultiPolygon(polys).release(); if(mp->getArea() - DBL_EPSILON <= DBL_EPSILON) { delete mp; mp = Isis::globalFactory->createMultiPolygon().release(); @@ -1484,28 +1474,27 @@ namespace Isis { geos::geom::MultiPolygon * result = NULL; if (intersectionStarted && intersectionEnded) { - geos::geom::CoordinateArraySequence *merged = - new geos::geom::CoordinateArraySequence; + geos::geom::CoordinateSequence merged; unsigned int i = 0; for (i = 0; i < aIntersectionBegin; i ++) { - merged->add(polyAPoints->getAt(i)); + merged.add(polyAPoints->getAt(i)); } i = bIntersectionBegin; while (i != bIntersectionEnd) { - merged->add(polyBPoints->getAt(i)); + merged.add(polyBPoints->getAt(i)); i++; if (i >= polyBPoints->getSize()) i = 0; } for (i = aIntersectionEnd; i < polyAPoints->getSize() - 1; i++) { - merged->add(polyAPoints->getAt(i)); + merged.add(polyAPoints->getAt(i)); } - merged->add(merged->getAt(0)); + merged.add(merged.getAt(0)); result = MakeMultiPolygon(globalFactory->createPolygon( - globalFactory->createLinearRing(merged), NULL)); + globalFactory->createLinearRing(merged)).release()); } return result; @@ -1515,32 +1504,31 @@ namespace Isis { geos::geom::MultiPolygon *PolygonTools::FixSeam( const geos::geom::MultiPolygon *poly) { - std::vector<geos::geom::Geometry *> *polys = - new std::vector<geos::geom::Geometry *>; + std::vector<const geos::geom::Geometry *> polys; for(unsigned int copyIndex = 0; copyIndex < poly->getNumGeometries(); copyIndex ++) { - polys->push_back(poly->getGeometryN(copyIndex)->clone().release()); + polys.push_back(poly->getGeometryN(copyIndex)->clone().release()); } unsigned int outerPolyIndex = 0; - while(outerPolyIndex + 1 < polys->size()) { + while(outerPolyIndex + 1 < polys.size()) { unsigned int innerPolyIndex = outerPolyIndex + 1; - while(innerPolyIndex < polys->size()) { + while(innerPolyIndex < polys.size()) { geos::geom::MultiPolygon *fixedPair = FixSeam( - dynamic_cast<geos::geom::Polygon *>(polys->at(outerPolyIndex)), - dynamic_cast<geos::geom::Polygon *>(polys->at(innerPolyIndex))); + dynamic_cast<const geos::geom::Polygon *>(polys.at(outerPolyIndex)), + dynamic_cast<const geos::geom::Polygon *>(polys.at(innerPolyIndex))); if(fixedPair != NULL) { - geos::geom::Geometry *oldInnerPoly = polys->at(innerPolyIndex); - geos::geom::Geometry *oldOuterPoly = polys->at(outerPolyIndex); + const geos::geom::Geometry *oldInnerPoly = polys.at(innerPolyIndex); + const geos::geom::Geometry *oldOuterPoly = polys.at(outerPolyIndex); - polys->erase(polys->begin() + innerPolyIndex); - (*polys)[outerPolyIndex] = fixedPair->getGeometryN(0)->clone().release(); + polys.erase(polys.begin() + innerPolyIndex); + polys[outerPolyIndex] = fixedPair->getGeometryN(0)->clone().release(); innerPolyIndex = outerPolyIndex + 1; delete fixedPair; @@ -1560,7 +1548,7 @@ namespace Isis { outerPolyIndex ++; } - return globalFactory->createMultiPolygon(polys); + return globalFactory->createMultiPolygon(polys).release(); } @@ -1610,7 +1598,7 @@ namespace Isis { geos::geom::MultiPolygon *PolygonTools::ReducePrecision(const geos::geom::MultiPolygon *poly, unsigned int precision) { // Maybe two points are on top of each other - vector<geos::geom::Geometry *> *newPolys = new vector<geos::geom::Geometry *>; + vector<const geos::geom::Geometry *> newPolys; // Convert each polygon in this multi-polygon for(unsigned int geomIndex = 0; geomIndex < poly->getNumGeometries(); geomIndex ++) { @@ -1620,14 +1608,14 @@ namespace Isis { precision); if(!lowerPrecision->isEmpty()) { - newPolys->push_back(lowerPrecision); + newPolys.push_back(lowerPrecision); } else { delete lowerPrecision; } } - geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(newPolys); + geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(newPolys).release(); return mp; } @@ -1644,13 +1632,13 @@ namespace Isis { geos::geom::Polygon *PolygonTools::ReducePrecision(const geos::geom::Polygon *poly, unsigned int precision) { // Convert each hole inside this polygon - vector<geos::geom::LinearRing *> *holes = new vector<geos::geom::LinearRing *>; + vector<unique_ptr<geos::geom::LinearRing>> holes; for(unsigned int holeIndex = 0; holeIndex < poly->getNumInteriorRing(); holeIndex ++) { - const geos::geom::LineString *thisHole = poly->getInteriorRingN(holeIndex); + const geos::geom::LinearRing *thisHole = poly->getInteriorRingN(holeIndex); // We hope they are all linear rings (closed/simple), but if not just leave it be if(thisHole->getGeometryTypeId() != geos::geom::GEOS_LINEARRING) { - holes->push_back(dynamic_cast<geos::geom::LinearRing *>(thisHole->clone().release())); + holes.push_back(thisHole->clone()); continue; } @@ -1659,7 +1647,7 @@ namespace Isis { precision); if(!newHole->isEmpty()) { - holes->push_back(newHole); + holes.push_back(newHole->clone()); } else { delete newHole; @@ -1676,10 +1664,10 @@ namespace Isis { const geos::geom::LineString *exterior = poly->getExteriorRing(); try { - geos::geom::LinearRing *newExterior = NULL; + unique_ptr<geos::geom::LinearRing> newExterior; if(exterior->getGeometryTypeId() == geos::geom::GEOS_LINEARRING) { - newExterior = ReducePrecision((geos::geom::LinearRing *)exterior, precision); + newExterior.reset(ReducePrecision((geos::geom::LinearRing *)exterior, precision)); } else { IString msg = "Failed when attempting to fix exterior ring of polygon. The exterior " @@ -1687,7 +1675,7 @@ namespace Isis { throw IException(IException::Programmer, msg, _FILEINFO_); } - return globalFactory->createPolygon(newExterior, holes); + return globalFactory->createPolygon(std::move(newExterior), std::move(holes)).release(); } catch(IException &e) { IString msg = "Failed when attempting to fix exterior ring of polygon"; @@ -1714,9 +1702,9 @@ namespace Isis { return dynamic_cast<geos::geom::LinearRing *>(ring->clone().release()); } - geos::geom::CoordinateArraySequence *newCoords = new geos::geom::DefaultCoordinateSequence(); + geos::geom::CoordinateSequence newCoords; geos::geom::Coordinate *coord = ReducePrecision(&coords->getAt(0), precision); - newCoords->add(*coord); + newCoords.add(*coord); delete coord; coord = NULL; @@ -1724,17 +1712,17 @@ namespace Isis { for(unsigned int coordIndex = 1; coordIndex < coords->getSize() - 1; coordIndex ++) { const geos::geom::Coordinate *thisCoordinate = &coords->getAt(coordIndex); coord = ReducePrecision(thisCoordinate, precision); - newCoords->add(*coord); + newCoords.add(*coord); delete coord; coord = NULL; } - newCoords->add(geos::geom::Coordinate(newCoords->getAt(0).x, newCoords->getAt(0).y)); + newCoords.add(geos::geom::Coordinate(newCoords.getAt(0).x, newCoords.getAt(0).y)); geos::geom::LinearRing *newRing = NULL; // Now that we've weeded out any bad coordinates, let's rebuild the geometry try { - newRing = globalFactory->createLinearRing(newCoords); + newRing = globalFactory->createLinearRing(newCoords).release(); } catch(geos::util::GEOSException *exc) { delete exc; @@ -2010,7 +1998,7 @@ namespace Isis { bool convertLon = false; bool negAdjust = false; bool newCoords = false; // coordinates have been adjusted - geos::geom::CoordinateArraySequence *newLonLatPts = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence *newLonLatPts = new geos::geom::CoordinateSequence(); double lon, lat; double lonOffset = 0; geos::geom::CoordinateSequence *inPolyCoords = inPoly->getCoordinates().release(); @@ -2063,7 +2051,7 @@ namespace Isis { // Nothing was done so return if (!newCoords) { geos::geom::Polygon *newPoly = globalFactory->createPolygon - (globalFactory->createLinearRing(newLonLatPts), NULL); + (globalFactory->createLinearRing(*newLonLatPts)).release(); geos::geom::MultiPolygon *multi_polygon = PolygonTools::MakeMultiPolygon(newPoly); delete newLonLatPts; return multi_polygon; @@ -2072,10 +2060,10 @@ namespace Isis { // bisect into seperate polygons try { geos::geom::Polygon *newPoly = globalFactory->createPolygon - (globalFactory->createLinearRing(newLonLatPts), NULL); + (globalFactory->createLinearRing(*newLonLatPts)).release(); - geos::geom::CoordinateArraySequence *pts = new geos::geom::CoordinateArraySequence(); - geos::geom::CoordinateArraySequence *pts2 = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence *pts = new geos::geom::CoordinateSequence(); + geos::geom::CoordinateSequence *pts2 = new geos::geom::CoordinateSequence(); // Depending on direction of compensation bound accordingly //*************************************************** @@ -2120,9 +2108,9 @@ namespace Isis { } geos::geom::Polygon *boundaryPoly = globalFactory->createPolygon - (globalFactory->createLinearRing(pts), NULL); + (globalFactory->createLinearRing(*pts)).release(); geos::geom::Polygon *boundaryPoly2 = globalFactory->createPolygon - (globalFactory->createLinearRing(pts2), NULL); + (globalFactory->createLinearRing(*pts2)).release(); /*------------------------------------------------------------------------ / Intersecting the original polygon (converted coordinates) with the / boundary polygons will create the multi polygons with the converted coordinates. @@ -2141,16 +2129,16 @@ namespace Isis { / the 0-360 world. This will always only need to be done on convertPoly. / Then add geometries to finalpolys. /-----------------------------------------------------------------------*/ - vector<geos::geom::Geometry *> *finalpolys = new vector<geos::geom::Geometry *>; + vector<const geos::geom::Geometry *> finalpolys; geos::geom::Geometry *newGeom = NULL; for (unsigned int i = 0; i < convertPoly->getNumGeometries(); i++) { newGeom = (convertPoly->getGeometryN(i))->clone().release(); geos::geom::CoordinateSequence *pts3 = convertPoly->getGeometryN(i)->getCoordinates().release(); - geos::geom::CoordinateArraySequence *newLonLatPts = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence *newLonLatPts = new geos::geom::CoordinateSequence(); // fix the points - for (unsigned int k = 0; k < pts3->getSize() ; k++) { + for (size_t k = 0; k < pts3->getSize() ; k++) { double lon = pts3->getAt(k).x; double lat = pts3->getAt(k).y; if (negAdjust) { @@ -2162,17 +2150,17 @@ namespace Isis { newLonLatPts->add(geos::geom::Coordinate(lon, lat), k); } // Add the points to polys - finalpolys->push_back(globalFactory->createPolygon - (globalFactory->createLinearRing(newLonLatPts), NULL)); + finalpolys.push_back(globalFactory->createPolygon + (globalFactory->createLinearRing(*newLonLatPts)).release()); } // 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().release(); - finalpolys->push_back(newGeom); + finalpolys.push_back(newGeom); } - geos::geom::MultiPolygon *multi_polygon = globalFactory->createMultiPolygon(finalpolys); + geos::geom::MultiPolygon *multi_polygon = globalFactory->createMultiPolygon(finalpolys).release(); delete newLonLatPts; delete pts; diff --git a/isis/src/base/objs/PolygonTools/PolygonTools.truth b/isis/src/base/objs/PolygonTools/PolygonTools.truth index d34a4bd64bd3ddeee7a8fa0ddc8e1c1e34a10d54..68968bf21b211cc7636ba5360ce433eaab70c269 100644 --- a/isis/src/base/objs/PolygonTools/PolygonTools.truth +++ b/isis/src/base/objs/PolygonTools/PolygonTools.truth @@ -6,25 +6,25 @@ Coordinates of polygon 2:(360 1, 359 1, 359 0, 360 0, 360 1) Coordinates of hole for polygon 2:(359.75 0.75, 359.25 0.75, 359.25 0.25, 359.75 0.25, 359.75 0.75) -Copy of the multipolygon = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 1.0000000000000000, 1.0000000000000000 1.0000000000000000, 1.0000000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000)), ((360.0000000000000000 1.0000000000000000, 359.0000000000000000 1.0000000000000000, 359.0000000000000000 0.0000000000000000, 360.0000000000000000 0.0000000000000000, 360.0000000000000000 1.0000000000000000), (359.7500000000000000 0.7500000000000000, 359.2500000000000000 0.7500000000000000, 359.2500000000000000 0.2500000000000000, 359.7500000000000000 0.2500000000000000, 359.7500000000000000 0.7500000000000000))) +Copy of the multipolygon = MULTIPOLYGON (((0 0, 0 1, 1 1, 1 0, 0 0)), ((360 1, 359 1, 359 0, 360 0, 360 1), (359.75 0.75, 359.25 0.75, 359.25 0.25, 359.75 0.25, 359.75 0.75))) -Lon/Lat polygon = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 1.0000000000000000, 1.0000000000000000 1.0000000000000000, 1.0000000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000)), ((360.0000000000000000 1.0000000000000000, 359.0000000000000000 1.0000000000000000, 359.0000000000000000 0.0000000000000000, 360.0000000000000000 0.0000000000000000, 360.0000000000000000 1.0000000000000000), (359.7500000000000000 0.7500000000000000, 359.2500000000000000 0.7500000000000000, 359.2500000000000000 0.2500000000000000, 359.7500000000000000 0.2500000000000000, 359.7500000000000000 0.7500000000000000))) +Lon/Lat polygon = MULTIPOLYGON (((0 0, 0 1, 1 1, 1 0, 0 0)), ((360 1, 359 1, 359 0, 360 0, 360 1), (359.75 0.75, 359.25 0.75, 359.25 0.25, 359.75 0.25, 359.75 0.75))) -X/Y polygon radius (1) = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 0.0174532925199433, 0.0174506342989556 0.0174532925199433, 0.0174532925199433 0.0000000000000000, 0.0000000000000000 0.0000000000000000)), ((6.2822283476240113 0.0174532925199433, 6.2647777133250555 0.0174532925199433, 6.2657320146596422 0.0000000000000000, 6.2831853071795862 0.0000000000000000, 6.2822283476240113 0.0174532925199433), (6.2782840621378480 0.0130899693899575, 6.2695581635108333 0.0130899693899575, 6.2700356510010868 0.0043633231299858, 6.2787622141896753 0.0043633231299858, 6.2782840621378480 0.0130899693899575))) +X/Y polygon radius (1) = MULTIPOLYGON (((0 0, 0 0.0174532925199433, 0.0174506342989556 0.0174532925199433, 0.0174532925199433 0, 0 0)), ((6.282228347624011 0.0174532925199433, 6.2647777133250555 0.0174532925199433, 6.265732014659642 0, 6.283185307179586 0, 6.282228347624011 0.0174532925199433), (6.278284062137848 0.0130899693899575, 6.269558163510833 0.0130899693899575, 6.270035651001087 0.0043633231299858, 6.278762214189675 0.0043633231299858, 6.278284062137848 0.0130899693899575))) -X/Y polygon radius (10) = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 0.1745329251994329, 0.1745063429895559 0.1745329251994329, 0.1745329251994329 0.0000000000000000, 0.0000000000000000 0.0000000000000000)), ((62.8222834762401163 0.1745329251994329, 62.6477771332505498 0.1745329251994329, 62.6573201465964189 0.0000000000000000, 62.8318530717958623 0.0000000000000000, 62.8222834762401163 0.1745329251994329), (62.7828406213784831 0.1308996938995747, 62.6955816351083257 0.1308996938995747, 62.7003565100108631 0.0436332312998582, 62.7876221418967546 0.0436332312998582, 62.7828406213784831 0.1308996938995747))) +X/Y polygon radius (10) = MULTIPOLYGON (((0 0, 0 0.174532925199433, 0.1745063429895559 0.174532925199433, 0.174532925199433 0, 0 0)), ((62.822283476240116 0.174532925199433, 62.64777713325055 0.174532925199433, 62.65732014659642 0, 62.83185307179586 0, 62.822283476240116 0.174532925199433), (62.78284062137848 0.1308996938995747, 62.695581635108326 0.1308996938995747, 62.70035651001086 0.0436332312998582, 62.787622141896755 0.0436332312998582, 62.78284062137848 0.1308996938995747))) -Lat/Lon polygon from X/Y with radius (10) = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 1.0000000000000000, 1.0000000000000000 1.0000000000000000, 1.0000000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000)), ((360.0000000000000000 1.0000000000000000, 358.9999999999999432 1.0000000000000000, 358.9999999999999432 0.0000000000000000, 360.0000000000000000 0.0000000000000000, 360.0000000000000000 1.0000000000000000), (359.7499999999999432 0.7500000000000000, 359.2499999999999432 0.7500000000000000, 359.2499999999999432 0.2500000000000000, 359.7499999999999432 0.2500000000000000, 359.7499999999999432 0.7500000000000000))) +Lat/Lon polygon from X/Y with radius (10) = MULTIPOLYGON (((0 0, 0 1, 1 1, 1 0, 0 0)), ((360 1, 358.99999999999994 1, 358.99999999999994 0, 360 0, 360 1), (359.74999999999994 0.75, 359.24999999999994 0.75, 359.24999999999994 0.25, 359.74999999999994 0.25, 359.74999999999994 0.75))) Coordinates of Lon/Lat polygon:(172 -31, 174 -14, 188 -16, 188 -33, 172 -31) -Coordinates of Sample/Line polygon:MULTIPOLYGON (((24.0000000000000000 9.9000000000000004, 1200.0000000000000000 26.0000000000000000, 1200.0000000000000000 1000.0000000000000000, 9.2000000000000011 1000.0000000000000000, 24.0000000000000000 9.9000000000000004))) +Coordinates of Sample/Line polygon:MULTIPOLYGON (((24 9.9, 1200 26, 1200 1000, 9.200000000000001 1000, 24 9.9))) Testing LatLonToSampleLine() with coords outside of the valid range. -Coordinates of Sample/Line polygon:MULTIPOLYGON (((290.0000000000000000 210.0000000000000000, 160.0000000000000000 620.0000000000000000, 450.0000000000000000 960.0000000000000000, 1100.0000000000000000 720.0000000000000000, 290.0000000000000000 210.0000000000000000))) +Coordinates of Sample/Line polygon:MULTIPOLYGON (((290 210, 160 620, 450 960, 1100 720, 290 210))) Well Knowen Text Polygon: -MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 1.0000000000000000, 1.0000000000000000 1.0000000000000000, 1.0000000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000)), ((360.0000000000000000 1.0000000000000000, 359.0000000000000000 1.0000000000000000, 359.0000000000000000 0.0000000000000000, 360.0000000000000000 0.0000000000000000, 360.0000000000000000 1.0000000000000000), (359.7500000000000000 0.7500000000000000, 359.2500000000000000 0.7500000000000000, 359.2500000000000000 0.2500000000000000, 359.7500000000000000 0.2500000000000000, 359.7500000000000000 0.7500000000000000))) +MULTIPOLYGON (((0 0, 0 1, 1 1, 1 0, 0 0)), ((360 1, 359 1, 359 0, 360 0, 360 1), (359.75 0.75, 359.25 0.75, 359.25 0.25, 359.75 0.25, 359.75 0.75))) GML Ploygon: <?xml version="1.0" encoding="utf-8" ?> @@ -52,13 +52,13 @@ GML Thickness: Testing Despike -Input: LINEARRING (1.0000000000000000 1.0000000000000000, 5.0000000000000000 1.0000000000000000, 5.0000000000100000 -10.0000000000000000, 5.0000000000100000 5.0000000000000000, 1.0000000000000000 5.0000000000000000, 1.0000000000000000 1.0000000000000000) -Output: LINEARRING (1.0000000000000000 1.0000000000000000, 5.0000000000000000 1.0000000000000000, 5.0000000000100000 5.0000000000000000, 1.0000000000000000 5.0000000000000000, 1.0000000000000000 1.0000000000000000) +Input: LINEARRING (1 1, 5 1, 5.00000000001 -10, 5.00000000001 5, 1 5, 1 1) +Output: LINEARRING (1 1, 5 1, 5.00000000001 5, 1 5, 1 1) Testing FixGeometry -Input: LINEARRING (1.0000000000000000 1.0000000000000000, 5.0000000000000000 1.0000000000000000, 5.0000000000000000 5.0000000000000000, 5.0000000000000098 5.0000000000000000, 1.0000000000000000 5.0000000000000000, 1.0000000000000000 1.0000000000000000) -Output: LINEARRING (1.0000000000000000 1.0000000000000000, 5.0000000000000000 1.0000000000000000, 5.0000000000000098 5.0000000000000000, 1.0000000000000000 5.0000000000000000, 1.0000000000000000 1.0000000000000000) +Input: LINEARRING (1 1, 5 1, 5 5, 5.00000000000001 5, 1 5, 1 1) +Output: LINEARRING (1 1, 5 1, 5.00000000000001 5, 1 5, 1 1) Testing Equal diff --git a/isis/src/base/objs/PolygonTools/unitTest.cpp b/isis/src/base/objs/PolygonTools/unitTest.cpp index 9f792dc2a1dc888acbd4b67aedcc7ad0db60e544..3fbc37662461d436b3f4094fb44f619f6a08ec2b 100644 --- a/isis/src/base/objs/PolygonTools/unitTest.cpp +++ b/isis/src/base/objs/PolygonTools/unitTest.cpp @@ -5,7 +5,6 @@ find files of those names at the top level of this repository. **/ /* SPDX-License-Identifier: CC0-1.0 */ #include <geos/geom/CoordinateSequence.h> -#include <geos/geom/CoordinateArraySequence.h> #include <geos/geom/LinearRing.h> #include <geos/geom/Polygon.h> #include <geos/util/GEOSException.h> @@ -32,46 +31,46 @@ int main() { cout << "Unit test for PolygonTools" << endl << endl; // Create coordinate sequence for the first of two polygons - geos::geom::CoordinateArraySequence *pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(0.0, 0.0)); - pts->add(geos::geom::Coordinate(0.0, 1.0)); - pts->add(geos::geom::Coordinate(1.0, 1.0)); - pts->add(geos::geom::Coordinate(1.0, 0.0)); - pts->add(geos::geom::Coordinate(0.0, 0.0)); - cout << "Coordinates of polygon 1:" << pts->toString() << endl << endl; + geos::geom::CoordinateSequence pts; + pts.add(geos::geom::Coordinate(0.0, 0.0)); + pts.add(geos::geom::Coordinate(0.0, 1.0)); + pts.add(geos::geom::Coordinate(1.0, 1.0)); + pts.add(geos::geom::Coordinate(1.0, 0.0)); + pts.add(geos::geom::Coordinate(0.0, 0.0)); + cout << "Coordinates of polygon 1:" << pts.toString() << endl << endl; // Create the first polygon - vector<const geos::geom::Geometry *> polys; + vector <const geos::geom::Geometry *> polys; polys.push_back(Isis::globalFactory->createPolygon( - Isis::globalFactory->createLinearRing(pts), NULL)); + Isis::globalFactory->createLinearRing(pts)).release()); // Create coordinate sequence for the second of two polygons - geos::geom::CoordinateArraySequence *pts2 = new geos::geom::CoordinateArraySequence(); - pts2->add(geos::geom::Coordinate(360.0, 1.0)); - pts2->add(geos::geom::Coordinate(359.0, 1.0)); - pts2->add(geos::geom::Coordinate(359.0, 0.0)); - pts2->add(geos::geom::Coordinate(360.0, 0.0)); - pts2->add(geos::geom::Coordinate(360.0, 1.0)); - cout << "Coordinates of polygon 2:" << pts2->toString() << endl << endl; + geos::geom::CoordinateSequence pts2; + pts2.add(geos::geom::Coordinate(360.0, 1.0)); + pts2.add(geos::geom::Coordinate(359.0, 1.0)); + pts2.add(geos::geom::Coordinate(359.0, 0.0)); + pts2.add(geos::geom::Coordinate(360.0, 0.0)); + pts2.add(geos::geom::Coordinate(360.0, 1.0)); + cout << "Coordinates of polygon 2:" << pts2.toString() << endl << endl; // Create coordinate sequence for the hole in the second polygon - geos::geom::CoordinateArraySequence *pts3 = new geos::geom::DefaultCoordinateSequence(); - pts3->add(geos::geom::Coordinate(359.75, 0.75)); - pts3->add(geos::geom::Coordinate(359.25, 0.75)); - pts3->add(geos::geom::Coordinate(359.25, 0.25)); - pts3->add(geos::geom::Coordinate(359.75, 0.25)); - pts3->add(geos::geom::Coordinate(359.75, 0.75)); - cout << "Coordinates of hole for polygon 2:" << pts3->toString() << endl << endl; + geos::geom::CoordinateSequence pts3; + pts3.add(geos::geom::Coordinate(359.75, 0.75)); + pts3.add(geos::geom::Coordinate(359.25, 0.75)); + pts3.add(geos::geom::Coordinate(359.25, 0.25)); + pts3.add(geos::geom::Coordinate(359.75, 0.25)); + pts3.add(geos::geom::Coordinate(359.75, 0.75)); + cout << "Coordinates of hole for polygon 2:" << pts3.toString() << endl << endl; - vector<geos::geom::LinearRing *> *hole2 = new vector<geos::geom::LinearRing *>; - hole2->push_back(Isis::globalFactory->createLinearRing(pts3)); + vector<std::unique_ptr<geos::geom::LinearRing>> hole2; + hole2.push_back(Isis::globalFactory->createLinearRing(pts3)); // Create the second polygon polys.push_back(Isis::globalFactory->createPolygon( - Isis::globalFactory->createLinearRing(pts2), hole2)); + Isis::globalFactory->createLinearRing(pts2), std::move(hole2)).release()); // Create a multipolygon from the two polygons - geos::geom::MultiPolygon *mPolygon = Isis::globalFactory->createMultiPolygon(polys); + geos::geom::MultiPolygon *mPolygon = Isis::globalFactory->createMultiPolygon(polys).release(); // Create a copy of the multipolygon geos::geom::MultiPolygon *tmpMp = PolygonTools::CopyMultiPolygon(mPolygon); @@ -119,35 +118,35 @@ int main() { UniversalGroundMap ugm = UniversalGroundMap(cube); // Create coordinate sequence for the first of two polygons - geos::geom::CoordinateArraySequence *llpts = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence llpts; ugm.SetImage(1.0, 1.0); - llpts->add(geos::geom::Coordinate( + llpts.add(geos::geom::Coordinate( qRound(ugm.UniversalLongitude()), qRound(ugm.UniversalLatitude()))); ugm.SetImage(1204.0, 1.0); - llpts->add(geos::geom::Coordinate( + llpts.add(geos::geom::Coordinate( qRound(ugm.UniversalLongitude()), qRound(ugm.UniversalLatitude()))); ugm.SetImage(1204.0, 1056.0); - llpts->add(geos::geom::Coordinate( + llpts.add(geos::geom::Coordinate( qRound(ugm.UniversalLongitude()), qRound(ugm.UniversalLatitude()))); ugm.SetImage(1.0, 1056.0); - llpts->add(geos::geom::Coordinate( + llpts.add(geos::geom::Coordinate( qRound(ugm.UniversalLongitude()), qRound(ugm.UniversalLatitude()))); ugm.SetImage(1.0, 1.0); - llpts->add(geos::geom::Coordinate( + llpts.add(geos::geom::Coordinate( qRound(ugm.UniversalLongitude()), qRound(ugm.UniversalLatitude()))); - cout << "Coordinates of Lon/Lat polygon:" << llpts->toString() << endl << endl; + cout << "Coordinates of Lon/Lat polygon:" << llpts.toString() << endl << endl; // Create the L/L polygon vector<const geos::geom::Geometry *> llpolys; llpolys.push_back(Isis::globalFactory->createPolygon( - Isis::globalFactory->createLinearRing(llpts), NULL)); + Isis::globalFactory->createLinearRing(llpts)).release()); - geos::geom::MultiPolygon *llmPolygon = Isis::globalFactory->createMultiPolygon(llpolys); + geos::geom::MultiPolygon *llmPolygon = Isis::globalFactory->createMultiPolygon(llpolys).release(); geos::geom::MultiPolygon *slmPolygon = PolygonTools::LatLonToSampleLine(*llmPolygon, &ugm); cout << "Coordinates of Sample/Line polygon:" << @@ -155,20 +154,20 @@ int main() { cout << endl << "Testing LatLonToSampleLine() with coords outside of the valid range." << endl; // Create coordinate sequence for the first of two polygons - geos::geom::CoordinateArraySequence *llpts2 = new geos::geom::CoordinateArraySequence(); - llpts2->add(geos::geom::Coordinate(175, 0)); - llpts2->add(geos::geom::Coordinate(175.6, -28)); - llpts2->add(geos::geom::Coordinate(181.5, -30.6)); - llpts2->add(geos::geom::Coordinate(186.8, -27)); - llpts2->add(geos::geom::Coordinate(183.7, -16.6)); - llpts2->add(geos::geom::Coordinate(175, 0)); + geos::geom::CoordinateSequence llpts2; + llpts2.add(geos::geom::Coordinate(175, 0)); + llpts2.add(geos::geom::Coordinate(175.6, -28)); + llpts2.add(geos::geom::Coordinate(181.5, -30.6)); + llpts2.add(geos::geom::Coordinate(186.8, -27)); + llpts2.add(geos::geom::Coordinate(183.7, -16.6)); + llpts2.add(geos::geom::Coordinate(175, 0)); // Create the L/L polygon vector<const geos::geom::Geometry *> llpolys2; llpolys2.push_back(Isis::globalFactory->createPolygon( - Isis::globalFactory->createLinearRing(llpts2), NULL)); + Isis::globalFactory->createLinearRing(llpts2)).release()); - geos::geom::MultiPolygon *llmPolygon2 = Isis::globalFactory->createMultiPolygon(llpolys2); + geos::geom::MultiPolygon *llmPolygon2 = Isis::globalFactory->createMultiPolygon(llpolys2).release(); geos::geom::MultiPolygon *slmPolygon2 = PolygonTools::LatLonToSampleLine(*llmPolygon2, &ugm); cout << "Coordinates of Sample/Line polygon:" << @@ -192,71 +191,71 @@ int main() { cout << endl << endl; cout << "Testing Despike" << endl; - pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(1.0, 1.0)); - pts->add(geos::geom::Coordinate(5.0, 1.0)); - pts->add(geos::geom::Coordinate(5.00000000001, -10.0)); - pts->add(geos::geom::Coordinate(5.00000000001, 5.0)); - pts->add(geos::geom::Coordinate(1.0, 5.0)); - pts->add(geos::geom::Coordinate(1.0, 1.0)); + pts.clear(); + pts.add(geos::geom::Coordinate(1.0, 1.0)); + pts.add(geos::geom::Coordinate(5.0, 1.0)); + pts.add(geos::geom::Coordinate(5.00000000001, -10.0)); + pts.add(geos::geom::Coordinate(5.00000000001, 5.0)); + pts.add(geos::geom::Coordinate(1.0, 5.0)); + pts.add(geos::geom::Coordinate(1.0, 1.0)); cout << "Input: " << Isis::globalFactory->createLinearRing(pts)->toString() << endl; - cout << "Output: " << PolygonTools::Despike(Isis::globalFactory->createLinearRing(pts))->toString() << endl; + cout << "Output: " << PolygonTools::Despike(Isis::globalFactory->createLinearRing(pts).release())->toString() << endl; cout << endl << endl; cout << "Testing FixGeometry" << endl; - pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(1.0, 1.0)); - pts->add(geos::geom::Coordinate(5.0, 1.0)); - pts->add(geos::geom::Coordinate(5.0, 5.0)); - pts->add(geos::geom::Coordinate(5.00000000000001, 5.0)); - pts->add(geos::geom::Coordinate(1.0, 5.0)); - pts->add(geos::geom::Coordinate(1.0, 1.0)); + pts.clear(); + pts.add(geos::geom::Coordinate(1.0, 1.0)); + pts.add(geos::geom::Coordinate(5.0, 1.0)); + pts.add(geos::geom::Coordinate(5.0, 5.0)); + pts.add(geos::geom::Coordinate(5.00000000000001, 5.0)); + pts.add(geos::geom::Coordinate(1.0, 5.0)); + pts.add(geos::geom::Coordinate(1.0, 1.0)); cout << "Input: " << Isis::globalFactory->createLinearRing(pts)->toString() << endl; - cout << "Output: " << PolygonTools::Despike(Isis::globalFactory->createLinearRing(pts))->toString() << endl; + cout << "Output: " << PolygonTools::Despike(Isis::globalFactory->createLinearRing(pts).release())->toString() << endl; cout << endl << endl; cout << "Testing Equal" << endl; - pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(1.0, 1.0)); - pts->add(geos::geom::Coordinate(5.0, 1.0)); - pts->add(geos::geom::Coordinate(5.0, 5.0)); - pts->add(geos::geom::Coordinate(1.0, 5.0)); - pts->add(geos::geom::Coordinate(1.0, 1.0)); - geos::geom::Polygon *poly1 = Isis::globalFactory->createPolygon(Isis::globalFactory->createLinearRing(*pts), NULL); + pts.clear(); + pts.add(geos::geom::Coordinate(1.0, 1.0)); + pts.add(geos::geom::Coordinate(5.0, 1.0)); + pts.add(geos::geom::Coordinate(5.0, 5.0)); + pts.add(geos::geom::Coordinate(1.0, 5.0)); + pts.add(geos::geom::Coordinate(1.0, 1.0)); + geos::geom::Polygon *poly1 = Isis::globalFactory->createPolygon(Isis::globalFactory->createLinearRing(pts)).release(); cout << "Same Poly Equal? " << PolygonTools::Equal(poly1, poly1) << " - " << poly1->equals(poly1) << endl; - pts2 = new geos::geom::CoordinateArraySequence(); - pts2->add(geos::geom::Coordinate(5.0, 1.0)); - pts2->add(geos::geom::Coordinate(5.0, 5.0)); - pts2->add(geos::geom::Coordinate(1.0, 5.0)); - pts2->add(geos::geom::Coordinate(1.0, 1.0)); - pts2->add(geos::geom::Coordinate(5.0, 1.0)); - geos::geom::Polygon *poly2 = Isis::globalFactory->createPolygon(Isis::globalFactory->createLinearRing(*pts2), NULL); + pts2.clear(); + pts2.add(geos::geom::Coordinate(5.0, 1.0)); + pts2.add(geos::geom::Coordinate(5.0, 5.0)); + pts2.add(geos::geom::Coordinate(1.0, 5.0)); + pts2.add(geos::geom::Coordinate(1.0, 1.0)); + pts2.add(geos::geom::Coordinate(5.0, 1.0)); + geos::geom::Polygon *poly2 = Isis::globalFactory->createPolygon(Isis::globalFactory->createLinearRing(pts2)).release(); cout << "Rearranged Poly Equal? " << PolygonTools::Equal(poly1, poly2) << " - " << poly1->equals(poly2) << endl; - pts2 = new geos::geom::CoordinateArraySequence(); - pts2->add(geos::geom::Coordinate(5.0, 1.0)); - pts2->add(geos::geom::Coordinate(5.0, 5.0)); - pts2->add(geos::geom::Coordinate(1.000000000000001, 5.0)); - pts2->add(geos::geom::Coordinate(1.0, 1.0)); - pts2->add(geos::geom::Coordinate(5.0, 1.0)); - poly2 = Isis::globalFactory->createPolygon(Isis::globalFactory->createLinearRing(*pts2), NULL); + pts2.clear(); + pts2.add(geos::geom::Coordinate(5.0, 1.0)); + pts2.add(geos::geom::Coordinate(5.0, 5.0)); + pts2.add(geos::geom::Coordinate(1.000000000000001, 5.0)); + pts2.add(geos::geom::Coordinate(1.0, 1.0)); + pts2.add(geos::geom::Coordinate(5.0, 1.0)); + poly2 = Isis::globalFactory->createPolygon(Isis::globalFactory->createLinearRing(pts2)).release(); cout << "Past 15 Places Equal? " << PolygonTools::Equal(poly1, poly2) << " - " << poly1->equals(poly2) << endl; - pts2 = new geos::geom::CoordinateArraySequence(); - pts2->add(geos::geom::Coordinate(5.0, 1.0)); - pts2->add(geos::geom::Coordinate(5.0, 5.0)); - pts2->add(geos::geom::Coordinate(1.00000000000001, 5.0)); - pts2->add(geos::geom::Coordinate(1.0, 1.0)); - pts2->add(geos::geom::Coordinate(5.0, 1.0)); - poly2 = Isis::globalFactory->createPolygon(Isis::globalFactory->createLinearRing(*pts2), NULL); + pts2.clear(); + pts2.add(geos::geom::Coordinate(5.0, 1.0)); + pts2.add(geos::geom::Coordinate(5.0, 5.0)); + pts2.add(geos::geom::Coordinate(1.00000000000001, 5.0)); + pts2.add(geos::geom::Coordinate(1.0, 1.0)); + pts2.add(geos::geom::Coordinate(5.0, 1.0)); + poly2 = Isis::globalFactory->createPolygon(Isis::globalFactory->createLinearRing(pts2)).release(); cout << "At 15 Place Difference Equal? " << PolygonTools::Equal(poly1, poly2) << " - " << poly1->equals(poly2) << endl; - pts2 = new geos::geom::CoordinateArraySequence(); - pts2->add(geos::geom::Coordinate(5.0, 1.0)); - pts2->add(geos::geom::Coordinate(5.0, 5.0)); - pts2->add(geos::geom::Coordinate(1.0000000000001, 5.0)); - pts2->add(geos::geom::Coordinate(1.0, 1.0)); - pts2->add(geos::geom::Coordinate(5.0, 1.0)); - poly2 = Isis::globalFactory->createPolygon(Isis::globalFactory->createLinearRing(*pts2), NULL); + pts2.clear(); + pts2.add(geos::geom::Coordinate(5.0, 1.0)); + pts2.add(geos::geom::Coordinate(5.0, 5.0)); + pts2.add(geos::geom::Coordinate(1.0000000000001, 5.0)); + pts2.add(geos::geom::Coordinate(1.0, 1.0)); + pts2.add(geos::geom::Coordinate(5.0, 1.0)); + poly2 = Isis::globalFactory->createPolygon(Isis::globalFactory->createLinearRing(pts2)).release(); cout << "Significantly Different Equal? " << PolygonTools::Equal(poly1, poly2) << " - " << poly1->equals(poly2) << endl; return 0; diff --git a/isis/src/base/objs/ProcessGroundPolygons/ProcessGroundPolygons.cpp b/isis/src/base/objs/ProcessGroundPolygons/ProcessGroundPolygons.cpp index a422b108cf257bc39b1b0170b442df5f4dbd5b28..4f5a1907f635e957ba557286603ae2e77bbe976e 100644 --- a/isis/src/base/objs/ProcessGroundPolygons/ProcessGroundPolygons.cpp +++ b/isis/src/base/objs/ProcessGroundPolygons/ProcessGroundPolygons.cpp @@ -9,7 +9,6 @@ find files of those names at the top level of this repository. **/ #include <vector> #include "geos/geom/CoordinateSequence.h" -#include "geos/geom/CoordinateArraySequence.h" #include "geos/geom/LineString.h" #include "Application.h" @@ -53,14 +52,14 @@ namespace Isis { if (crosses) { // Make a polygon from the lat/lon vectors and split it on 360 - geos::geom::CoordinateArraySequence *pts = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence pts; for (unsigned int i = 0; i < lat.size(); i++) { - pts->add(geos::geom::Coordinate(lon[i], lat[i])); + pts.add(geos::geom::Coordinate(lon[i], lat[i])); } - pts->add(geos::geom::Coordinate(lon[0], lat[0])); + pts.add(geos::geom::Coordinate(lon[0], lat[0])); geos::geom::Polygon *crossingPoly = Isis::globalFactory->createPolygon( - globalFactory->createLinearRing(pts), NULL); + globalFactory->createLinearRing(pts)).release(); geos::geom::MultiPolygon *splitPoly = NULL; try { diff --git a/isis/src/base/objs/ProcessPolygons/ProcessPolygons.cpp b/isis/src/base/objs/ProcessPolygons/ProcessPolygons.cpp index 815497a1876fbf3ab951a91137b223cc7939be33..f5b46aacd8164c5aa19f953517cbccb14134d9c9 100644 --- a/isis/src/base/objs/ProcessPolygons/ProcessPolygons.cpp +++ b/isis/src/base/objs/ProcessPolygons/ProcessPolygons.cpp @@ -11,7 +11,6 @@ find files of those names at the top level of this repository. **/ #include "SpecialPixel.h" #include "geos/geom/CoordinateSequence.h" -#include "geos/geom/CoordinateArraySequence.h" #include "geos/geom/Coordinate.h" #include "geos/geom/Envelope.h" #include "geos/geom/LineString.h" @@ -89,18 +88,18 @@ namespace Isis { void ProcessPolygons::FillPolygon(int Flag) { // Create a sample/line polygon for the input pixel vertices - geos::geom::CoordinateArraySequence *pts = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence pts; for (unsigned int i = 0; i < m_sampleVertices.size(); i++) { - pts->add(geos::geom::Coordinate(m_sampleVertices[i], m_lineVertices[i])); + pts.add(geos::geom::Coordinate(m_sampleVertices[i], m_lineVertices[i])); } - pts->add(geos::geom::Coordinate(m_sampleVertices[0], m_lineVertices[0])); + pts.add(geos::geom::Coordinate(m_sampleVertices[0], m_lineVertices[0])); try { // Create a polygon from the pixel vertices. This polygon may have spikes or other // problems such as multiple polygons. Despike, then make sure we have a single polygon. // Do not rasterize pixel if despiking fails or there are multiple polygons. geos::geom::Polygon *spikedPixelPoly = Isis::globalFactory->createPolygon( - globalFactory->createLinearRing(pts), NULL); + globalFactory->createLinearRing(pts)).release(); const geos::geom::Polygon *projectedInputPixelPoly; @@ -150,20 +149,20 @@ namespace Isis { if (m_useCenter) { geos::geom::Coordinate c(x, y); - geos::geom::Point *p = Isis::globalFactory->createPoint(c); + geos::geom::Point *p = Isis::globalFactory->createPoint(c).release(); contains = preparedPoly->contains(p); delete p; } else { - geos::geom::CoordinateArraySequence *tpts = new geos::geom::CoordinateArraySequence(); - tpts->add(geos::geom::Coordinate(x - 0.5, y - 0.5)); - tpts->add(geos::geom::Coordinate(x + 0.5, y - 0.5)); - tpts->add(geos::geom::Coordinate(x + 0.5, y + 0.5)); - tpts->add(geos::geom::Coordinate(x - 0.5, y + 0.5)); - tpts->add(geos::geom::Coordinate(x - 0.5, y - 0.5)); + geos::geom::CoordinateSequence tpts; + tpts.add(geos::geom::Coordinate(x - 0.5, y - 0.5)); + tpts.add(geos::geom::Coordinate(x + 0.5, y - 0.5)); + tpts.add(geos::geom::Coordinate(x + 0.5, y + 0.5)); + tpts.add(geos::geom::Coordinate(x - 0.5, y + 0.5)); + tpts.add(geos::geom::Coordinate(x - 0.5, y - 0.5)); geos::geom::Polygon *outPixelFootPrint = Isis::globalFactory->createPolygon( - globalFactory->createLinearRing(tpts), NULL); + globalFactory->createLinearRing(tpts)).release(); contains = preparedPoly->intersects(outPixelFootPrint); delete outPixelFootPrint; } @@ -326,7 +325,7 @@ namespace Isis { OutputCubes[0]->addCachingAlgorithm(new BoxcarCachingAlgorithm()); OutputCubes[1]->addCachingAlgorithm(new BoxcarCachingAlgorithm()); - geos::geom::CoordinateArraySequence imagePts; + geos::geom::CoordinateSequence imagePts; imagePts.add(geos::geom::Coordinate(0.0, 0.0)); imagePts.add(geos::geom::Coordinate(0.0, this->OutputCubes[0]->lineCount())); @@ -336,7 +335,7 @@ namespace Isis { imagePts.add(geos::geom::Coordinate(0.0, 0.0)); m_imagePoly = Isis::globalFactory->createPolygon( - globalFactory->createLinearRing(imagePts), NULL); + globalFactory->createLinearRing(imagePts)).release(); m_average = new Brick(*this->OutputCubes[0], 1, 1, nbands); m_count = new Brick(*this->OutputCubes[1], 1, 1, nbands); diff --git a/isis/src/base/objs/StripPolygonSeeder/StripPolygonSeeder.cpp b/isis/src/base/objs/StripPolygonSeeder/StripPolygonSeeder.cpp index a75598c78e783f48569c55ff6386e591045faec2..eb52788b88743f0c12a95e414f7bc9a54bcd218c 100644 --- a/isis/src/base/objs/StripPolygonSeeder/StripPolygonSeeder.cpp +++ b/isis/src/base/objs/StripPolygonSeeder/StripPolygonSeeder.cpp @@ -83,15 +83,15 @@ namespace Isis { //printf("Grid Line,%.10f,%.10f,Through,%.10f,%.10f\n",dRealMinX, y, xyBoundBox->getMaxX(), y); for(double x = dRealMinX; x <= polyBoundBox->getMaxX(); x += p_Xspacing) { geos::geom::Coordinate c(x + dDeltaXToReal, y + dDeltaYToReal); - geos::geom::Point *p = Isis::globalFactory->createPoint(c); + geos::geom::Point *p = Isis::globalFactory->createPoint(c).release(); if(p->within(multiPoly)) { - points.push_back(Isis::globalFactory->createPoint(c)); + points.push_back(Isis::globalFactory->createPoint(c).release()); } geos::geom::Coordinate c2(x - dDeltaXToReal, y - dDeltaYToReal); - p = Isis::globalFactory->createPoint(c2); + p = Isis::globalFactory->createPoint(c2).release(); if(p->within(multiPoly)) { - points.push_back(Isis::globalFactory->createPoint(c2)); + points.push_back(Isis::globalFactory->createPoint(c2).release()); } } } diff --git a/isis/src/base/objs/StripPolygonSeeder/StripPolygonSeeder.truth b/isis/src/base/objs/StripPolygonSeeder/StripPolygonSeeder.truth index 8d0b8974d2c0665ce6b209d68b3a44405835f39c..b1f54ca7dee61ddf035d202d5d1c913d78067138 100644 --- a/isis/src/base/objs/StripPolygonSeeder/StripPolygonSeeder.truth +++ b/isis/src/base/objs/StripPolygonSeeder/StripPolygonSeeder.truth @@ -15,7 +15,7 @@ Test to make sure Parse did it's job MinimumThickness = 0.3 MinimumArea = 10 Test 2, test a square polygon -Lon/Lat polygon = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 1.5000000000000000, 0.5000000000000000 1.5000000000000000, 0.5000000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000))) +Lon/Lat polygon = MULTIPOLYGON (((0 0, 0 1.5, 0.5 1.5, 0.5 0, 0 0))) POINT (0.001115746481597 0.02030349816807) POINT (0.02642165535764 0.02030349816807) POINT (0.01798635165552 0.01186819573901) @@ -2318,4 +2318,4 @@ Lon/Lat polygon = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.00000 POINT (0.4820905628549 1.488046120824) POINT (0.4736506084621 1.479610818395) Test 3, test for too thin -Lon/Lat polygon = MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 0.5000000000000000, 0.0125000000000000 0.5000000000000000, 0.0125000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000))) +Lon/Lat polygon = MULTIPOLYGON (((0 0, 0 0.5, 0.0125 0.5, 0.0125 0, 0 0))) diff --git a/isis/src/base/objs/StripPolygonSeeder/unitTest.cpp b/isis/src/base/objs/StripPolygonSeeder/unitTest.cpp index 2502a2bdd0eff5c61070be382925bda82d0d86a1..e6165f4d98e79266f3db2edcc2b77e208e2d3cef 100644 --- a/isis/src/base/objs/StripPolygonSeeder/unitTest.cpp +++ b/isis/src/base/objs/StripPolygonSeeder/unitTest.cpp @@ -9,7 +9,7 @@ find files of those names at the top level of this repository. **/ #include <cmath> #include <iomanip> -#include <geos/geom/CoordinateArraySequence.h> +#include <geos/geom/CoordinateSequence.h> #include <geos/geom/Geometry.h> #include <geos/geom/Polygon.h> @@ -60,21 +60,20 @@ int main() { std::cout << "Test 2, test a square polygon" << std::endl; try { // Call the seed member with a polygon - geos::geom::CoordinateArraySequence *pts; - vector<const geos::geom::Geometry *> polys; + geos::geom::CoordinateSequence pts; + vector <const geos::geom::Geometry *> polys; // Create the A polygon - pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(0, 0)); - pts->add(geos::geom::Coordinate(0, 1.5)); - pts->add(geos::geom::Coordinate(0.5, 1.5)); - pts->add(geos::geom::Coordinate(0.5, 0)); - pts->add(geos::geom::Coordinate(0, 0)); + pts.add(geos::geom::Coordinate(0, 0)); + pts.add(geos::geom::Coordinate(0, 1.5)); + pts.add(geos::geom::Coordinate(0.5, 1.5)); + pts.add(geos::geom::Coordinate(0.5, 0)); + pts.add(geos::geom::Coordinate(0, 0)); polys.push_back(Isis::globalFactory->createPolygon( - Isis::globalFactory->createLinearRing(pts), NULL)); + Isis::globalFactory->createLinearRing(pts)).release()); - geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(polys); + geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(polys).release(); cout << "Lon/Lat polygon = " << mp->toString() << endl; // Create the projection necessary for seeding @@ -115,7 +114,7 @@ int main() { if(proj->SetCoordinate(seedValues[pt]->getX(), seedValues[pt]->getY())) { points.push_back(Isis::globalFactory->createPoint( geos::geom::Coordinate(proj->UniversalLongitude(), - proj->UniversalLatitude()))); + proj->UniversalLatitude())).release()); } else { IString msg = "Unable to convert to a (lon,lat)"; @@ -136,21 +135,20 @@ int main() { cout << "Test 3, test for too thin" << endl; try { // Call the seed member with a polygon - geos::geom::CoordinateArraySequence *pts; + geos::geom::CoordinateSequence pts; vector<const geos::geom::Geometry *> polys; // Create the A polygon - pts = new geos::geom::DefaultCoordinateSequence(); - pts->add(geos::geom::Coordinate(0, 0)); - pts->add(geos::geom::Coordinate(0, 0.5)); - pts->add(geos::geom::Coordinate(0.0125, 0.5)); - pts->add(geos::geom::Coordinate(0.0125, 0)); - pts->add(geos::geom::Coordinate(0, 0)); + pts.add(geos::geom::Coordinate(0, 0)); + pts.add(geos::geom::Coordinate(0, 0.5)); + pts.add(geos::geom::Coordinate(0.0125, 0.5)); + pts.add(geos::geom::Coordinate(0.0125, 0)); + pts.add(geos::geom::Coordinate(0, 0)); polys.push_back(Isis::globalFactory->createPolygon( - Isis::globalFactory->createLinearRing(pts), NULL)); + Isis::globalFactory->createLinearRing(pts)).release()); - geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(polys); + geos::geom::MultiPolygon *mp = Isis::globalFactory->createMultiPolygon(polys).release(); cout << "Lon/Lat polygon = " << mp->toString() << endl; diff --git a/isis/src/control/apps/autoseed/autoseed.cpp b/isis/src/control/apps/autoseed/autoseed.cpp index 4f7a6ada2f59c5bb146e60cfaa8b4fd7d9df5528..01868df4048af0848ce6f938223c65315f9e673d 100644 --- a/isis/src/control/apps/autoseed/autoseed.cpp +++ b/isis/src/control/apps/autoseed/autoseed.cpp @@ -237,7 +237,7 @@ namespace Isis { points.push_back(Isis::globalFactory->createPoint(geos::geom::Coordinate( - cam->UniversalLongitude(), cam->UniversalLatitude()))); + cam->UniversalLongitude(), cam->UniversalLatitude())).release()); delete cam; cam = NULL; @@ -333,7 +333,7 @@ namespace Isis { if (proj->SetCoordinate(points[pt]->getX(), points[pt]->getY())) { seed.push_back(Isis::globalFactory->createPoint( geos::geom::Coordinate(proj->UniversalLongitude(), - proj->UniversalLatitude()))); + proj->UniversalLatitude())).release()); } else { IString msg = "Unable to convert from X/Y to a (lon,lat)"; @@ -347,7 +347,7 @@ namespace Isis { if (ugmap->SetImage(points[pt]->getX(), points[pt]->getY())) { seed.push_back(Isis::globalFactory->createPoint( geos::geom::Coordinate(ugmap->UniversalLongitude(), - ugmap->UniversalLatitude()))); + ugmap->UniversalLatitude())).release()); } else { IString msg = "Unable to convert from Sample/Line to a (lon,lat)"; diff --git a/isis/src/control/apps/cnetcheck/cnetcheck.cpp b/isis/src/control/apps/cnetcheck/cnetcheck.cpp index f0b27ff34274faa3328986166728bb58c8e70484..2a200796cedc6e7b0e426335939f93820dd84a91 100644 --- a/isis/src/control/apps/cnetcheck/cnetcheck.cpp +++ b/isis/src/control/apps/cnetcheck/cnetcheck.cpp @@ -20,7 +20,6 @@ find files of those names at the top level of this repository. **/ #include <geos_c.h> #include <geos/algorithm/ConvexHull.h> #include <geos/geom/CoordinateSequence.h> -#include <geos/geom/CoordinateArraySequence.h> #include <geos/geom/Envelope.h> #include <geos/geom/Geometry.h> #include <geos/geom/GeometryFactory.h> @@ -575,31 +574,26 @@ namespace Isis { double controlFitness = 0; static geos::geom::GeometryFactory::Ptr geosFactory = geos::geom::GeometryFactory::create(); - geos::geom::CoordinateArraySequence * pts = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence pts; QList< ControlMeasure * > measures = cnet.GetMeasuresInCube(sn); // Populate pts with a list of control points foreach (ControlMeasure * measure, measures) { - pts->add(geos::geom::Coordinate(measure->GetSample(), measure->GetLine())); + pts.add(geos::geom::Coordinate(measure->GetSample(), measure->GetLine())); } - pts->add(geos::geom::Coordinate(measures[0]->GetSample(), measures[0]->GetLine())); + pts.add(geos::geom::Coordinate(measures[0]->GetSample(), measures[0]->GetLine())); - if (pts->size() >= 4) { + if (pts.size() >= 4) { // Calculate the convex hull geos::geom::Geometry * convexHull = geosFactory->createPolygon( - geosFactory->createLinearRing(pts), 0)->convexHull().release(); + geosFactory->createLinearRing(pts))->convexHull().release(); // Calculate the area of the convex hull double convexArea = convexHull->getArea(); double cubeArea = cube->sampleCount() * cube->lineCount(); controlFitness = convexArea / cubeArea; - - if (pts) { - delete pts; - pts = NULL; - } } return controlFitness; diff --git a/isis/src/control/apps/cnetwinnow/cnetwinnow.cpp b/isis/src/control/apps/cnetwinnow/cnetwinnow.cpp index 5b013df7152e780de5634f5faa1cced9a3c19d5d..591cf2a773d6583f62c08898e706ed57b2dd1082 100644 --- a/isis/src/control/apps/cnetwinnow/cnetwinnow.cpp +++ b/isis/src/control/apps/cnetwinnow/cnetwinnow.cpp @@ -11,7 +11,6 @@ find files of those names at the top level of this repository. **/ #include <geos_c.h> #include <geos/algorithm/ConvexHull.h> #include <geos/geom/CoordinateSequence.h> -#include <geos/geom/CoordinateArraySequence.h> #include <geos/geom/Envelope.h> #include <geos/geom/Geometry.h> #include <geos/geom/GeometryFactory.h> @@ -431,7 +430,7 @@ namespace Isis { bool ignorMeas; QList<ControlMeasure *> cubeMeasures = net.GetMeasuresInCube(serialNum); static geos::geom::GeometryFactory::Ptr geosFactory = geos::geom::GeometryFactory::create(); - geos::geom::CoordinateArraySequence * pts = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence pts; for (i=0;i<cubeMeasures.size();i++) { if (cubeMeasures[i]->IsIgnored()) continue; //skip ignored measures if (cubeMeasures[i]->Parent()->IsIgnored()) continue; //skip measures of ignored points @@ -451,22 +450,22 @@ namespace Isis { firstIndex =i; } //build point sequence - pts->add(geos::geom::Coordinate(cubeMeasures[i]->GetSample(), cubeMeasures[i]->GetLine())); + pts.add(geos::geom::Coordinate(cubeMeasures[i]->GetSample(), cubeMeasures[i]->GetLine())); } //Adding the first active point again closes the "linestring" - pts->add(geos::geom::Coordinate(cubeMeasures[firstIndex]->GetSample(), + pts.add(geos::geom::Coordinate(cubeMeasures[firstIndex]->GetSample(), cubeMeasures[firstIndex]->GetLine())); - if (pts->size() >= 4) { + if (pts.size() >= 4) { // Calculate the convex hull geos::geom::Geometry * convexHull = geosFactory->createPolygon( - geosFactory->createLinearRing(pts), 0)->convexHull().release(); + geosFactory->createLinearRing(pts))->convexHull().release(); // Calculate the area of the convex hull area = convexHull->getArea(); } else { area = 0.0; } - validMeasures = pts->size()-1; //subtract one because one point is in there twice + validMeasures = pts.size()-1; //subtract one because one point is in there twice return; } } diff --git a/isis/src/control/objs/ControlNetStatistics/ControlNetStatistics.cpp b/isis/src/control/objs/ControlNetStatistics/ControlNetStatistics.cpp index e7ac4d9bba76bf6c774a0fcf5850e8016a829845..4007020e503945521d7469ef66f0ded5695eeaf0 100644 --- a/isis/src/control/objs/ControlNetStatistics/ControlNetStatistics.cpp +++ b/isis/src/control/objs/ControlNetStatistics/ControlNetStatistics.cpp @@ -13,7 +13,6 @@ find files of those names at the top level of this repository. **/ #include <geos_c.h> #include <geos/algorithm/ConvexHull.h> #include <geos/geom/CoordinateSequence.h> -#include <geos/geom/CoordinateArraySequence.h> #include <geos/geom/Envelope.h> #include <geos/geom/Geometry.h> #include <geos/geom/GeometryFactory.h> @@ -232,8 +231,7 @@ namespace Isis { } foreach (QString sn, cnetSerials) { - geos::geom::CoordinateArraySequence * ptCoordinates = - new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence ptCoordinates; // setup vector for number of image properties and init to 0 QVector<double> imgStats(numImageStats, 0); @@ -273,22 +271,22 @@ namespace Isis { if (measure->IsEditLocked()) { imgStats[imgLocked]++; } - ptCoordinates->add(geos::geom::Coordinate(measure->GetSample(), + ptCoordinates.add(geos::geom::Coordinate(measure->GetSample(), measure->GetLine())); } - ptCoordinates->add(geos::geom::Coordinate(measures[0]->GetSample(), + ptCoordinates.add(geos::geom::Coordinate(measures[0]->GetSample(), measures[0]->GetLine())); } - if (ptCoordinates->size() >= 4) { + if (ptCoordinates.size() >= 4) { // Calculate the convex hull // Even though geos doesn't create valid linear rings/polygons from this set of coordinates, // because it self-intersects many many times, it still correctly does a convex hull // calculation on the points in the polygon. geos::geom::Geometry * convexHull = geosFactory->createPolygon( - geosFactory->createLinearRing(ptCoordinates), 0)->convexHull().release(); + geosFactory->createLinearRing(ptCoordinates))->convexHull().release(); // Calculate the area of the convex hull imgStats[imgConvexHullArea] = convexHull->getArea(); @@ -301,9 +299,6 @@ namespace Isis { mImageMap[sn] = imgStats; - delete ptCoordinates; - ptCoordinates = NULL; - // Update Progress if (mProgress != NULL) mProgress->CheckStatus(); diff --git a/isis/src/mro/apps/hijitreg/HiJitCube.cpp b/isis/src/mro/apps/hijitreg/HiJitCube.cpp index 00a42d8194d2e62388360b4f57bb4ff6347acbfd..731ca10a4e98d9f6d3a47af26f810c4871d37f65 100644 --- a/isis/src/mro/apps/hijitreg/HiJitCube.cpp +++ b/isis/src/mro/apps/hijitreg/HiJitCube.cpp @@ -353,18 +353,18 @@ namespace Isis { int line0(jdata.fpLine0 + jdata.lineOffset), lineN(line0 + lineCount() - 1); // Allocate a new coordinate sequence and define it - geos::geom::CoordinateArraySequence *pts = new geos::geom::CoordinateArraySequence(); - pts->add(geos::geom::Coordinate(samp0, lineN)); - pts->add(geos::geom::Coordinate(sampN, lineN)); - pts->add(geos::geom::Coordinate(sampN, line0)); - pts->add(geos::geom::Coordinate(samp0, line0)); - pts->add(geos::geom::Coordinate(samp0, lineN)); + geos::geom::CoordinateSequence pts; + pts.add(geos::geom::Coordinate(samp0, lineN)); + pts.add(geos::geom::Coordinate(sampN, lineN)); + pts.add(geos::geom::Coordinate(sampN, line0)); + pts.add(geos::geom::Coordinate(samp0, line0)); + pts.add(geos::geom::Coordinate(samp0, lineN)); // Make this reentrant and delete previous one if it exists and get the // new one delete fpGeom; - fpGeom = geosFactory->createPolygon(geosFactory->createLinearRing(pts), 0); + fpGeom = geosFactory->createPolygon(geosFactory->createLinearRing(pts)).release(); return; } @@ -396,7 +396,7 @@ namespace Isis { // Get the coordinate list geos::geom::CoordinateSequence *clist = poly.getCoordinates().release(); - const geos::geom::Coordinate *minpt = clist->minCoordinate(); + const geos::geom::CoordinateXY *minpt = clist->minCoordinate(); // cout << "MinPoint: " << minpt->x << ", " << minpt->y << std::endl; geos::geom::Coordinate maxpt(clist->getAt(0)); diff --git a/isis/src/mro/apps/hijitreg/HiJitCube.h b/isis/src/mro/apps/hijitreg/HiJitCube.h index 3be9ab1eb51a0f43ea5e09514b763095a9f0d6fe..197c0ac0cbae2f165382b63205fd0e45c4ce2dd7 100644 --- a/isis/src/mro/apps/hijitreg/HiJitCube.h +++ b/isis/src/mro/apps/hijitreg/HiJitCube.h @@ -15,7 +15,6 @@ find files of those names at the top level of this repository. **/ #include "geos/geom/CoordinateSequence.h" #include "geos/geom/Envelope.h" #include "geos/geom/GeometryFactory.h" -#include "geos/geom/CoordinateArraySequence.h" namespace Isis { diff --git a/isis/src/qisis/objs/HistogramTool/HistogramTool.cpp b/isis/src/qisis/objs/HistogramTool/HistogramTool.cpp index b376e0c8cdae017447306351a74e085a991403d0..24b0e33a84ae4ae37f50217ad73f6bc42dbacf99 100644 --- a/isis/src/qisis/objs/HistogramTool/HistogramTool.cpp +++ b/isis/src/qisis/objs/HistogramTool/HistogramTool.cpp @@ -338,7 +338,7 @@ namespace Isis { int x1, y1; activeViewport->cubeToViewport(x, y, x1, y1); geos::geom::Coordinate c(x1, y1); - geos::geom::Point *p = globalFactory->createPoint(c); + geos::geom::Point *p = globalFactory->createPoint(c).release(); bool contains = p->within(polygon); delete p; diff --git a/isis/src/qisis/objs/RubberBandTool/RubberBandTool.cpp b/isis/src/qisis/objs/RubberBandTool/RubberBandTool.cpp index b9be21c2edc3f2f25144f975aa562b3391ebc873..4e296b4d0154dc1f942050de9089346a639eacfb 100644 --- a/isis/src/qisis/objs/RubberBandTool/RubberBandTool.cpp +++ b/isis/src/qisis/objs/RubberBandTool/RubberBandTool.cpp @@ -11,7 +11,6 @@ #include <QPoint> #include <QRect> -#include "geos/geom/CoordinateArraySequence.h" #include "geos/geom/CoordinateSequence.h" #include "geos/geom/Coordinate.h" #include "geos/geom/LineString.h" @@ -829,21 +828,21 @@ namespace Isis { if(verticesList.size() != 3) break; - geos::geom::CoordinateArraySequence *points1 = new geos::geom::CoordinateArraySequence(); - geos::geom::CoordinateArraySequence *points2 = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence points1; + geos::geom::CoordinateSequence points2; - points1->add(geos::geom::Coordinate(verticesList[0].x(), verticesList[0].y())); - points1->add(geos::geom::Coordinate(verticesList[1].x(), verticesList[1].y())); - points2->add(geos::geom::Coordinate(verticesList[1].x(), verticesList[1].y())); - points2->add(geos::geom::Coordinate(verticesList[2].x(), verticesList[2].y())); + points1.add(geos::geom::Coordinate(verticesList[0].x(), verticesList[0].y())); + points1.add(geos::geom::Coordinate(verticesList[1].x(), verticesList[1].y())); + points2.add(geos::geom::Coordinate(verticesList[1].x(), verticesList[1].y())); + points2.add(geos::geom::Coordinate(verticesList[2].x(), verticesList[2].y())); - geos::geom::LineString *line1 = globalFactory->createLineString(points1); - geos::geom::LineString *line2 = globalFactory->createLineString(points2); - std::vector<geos::geom::Geometry *> *lines = new std::vector<geos::geom::Geometry *>; - lines->push_back(line1); - lines->push_back(line2); + geos::geom::LineString *line1 = globalFactory->createLineString(points1).release(); + geos::geom::LineString *line2 = globalFactory->createLineString(points2).release(); + std::vector<const geos::geom::Geometry *> lines; + lines.push_back(line1); + lines.push_back(line2); - geos::geom::MultiLineString *angle = globalFactory->createMultiLineString(lines); + geos::geom::MultiLineString *angle = globalFactory->createMultiLineString(lines).release(); geometry = angle; } break; @@ -871,12 +870,12 @@ namespace Isis { // We're ready to try to solve double originalX = 0.0, originalY = 0.0; - geos::geom::CoordinateArraySequence *points = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence points; // Now iterate through our domain, solving for y positive, using 1/5th of a pixel increments for(double x = h - a; x <= h + a; x += 0.2) { double y = sqrt(pow(b, 2) * (1.0 - pow((x - h), 2) / pow(a, 2))) + k; - points->add(geos::geom::Coordinate(x, y)); + points.add(geos::geom::Coordinate(x, y)); if(x == h - a) { originalX = x; @@ -887,14 +886,13 @@ namespace Isis { // Iterate through our domain backwards, solving for y negative, using 1/5th of a pixel decrements for(double x = h + a; x >= h - a; x -= 0.2) { double y = -1.0 * sqrt(pow(b, 2) * (1.0 - pow((x - h), 2) / pow(a, 2))) + k; - points->add(geos::geom::Coordinate(x, y)); + points.add(geos::geom::Coordinate(x, y)); } - points->add(geos::geom::Coordinate(originalX, originalY)); + points.add(geos::geom::Coordinate(originalX, originalY)); geometry = globalFactory->createPolygon( - globalFactory->createLinearRing(points), NULL - ); + globalFactory->createLinearRing(points)).release(); } break; @@ -904,15 +902,15 @@ namespace Isis { if(verticesList.size() < 3) break; - geos::geom::CoordinateArraySequence *points = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence points; for(int vertex = 0; vertex < verticesList.size(); vertex++) { - points->add(geos::geom::Coordinate(verticesList[vertex].x(), verticesList[vertex].y())); + points.add(geos::geom::Coordinate(verticesList[vertex].x(), verticesList[vertex].y())); } - points->add(geos::geom::Coordinate(verticesList[0].x(), verticesList[0].y())); + points.add(geos::geom::Coordinate(verticesList[0].x(), verticesList[0].y())); - geometry = globalFactory->createPolygon(globalFactory->createLinearRing(points), NULL); + geometry = globalFactory->createPolygon(globalFactory->createLinearRing(points)).release(); } break; @@ -921,10 +919,10 @@ namespace Isis { if(verticesList.size() != 2) break; - geos::geom::CoordinateArraySequence *points = new geos::geom::CoordinateArraySequence(); - points->add(geos::geom::Coordinate(verticesList[0].x(), verticesList[0].y())); - points->add(geos::geom::Coordinate(verticesList[1].x(), verticesList[1].y())); - geos::geom::LineString *line = globalFactory->createLineString(points); + geos::geom::CoordinateSequence points; + points.add(geos::geom::Coordinate(verticesList[0].x(), verticesList[0].y())); + points.add(geos::geom::Coordinate(verticesList[1].x(), verticesList[1].y())); + geos::geom::LineString *line = globalFactory->createLineString(points).release(); geometry = line; } break; @@ -932,13 +930,13 @@ namespace Isis { case SegmentedLineMode: { if(verticesList.size() < 2) break; - geos::geom::CoordinateArraySequence *points = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence points; for(int vertex = 0; vertex < verticesList.size(); vertex++) { - points->add(geos::geom::Coordinate(verticesList[vertex].x(), verticesList[vertex].y())); + points.add(geos::geom::Coordinate(verticesList[vertex].x(), verticesList[vertex].y())); } - geos::geom::LineString *line = globalFactory->createLineString(points); + geos::geom::LineString *line = globalFactory->createLineString(points).release(); geometry = line; } break; diff --git a/isis/src/qisis/objs/SpatialPlotTool/SpatialPlotTool.cpp b/isis/src/qisis/objs/SpatialPlotTool/SpatialPlotTool.cpp index c65ad97645db3038af4e73db9f755cd5a07282d5..8ffd463907f43f33552ea1f1475acbeece894e23 100644 --- a/isis/src/qisis/objs/SpatialPlotTool/SpatialPlotTool.cpp +++ b/isis/src/qisis/objs/SpatialPlotTool/SpatialPlotTool.cpp @@ -3,7 +3,6 @@ #include <iostream> #include <geos/geom/Polygon.h> -#include <geos/geom/CoordinateArraySequence.h> #include <geos/geom/Point.h> #include <QHBoxLayout> diff --git a/isis/src/qisis/objs/SpectralPlotTool/SpectralPlotTool.cpp b/isis/src/qisis/objs/SpectralPlotTool/SpectralPlotTool.cpp index 90fef290ace35115db82f33f50f184cbbd0ddb44..ffb4b7593cfa1a868200ee525be573bb2c35c4a6 100644 --- a/isis/src/qisis/objs/SpectralPlotTool/SpectralPlotTool.cpp +++ b/isis/src/qisis/objs/SpectralPlotTool/SpectralPlotTool.cpp @@ -3,7 +3,7 @@ #include <iostream> #include "geos/geom/Polygon.h" -#include "geos/geom/CoordinateArraySequence.h" +#include "geos/geom/CoordinateSequence.h" #include "geos/geom/Point.h" #include <QAction> @@ -592,19 +592,19 @@ namespace Isis { if (rubberBandTool()->currentMode() == RubberBandTool::PolygonMode) { // samps = 1; - geos::geom::CoordinateArraySequence *pts = new geos::geom::CoordinateArraySequence(); + geos::geom::CoordinateSequence pts; for (int i = 0; i < vertices.size(); i++) { viewport->viewportToCube(vertices[i].x(), vertices[i].y(), x, y); // add the x,y vertices (double) to the pts CoordinateSequence - pts->add(geos::geom::Coordinate(x, y)); + pts.add(geos::geom::Coordinate(x, y)); }/*end for*/ /*Add the first point again in order to make a closed line string*/ viewport->viewportToCube(vertices[0].x(), vertices[0].y(), x, y); - pts->add(geos::geom::Coordinate(x, y)); + pts.add(geos::geom::Coordinate(x, y)); geos::geom::Polygon *poly = globalFactory->createPolygon( - globalFactory->createLinearRing(pts), NULL); + globalFactory->createLinearRing(pts)).release(); const geos::geom::Envelope *envelope = poly->getEnvelopeInternal(); @@ -615,7 +615,7 @@ namespace Isis { x <= (int)round(envelope->getMaxX()); x++) { // create a point at the center of the pixel geos::geom::Coordinate c(x, y); - geos::geom::Point *p = globalFactory->createPoint(c); + geos::geom::Point *p = globalFactory->createPoint(c).release(); // check if the center of the pixel is in the polygon's envelope (the selection) bool contains = p->within(poly); delete p; diff --git a/isis/tests/FunctionalTestsFindimageoverlaps.cpp b/isis/tests/FunctionalTestsFindimageoverlaps.cpp index 85448d4ae2c252d7077be8470f050d4bcd7546f4..6d0b2ebe996b273bd0a8142c1bfc9ce28bb91b65 100644 --- a/isis/tests/FunctionalTestsFindimageoverlaps.cpp +++ b/isis/tests/FunctionalTestsFindimageoverlaps.cpp @@ -15,7 +15,6 @@ #include <geos/io/WKTReader.h> #include <geos/io/WKTWriter.h> -#include "geos/geom/CoordinateArraySequence.h" #include "geos/geom/CoordinateSequence.h" #include "geos/geom/LinearRing.h" #include "geos/geom/Polygon.h" diff --git a/isis/tests/FunctionalTestsFootprintinit.cpp b/isis/tests/FunctionalTestsFootprintinit.cpp index ae1326706c402d9091f6c9dd4440fe48bf11f867..d88c51aa09b253db6b3d345dfe95b8dffd905a7c 100644 --- a/isis/tests/FunctionalTestsFootprintinit.cpp +++ b/isis/tests/FunctionalTestsFootprintinit.cpp @@ -3,7 +3,7 @@ #include <QTemporaryDir> #include <geos/geom/Geometry.h> -#include <geos/geom/CoordinateArraySequence.h> +#include <geos/geom/CoordinateSequence.h> #include "footprintinit.h" @@ -37,7 +37,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitDefault) { std::vector<double> lons = {255.645358, 256.146267, 256.146267, 255.645358, 255.645358}; std::vector<double> lats = {9.928502, 9.928502, 10.434859, 10.434859, 9.928502}; - geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); + geos::geom::CoordinateSequence coordArray = *boundary->getCoordinates().release(); for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); @@ -59,7 +59,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitLincSinc) { std::vector<double> lons = {255.645390, 256.146233, 256.146233, 255.645390, 255.645390}; std::vector<double> lats = {9.928500, 9.928500, 10.434861, 10.434861, 9.928500}; - geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); + geos::geom::CoordinateSequence coordArray = *boundary->getCoordinates().release(); for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); @@ -81,7 +81,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitVertices) { std::vector<double> lons = {255.645374, 256.146251, 256.146251, 255.645374, 255.645374}; std::vector<double> lats = {9.928456, 9.928456, 10.434903, 10.434903, 9.928456}; - geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); + geos::geom::CoordinateSequence coordArray = *boundary->getCoordinates().release(); for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); @@ -103,7 +103,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitCamera) { std::vector<double> lons = {255.923821, 256.215272, 256.215272, 255.923821, 255.923821}; std::vector<double> lats = {9.924583, 9.924583, 10.329275, 10.329275, 9.924583}; - geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); + geos::geom::CoordinateSequence coordArray = *boundary->getCoordinates().release(); for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); @@ -125,7 +125,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitTestXY) { std::vector<double> lons = {255.645358, 256.146267, 256.146267, 255.645358, 255.645358}; std::vector<double> lats = {9.928502, 9.928502, 10.434859, 10.434859, 9.928502}; - geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); + geos::geom::CoordinateSequence coordArray = *boundary->getCoordinates().release(); for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); @@ -153,7 +153,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitPrecision) { std::vector<double> lons = {255.645358, 256.146267, 256.146267, 255.645358, 255.645358}; std::vector<double> lats = {9.928502, 9.928502, 10.434859, 10.434859, 9.928502}; - geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); + geos::geom::CoordinateSequence coordArray = *boundary->getCoordinates().release(); for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); diff --git a/isis/tests/UnitTestImagePolygon.cpp b/isis/tests/UnitTestImagePolygon.cpp index d8278772bdabdf4507ec652007a01fe0e185a144..fd6d1fc89b95e716370fbc1c18c54ab43b46613c 100644 --- a/isis/tests/UnitTestImagePolygon.cpp +++ b/isis/tests/UnitTestImagePolygon.cpp @@ -6,7 +6,7 @@ #include "Pvl.h" #include "geos/geom/Point.h" #include "geos/geom/MultiPolygon.h" -#include "geos/geom/CoordinateArraySequence.h" +#include "geos/geom/CoordinateSequence.h" #include <gtest/gtest.h> @@ -32,7 +32,7 @@ TEST_F(DefaultCube, UnitTestImagePolygonDefaultParams) { std::vector<double> lons = {255.645377, 256.146301, 256.146301, 255.645377, 255.645377}; std::vector<double> lats = {9.928429, 9.928429, 10.434929, 10.434929, 9.928429}; - geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); + geos::geom::CoordinateSequence coordArray = *(boundary->getCoordinates().release()); for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); @@ -59,7 +59,7 @@ TEST_F(DefaultCube, UnitTestImagePolygonSubPoly) { std::vector<double> lons = {255.894656, 256.081313, 256.081313, 255.894656, 255.894656}; std::vector<double> lats = {10.039260, 10.039260, 10.213952, 10.213952, 10.039260}; - geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); + geos::geom::CoordinateSequence coordArray = *(boundary->getCoordinates().release()); for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); @@ -93,7 +93,7 @@ TEST_F(TempTestingFiles, UnitTestImagePolygonCross) { std::vector<double> lons = {0.000000, 360.000000, 360.000000, 0.000000, 0.000000}; std::vector<double> lats = {54.208699, 54.208699, 77.858559, 77.858559, 54.208699}; - geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); + geos::geom::CoordinateSequence coordArray = *(boundary->getCoordinates().release()); for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); @@ -150,7 +150,7 @@ TEST_F(DefaultCube, UnitTestImagePolygonBoundary) { std::vector<double> lons = {222.252839, 262.514600, 262.514600, 222.252839, 222.252839}; std::vector<double> lats = {12.939321, 12.939321, 26.058448, 26.058448, 12.939321}; - geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); + geos::geom::CoordinateSequence coordArray = *(boundary->getCoordinates().release()); for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); @@ -197,7 +197,7 @@ TEST_F(TempTestingFiles, UnitTestImagePolygonMosaic) { std::vector<double> lons = {347.895055, 349.699395, 349.699395, 347.895055, 347.895055}; std::vector<double> lats = {-43.643248, -43.643248, -42.323638, -42.323638, -43.643248}; - geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); + geos::geom::CoordinateSequence coordArray = *(boundary->getCoordinates().release()); for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); @@ -259,7 +259,7 @@ TEST_F(DefaultCube, UnitTestImagePolygonOutlier) { std::vector<double> lons = {194.815808, 269.631838, 269.631838, 194.815808, 194.815808}; std::vector<double> lats = {-66.783521, -66.783521, 5.718550, 5.718550, -66.783521}; - geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); + geos::geom::CoordinateSequence coordArray = *(boundary->getCoordinates().release()); for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6);