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 == "Swamp or Marsh" ) {
68 } else if ( area == "Bay Estuary or Ocean" ) {
70 } else if ( area == "Lake" ) {
72 } else if ( area == "Lake Dry" ) {
74 } else if ( area == "Lake Intermittent" ) {
76 } else if ( area == "Reservoir" ) {
78 } else if ( area == "Reservoir Intermittent" ) {
79 return IntReservoirArea;
80 } else if ( area == "Stream" ) {
82 } else if ( area == "Canal" ) {
84 } else if ( area == "Glacier" ) {
86 } else if ( area == "Void Area" ) {
88 } else if ( area == "Null" ) {
91 cout << "unknown area = '" << area << "'" << endl;
92 // cout << "area = " << area << endl;
93 for ( int i = 0; i < area.length(); i++ ) {
94 cout << i << ") " << (int)area[i] << endl;
102 // Revision 1.1 1999/02/23 01:29:05 curt
103 // Additional progress.