ToolMap
Loading...
Searching...
No Matches
tmgisdatavectormysql.h
1/***************************************************************************
2 tmgisdatavectormysql.h
3 For dealing with spatial data from a mysql database
4 -------------------
5 copyright : (C) 2007 CREALP Lucien Schreiber
6 ***************************************************************************/
7
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17// comment doxygen
18
19#ifndef _TM_GISDATAVECTOR_MYSQL_H_
20#define _TM_GISDATAVECTOR_MYSQL_H_
21
22// For compilers that support precompilation, includes "wx/wx.h".
23#include <wx/wxprec.h>
24
25// Include wxWidgets' headers
26#ifndef WX_PRECOMP
27#include <wx/wx.h>
28#endif
29
30#include "../database/database_tm.h"
31#include "tmgisdatavector.h"
32
34
35const wxString tmGISMYSQL_FIELD1 = _T("OBJECT_ID");
36const wxString tmGISMYSQL_FIELD2 = _T("OBJECT_GEOMETRY");
37
38// same order as in TM_GIS_SPATIAL_TYPES
39const wxString tmGISMYSQL_TEXT_TYPES[] = {_T("linestring"), _T("multipoint"), _T("polygon")};
40
42 private:
43 static DataBaseTM* m_DB;
44 // static PrjDefMemManage * m_ProjDef;
45
46 tmAttributionData* _CreateAttributionObject(int& layertype);
47
48 PrjDefMemManage* m_PrjDef;
49
50 protected:
51 // checking db fields
52 bool CheckGeometryFields(const wxString& tablename);
53
54 // gis database function
55 OGRGeometry* CreateDataBaseGeometry(MYSQL_ROW& row, const tmArrayULong& row_lengths, int geometry_col = 0);
56
57 long GetOid(MYSQL_ROW& row, const int& col);
58
59 virtual wxString GetTableName(TOC_GENERIC_NAME type);
60
61 public:
63
65
66 // special function for DB, use it first.
67 static void SetDataBaseHandle(DataBaseTM* db) {
68 m_DB = db;
69 }
70
71 static DataBaseTM* GetDataBaseHandle() {
72 return m_DB;
73 }
74
75 void SetProject(PrjDefMemManage* prj) {
76 m_PrjDef = prj;
77 }
78
79 // implementing virtual function
80 virtual bool Open(const wxString& filename, bool bReadWrite = FALSE);
81
82 virtual tmRealRect GetMinimalBoundingRectangle();
83
84 virtual TM_GIS_SPATIAL_TYPES GetSpatialType();
85
86 // virtual function for getting data & drawing
87 virtual bool SetSpatialFilter(tmRealRect filter, int type);
88
89 virtual wxRealPoint* GetNextDataLine(int& nbvertex, long& oid, bool& isOver);
90
91 virtual wxRealPoint* GetNextDataPoint(long& oid, bool& isOver);
92
93 OGRPoint* GetNextDataPointWithAttrib(long& oid, wxArrayString& values);
94
95 virtual OGRLineString* GetNextDataLine(long& oid);
96
97 virtual OGRPoint* GetOGRNextDataPoint(long& oid);
98
99 virtual OGRFeature* GetFeatureByOID(long oid);
100
101 virtual long AddGeometry(OGRGeometry* Geom, const long& oid, int layertype = wxNOT_FOUND);
102
103 virtual bool UpdateGeometry(OGRGeometry* geom, const long& oid);
104
105 virtual OGRGeometryCollection* GetGeometryColByOID(wxArrayLong* OIDs);
106
107 virtual OGRGeometry* GetNextGeometry(bool restart, long& oid);
108
109 // metadata
110 virtual wxString GetMetaDataAsHtml();
111
112 virtual wxString GetDataSizeAsHtml(int iPrecision = 2);
113
114 // fields functions
115 // static void SetProjectDefinition(PrjDefMemManage * project){m_ProjDef = project;}
116 virtual int GetFieldsCount();
117
118 virtual bool GetFieldsName(wxArrayString& Fields, long oid = wxNOT_FOUND);
119
120 virtual bool GetFieldsValue(wxArrayString& values, long oid);
121
122 // count
123 virtual int GetCount();
124
125 // searching data
126 virtual wxArrayLong* SearchData(const tmRealRect& rect, int type);
127
128 virtual wxArrayLong* GetAllData();
129
130 virtual wxArrayLong* SearchIntersectingGeometry(OGRGeometry* intersectinggeom);
131
132 virtual bool GetSnapCoord(const wxRealPoint& clickpt, double buffersize, wxArrayRealPoints& snapppts, int snaptype);
133
134 virtual bool IsPointSnapped(const wxRealPoint& point, int snaptype, long excludeoid = wxNOT_FOUND);
135};
136
137#endif
Definition database_tm.h:80
Definition prjdefmemmanage.h:54
Class for attributing data.
Definition tmattributiondata.h:43
Definition tmgisdatavectormysql.h:41
virtual wxArrayLong * GetAllData()
Get All OID back from the MySQL layer.
Definition tmgisdatavectormysql.cpp:752
virtual bool SetSpatialFilter(tmRealRect filter, int type)
Set a spatial filter for geometric data.
Definition tmgisdatavectormysql.cpp:180
virtual int GetCount()
Getting number of features.
Definition tmgisdatavectormysql.cpp:445
virtual wxString GetDataSizeAsHtml(int iPrecision=2)
Getting Database size.
Definition tmgisdatavectormysql.cpp:467
virtual OGRFeature * GetFeatureByOID(long oid)
Get the geometry for specified oid.
Definition tmgisdatavectormysql.cpp:939
long GetOid(MYSQL_ROW &row, const int &col)
Get object ID from MYSQL row results.
Definition tmgisdatavectormysql.cpp:163
virtual wxArrayLong * SearchIntersectingGeometry(OGRGeometry *intersectinggeom)
Search data for intersection.
Definition tmgisdatavectormysql.cpp:778
virtual bool GetSnapCoord(const wxRealPoint &clickpt, double buffersize, wxArrayRealPoints &snapppts, int snaptype)
Get snapping coordinate.
Definition tmgisdatavectormysql.cpp:838
virtual bool Open(const wxString &filename, bool bReadWrite=FALSE)
Generic open code.
Definition tmgisdatavectormysql.cpp:66
virtual wxArrayLong * SearchData(const tmRealRect &rect, int type)
Search spatial data.
Definition tmgisdatavectormysql.cpp:705
virtual wxString GetMetaDataAsHtml()
Get Metadata information well formated.
Definition tmgisdatavectormysql.cpp:419
virtual bool UpdateGeometry(OGRGeometry *geom, const long &oid)
Update the geometry for specified OID.
Definition tmgisdatavectormysql.cpp:1060
virtual TM_GIS_SPATIAL_TYPES GetSpatialType()
Getting Data Spatial type.
Definition tmgisdatavectormysql.cpp:382
virtual long AddGeometry(OGRGeometry *Geom, const long &oid, int layertype=wxNOT_FOUND)
Add geometry into database.
Definition tmgisdatavectormysql.cpp:1024
virtual OGRGeometryCollection * GetGeometryColByOID(wxArrayLong *OIDs)
Get all geometries passed as array.
Definition tmgisdatavectormysql.cpp:1089
Definition tmgisdatavector.h:48
Class representing real rectangle.
Definition tmgisscale.h:44