]> git.mxchange.org Git - flightgear.git/blob - ShapeFile/names.cxx
Additional progress.
[flightgear.git] / ShapeFile / names.cxx
1 // names.cxx -- process shapefiles names
2 //
3 // Written by Curtis Olson, started February 1999.
4 //
5 // Copyright (C) 1999  Curtis L. Olson  - curt@flightgear.org
6 //
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.
11 //
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.
16 //
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.
20 //
21 // $Id$
22 // (Log is kept at end of this file)
23  
24 #include <Include/compiler.h>
25
26 #include STL_STRING
27
28 #include "names.hxx"
29
30
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
36
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;
42     // }
43
44     // this is the whole name record
45     dbf_rec = dbf->getRecord( rec );
46
47     // parse it into individual fields
48     if ( dbf_rec ) {
49         fields = dbf->recordDeform( dbf_rec );
50     }
51
52     string area = fields[4].str_v;
53     // strip leading spaces
54     while ( area[0] == ' ' ) {
55         area = area.substr(1, area.length() - 1);
56     }
57     // strip trailing spaces
58     while ( area[area.length() - 1] == ' ' ) {
59         area = area.substr(0, area.length() - 1);
60     }
61     // strip other junk encountered
62     while ( (int)area[area.length() - 1] == 9 ) {
63         area = area.substr(0, area.length() - 1);
64     }
65
66     if ( area == "Swamp or Marsh" ) {
67         return MarshArea;
68     } else if ( area == "Bay  Estuary or Ocean" ) {
69         return OceanArea;
70     } else if ( area == "Lake" ) {
71         return LakeArea;
72     } else if ( area == "Lake   Dry" ) {
73         return DryLakeArea;
74     } else if ( area == "Lake   Intermittent" ) {
75         return IntLakeArea;
76     } else if ( area == "Reservoir" ) {
77         return ReservoirArea;
78     } else if ( area == "Reservoir   Intermittent" ) {
79         return IntReservoirArea;
80     } else if ( area == "Stream" ) {
81         return StreamArea;
82     } else if ( area == "Canal" ) {
83         return CanalArea;
84     } else if ( area == "Glacier" ) {
85         return GlacierArea;
86     } else if ( area == "Void Area" ) {
87         return VoidArea;
88     } else if ( area == "Null" ) {
89         return NullArea;
90     } else {
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;
95         }
96         return UnknownArea;
97     }
98 }
99
100
101 // $Log$
102 // Revision 1.1  1999/02/23 01:29:05  curt
103 // Additional progress.
104 //