1 // main.cxx -- process shapefiles and extract polygon outlines,
2 // clipping against and sorting them into the revelant
5 // Written by Curtis Olson, started February 1999.
7 // Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
9 // This program is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation; either version 2 of the License, or
12 // (at your option) any later version.
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 // (Log is kept at end of this file)
27 // Include Geographic Foundation Classes library
29 // libgfc.a includes need this bit o' strangeness
34 #include <gfc/gadt_polygon.h>
36 #include <gfc/gshapefile.h>
38 // include Generic Polygon Clipping Library
44 #include <Debug/logstream.hxx>
47 int main( int argc, char **argv ) {
48 fglog().setLogLevels( FG_ALL, FG_DEBUG );
51 FG_LOG( FG_GENERAL, FG_ALERT, "Usage: " << argv[0] << " <shapefile>" );
55 FG_LOG( FG_GENERAL, FG_DEBUG, "Opening " << argv[1] << " for reading." );
57 GShapeFile * sf = new GShapeFile( argv[1] );
58 GDBFile *names = new GDBFile( argv[1] );
61 double *coords; // in decimal degrees
65 FG_LOG( FG_GENERAL, FG_INFO, sf->numRecords() );
67 GShapeFile::ShapeType t = sf->shapeType();
68 if ( t != GShapeFile::av_Polygon ) {
69 FG_LOG( FG_GENERAL, FG_ALERT, "Can't handle non-polygon shape files" );
73 for ( int i = 0; i < sf->numRecords(); i++ ) {
74 //fetch i-th record (shape)
75 FG_LOG( FG_GENERAL, FG_DEBUG, names->getRecord( i ) );
77 sf->getShapeRec(i, &shape);
79 FG_LOG( FG_GENERAL, FG_DEBUG, "Record = " << i << " rings = "
80 << shape.numRings() );
82 for ( int j = 0; j < shape.numRings(); j++ ) {
83 //return j-th branch's coords, # of vertices
84 n_vertices = shape.getRing(j, coords);
86 FG_LOG( FG_GENERAL, FG_DEBUG, " ring " << j << " = " );
87 FG_LOG( FG_GENERAL, FG_INFO, n_vertices );
89 for ( int k = 0; k < n_vertices; k++ ) {
92 FG_LOG( FG_GENERAL, FG_INFO, lon << " " << lat );
101 // Revision 1.1 1999/02/15 19:10:23 curt