Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
GEOnet.h
1 //
2 // GEOnet.h
3 //
4 // Copyright (c) 2002-2011 Virtual Terrain Project
5 // Free for all uses, see license.txt for details.
6 //
7 
8 #ifndef GEONET_H
9 #define GEONET_H
10 
11 #include "config_vtdata.h"
12 #include "MathTypes.h"
13 #include "vtString.h"
14 
15 #if SUPPORT_WSTRING
16 
17 class Place
18 {
19 public:
20  DPoint2 m_pos;
21  wstring2 m_fullname;
22  vtString m_fullname_nd;
23  short m_ppc; // Populated Place Classification (1 high to 5 low, 6=unknown)
24 };
25 
26 class PlaceArray : public vtArray<Place *>
27 {
28 public:
29  // this class is used for reference purposes only, it does not own the
30  // objects it contains so it does not and should not delete them
31 };
32 
33 class Country
34 {
35 public:
36  Country();
37  ~Country();
38 
39  bool FindPlace(const char *name_nd, DPoint2 &point, bool bFullLength);
40  bool FindPlace(const std::wstring &name, DPoint2 &point, bool bFullLength);
41  bool FindAllMatchingPlaces(const char *name_nd, bool bFullLength, PlaceArray &places);
42 
43  bool WriteSHP(const char *fname);
44 
45  vtString m_abb;
46  vtString m_full;
47  vtArray<Place*> m_places;
48 };
49 
64 class Countries
65 {
66 public:
67  ~Countries();
68 
69  // create GCF from raw GEOnet Names Server (GNS) files
70  bool ReadCountryList(const char *fname);
71  void ParseRawCountryFiles(const char *path_prefix, bool bNativeNames);
72  void ParseRawCountry(int i, bool bNativeNames);
73  void WriteGCF(const char *fname);
74  bool WriteSingleSHP(const char *fname);
75  bool WriteSHPPerCountry(const char *prefix);
76  void Free(bool progress_callback(int)=0);
77 
78  // load and use GCF
79  bool ReadGCF(const char *fname, bool progress_callback(int) = NULL);
80  bool FindPlace(const char *country, const char *place, DPoint2 &point);
81  bool FindPlaceWithGuess(const char *country, const char *place, DPoint2 &point, bool bUTF8=false);
82 
83 protected:
84  vtArray<Country*> m_countries;
85  vtString m_path;
86 };
87 
88 #endif // SUPPORT_WSTRING
89 
93 class Gazetteer
94 {
95 public:
96  bool ReadPlaces(const char *fname);
97  bool ReadZips(const char *fname);
98 
99  bool FindPlace(const vtString &state, const vtString &place, DPoint2 &geo);
100  bool FindZip(int zip, DPoint2 &geo);
101 
102  class Place {
103  public:
104  vtString m_state;
105  vtString m_name;
106  DPoint2 geo;
107  };
108  std::vector<Place> m_places;
109 
110  class Zip {
111  public:
112  int m_zip;
113  DPoint2 geo;
114  };
115  std::vector<Zip> m_zips;
116 };
117 
118 
119 #endif // GEONET_H
120