1 // main.cxx -- sample use of the clipper lib
3 // Written by Curtis Olson, started February 1999.
5 // Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 // (Log is kept at end of this file)
26 #include "clipper.hxx"
28 #include <Debug/logstream.hxx>
29 #include <Bucket/newbucket.hxx>
32 int main( int argc, char **argv ) {
33 point2d global_min, global_max;
35 fglog().setLogLevels( FG_ALL, FG_DEBUG );
37 global_min.x = global_min.y = 200;
38 global_max.y = global_max.x = -200;
43 FG_LOG( FG_CLIPPER, FG_ALERT, "Usage: " << argv[0]
44 << " file1 file2 ..." );
48 // process all specified polygon files
49 for ( int i = 1; i < argc; i++ ) {
50 string full_path = argv[i];
52 // determine bucket for this polygon
53 int pos = full_path.rfind("/");
54 string file_name = full_path.substr(pos + 1);
55 cout << "file name = " << file_name << endl;
57 pos = file_name.find(".");
58 string base_name = file_name.substr(0, pos);
59 cout << "base_name = " << base_name << endl;
62 sscanf( base_name.c_str(), "%ld", &index);
64 cout << "bucket = " << b << endl;
66 // calculate bucket dimensions
69 c.x = b.get_center_lon();
70 c.y = b.get_center_lat();
71 double span = bucket_span(c.y);
73 if ( (c.y >= -89.0) && (c.y < 89.0) ) {
74 min.x = c.x - span / 2.0;
75 max.x = c.x + span / 2.0;
76 min.y = c.y - FG_HALF_BUCKET_SPAN;
77 max.y = c.y + FG_HALF_BUCKET_SPAN;
78 } else if ( c.y < -89.0) {
83 } else if ( c.y >= 89.0) {
89 FG_LOG ( FG_GENERAL, FG_ALERT,
90 "Out of range latitude in clip_and_write_poly() = "
94 if ( min.x < global_min.x ) global_min.x = min.x;
95 if ( min.y < global_min.y ) global_min.y = min.y;
96 if ( max.x > global_max.x ) global_max.x = max.x;
97 if ( max.y > global_max.y ) global_max.y = max.y;
99 // finally, load the polygon(s) from this file
100 fgClipperLoadPolygons( full_path );
104 fgClipperMaster(global_min, global_max);
106 FG_LOG( FG_CLIPPER, FG_INFO, "finished main" );
112 // Revision 1.1 1999/03/01 15:39:39 curt