+ // for performance reasons, we'll clip out just this
+ // horizontal row, and clip all the tiles in this row
+ // against the smaller shape
+
+ FG_LOG ( FG_GENERAL, FG_INFO,
+ "Generating clip row " << j << " of " << dy );
+
+ FGBucket b_clip = fgBucketOffset(min.x, min.y, 0, j);
+ gpc_polygon row, clip_row;
+ point2d c, clip_max, clip_min;
+ c.x = b_clip.get_center_lon();
+ c.y = b_clip.get_center_lat();
+
+ // calculate bucket clip_min.y and clip_max.y
+ if ( (c.y >= -89.0) && (c.y < 89.0) ) {
+ clip_min.y = c.y - FG_HALF_BUCKET_SPAN;
+ clip_max.y = c.y + FG_HALF_BUCKET_SPAN;
+ } else if ( c.y < -89.0) {
+ clip_min.y = -90.0;
+ clip_max.y = -89.0;
+ } else if ( c.y >= 89.0) {
+ clip_min.y = 89.0;
+ clip_max.y = 90.0;
+ } else {
+ FG_LOG ( FG_GENERAL, FG_ALERT,
+ "Out of range latitude in clip_and_write_poly() = "
+ << c.y );
+ }
+ clip_min.x = -180.0;
+ clip_max.x = 180.0;
+
+ // set up clipping tile
+ v_list.vertex[0].x = clip_min.x;
+ v_list.vertex[0].y = clip_min.y;
+
+ v_list.vertex[1].x = clip_max.x;
+ v_list.vertex[1].y = clip_min.y;
+
+ v_list.vertex[2].x = clip_max.x;
+ v_list.vertex[2].y = clip_max.y;
+
+ v_list.vertex[3].x = clip_min.x;
+ v_list.vertex[3].y = clip_max.y;
+
+ v_list.num_vertices = 4;
+
+ row.num_contours = 0;
+ row.contour = NULL;
+ row.hole = NULL;
+ gpc_add_contour( &row, &v_list, 0 );
+
+ clip_row.num_contours = 0;
+ clip_row.contour = NULL;
+ clip_row.hole = NULL;
+
+ gpc_polygon_clip(GPC_INT, &row, master_gpc_shape, &clip_row);
+
+ /* FILE *sfp = fopen("master_shape", "w");
+ gpc_write_polygon(sfp, 0, master_gpc_shape);
+ fclose(sfp);
+ sfp = fopen("clip_row", "w");
+ gpc_write_polygon(sfp, 0, &clip_row);
+ fclose(sfp); */
+