From 97a83fb03c29b0f74f2b8692a0d3305873ac2c05 Mon Sep 17 00:00:00 2001
From: curt <curt>
Date: Thu, 16 Nov 2000 16:09:05 +0000
Subject: [PATCH] Fixed a bug that occured when an airport was located on a
 tile corner.  The first tile to build that corner gets to define the shared
 point, but since it was clipped out by the airport hole, the value defaulted
 to randomness. This was then propogated on to adjacent tiles.  I now
 calculate the corner value in advance so the code is not dependent on finding
 the corner in the resulting point set.

---
 src/BuildTiles/Clipper/clipper.cxx |  6 +++---
 src/BuildTiles/Match/match.cxx     | 10 ++++++++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/BuildTiles/Clipper/clipper.cxx b/src/BuildTiles/Clipper/clipper.cxx
index 51d24656..18925856 100644
--- a/src/BuildTiles/Clipper/clipper.cxx
+++ b/src/BuildTiles/Clipper/clipper.cxx
@@ -109,6 +109,7 @@ bool FGClipper::load_polys(const string& path) {
 	    in >> startx;
 	    in >> starty;
 	    p = Point3D(startx, starty, 0.0);
+	    cout << "poly pt = " << p << endl;
 	    poly.add_node( i, p );
 	    FG_LOG( FG_CLIPPER, FG_BULK, "0 = " 
 		    << startx << ", " << starty );
@@ -117,8 +118,8 @@ bool FGClipper::load_polys(const string& path) {
 		in >> x;
 		in >> y;
 		p = Point3D( x, y, 0.0 );
+		cout << "poly pt = " << p << endl;
 		poly.add_node( i, p );
-		FG_LOG( FG_CLIPPER, FG_BULK, j << " = " << x << ", " << y );
 	    }
 
 	    in >> lastx;
@@ -129,9 +130,8 @@ bool FGClipper::load_polys(const string& path) {
 		// last point same as first, discard
 	    } else {
 		p = Point3D( lastx, lasty, 0.0 );
+		cout << "poly pt = " << p << endl;
 		poly.add_node( i, p );
-		FG_LOG( FG_CLIPPER, FG_BULK, count - 1 << " = " 
-			<< lastx << ", " << lasty );
 	    }
 
 	    // gpc_add_contour( poly, &v_list, hole_flag );
diff --git a/src/BuildTiles/Match/match.cxx b/src/BuildTiles/Match/match.cxx
index b6fa0e7f..e7b5bf24 100644
--- a/src/BuildTiles/Match/match.cxx
+++ b/src/BuildTiles/Match/match.cxx
@@ -59,7 +59,7 @@ void FGMatch::scan_share_file( const string& dir, const FGBucket& b,
 	return;
     }
 
-    // cout << "reading shared data from " << file << endl;
+    cout << "reading shared data from " << file << endl;
 
     string target;
     if ( search == SW_Corner ) {
@@ -228,7 +228,7 @@ void FGMatch::load_neighbor_shared( FGConstruct& c ) {
     if ( se_flag ) { cout << "  se corner = " << se_node << endl; }
     if ( ne_flag ) { cout << "  ne corner = " << ne_node << endl; }
     if ( nw_flag ) { cout << "  nw corner = " << nw_node << endl; }
-    if ( north_flag ) { 
+    if ( north_flag ) {
 	cout << "  north nodes = " << north_nodes.size() << endl;
 	for ( int i = 0; i < (int)north_nodes.size(); ++i ) {
 	    cout << "    " << north_nodes[i] << endl;
@@ -273,6 +273,12 @@ void FGMatch::split_tile( FGConstruct& c ) {
     max.x = b.get_center_lon() + 0.5 * b.get_width();
     max.y = b.get_center_lat() + 0.5 * b.get_height();
 
+    // defaults "just in case"
+    sw_node = Point3D( min.x, min.y, 0.0 );
+    se_node = Point3D( max.x, min.y, 0.0 );
+    nw_node = Point3D( min.x, max.y, 0.0 );
+    ne_node = Point3D( max.x, max.y, 0.0 );
+
     // separate nodes and normals into components
 
     body_nodes.clear();