]> git.mxchange.org Git - flightgear.git/blobdiff - ShapeFile/main.cxx
Don't crash when work directory doesn't exist ... create it.
[flightgear.git] / ShapeFile / main.cxx
index 3af9438c61d37db7a9783ca0faff7083b39fbbde..b123d26b70248218c6e47aa7beae88380feb2b3f 100644 (file)
@@ -48,7 +48,8 @@ extern "C" {
 
 #include <Debug/logstream.hxx>
 
-#include "names.hxx"
+#include <Polygon/index.hxx>
+#include <Polygon/names.hxx>
 #include "shape.hxx"
 
 
@@ -60,12 +61,21 @@ int main( int argc, char **argv ) {
 
     if ( argc != 3 ) {
        FG_LOG( FG_GENERAL, FG_ALERT, "Usage: " << argv[0] 
-               << " <shapefile> <workdir>" );
+               << " <shape_file> <work_dir>" );
        exit(-1);
     }
 
     FG_LOG( FG_GENERAL, FG_DEBUG, "Opening " << argv[1] << " for reading." );
 
+    // make work directory
+    string work_dir = argv[2];
+    string command = "mkdir -p " + work_dir;
+    system( command.c_str() );
+
+    // initialize persistant polygon counter
+    string counter_file = work_dir + "/polygon.counter";
+    poly_index_init( counter_file );
+
     // initialize structure for building gpc polygons
     shape_utils_init();
 
@@ -85,14 +95,15 @@ int main( int argc, char **argv ) {
        exit(-1);
     }
 
-    for ( i = 16473; i < sf->numRecords(); i++ ) {
+    for ( i = 0; i < sf->numRecords(); i++ ) {
        //fetch i-th record (shape)
        sf->getShapeRec(i, &shape); 
        FG_LOG( FG_GENERAL, FG_DEBUG, "Record = " << i << "  rings = " 
                << shape.numRings() );
 
-       AreaType area = get_area_type(dbf, i);
-       FG_LOG( FG_GENERAL, FG_DEBUG, "area type = " << (int)area );
+       AreaType area = get_shapefile_type(dbf, i);
+       FG_LOG( FG_GENERAL, FG_DEBUG, "area type = " << get_area_name(area) 
+               << " (" << (int)area << ")" );
 
        FG_LOG( FG_GENERAL, FG_INFO, "  record = " << i 
                << " ring = " << 0 );
@@ -254,6 +265,15 @@ int main( int argc, char **argv ) {
 
 
 // $Log$
+// Revision 1.6  1999/03/02 01:04:28  curt
+// Don't crash when work directory doesn't exist ... create it.
+//
+// Revision 1.5  1999/03/01 15:36:28  curt
+// Tweaked a function call name in "names.hxx".
+//
+// Revision 1.4  1999/02/25 21:31:05  curt
+// First working version???
+//
 // Revision 1.3  1999/02/23 01:29:04  curt
 // Additional progress.
 //