+ // find min/max of this polygon
+ min.x = min.y = 200.0;
+ max.x = max.y = -200.0;
+ for ( int k = 0; k < n_vertices; k++ ) {
+ if ( coords[k*2+0] < min.x ) { min.x = coords[k*2+0]; }
+ if ( coords[k*2+1] < min.y ) { min.y = coords[k*2+1]; }
+ if ( coords[k*2+0] > max.x ) { max.x = coords[k*2+0]; }
+ if ( coords[k*2+1] > max.y ) { max.y = coords[k*2+1]; }
+ }
+ FG_LOG( FG_GENERAL, FG_INFO, "min = " << min.x << "," << min.y
+ << " max = " << max.x << "," << max.y );
+
+ // find buckets for min, and max points of convex hull.
+ // note to self: self, you should think about checking for
+ // polygons that span the date line
+ FGBucket b_min(min.x, min.y);
+ FGBucket b_max(max.x, max.y);
+ cout << "Bucket min = " << b_min << endl;
+ cout << "Bucket max = " << b_max << endl;
+
+ if ( b_min == b_max ) {
+ clip_and_write_poly( b_min, n_vertices, coords );
+ } else {
+ FGBucket b_cur;
+ int dx, dy, i, j;
+
+ fgBucketDiff(b_min, b_max, &dx, &dy);
+ cout << "airport spans tile boundaries" << endl;
+ cout << " dx = " << dx << " dy = " << dy << endl;
+
+ if ( (dx > 1) || (dy > 1) ) {
+ cout << "somethings really wrong!!!!" << endl;
+ exit(-1);
+ }
+
+ for ( j = 0; j <= dy; j++ ) {
+ for ( i = 0; i <= dx; i++ ) {
+ b_cur = fgBucketOffset(min.x, min.y, i, j);
+ clip_and_write_poly( b_cur, n_vertices, coords );
+ }
+ }
+ // string answer; cin >> answer;
+ }
+