From 3f9c296bf4f91d9a00ec079b86fe90c25f2ce920 Mon Sep 17 00:00:00 2001 From: "James.Hester" Date: Sun, 30 Dec 2018 16:25:56 +1100 Subject: [PATCH] Brought cliff-decode more closely in line with current ogr-decode. Fixed bug introduced during merging. --- src/Lib/terragear/tg_polygon_clip.cxx | 3 ++- src/Prep/Cliff/cliff-decode.cxx | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/Lib/terragear/tg_polygon_clip.cxx b/src/Lib/terragear/tg_polygon_clip.cxx index 791ca400..e97f9d4e 100644 --- a/src/Lib/terragear/tg_polygon_clip.cxx +++ b/src/Lib/terragear/tg_polygon_clip.cxx @@ -164,11 +164,12 @@ tgPolygon tgPolygon::Intersect( const tgPolygon& subject, const tgPolygon& clip) c.Clear(); c.AddPaths(clipper_subject, ClipperLib::PolyType::Subject, subject.IsClosed()); c.AddPaths(clipper_clip, ClipperLib::PolyType::Clip, true); + if(subject.IsClosed()) { c.Execute(ClipperLib::ClipType::Intersection, clipper_result, ClipperLib::PolyFillType::EvenOdd, ClipperLib::PolyFillType::EvenOdd); result = tgPolygon::FromClipper( clipper_result ); } else { - c.Execute(ClipperLib::ctIntersection, clipper_tree_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd); + c.Execute(ClipperLib::ClipType::Intersection, clipper_tree_result, ClipperLib::PolyFillType::EvenOdd, ClipperLib::PolyFillType::EvenOdd); result = tgPolygon::FromClipper( clipper_tree_result ); } result = tgPolygon::AddColinearNodes( result, all_nodes ); diff --git a/src/Prep/Cliff/cliff-decode.cxx b/src/Prep/Cliff/cliff-decode.cxx index 4b38298c..c60d31aa 100644 --- a/src/Prep/Cliff/cliff-decode.cxx +++ b/src/Prep/Cliff/cliff-decode.cxx @@ -3,9 +3,9 @@ // against and sorting // them into the relevant tiles. // -// Written by James Hester starting 2018 +// Written by James Hester 2018 // -// Based on ogr-decode by Ralf Gerlich. +// Largely copied from ogr-decode by Ralf Gerlich. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. // +#include #include #include @@ -100,9 +101,9 @@ void Decoder::processLineString(OGRLineString* poGeometry) // Do not close this contour line.SetOpen(true); - // clip the contour. Do not use usual clipper, as we wish to preserve the - // whole contour, even if it goes outside the bounding box, as height - // calculations along the boundary might be affected by it. + // clip the contour. + // TODO: don't bother clipping, as the contour is informational + // only, and simply output to all relevant buckets instead. tgPolygon open_poly; open_poly.SetOpen(); //do not try to close this one up open_poly.AddContour(line); @@ -299,6 +300,8 @@ int main( int argc, char **argv ) { char* progname=argv[0]; string datasource,work_dir; + auto start_time = std::chrono::high_resolution_clock::now(); + sglog().setLogLevels( SG_ALL, SG_INFO ); while (argc>1) { @@ -379,14 +382,6 @@ int main( int argc, char **argv ) { tgChopper results( work_dir ); - // initialize persistant polygon counter - //string counter_file = work_dir + "/poly_counter"; - //poly_index_init( counter_file ); - - // new chop api - //std::string counter_file2 = work_dir + "/poly_counter2"; - //tgPolygon::ChopIdxInit( counter_file ); - SG_LOG( SG_GENERAL, SG_DEBUG, "Opening datasource " << datasource << " for reading." ); GDALAllRegister(); @@ -428,6 +423,12 @@ int main( int argc, char **argv ) { SG_LOG(SG_GENERAL, SG_ALERT, "Saving to buckets"); results.Add_Extension("cliffs"); results.Save( save_shapefiles ); + + auto finish_time = std::chrono::high_resolution_clock::now(); + std::chrono::duration elapsed = finish_time - start_time; + std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl; + + return 0; }