Brought cliff-decode more closely in line with current ogr-decode.
Fixed bug introduced during merging.
This commit is contained in:
parent
44bfe79007
commit
3f9c296bf4
2 changed files with 16 additions and 14 deletions
|
@ -164,11 +164,12 @@ tgPolygon tgPolygon::Intersect( const tgPolygon& subject, const tgPolygon& clip)
|
||||||
c.Clear();
|
c.Clear();
|
||||||
c.AddPaths(clipper_subject, ClipperLib::PolyType::Subject, subject.IsClosed());
|
c.AddPaths(clipper_subject, ClipperLib::PolyType::Subject, subject.IsClosed());
|
||||||
c.AddPaths(clipper_clip, ClipperLib::PolyType::Clip, true);
|
c.AddPaths(clipper_clip, ClipperLib::PolyType::Clip, true);
|
||||||
|
if(subject.IsClosed()) {
|
||||||
c.Execute(ClipperLib::ClipType::Intersection, clipper_result, ClipperLib::PolyFillType::EvenOdd, ClipperLib::PolyFillType::EvenOdd);
|
c.Execute(ClipperLib::ClipType::Intersection, clipper_result, ClipperLib::PolyFillType::EvenOdd, ClipperLib::PolyFillType::EvenOdd);
|
||||||
result = tgPolygon::FromClipper( clipper_result );
|
result = tgPolygon::FromClipper( clipper_result );
|
||||||
}
|
}
|
||||||
else {
|
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::FromClipper( clipper_tree_result );
|
||||||
}
|
}
|
||||||
result = tgPolygon::AddColinearNodes( result, all_nodes );
|
result = tgPolygon::AddColinearNodes( result, all_nodes );
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
// against and sorting
|
// against and sorting
|
||||||
// them into the relevant tiles.
|
// 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
|
// 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
|
// 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
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
//
|
//
|
||||||
|
#include <chrono>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
@ -100,9 +101,9 @@ void Decoder::processLineString(OGRLineString* poGeometry)
|
||||||
// Do not close this contour
|
// Do not close this contour
|
||||||
line.SetOpen(true);
|
line.SetOpen(true);
|
||||||
|
|
||||||
// clip the contour. Do not use usual clipper, as we wish to preserve the
|
// clip the contour.
|
||||||
// whole contour, even if it goes outside the bounding box, as height
|
// TODO: don't bother clipping, as the contour is informational
|
||||||
// calculations along the boundary might be affected by it.
|
// only, and simply output to all relevant buckets instead.
|
||||||
tgPolygon open_poly;
|
tgPolygon open_poly;
|
||||||
open_poly.SetOpen(); //do not try to close this one up
|
open_poly.SetOpen(); //do not try to close this one up
|
||||||
open_poly.AddContour(line);
|
open_poly.AddContour(line);
|
||||||
|
@ -299,6 +300,8 @@ int main( int argc, char **argv ) {
|
||||||
char* progname=argv[0];
|
char* progname=argv[0];
|
||||||
string datasource,work_dir;
|
string datasource,work_dir;
|
||||||
|
|
||||||
|
auto start_time = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
sglog().setLogLevels( SG_ALL, SG_INFO );
|
sglog().setLogLevels( SG_ALL, SG_INFO );
|
||||||
|
|
||||||
while (argc>1) {
|
while (argc>1) {
|
||||||
|
@ -379,14 +382,6 @@ int main( int argc, char **argv ) {
|
||||||
|
|
||||||
tgChopper results( work_dir );
|
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." );
|
SG_LOG( SG_GENERAL, SG_DEBUG, "Opening datasource " << datasource << " for reading." );
|
||||||
|
|
||||||
GDALAllRegister();
|
GDALAllRegister();
|
||||||
|
@ -428,6 +423,12 @@ int main( int argc, char **argv ) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Saving to buckets");
|
SG_LOG(SG_GENERAL, SG_ALERT, "Saving to buckets");
|
||||||
results.Add_Extension("cliffs");
|
results.Add_Extension("cliffs");
|
||||||
results.Save( save_shapefiles );
|
results.Save( save_shapefiles );
|
||||||
|
|
||||||
|
auto finish_time = std::chrono::high_resolution_clock::now();
|
||||||
|
std::chrono::duration<double> elapsed = finish_time - start_time;
|
||||||
|
std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl;
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue