fix tile bounding box errors leading to z-fightine near tile borders
- round to coorect snap point when converting double to clipper uint64 - add tgPolygon::ToClipperfile to aid debugging clipper related issues
This commit is contained in:
parent
36e75560e6
commit
5d45916b23
4 changed files with 34 additions and 6 deletions
|
@ -200,6 +200,18 @@ bool TGConstruct::ClipLandclassPolys( void ) {
|
|||
|
||||
slivers.clear();
|
||||
|
||||
if ( debug_shapes.size() )
|
||||
{
|
||||
char layer[32];
|
||||
char name[32];
|
||||
|
||||
sprintf(layer, "tile_rect" );
|
||||
sprintf(name, "shape");
|
||||
|
||||
tgShapefile::FromPolygon( safety_base, ds_name, layer, name );
|
||||
tgPolygon::ToClipperFile( safety_base, ds_name, layer );
|
||||
}
|
||||
|
||||
// finally, what ever is left over goes to ocean
|
||||
remains = accum.Diff( safety_base );
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
const double isEqual2D_Epsilon = 0.000001;
|
||||
|
||||
#define CLIPPER_FIXEDPT (10000000000000000)
|
||||
#define CLIPPER_FIXED1M ( 90090)
|
||||
#define CLIPPER_FIXEDPT (1000000000000)
|
||||
#define CLIPPER_METERS_PER_DEGREE (111000)
|
||||
|
||||
SGGeod SGGeod_snap( const SGGeod& in, double grid )
|
||||
{
|
||||
|
@ -72,8 +72,8 @@ ClipperLib::IntPoint SGGeod_ToClipper( const SGGeod& p )
|
|||
{
|
||||
ClipperLib::cUInt x, y;
|
||||
|
||||
x = (ClipperLib::cUInt)( p.getLongitudeDeg() * CLIPPER_FIXEDPT );
|
||||
y = (ClipperLib::cUInt)( p.getLatitudeDeg() * CLIPPER_FIXEDPT );
|
||||
x = (ClipperLib::cUInt)( (p.getLongitudeDeg() * CLIPPER_FIXEDPT) + 0.5);
|
||||
y = (ClipperLib::cUInt)( (p.getLatitudeDeg() * CLIPPER_FIXEDPT) + 0.5);
|
||||
|
||||
return ClipperLib::IntPoint( x, y );
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ SGGeod SGGeod_FromClipper( const ClipperLib::IntPoint& p )
|
|||
|
||||
double Dist_ToClipper( double dist )
|
||||
{
|
||||
return ( dist * ( CLIPPER_FIXEDPT / CLIPPER_FIXED1M ) );
|
||||
return ( (dist / CLIPPER_METERS_PER_DEGREE) * CLIPPER_FIXEDPT );
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/threads/SGThread.hxx>
|
||||
#include <simgear/threads/SGGuard.hxx>
|
||||
|
@ -358,6 +361,18 @@ void tgPolygon::LoadFromGzFile( gzFile& fp )
|
|||
sgReadInt( fp, (int *)&preserve3d );
|
||||
}
|
||||
|
||||
void tgPolygon::ToClipperFile( const tgPolygon& subject, const std::string& path, const std::string& filename )
|
||||
{
|
||||
ClipperLib::Paths clipper_subject = tgPolygon::ToClipper( subject );
|
||||
std::ofstream dmpfile;
|
||||
char pathname[256];
|
||||
|
||||
sprintf( pathname, "%s/%s", path.c_str(), filename.c_str() );
|
||||
dmpfile.open (pathname);
|
||||
dmpfile << clipper_subject;
|
||||
dmpfile.close();
|
||||
}
|
||||
|
||||
// Friends for serialization
|
||||
std::ostream& operator<< ( std::ostream& output, const tgPolygon& subject )
|
||||
{
|
||||
|
|
|
@ -403,7 +403,8 @@ public:
|
|||
// Conversions
|
||||
static ClipperLib::Paths ToClipper( const tgPolygon& subject );
|
||||
static tgPolygon FromClipper( const ClipperLib::Paths& subject );
|
||||
|
||||
static void ToClipperFile( const tgPolygon& subject, const std::string& path, const std::string& filename );
|
||||
|
||||
static void ToShapefile( const tgPolygon& subject, const std::string& datasource, const std::string& layer, const std::string& feature );
|
||||
|
||||
// T-Junctions and segment search
|
||||
|
|
Loading…
Add table
Reference in a new issue