GlobeEngine
FeatureObject.h
Go to the documentation of this file.
1 
9 #ifndef GlobeEngine_FeatureObject_h
10 #define GlobeEngine_FeatureObject_h
11 
12 #include "SHPObject.h"
13 #include "DBFObject.h"
14 #include "OpenGL_Includes.h"
15 #include "DrawableComponent.h"
16 #include "GPUProgramFactory.h"
17 #include "VBOVertex.h"
18 #include "FeatureRange.h"
19 #include "TileFeatureService.h"
20 #include "StyleCollection.h"
21 #include <string>
22 #include <vector>
23 #include <memory>
24 
25 namespace geGIS {
26  class ReferenceSystem;
27 
29  {
30  public:
31  //enum RENDERMODE { NORMAL_LINES, PATH_VOLUMES };
32  /* 0 = line,
33  1 = triangulated with overlaps,
34  2 = triangulated as nice ribbon,
35  3 = gputriangulated
36  */
41 
42  enum FEATUREFORMAT { SHP=0, JSON, CSV, NONE};
43 
45 
46  FeatureObject();
47  virtual ~FeatureObject();
48  virtual void clear();
49  virtual void create();
50  virtual void update() = 0;
51  virtual void draw(std::shared_ptr<ge::Camera> _cam) = 0;
52  virtual void createVAO(enum GEOMETRYDRAWMODE _in) = 0;
53 
58  vmml::Vector4d getBounds2D() const;
59  vmml::Vector3d getMinBounds() const;
60  vmml::Vector3d getMaxBounds() const;
61  vmml::Vector3d getEdgeLength() const;
62 
63  int getShapeType() const;
64 
65 
66  enum GEOMETRYDRAWMODE getDrawMode() const{ return this->drawMode; };
67  int getEntityCount() const;
68  int getEdgeCount() const;
69  int getLocationPointCount() const;
70 
71  void exportToSHPFile(std::string _path, enum shpio::SHPFileExportContainer::EXPORT_TYPE _type, shpio::SHPFileExportContainer* _content);
72  void exportToCSVFile(std::string _path, enum shpio::SHPFileExportContainer::EXPORT_TYPE _type, shpio::SHPFileExportContainer* _content);
73  void loadDatabaseFields();
74 
75  enum FEATUREFORMAT getFormatFromString(std::string _input);
76  std::string getStringForFormat(enum FEATUREFORMAT _input);
77  enum FEATUREFORMAT checkForFileWithStandardExtension(std::string _input);
78 
79  // access to datatable
88  char getFieldType(int _fieldnumber);
89  std::vector<std::string> getFieldNames();
90 
91  int* readIntegerFieldFromDBFtoArray(int _fieldnumber){
92  return this->datatable.readIntegerFieldFromDBFtoArray(_fieldnumber);
93  }
94 
95  template <typename T>
96  std::vector<T> readStringField(int _fieldnumber) {
97  return this->datatable.readStringFieldFromDBF<T>(_fieldnumber);
98  }
99 
100  template <typename T>
101  std::vector<T> readNumericField(int _fieldnumber) {
102  return this->datatable.readFieldFromDBF<T>(_fieldnumber);
103  }
104 
105  float getWheightMax() const;
106  float getWheightMin() const;
107  void saveFeature(std::string _path, std::string _ext);
108 
109  const tileService::TileFeatureService* getTFSInfo(){
110  return &this->tfsloader;
111  }
112 
113  vmml::Vector3d getMidpointOfBounds();
114  vmml::Vector2d getMidpointOfBoundsProj2D();
115 
116  void setTextColor(vmml::Vector3f _textcolor);
117  vmml::Vector3f getTextColor() const;
118 
119  // get feature styling information
120  std::shared_ptr<StyleCollection> getStyleCollection() const;
121 
122  protected:
123  void deleteMemory();
124  void setupInitialShapeData(std::string _filename, std::string _driver, geGIS::FeatureRange _entRange);
125  void setupInitialTFSData(std::string _filename, int _minlod, int _maxlod);
126 
127  virtual shpio::SHPFileExportContainer* getExportContainer(std::shared_ptr<ReferenceSystem> _referenceSystem);
128 
129  void checkForBoundaries();
130  void setEntityRanges(geGIS::FeatureRange _entRange);
131  void print();
132 
133  void setFeatureType(std::string _type);
134 
135  void loadDataFromSHP(std::string filename);
136 
137  private:
138  void loadDataFromJSON(std::string _filename);
139  void loadDataFromTFS(std::string _repourl, int _minlod, int _maxlod);
140 
141 
142  void convertWGS84toLocalCoordinates(std::shared_ptr<ReferenceSystem> _referenceSystem);
143  void convertLocalToWGS84Coordinates(std::shared_ptr<ReferenceSystem> _referenceSystem);
144 
145  protected:
149 
155 
160  double bounds[6];
161  vmml::Vector3d midPoint;
162  double edgelength[3];
163 
164  // Singleton object references
165  std::shared_ptr<ReferenceSystem> referenceSystem;
166 
167  // feature file content
168  std::vector< vmml::Vector3d > feature_vec;
169  // index of feature vector to shp variables
170  std::vector< int > shapeVecIdx;
171 
172  std::vector<SHPObject*> shape_vec;
173  SHPHandle shapehandle;
174  shpio::DBFDataContainer datatable;
175 
176  vmml::Vector3f textColor;
177 
178  float weightMax;
179  float weightMin;
180 
181  // Blueprint information
182  vmml::Vector3f blueprintColor;
184 
185  tileService::TileFeatureService tfsloader;
186 
187  std::string fileUrl;
188 
189  // style information
190  std::shared_ptr<StyleCollection> vectorStyling;
191 
192  private:
193  int numberOfEntitiesInFile;
194  };
195 }
196 
197 #endif
void loadDatabaseFields()
Definition: FeatureObject.cpp:145
void exportToCSVFile(std::string _path, enum shpio::SHPFileExportContainer::EXPORT_TYPE _type, shpio::SHPFileExportContainer *_content)
Definition: FeatureObject.cpp:296
GEOMETRYDRAWMODE drawMode
Definition: FeatureObject.h:146
std::shared_ptr< ReferenceSystem > referenceSystem
Definition: FeatureObject.h:165
Definition: DrawableComponent.h:25
vmml::Vector4d getBounds2D() const
Definition: FeatureObject.cpp:366
Definition: FeatureObject.h:44
Definition: FeatureObject.h:44
Definition: FeatureObject.h:44
GEOMETRYDRAWMODE
Definition: FeatureObject.h:37
std::string fileUrl
Definition: FeatureObject.h:187
void exportToSHPFile(std::string _path, enum shpio::SHPFileExportContainer::EXPORT_TYPE _type, shpio::SHPFileExportContainer *_content)
Definition: FeatureObject.cpp:284
vmml::Vector3f textColor
Definition: FeatureObject.h:176
geGIS::FeatureRange entityRange
Definition: FeatureObject.h:154
virtual void createVAO(enum GEOMETRYDRAWMODE _in)=0
char getFieldType(int _fieldnumber)
Definition: FeatureObject.cpp:405
Definition: FeatureObject.h:42
vmml::Vector2d getMidpointOfBoundsProj2D()
Definition: FeatureObject.cpp:445
virtual void update()=0
Definition: ClusterGrid.h:17
std::vector< vmml::Vector3d > feature_vec
Definition: FeatureObject.h:168
Definition: FeatureObject.h:42
std::vector< SHPObject * > shape_vec
Definition: FeatureObject.h:172
Definition: FeatureObject.h:39
Definition: FeatureObject.h:42
int getEntityCount() const
Definition: FeatureObject.cpp:390
Definition: FeatureObject.h:38
virtual ~FeatureObject()
Definition: FeatureObject.cpp:21
Definition: FeatureObject.h:42
void setTextColor(vmml::Vector3f _textcolor)
Definition: FeatureObject.cpp:423
Definition: FeatureObject.h:40
int numberOfLocations
Definition: FeatureObject.h:153
Definition: FeatureObject.h:44
Definition: FeatureObject.h:40
int shapetype
Definition: FeatureObject.h:150
Definition: FeatureObject.h:28
tileService::TileFeatureService tfsloader
Definition: FeatureObject.h:185
FEATURETYPE featureType
Definition: FeatureObject.h:147
void setFeatureType(std::string _type)
void saveFeature(std::string _path, std::string _ext)
Definition: FeatureObject.cpp:266
virtual shpio::SHPFileExportContainer * getExportContainer(std::shared_ptr< ReferenceSystem > _referenceSystem)
Definition: FeatureObject.cpp:242
float getWheightMin() const
Definition: FeatureObject.cpp:419
enum FEATUREFORMAT getFormatFromString(std::string _input)
Definition: FeatureObject.cpp:321
std::shared_ptr< StyleCollection > vectorStyling
Definition: FeatureObject.h:190
Definition: FeatureObject.h:44
vmml::Vector3d getMaxBounds() const
Definition: FeatureObject.cpp:375
int numberOfEdges
Definition: FeatureObject.h:152
virtual void clear()
Definition: FeatureObject.cpp:27
Definition: FeatureObject.h:40
virtual void create()
Definition: FeatureObject.cpp:47
Definition: FeatureObject.h:44
void setEntityRanges(geGIS::FeatureRange _entRange)
Definition: FeatureObject.cpp:96
double bounds[6]
Definition: FeatureObject.h:160
void print()
Definition: FeatureObject.cpp:431
void deleteMemory()
Definition: FeatureObject.cpp:42
vmml::Vector3f getTextColor() const
Definition: FeatureObject.cpp:427
bool isRepository
Definition: FeatureObject.h:183
std::shared_ptr< StyleCollection > getStyleCollection() const
Definition: FeatureObject.cpp:449
double edgelength[3]
Definition: FeatureObject.h:162
FeatureObject()
Definition: FeatureObject.cpp:16
int numberOfEntities
Definition: FeatureObject.h:151
std::vector< T > readStringField(int _fieldnumber)
Definition: FeatureObject.h:96
void checkForBoundaries()
Definition: FeatureObject.cpp:176
enum GEOMETRYDRAWMODE getDrawMode() const
Definition: FeatureObject.h:66
int getLocationPointCount() const
Definition: FeatureObject.cpp:400
float weightMax
Definition: FeatureObject.h:178
std::vector< int > shapeVecIdx
Definition: FeatureObject.h:170
std::vector< std::string > getFieldNames()
Definition: FeatureObject.cpp:410
shpio::DBFDataContainer datatable
Definition: FeatureObject.h:174
Definition: FeatureObject.h:44
enum FEATUREFORMAT checkForFileWithStandardExtension(std::string _input)
Definition: FeatureObject.cpp:340
vmml::Vector3f blueprintColor
Definition: FeatureObject.h:182
FEATURETYPE
Definition: FeatureObject.h:44
float getWheightMax() const
Definition: FeatureObject.cpp:415
std::string getStringForFormat(enum FEATUREFORMAT _input)
Definition: FeatureObject.cpp:330
float weightMin
Definition: FeatureObject.h:179
int * readIntegerFieldFromDBFtoArray(int _fieldnumber)
Definition: FeatureObject.h:91
void loadDataFromSHP(std::string filename)
Definition: FeatureObject.cpp:124
vmml::Vector3d midPoint
Definition: FeatureObject.h:161
void setupInitialShapeData(std::string _filename, std::string _driver, geGIS::FeatureRange _entRange)
Definition: FeatureObject.cpp:62
const tileService::TileFeatureService * getTFSInfo()
Definition: FeatureObject.h:109
std::vector< T > readNumericField(int _fieldnumber)
Definition: FeatureObject.h:101
void setupInitialTFSData(std::string _filename, int _minlod, int _maxlod)
Definition: FeatureObject.cpp:52
vmml::Vector3d getMidpointOfBounds()
Definition: FeatureObject.cpp:441
SHPHandle shapehandle
Definition: FeatureObject.h:173
int getEdgeCount() const
Definition: FeatureObject.cpp:395
FEATUREFORMAT featureFormat
Definition: FeatureObject.h:148
virtual void draw(std::shared_ptr< ge::Camera > _cam)=0
vmml::Vector3d getEdgeLength() const
Definition: FeatureObject.cpp:380
vmml::Vector3d getMinBounds() const
Definition: FeatureObject.cpp:370
FEATUREFORMAT
Definition: FeatureObject.h:42
int getShapeType() const
Definition: FeatureObject.cpp:385
Definition: FeatureObject.h:37