1 // names.cxx -- process shapefiles names
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)
24 #include <Include/compiler.h>
31 // return the type of the shapefile record
32 AreaType get_area_type(GDBFile *dbf, int rec) {
33 GDBFieldDesc *fdesc[128]; // 128 is an arbitrary number here
34 GDBFValue *fields; //an array of field values
35 char* dbf_rec; //a record containing all the fields
37 // grab the meta-information for all the fields
38 // this applies to all the records in the DBF file.
39 // for ( int i = 0; i < dbf->numFields(); i++ ) {
40 // fdesc[i] = dbf->getFieldDesc(i);
41 // cout << i << ") " << fdesc[i]->name << endl;
44 // this is the whole name record
45 dbf_rec = dbf->getRecord( rec );
47 // parse it into individual fields
49 fields = dbf->recordDeform( dbf_rec );
52 string area = fields[4].str_v;
53 // strip leading spaces
54 while ( area[0] == ' ' ) {
55 area = area.substr(1, area.length() - 1);
57 // strip trailing spaces
58 while ( area[area.length() - 1] == ' ' ) {
59 area = area.substr(0, area.length() - 1);
61 // strip other junk encountered
62 while ( (int)area[area.length() - 1] == 9 ) {
63 area = area.substr(0, area.length() - 1);
66 if ( area == "AirportKeep" ) {
67 return AirportKeepArea;
68 } else if ( area == "AirportIgnore" ) {
69 return AirportIgnoreArea;
70 } else if ( area == "Swamp or Marsh" ) {
72 } else if ( area == "Bay Estuary or Ocean" ) {
74 } else if ( area == "Lake" ) {
76 } else if ( area == "Lake Dry" ) {
78 } else if ( area == "Lake Intermittent" ) {
80 } else if ( area == "Reservoir" ) {
82 } else if ( area == "Reservoir Intermittent" ) {
83 return IntReservoirArea;
84 } else if ( area == "Stream" ) {
86 } else if ( area == "Canal" ) {
88 } else if ( area == "Glacier" ) {
90 } else if ( area == "Void Area" ) {
92 } else if ( area == "Null" ) {
95 cout << "unknown area = '" << area << "'" << endl;
96 // cout << "area = " << area << endl;
97 for ( int i = 0; i < area.length(); i++ ) {
98 cout << i << ") " << (int)area[i] << endl;
105 // return text form of area name
106 string get_area_name( AreaType area ) {
107 if ( area == AirportKeepArea ) {
108 return "AirportKeep";
109 } else if ( area == AirportIgnoreArea ) {
110 return "AirportIgnore";
111 } else if ( area == MarshArea ) {
113 } else if ( area == OceanArea ) {
115 } else if ( area == LakeArea ) {
117 } else if ( area == DryLakeArea ) {
119 } else if ( area == IntLakeArea ) {
120 return "IntermittentLake";
121 } else if ( area == ReservoirArea ) {
123 } else if ( area == IntReservoirArea ) {
124 return "IntermittentReservoir";
125 } else if ( area == StreamArea ) {
127 } else if ( area == CanalArea ) {
129 } else if ( area == GlacierArea ) {
131 } else if ( area == VoidArea ) {
133 } else if ( area == NullArea ) {
136 cout << "unknown area code = " << (int)area << endl;
143 // Revision 1.1 1999/02/25 21:30:24 curt
146 // Revision 1.1 1999/02/23 01:29:05 curt
147 // Additional progress.