Initial revision.
This commit is contained in:
parent
1a7c97601d
commit
ad34c1e4e4
5 changed files with 355 additions and 0 deletions
7
Polygon/Makefile.am
Normal file
7
Polygon/Makefile.am
Normal file
|
@ -0,0 +1,7 @@
|
|||
noinst_LIBRARIES = libPolygon.a
|
||||
|
||||
libPolygon_a_SOURCES = \
|
||||
index.cxx index.hxx \
|
||||
names.cxx names.hxx
|
||||
|
||||
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib
|
76
Polygon/index.cxx
Normal file
76
Polygon/index.cxx
Normal file
|
@ -0,0 +1,76 @@
|
|||
// index.cxx -- routines to handle a unique/persistant integer polygon index
|
||||
//
|
||||
// Written by Curtis Olson, started February 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
#include <Include/compiler.h>
|
||||
|
||||
#include STL_STRING
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "index.hxx"
|
||||
|
||||
|
||||
static int poly_index;
|
||||
static string poly_path;
|
||||
|
||||
|
||||
// initialize the unique polygon index counter stored in path
|
||||
bool poly_index_init( string path ) {
|
||||
poly_path = path;
|
||||
|
||||
FILE *fp = fopen( poly_path.c_str(), "r" );
|
||||
|
||||
if ( fp == NULL ) {
|
||||
cout << "Error cannot open " << poly_path << endl;
|
||||
poly_index = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
fscanf( fp, "%d", &poly_index );
|
||||
|
||||
fclose( fp );
|
||||
}
|
||||
|
||||
|
||||
// increment the persistant counter and return the next poly_index
|
||||
int poly_index_next() {
|
||||
++poly_index;
|
||||
|
||||
FILE *fp = fopen( poly_path.c_str(), "w" );
|
||||
|
||||
if ( fp == NULL ) {
|
||||
cout << "Error cannot open " << poly_path << " for writing" << endl;
|
||||
}
|
||||
|
||||
fprintf( fp, "%d\n", poly_index );
|
||||
|
||||
fclose( fp );
|
||||
|
||||
return poly_index;
|
||||
}
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.1 1999/02/25 21:30:24 curt
|
||||
// Initial revision.
|
||||
//
|
48
Polygon/index.hxx
Normal file
48
Polygon/index.hxx
Normal file
|
@ -0,0 +1,48 @@
|
|||
// index.cxx -- routines to handle a unique/persistant integer polygon index
|
||||
//
|
||||
// Written by Curtis Olson, started February 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
|
||||
#ifndef _INDEX_HXX
|
||||
#define _INDEX_HXX
|
||||
|
||||
|
||||
#include <Include/compiler.h>
|
||||
|
||||
#include STL_STRING
|
||||
|
||||
|
||||
// initialize the unique polygon index counter stored in path
|
||||
bool poly_index_init( string path );
|
||||
|
||||
// increment the persistant counter and return the next poly_index
|
||||
int poly_index_next();
|
||||
|
||||
|
||||
|
||||
#endif // _INDEX_HXX
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.1 1999/02/25 21:30:24 curt
|
||||
// Initial revision.
|
||||
//
|
148
Polygon/names.cxx
Normal file
148
Polygon/names.cxx
Normal file
|
@ -0,0 +1,148 @@
|
|||
// names.cxx -- process shapefiles names
|
||||
//
|
||||
// Written by Curtis Olson, started February 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
#include <Include/compiler.h>
|
||||
|
||||
#include STL_STRING
|
||||
|
||||
#include "names.hxx"
|
||||
|
||||
|
||||
// return the type of the shapefile record
|
||||
AreaType get_area_type(GDBFile *dbf, int rec) {
|
||||
GDBFieldDesc *fdesc[128]; // 128 is an arbitrary number here
|
||||
GDBFValue *fields; //an array of field values
|
||||
char* dbf_rec; //a record containing all the fields
|
||||
|
||||
// grab the meta-information for all the fields
|
||||
// this applies to all the records in the DBF file.
|
||||
// for ( int i = 0; i < dbf->numFields(); i++ ) {
|
||||
// fdesc[i] = dbf->getFieldDesc(i);
|
||||
// cout << i << ") " << fdesc[i]->name << endl;
|
||||
// }
|
||||
|
||||
// this is the whole name record
|
||||
dbf_rec = dbf->getRecord( rec );
|
||||
|
||||
// parse it into individual fields
|
||||
if ( dbf_rec ) {
|
||||
fields = dbf->recordDeform( dbf_rec );
|
||||
}
|
||||
|
||||
string area = fields[4].str_v;
|
||||
// strip leading spaces
|
||||
while ( area[0] == ' ' ) {
|
||||
area = area.substr(1, area.length() - 1);
|
||||
}
|
||||
// strip trailing spaces
|
||||
while ( area[area.length() - 1] == ' ' ) {
|
||||
area = area.substr(0, area.length() - 1);
|
||||
}
|
||||
// strip other junk encountered
|
||||
while ( (int)area[area.length() - 1] == 9 ) {
|
||||
area = area.substr(0, area.length() - 1);
|
||||
}
|
||||
|
||||
if ( area == "AirportKeep" ) {
|
||||
return AirportKeepArea;
|
||||
} else if ( area == "AirportIgnore" ) {
|
||||
return AirportIgnoreArea;
|
||||
} else if ( area == "Swamp or Marsh" ) {
|
||||
return MarshArea;
|
||||
} else if ( area == "Bay Estuary or Ocean" ) {
|
||||
return OceanArea;
|
||||
} else if ( area == "Lake" ) {
|
||||
return LakeArea;
|
||||
} else if ( area == "Lake Dry" ) {
|
||||
return DryLakeArea;
|
||||
} else if ( area == "Lake Intermittent" ) {
|
||||
return IntLakeArea;
|
||||
} else if ( area == "Reservoir" ) {
|
||||
return ReservoirArea;
|
||||
} else if ( area == "Reservoir Intermittent" ) {
|
||||
return IntReservoirArea;
|
||||
} else if ( area == "Stream" ) {
|
||||
return StreamArea;
|
||||
} else if ( area == "Canal" ) {
|
||||
return CanalArea;
|
||||
} else if ( area == "Glacier" ) {
|
||||
return GlacierArea;
|
||||
} else if ( area == "Void Area" ) {
|
||||
return VoidArea;
|
||||
} else if ( area == "Null" ) {
|
||||
return NullArea;
|
||||
} else {
|
||||
cout << "unknown area = '" << area << "'" << endl;
|
||||
// cout << "area = " << area << endl;
|
||||
for ( int i = 0; i < area.length(); i++ ) {
|
||||
cout << i << ") " << (int)area[i] << endl;
|
||||
}
|
||||
return UnknownArea;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// return text form of area name
|
||||
string get_area_name( AreaType area ) {
|
||||
if ( area == AirportKeepArea ) {
|
||||
return "AirportKeep";
|
||||
} else if ( area == AirportIgnoreArea ) {
|
||||
return "AirportIgnore";
|
||||
} else if ( area == MarshArea ) {
|
||||
return "Marsh";
|
||||
} else if ( area == OceanArea ) {
|
||||
return "Ocean";
|
||||
} else if ( area == LakeArea ) {
|
||||
return "Lake";
|
||||
} else if ( area == DryLakeArea ) {
|
||||
return "DryLake";
|
||||
} else if ( area == IntLakeArea ) {
|
||||
return "IntermittentLake";
|
||||
} else if ( area == ReservoirArea ) {
|
||||
return "Reservoir";
|
||||
} else if ( area == IntReservoirArea ) {
|
||||
return "IntermittentReservoir";
|
||||
} else if ( area == StreamArea ) {
|
||||
return "Stream";
|
||||
} else if ( area == CanalArea ) {
|
||||
return "Canal";
|
||||
} else if ( area == GlacierArea ) {
|
||||
return "Glacier";
|
||||
} else if ( area == VoidArea ) {
|
||||
return "VoidArea";
|
||||
} else if ( area == NullArea ) {
|
||||
return "Null";
|
||||
} else {
|
||||
cout << "unknown area code = " << (int)area << endl;
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.1 1999/02/25 21:30:24 curt
|
||||
// Initial revision.
|
||||
//
|
||||
// Revision 1.1 1999/02/23 01:29:05 curt
|
||||
// Additional progress.
|
||||
//
|
76
Polygon/names.hxx
Normal file
76
Polygon/names.hxx
Normal file
|
@ -0,0 +1,76 @@
|
|||
// names.hxx -- process shapefiles names
|
||||
//
|
||||
// Written by Curtis Olson, started February 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
|
||||
#ifndef _NAMES_HXX
|
||||
#define _NAMES_HXX
|
||||
|
||||
|
||||
// libgfc.a includes need this bit o' strangeness
|
||||
#if defined ( linux )
|
||||
# define _LINUX_
|
||||
#endif
|
||||
#include <gfc/gadt_polygon.h>
|
||||
#include <gfc/gdbf.h>
|
||||
#undef E
|
||||
#undef DEG_TO_RAD
|
||||
#undef RAD_TO_DEG
|
||||
|
||||
|
||||
// Posible shape file types
|
||||
enum AreaType {
|
||||
AirportKeepArea = 0,
|
||||
AirportIgnoreArea = 1,
|
||||
MarshArea = 2,
|
||||
OceanArea = 3,
|
||||
LakeArea = 4,
|
||||
DryLakeArea = 5,
|
||||
IntLakeArea = 6,
|
||||
ReservoirArea = 7,
|
||||
IntReservoirArea = 8,
|
||||
StreamArea = 9,
|
||||
CanalArea = 10,
|
||||
GlacierArea = 11,
|
||||
VoidArea = 9997,
|
||||
NullArea = 9998,
|
||||
UnknownArea = 9999
|
||||
};
|
||||
|
||||
|
||||
// return the type of the shapefile record
|
||||
AreaType get_area_type(GDBFile *dbf, int rec);
|
||||
|
||||
// return text form of area name
|
||||
string get_area_name( AreaType area );
|
||||
|
||||
|
||||
#endif // _NAMES_HXX
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.1 1999/02/25 21:30:24 curt
|
||||
// Initial revision.
|
||||
//
|
||||
// Revision 1.1 1999/02/23 01:29:05 curt
|
||||
// Additional progress.
|
||||
//
|
Loading…
Reference in a new issue