1 /*
2 / Classdef.h
3 / class definitions for spatialite_gui  - a SQLite /SpatiaLite GUI tool
4 /
5 / version 1.7, 2013 May 8
6 /
7 / Author: Sandro Furieri a-furieri@lqt.it
8 /
9 / Copyright (C) 2008-2013  Alessandro Furieri
10 /
11 /    This program is free software: you can redistribute it and/or modify
12 /    it under the terms of the GNU General Public License as published by
13 /    the Free Software Foundation, either version 3 of the License, or
14 /    (at your option) any later version.
15 /
16 /    This program is distributed in the hope that it will be useful,
17 /    but WITHOUT ANY WARRANTY; without even the implied warranty of
18 /    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 /    GNU General Public License for more details.
20 /
21 /    You should have received a copy of the GNU General Public License
22 /    along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 /
24 */
25 
26 #include "wx/wx.h"
27 #include "wx/aui/aui.h"
28 #include "wx/treectrl.h"
29 #include "wx/grid.h"
30 #include "wx/listctrl.h"
31 #include "wx/textctrl.h"
32 #include "wx/propdlg.h"
33 #include "wx/generic/propdlg.h"
34 #include "wx/timer.h"
35 
36 #include "config.h"
37 
38 #ifdef SPATIALITE_AMALGAMATION
39 #include <spatialite/sqlite3.h>
40 #else
41 #include <sqlite3.h>
42 #endif
43 
44 #include <spatialite/gaiaaux.h>
45 #include <spatialite/gaiaexif.h>
46 #include <spatialite/gaiageo.h>
47 #include <spatialite.h>
48 #include <spatialite/gg_wfs.h>
49 
50 #include <freexl.h>
51 
52 //
53 // functions for QSORT / BSEARCH
54 //
55 int cmp_prenodes_code(const void *p1, const void *p2);
56 int cmp_prenodes_id(const void *p1, const void *p2);
57 int cmp_nodes2_code(const void *p1, const void *p2);
58 int cmp_nodes2_id(const void *p1, const void *p2);
59 int cmp_nodes1_code(const void *p1, const void *p2);
60 int cmp_nodes1_id(const void *p1, const void *p2);
61 
62 //
63 // functions for threaded queries
64 //
65 int SqlProgressCallback(void *arg);
66 #ifdef _WIN32
67 DWORD WINAPI DoExecuteSqlThread(void *arg);
68 #else
69 void *DoExecuteSqlThread(void *arg);
70 #endif
71 
72 //
73 // functions for threaded WFS download
74 //
75 void WfsCallback(int rows, void *ptr);
76 #ifdef _WIN32
77 DWORD WINAPI DoExecuteWfs(void *arg);
78 #else
79 void *DoExecuteWfs(void *arg);
80 #endif
81 
82 enum
83 {
84 // control IDs for main window and tree list control
85   ID_Connect = 1,
86   ID_CreateNew,
87   ID_Disconnect,
88   ID_MemoryDbLoad,
89   ID_MemoryDbNew,
90   ID_MemoryDbClock,
91   ID_MemoryDbSave,
92   ID_Vacuum,
93   ID_SqlScript,
94   ID_QueryViewComposer,
95   ID_LoadShp,
96   ID_LoadTxt,
97   ID_LoadDbf,
98   ID_LoadXL,
99   ID_VirtualShp,
100   ID_VirtualTxt,
101   ID_VirtualDbf,
102   ID_VirtualXL,
103   ID_Network,
104   ID_Exif,
105   ID_LoadXml,
106   ID_Srids,
107   ID_Charset,
108   ID_Help,
109   ID_Attach,
110   ID_SqlLog,
111   ID_DbStatus,
112   ID_CheckGeom,
113   ID_SaneGeom,
114   ID_WFS,
115   ID_DXF,
116   Tree_NewTable,
117   Tree_NewView,
118   Tree_NewIndex,
119   Tree_NewTrigger,
120   Tree_NewColumn,
121   Tree_QueryViewComposer,
122   Tree_Show,
123   Tree_Drop,
124   Tree_Rename,
125   Tree_Select,
126   Tree_Refresh,
127   Tree_SpatialIndex,
128   Tree_CheckSpatialIndex,
129   Tree_RecoverSpatialIndex,
130   Tree_MbrCache,
131   Tree_RebuildTriggers,
132   Tree_ShowSql,
133   Tree_Recover,
134   Tree_CheckGeometry,
135   Tree_Extent,
136   Tree_UpdateLayerStatistics,
137   Tree_UpdateLayerStatisticsAll,
138   Tree_ElementaryGeoms,
139   Tree_MalformedGeometries,
140   Tree_RepairPolygons,
141   Tree_SetSrid,
142   Tree_DumpShp,
143   Tree_DumpKml,
144   Tree_DumpTxtTab,
145   Tree_DumpCsv,
146   Tree_DumpHtml,
147   Tree_DumpDif,
148   Tree_DumpSylk,
149   Tree_DumpDbf,
150   Tree_DumpPostGIS,
151   Tree_Edit,
152   Tree_DropColumn,
153   Tree_RenameColumn,
154   Tree_GisLayerAuth,
155   Tree_ColumnStats,
156   Tree_MapPreview,
157   Tree_CheckDuplicates,
158   Tree_RemoveDuplicates,
159   Tree_Detach,
160   Tree_CheckGeom,
161   Tree_SaneGeom,
162   Grid_Clear,
163   Grid_All,
164   Grid_Column,
165   Grid_Row,
166   Grid_Copy,
167   Grid_Blob,
168   Grid_Delete,
169   Grid_Insert,
170   Grid_Abort,
171   Grid_BlobIn,
172   Grid_BlobOut,
173   Grid_BlobNull,
174   Grid_XmlBlobIn,
175   Grid_XmlBlobOut,
176   Grid_XmlBlobOutIndented,
177   Grid_ExpTxtTab,
178   Grid_ExpCsv,
179   Grid_ExpHtml,
180   Grid_ExpShp,
181   Grid_ExpDif,
182   Grid_ExpSylk,
183   Grid_ExpDbf,
184   Image_Copy,
185   Wfs_Copy,
186   Wfs_Layer
187 };
188 
189 enum
190 {
191 // control IDs for dialogs
192   ID_SQL = 10000,
193   ID_SQL_GO,
194   ID_SQL_ABORT,
195   ID_HISTORY_BACK,
196   ID_HISTORY_FORWARD,
197   ID_RS_FIRST,
198   ID_RS_LAST,
199   ID_RS_NEXT,
200   ID_RS_PREVIOUS,
201   ID_REFRESH,
202   ID_RS_BLOCK,
203   ID_RS_THREAD_FINISHED,
204   ID_RS_STATS_UPDATE,
205   ID_PANE_HEXADECIMAL,
206   ID_PANE_GEOMETRY,
207   ID_PANE_WKT,
208   ID_PANE_EWKT,
209   ID_PANE_SVG,
210   ID_PANE_KML,
211   ID_PANE_GML,
212   ID_PANE_GEOJSON,
213   ID_PANE_IMAGE,
214   ID_HEX,
215   ID_GEOM_TABLE,
216   ID_WKT_TABLE,
217   ID_WKT_COPY,
218   ID_EWKT_TABLE,
219   ID_EWKT_COPY,
220   ID_SVG_TABLE,
221   ID_SVG_RELATIVE,
222   ID_SVG_PRECISION,
223   ID_SVG_COPY,
224   ID_KML_TABLE,
225   ID_KML_PRECISION,
226   ID_KML_COPY,
227   ID_GML_TABLE,
228   ID_GML_V2_V3,
229   ID_GML_PRECISION,
230   ID_GML_COPY,
231   ID_GEOJSON_TABLE,
232   ID_GEOJSON_OPTIONS,
233   ID_GEOJSON_PRECISION,
234   ID_GEOJSON_COPY,
235   ID_GEOM_GRAPH,
236   ID_GEOM_BOX,
237   ID_IMAGE_TITLE,
238   ID_IMG_BOX,
239   ID_IMAGE,
240   ID_XML_DOCUMENT_TABLE,
241   ID_XML_DOCUMENT_COPY,
242   ID_XML_INDENTED_TABLE,
243   ID_XML_INDENTED_COPY,
244   ID_VIRTSHP_TABLE,
245   ID_VIRTSHP_SRID,
246   ID_VIRTSHP_CHARSET,
247   ID_VIRTTXT_TABLE,
248   ID_VIRTTXT_CHARSET,
249   ID_VIRTTXT_TITLES,
250   ID_VIRTTXT_SEPARATOR,
251   ID_VIRTTXT_CHARSEPARATOR,
252   ID_VIRTTXT_QUOTE,
253   ID_VIRTTXT_POINT,
254   ID_VIRTDBF_TABLE,
255   ID_VIRTDBF_CHARSET,
256   ID_VIRTXL_TABLE,
257   ID_VIRTXL_WORKSHEET,
258   ID_VIRTXL_TITLES,
259   ID_LDSHP_TABLE,
260   ID_LDSHP_COLUMN,
261   ID_LDSHP_SRID,
262   ID_LDSHP_CHARSET,
263   ID_LDSHP_COERCE_2D,
264   ID_LDSHP_COMPRESSED,
265   ID_LDSHP_RTREE,
266   ID_LDSHP_USER_GTYPE,
267   ID_LDSHP_GTYPE,
268   ID_LDSHP_USER_PKEY,
269   ID_LDSHP_PKCOL,
270   ID_LDXL_TABLE,
271   ID_LDXL_WORKSHEET,
272   ID_LDXL_TITLES,
273   ID_LDXML_COMPRESSED,
274   ID_LDXML_VALIDATE,
275   ID_LDXML_INTERNAL_SCHEMA,
276   ID_LDXML_SCHEMA_URI,
277   ID_LDTXT_TABLE,
278   ID_LDTXT_CHARSET,
279   ID_LDTXT_TITLES,
280   ID_LDTXT_SEPARATOR,
281   ID_LDTXT_CHARSEPARATOR,
282   ID_LDTXT_QUOTE,
283   ID_LDTXT_POINT,
284   ID_LDDBF_TABLE,
285   ID_LDDBF_CHARSET,
286   ID_LDDBF_USER_PKEY,
287   ID_LDDBF_PKCOL,
288   ID_DMPSHP_CHARSET,
289   ID_DMPTXT_CHARSET,
290   ID_NET_TABLE,
291   ID_NET_FROM,
292   ID_NET_TO,
293   ID_NET_GEOM,
294   ID_NET_LENGTH,
295   ID_NET_COST,
296   ID_NET_BIDIR,
297   ID_NET_ONEWAY,
298   ID_NET_FROM_TO,
299   ID_NET_TO_FROM,
300   ID_NET_NAME_ENABLE,
301   ID_NET_NAME,
302   ID_NET_A_STAR,
303   ID_EXIF_PATH,
304   ID_EXIF_FOLDER,
305   ID_EXIF_METADATA,
306   ID_EXIF_GPS_ONLY,
307   ID_XML_OK_SUFFIX,
308   ID_XML_SUFFIX,
309   ID_XML_PATH,
310   ID_XML_FOLDER,
311   ID_XML_TARGET_TABLE,
312   ID_XML_PK_NAME,
313   ID_XML_BLOB_COLUMN,
314   ID_XML_OK_PATH,
315   ID_XML_PATH_COLUMN,
316   ID_XML_OK_SCHEMA_URI,
317   ID_XML_SCHEMA_URI_COLUMN,
318   ID_XML_OK_PARSE_ERR,
319   ID_XML_PARSE_ERR_COLUMN,
320   ID_XML_OK_VALIDATE_ERR,
321   ID_XML_VALIDATE_ERR_COLUMN,
322   ID_XML_COMPRESSED,
323   ID_XML_VALIDATED,
324   ID_XML_INTERNAL_SCHEMA,
325   ID_XML_SCHEMA_URI,
326   ID_DXF_OK_PREFIX,
327   ID_DXF_PREFIX,
328   ID_DXF_PATH,
329   ID_DXF_FOLDER,
330   ID_DXF_OK_SINGLE,
331   ID_DXF_SINGLE,
332   ID_DXF_DIMS,
333   ID_DXF_SRID,
334   ID_DXF_RINGS,
335   ID_DXF_MIXED,
336   ID_DXF_APPEND,
337   ID_DFLT_CHARSET,
338   ID_DFLT_ASK,
339   ID_SCRIPT_CHARSET,
340   ID_RCVR_SRID,
341   ID_RCVR_TYPE,
342   ID_RCVR_DIMS,
343   ID_SRID_OLD,
344   ID_SRID_SRID,
345   ID_SEARCH,
346   ID_BY_SRID,
347   ID_HELP_HTML,
348   ID_AUTO_SAVE_PATH,
349   ID_AUTO_SAVE_INTERVAL,
350   ID_AUTO_SAVE_CHANGE_PATH,
351   ID_QVC_SQL,
352   ID_QVC_TAB,
353   ID_QVC_TABLE_2,
354   ID_QVC_TABLE_NAME_1,
355   ID_QVC_TABLE_NAME_2,
356   ID_QVC_TABLE_ALIAS_1,
357   ID_QVC_TABLE_ALIAS_2,
358   ID_QVC_COLUMNS_1,
359   ID_QVC_COLUMNS_2,
360   ID_QVC_JOIN_MODE,
361   ID_QVC_MATCH_1_T1,
362   ID_QVC_MATCH_1_T2,
363   ID_QVC_MATCH_2_ENABLE,
364   ID_QVC_MATCH_2_T1,
365   ID_QVC_MATCH_2_T2,
366   ID_QVC_MATCH_3_ENABLE,
367   ID_QVC_MATCH_3_T1,
368   ID_QVC_MATCH_3_T2,
369   ID_QVC_WHERE_1_ENABLE,
370   ID_QVC_WHERE_1_TABLE,
371   ID_QVC_WHERE_1_COLUMN,
372   ID_QVC_WHERE_1_OPERATOR,
373   ID_QVC_WHERE_1_VALUE,
374   ID_QVC_WHERE_2_ENABLE,
375   ID_QVC_WHERE_2_TABLE,
376   ID_QVC_WHERE_2_COLUMN,
377   ID_QVC_WHERE_2_OPERATOR,
378   ID_QVC_WHERE_2_VALUE,
379   ID_QVC_WHERE_3_ENABLE,
380   ID_QVC_WHERE_3_TABLE,
381   ID_QVC_WHERE_3_COLUMN,
382   ID_QVC_WHERE_3_OPERATOR,
383   ID_QVC_WHERE_3_VALUE,
384   ID_QVC_CONNECTOR_12,
385   ID_QVC_CONNECTOR_23,
386   ID_QVC_ORDER_1_ENABLE,
387   ID_QVC_ORDER_1_TABLE,
388   ID_QVC_ORDER_1_COLUMN,
389   ID_QVC_ORDER_1_DESC,
390   ID_QVC_ORDER_2_ENABLE,
391   ID_QVC_ORDER_2_TABLE,
392   ID_QVC_ORDER_2_COLUMN,
393   ID_QVC_ORDER_2_DESC,
394   ID_QVC_ORDER_3_ENABLE,
395   ID_QVC_ORDER_3_TABLE,
396   ID_QVC_ORDER_3_COLUMN,
397   ID_QVC_ORDER_3_DESC,
398   ID_QVC_ORDER_4_ENABLE,
399   ID_QVC_ORDER_4_TABLE,
400   ID_QVC_ORDER_4_COLUMN,
401   ID_QVC_ORDER_4_DESC,
402   ID_QVC_VIEW_TYPE,
403   ID_QVC_VIEW_NAME,
404   ID_QVC_VIEW_GEOTABLE,
405   ID_QVC_VIEW_GEOMETRY,
406   ID_QVC_WRITABLE_1,
407   ID_QVC_WRITABLE_2,
408   ID_AUTH_RDONLY,
409   ID_AUTH_HIDDEN,
410   ID_MALFORMED_GRID,
411   ID_MALFORMED_CLOSE,
412   ID_MALFORMED_REPAIR,
413   ID_MALFORMED_CLEAR,
414   ID_MALFORMED_ALL,
415   ID_MALFORMED_ROW,
416   ID_MALFORMED_COLUMN,
417   ID_MALFORMED_COPY,
418   ID_MALFORMED_BLOB,
419   ID_DB_STATUS_GRID,
420   ID_DB_STATUS_CLOSE,
421   ID_DB_STATUS_RESET,
422   ID_DB_STATUS_CLEAR,
423   ID_DB_STATUS_ALL,
424   ID_DB_STATUS_ROW,
425   ID_DB_STATUS_COLUMN,
426   ID_DB_STATUS_COPY,
427   ID_STAT_CHART,
428   ID_CHART_TYPE,
429   ID_CHART_SIZE,
430   ID_CHART_MODE,
431   ID_CHART_CLASS,
432   ID_CHART_COPY,
433   ID_CHART_PNG,
434   ID_CHART_SVG,
435   ID_CHART_PDF,
436   ID_MAP_SYMBOL,
437   ID_MAP_SIZE,
438   ID_MAP_SYM_SIZE,
439   ID_MAP_THICKNESS,
440   ID_MAP_FILL,
441   ID_MAP_FILL_COL,
442   ID_MAP_LINE_COL,
443   ID_MAP_COPY,
444   ID_MAP_PNG,
445   ID_MAP_SVG,
446   ID_MAP_PDF,
447   ID_KML_NAME,
448   ID_KML_NAME_K,
449   ID_KML_DESC,
450   ID_KML_DESC_K,
451   ID_SHEET_DECIMAL_POINT,
452   ID_SHEET_DATE_TIME,
453   ID_ELEMGEOM_TABLE,
454   ID_ELEMGEOM_PKEY,
455   ID_ELEMGEOM_MULTI_ID,
456   ID_ELEMGEOM_TYPE,
457   ID_ELEMGEOM_SRID,
458   ID_ELEMGEOM_COORDS,
459   ID_ELEMGEOM_RTREE,
460   ID_POSTGIS_SCHEMA,
461   ID_POSTGIS_TABLE,
462   ID_POSTGIS_LOWER,
463   ID_POSTGIS_CREATE,
464   ID_POSTGIS_SPINDEX,
465   ID_SANEGEOM_PREFIX,
466   ID_WFS_URL,
467   ID_WFS_CATALOG,
468   ID_WFS_RESET,
469   ID_WFS_NAME,
470   ID_WFS_SRID,
471   ID_WFS_VERSION,
472   ID_WFS_LABEL,
473   ID_WFS_PAGE,
474   ID_WFS_MAX,
475   ID_WFS_PAGING,
476   ID_WFS_TABLE,
477   ID_WFS_PK,
478   ID_WFS_RTREE,
479   ID_WFS_SWAP,
480   ID_WFS_LOAD,
481   ID_WFS_EXTRA,
482   ID_WFS_KEYWORD,
483   ID_WFS_KEYFILTER,
484   ID_WFS_KEYRESET,
485   ID_WFS_STATUS,
486   ID_WFS_THREAD_FINISHED
487 };
488 
489 enum
490 {
491 // tree item data types
492   MY_TABLE = 0,
493   MY_VTABLE,
494   MY_VIEW,
495   MY_COLUMN,
496   MY_VIEW_COLUMN,
497   MY_VIRTUAL_COLUMN,
498   MY_GEOMETRY,
499   MY_GEOMETRY_INDEX,
500   MY_GEOMETRY_CACHED,
501   MY_VIEW_GEOMETRY,
502   MY_VIEW_GEOMETRY_INDEX,
503   MY_VIEW_GEOMETRY_CACHED,
504   MY_VIRTUAL_GEOMETRY,
505   MY_INDEX,
506   MY_TRIGGER,
507   MY_ATTACHED,
508   MY_INT_VARIANT,
509   MY_DBL_VARIANT,
510   MY_TXT_VARIANT,
511   MY_BLOB_VARIANT,
512   MY_NULL_VARIANT
513 };
514 
515 enum
516 {
517 // control IDs for timers
518   ID_AUTO_SAVE_TIMER = 20000,
519   ID_DB_STATUS_TIMER,
520   ID_WFS_TIMER,
521 };
522 
523 enum
524 {
525 // DOT-COMMANDS [SQL scripts]
526   CMD_NONE = 0,
527   CMD_LOADSHP,
528   CMD_LOADDBF,
529   CMD_LOADXL,
530   CMD_DUMPSHP,
531   CMD_DUMPDBF,
532   CMD_SQLLOG
533 };
534 
535 enum
536 {
537 // METADATA TYPEs
538   METADATA_UNKNOWN = 0,
539   METADATA_LEGACY,
540   METADATA_CURRENT
541 };
542 
543 class TopologyItem
544 {
545 //
546 // a class wrapping a Topology related Table or View
547 //
548 private:
549   wxString Name;
550   bool Table;
551   bool View;
552   TopologyItem *Next;
553 public:
554     TopologyItem(wxString & name);
~TopologyItem()555    ~TopologyItem()
556   {;
557   }
GetName()558   wxString & GetName()
559   {
560     return Name;
561   }
SetTable()562   void SetTable()
563   {
564     Table = true;
565   }
SetView()566   void SetView()
567   {
568     View = true;
569   }
IsTable()570   bool IsTable()
571   {
572     return Table;
573   }
IsView()574   bool IsView()
575   {
576     return View;
577   }
SetNext(TopologyItem * next)578   void SetNext(TopologyItem * next)
579   {
580     Next = next;
581   }
GetNext()582   TopologyItem *GetNext()
583   {
584     return Next;
585   }
586 };
587 
588 class TopologySet
589 {
590 //
591 // a class representing a full Topology Set
592 private:
593   wxString Prefix;
594   wxString CoordDims;
595   int Srid;
596   TopologyItem *First;
597   TopologyItem *Last;
598 public:
599     TopologySet();
600    ~TopologySet();
601   bool CheckPrefix();
SetPrefix(wxString & prefix)602   void SetPrefix(wxString & prefix)
603   {
604     Prefix = prefix;
605   }
GetPrefix()606   wxString & GetPrefix()
607   {
608     return Prefix;
609   }
SetSrid(int srid)610   void SetSrid(int srid)
611   {
612     Srid = srid;
613   }
GetSrid()614   int GetSrid()
615   {
616     return Srid;
617   }
618   void SetCoordDims(const char *coords);
SetCoordDims(wxString & coords)619   void SetCoordDims(wxString & coords)
620   {
621     CoordDims = coords;
622   }
GetCoordDims()623   wxString & GetCoordDims()
624   {
625     return CoordDims;
626   }
627   void Add(const char *name, bool table, bool view);
628   void AddTable(wxString & name);
629   void AddView(wxString & name);
630   void SetTable(wxString & table_name);
631   void SetView(wxString & view_name);
GetFirst()632   TopologyItem *GetFirst()
633   {
634     return First;
635   }
636 };
637 
638 class MyObject:public wxTreeItemData
639 {
640 //
641 // a class to store TreeItemData
642 //
643 private:
644   int Type;                     // the object type
645   wxString DbAlias;             // the DB alias [Attached DB]
646   wxString Name;                // the object name
647   wxString Column;              // the column name [optional]
648   bool Temporary;               // the TMP switch
649 public:
650     MyObject(int type, wxString & name);
651     MyObject(int type, wxString & name, bool tmp);
652     MyObject(int type, wxString & dbAlias, wxString & name, bool tmp);
653     MyObject(int type, wxString & name, wxString & column);
654     MyObject(int type, bool attached, wxString & dbAlias, wxString & name);
~MyObject()655     virtual ~ MyObject()
656   {;
657   }
GetType()658   int GetType()
659   {
660     return Type;
661   }
GetDbAlias()662   wxString & GetDbAlias()
663   {
664     return DbAlias;
665   }
GetName()666   wxString & GetName()
667   {
668     return Name;
669   }
GetColumn()670   wxString & GetColumn()
671   {
672     return Column;
673   }
IsTemporary()674   bool IsTemporary()
675   {
676     return Temporary;
677   }
IsAttached()678   bool IsAttached()
679   {
680     if (DbAlias.Len() > 0)
681       return true;
682     else
683       return false;
684   }
685 };
686 
687 class MyColumnInfo
688 {
689 //
690 // a class to store a DB column
691 //
692 private:
693   wxString Name;                // the column name
694   bool PrimaryKey;              // Primary Key column
695   bool Geometry;                // Geometry column
696   bool GeometryIndex;           // Geometry column + SpatialIndex
697   bool MbrCache;                // Geometry column + MbrCache
698   MyColumnInfo *Next;           // pointer to next element into the linked list
699 public:
700     MyColumnInfo(wxString & name, bool pkey);
~MyColumnInfo()701    ~MyColumnInfo()
702   {;
703   }
GetName()704   wxString & GetName()
705   {
706     return Name;
707   }
IsPrimaryKey()708   bool IsPrimaryKey()
709   {
710     return PrimaryKey;
711   }
SetGeometry()712   void SetGeometry()
713   {
714     Geometry = true;
715   }
IsGeometry()716   bool IsGeometry()
717   {
718     return Geometry;
719   }
SetGeometryIndex()720   void SetGeometryIndex()
721   {
722     GeometryIndex = true;
723   }
IsGeometryIndex()724   bool IsGeometryIndex()
725   {
726     return GeometryIndex;
727   }
SetMbrCache()728   void SetMbrCache()
729   {
730     MbrCache = true;
731   }
IsMbrCache()732   bool IsMbrCache()
733   {
734     return MbrCache;
735   }
SetNext(MyColumnInfo * next)736   void SetNext(MyColumnInfo * next)
737   {
738     Next = next;
739   }
GetNext()740   MyColumnInfo *GetNext()
741   {
742     return Next;
743   }
744 };
745 
746 class MyIndexInfo
747 {
748 //
749 // a class to store a DB index
750 //
751 private:
752   wxString Name;                // the index name
753   MyIndexInfo *Next;            // pointer to next element into the linked list
754 public:
755     MyIndexInfo(wxString & name);
MyIndexInfo()756     MyIndexInfo()
757   {;
758   }
GetName()759   wxString & GetName()
760   {
761     return Name;
762   }
SetNext(MyIndexInfo * next)763   void SetNext(MyIndexInfo * next)
764   {
765     Next = next;
766   }
GetNext()767   MyIndexInfo *GetNext()
768   {
769     return Next;
770   }
771 };
772 
773 class MyTriggerInfo
774 {
775 //
776 // a class to store a DB trigger
777 //
778 private:
779   wxString Name;                // the trigger name
780   MyTriggerInfo *Next;          // pointer to next element into the linked list
781 public:
782     MyTriggerInfo(wxString & name);
~MyTriggerInfo()783    ~MyTriggerInfo()
784   {;
785   }
GetName()786   wxString & GetName()
787   {
788     return Name;
789   }
SetNext(MyTriggerInfo * next)790   void SetNext(MyTriggerInfo * next)
791   {
792     Next = next;
793   }
GetNext()794   MyTriggerInfo *GetNext()
795   {
796     return Next;
797   }
798 };
799 
800 class MyTableInfo
801 {
802 //
803 // a class to store DB table columns
804 //
805 private:
806   MyColumnInfo * FirstColumn;   // first element into the columns linked list
807   MyColumnInfo *LastColumn;     // last element into the columns linked list
808   MyIndexInfo *FirstIndex;      // first element into the indices linked list
809   MyIndexInfo *LastIndex;       // last element into the indices linked list
810   MyTriggerInfo *FirstTrigger;  // first element into the triggers linked list
811   MyTriggerInfo *LastTrigger;   // last element into the triggers linked list
812 public:
MyTableInfo()813     MyTableInfo()
814   {
815     FirstColumn = NULL;
816     LastColumn = NULL;
817     FirstIndex = NULL;
818     LastIndex = NULL;
819     FirstTrigger = NULL;
820     LastTrigger = NULL;
821   }
822    ~MyTableInfo();
823   void AddColumn(wxString & name, bool pkey);
824   void SetGeometry(wxString & name, bool index, bool cached);
825   void AddIndex(wxString & name);
826   void AddTrigger(wxString & name);
GetFirstColumn()827   MyColumnInfo *GetFirstColumn()
828   {
829     return FirstColumn;
830   }
GetFirstIndex()831   MyIndexInfo *GetFirstIndex()
832   {
833     return FirstIndex;
834   }
GetFirstTrigger()835   MyTriggerInfo *GetFirstTrigger()
836   {
837     return FirstTrigger;
838   }
839 };
840 
841 class MyViewInfo
842 {
843 //
844 // a class to store DB view columns
845 //
846 private:
847   MyColumnInfo * First;         // first element into the columns linked list
848   MyColumnInfo *Last;           // last element into the columns linked list
849   MyTriggerInfo *FirstTrigger;  // first element into the triggers linked list
850   MyTriggerInfo *LastTrigger;   // last element into the triggers linked list
851 public:
MyViewInfo()852     MyViewInfo()
853   {
854     First = NULL;
855     Last = NULL;
856     FirstTrigger = NULL;
857     LastTrigger = NULL;
858   }
859    ~MyViewInfo();
860   void AddColumn(wxString & name);
861   void AddTrigger(wxString & name);
862   void SetGeometry(wxString & name, bool index, bool cached);
GetFirst()863   MyColumnInfo *GetFirst()
864   {
865     return First;
866   }
GetFirstTrigger()867   MyTriggerInfo *GetFirstTrigger()
868   {
869     return FirstTrigger;
870   }
871 };
872 
873 class MyVariant
874 {
875 //
876 // a class to store Variant-Type values
877 //
878 private:
879   int Type;                     // the Variant-Type
880   sqlite3_int64 IntValue;       // the Integer value
881   double DblValue;              // the Double value
882   wxString TxtValue;            // the Text value
883   unsigned char *Blob;          // the BLOB value
884   int BlobSize;                 // the BLOB size
885 public:
MyVariant()886     MyVariant()
887   {
888     Type = MY_NULL_VARIANT;
889     Blob = NULL;
890   }
~MyVariant()891    ~MyVariant()
892   {
893     if (Blob)
894       delete[]Blob;
895   }
Clear()896   void Clear()
897   {
898     if (Blob)
899       delete[]Blob;
900     Blob = NULL;
901     Type = MY_NULL_VARIANT;
902   }
Set(sqlite3_int64 value)903   void Set(sqlite3_int64 value)
904   {
905     Type = MY_INT_VARIANT;
906     IntValue = value;
907   }
Set(double value)908   void Set(double value)
909   {
910     Type = MY_DBL_VARIANT;
911     DblValue = value;
912   }
913   void Set(const unsigned char *text);
Set(wxString & string)914   void Set(wxString & string)
915   {
916     Type = MY_TXT_VARIANT;
917     TxtValue = string;
918   }
919   void Set(const void *blob, int size);
920   void Copy(MyVariant * other);
GetType()921   int GetType()
922   {
923     return Type;
924   }
GetIntValue()925   sqlite3_int64 GetIntValue()
926   {
927     return IntValue;
928   }
GetDblValue()929   double GetDblValue()
930   {
931     return DblValue;
932   }
GetTxtValue()933   wxString & GetTxtValue()
934   {
935     return TxtValue;
936   }
GetBlobSize()937   int GetBlobSize()
938   {
939     return BlobSize;
940   }
GetBlob()941   unsigned char *GetBlob()
942   {
943     return Blob;
944   }
945 };
946 
947 class MyRowVariant
948 {
949 //
950 // a class to store a row composed of Variant-Type values
951 //
952 private:
953   int NumCols;                  // number of columns
954   MyVariant *ColumnArray;       // the column as an array
955   bool Deleted;                 // switch to mark row deletion
956   MyRowVariant *Next;           // pointer to next element into the linked list
957 public:
MyRowVariant()958     MyRowVariant()
959   {
960     NumCols = 0;
961     ColumnArray = NULL;
962     Deleted = false;
963     Next = NULL;
964   }
MyRowVariant(int cols)965   MyRowVariant(int cols)
966   {
967     NumCols = cols;
968     ColumnArray = new MyVariant[cols];
969     Next = NULL;
970   }
~MyRowVariant()971   ~MyRowVariant()
972   {
973     if (ColumnArray)
974       delete[]ColumnArray;
975   }
976   void Create(int cols);
GetNumCols()977   int GetNumCols()
978   {
979     return NumCols;
980   }
981   void Set(int col, sqlite3_int64 value);
982   void Set(int col, double value);
983   void Set(int col, const unsigned char *text);
984   void Set(int col, const void *blob, int size);
985   MyVariant *GetColumn(int col);
SetDeleted()986   void SetDeleted()
987   {
988     Deleted = true;
989   }
IsDeleted()990   bool IsDeleted()
991   {
992     return Deleted;
993   }
SetNext(MyRowVariant * next)994   void SetNext(MyRowVariant * next)
995   {
996     Next = next;
997   }
GetNext()998   MyRowVariant *GetNext()
999   {
1000     return Next;
1001   }
1002 };
1003 
1004 class MyVariantList
1005 {
1006 //
1007 // a class to store a whole result set
1008 //
1009 private:
1010   int NumCols;                  // number of columns
1011   wxString *ColumnName;         // the column names
1012   MyRowVariant *First;          // first element into the linked list
1013   MyRowVariant *Last;           // last element into the linked list
1014 public:
1015     MyVariantList();
1016    ~MyVariantList();
1017   void Reset(void);
1018   MyRowVariant *Add(int columns);
1019   void SetColumnName(int col, const char *colName);
GetFirst()1020   MyRowVariant *GetFirst()
1021   {
1022     return First;
1023   }
1024   int GetRows();
GetColumns()1025   int GetColumns()
1026   {
1027     return NumCols;
1028   }
1029   wxString & GetColumnName(int col);
1030 };
1031 
1032 class MyBlobs
1033 {
1034 //
1035 // a class to store BLOBs
1036 //
1037 private:
1038   int NumRows;                  // the number of rows
1039   int NumCols;                  // the number of columns
1040   MyRowVariant *Rows;           // pointer to an array of rows
1041 public:
1042     MyBlobs(int rows, int cols);
1043    ~MyBlobs();
1044   void SetBlob(int row, int col, MyVariant * blobVar);
1045   MyVariant *GetBlob(int row, int col);
1046 };
1047 
1048 class MyValues
1049 {
1050 //
1051 // a class to store column values for editing
1052 //
1053 private:
1054   int NumRows;                  // the number of rows
1055   int NumCols;                  // the number of columns
1056   MyRowVariant *Rows;           // pointer to an array of rows
1057 public:
1058     MyValues(int rows, int cols);
1059    ~MyValues();
1060   void SetValue(int row, int col, sqlite3_int64 value);
1061   void SetValue(int row, int col, double value);
1062   void SetValue(int row, int col, wxString & string);
1063   MyRowVariant *GetRow(int row);
1064   MyVariant *GetValue(int row, int col);
1065 };
1066 
1067 class MySqlQuery
1068 {
1069 //
1070 // a class to store an SQL query - history
1071 //
1072 private:
1073   wxString Sql;
1074   MySqlQuery *Prev;
1075   MySqlQuery *Next;
1076 public:
MySqlQuery(wxString & sql)1077     MySqlQuery(wxString & sql)
1078   {
1079     Sql = sql;
1080     Prev = NULL;
1081     Next = NULL;
1082   }
~MySqlQuery()1083    ~MySqlQuery()
1084   {;
1085   }
GetSql()1086   wxString & GetSql()
1087   {
1088     return Sql;
1089   }
SetPrev(MySqlQuery * prev)1090   void SetPrev(MySqlQuery * prev)
1091   {
1092     Prev = prev;
1093   }
GetPrev()1094   MySqlQuery *GetPrev()
1095   {
1096     return Prev;
1097   }
SetNext(MySqlQuery * next)1098   void SetNext(MySqlQuery * next)
1099   {
1100     Next = next;
1101   }
GetNext()1102   MySqlQuery *GetNext()
1103   {
1104     return Next;
1105   }
1106 };
1107 
1108 class MySqlHistory
1109 {
1110 //
1111 // a class supporting SQL queries history
1112 //
1113 private:
1114   MySqlQuery * First;
1115   MySqlQuery *Last;
1116   MySqlQuery *Current;
1117 public:
MySqlHistory()1118     MySqlHistory()
1119   {
1120     First = NULL;
1121     Last = NULL;
1122     Current = NULL;
1123   }
1124    ~MySqlHistory();
1125   void Prepend(wxString & sql);
1126   void Add(wxString & sql);
GetCurrent()1127   MySqlQuery *GetCurrent()
1128   {
1129     return Current;
1130   }
1131   MySqlQuery *GetNext();
1132   MySqlQuery *GetPrev();
1133   bool TestNext();
1134   bool TestPrev();
1135 };
1136 
1137 class MyApp:public wxApp
1138 {
1139 //
1140 // the main APP
1141 //
1142   virtual bool OnInit();
1143 };
1144 
1145 class DuplColumn
1146 {
1147 //
1148 // a column value in a duplicated row
1149 //
1150 private:
1151   int Pos;
1152   wxString Name;
1153   int Type;
1154   sqlite3_int64 IntValue;
1155   double DblValue;
1156   const char *TxtValue;
1157   const void *Blob;
1158   int Size;
1159   int QueryPos;
1160   DuplColumn *Next;
1161 public:
DuplColumn(int pos,wxString & name)1162     DuplColumn(int pos, wxString & name)
1163   {
1164     Pos = pos;
1165     Name = name;
1166     Type = SQLITE_NULL;
1167     Next = NULL;
1168   }
~DuplColumn()1169    ~DuplColumn()
1170   {;
1171   }
GetPos()1172   int GetPos()
1173   {
1174     return Pos;
1175   }
GetName()1176   wxString & GetName()
1177   {
1178     return Name;
1179   }
SetValue(sqlite3_int64 value)1180   void SetValue(sqlite3_int64 value)
1181   {
1182     Type = SQLITE_INTEGER;
1183     IntValue = value;
1184   }
SetValue(double value)1185   void SetValue(double value)
1186   {
1187     Type = SQLITE_FLOAT;
1188     DblValue = value;
1189   }
SetValue(const char * value)1190   void SetValue(const char *value)
1191   {
1192     Type = SQLITE_TEXT;
1193     TxtValue = value;
1194   }
SetValue(const void * blob,int size)1195   void SetValue(const void *blob, int size)
1196   {
1197     Type = SQLITE_BLOB;
1198     Blob = blob;
1199     Size = size;
1200   }
SetValue(void)1201   void SetValue(void)
1202   {
1203     Type = SQLITE_NULL;
1204   }
GetType()1205   int GetType()
1206   {
1207     return Type;
1208   }
GetIntValue()1209   sqlite3_int64 GetIntValue()
1210   {
1211     return IntValue;
1212   }
GetDblValue()1213   double GetDblValue()
1214   {
1215     return DblValue;
1216   }
GetTxtValue()1217   const char *GetTxtValue()
1218   {
1219     return TxtValue;
1220   }
1221   bool CheckBlob(const void *blob, int size);
SetQueryPos(int pos)1222   void SetQueryPos(int pos)
1223   {
1224     QueryPos = pos;
1225   }
GetQueryPos()1226   int GetQueryPos()
1227   {
1228     return QueryPos;
1229   }
SetNext(DuplColumn * next)1230   void SetNext(DuplColumn * next)
1231   {
1232     Next = next;
1233   }
GetNext()1234   DuplColumn *GetNext()
1235   {
1236     return Next;
1237   }
1238 };
1239 
1240 class DuplRow
1241 {
1242 //
1243 // a duplicated row with column values
1244 //
1245 private:
1246   int Count;
1247   DuplColumn *First;
1248   DuplColumn *Last;
1249   wxString Table;
1250 public:
DuplRow()1251     DuplRow()
1252   {
1253     Count = 0;
1254     First = NULL;
1255     Last = NULL;
1256   }
1257    ~DuplRow();
SetTable(wxString & table)1258   void SetTable(wxString & table)
1259   {
1260     Table = table;
1261   }
GetTable()1262   wxString & GetTable()
1263   {
1264     return Table;
1265   }
1266   void Add(wxString & name);
1267   void SetValue(int pos, sqlite3_int64 value);
1268   void SetValue(int pos, double value);
1269   void SetValue(int pos, const char *value);
1270   void SetValue(int pos, const void *blob, int size);
1271   void SetValue(int pos);
1272   void ResetQueryPos();
1273   bool CheckBlob(int pos, const void *blob, int size);
GetFirst()1274   DuplColumn *GetFirst()
1275   {
1276     return First;
1277   }
1278 };
1279 
1280 class Topology
1281 {
1282 //
1283 // Topology container
1284 //
1285 private:
1286   wxTreeItemId TopologyNode;
1287   TopologySet TopologyItems;
1288   Topology *Next;
1289 public:
1290     Topology(class MyTableTree * tree, wxTreeItemId & root,
1291              TopologySet * topology);
~Topology()1292    ~Topology()
1293   {;
1294   }
1295   wxTreeItemId *Check(wxString & table);
GetNext()1296   Topology *GetNext()
1297   {
1298     return Next;
1299   }
SetNext(Topology * next)1300   void SetNext(Topology * next)
1301   {
1302     Next = next;
1303   }
1304 };
1305 
1306 class TopologyList
1307 {
1308 //
1309 // Topology container
1310 //
1311 private:
1312   Topology * First;
1313   Topology *Last;
1314   int Count;
1315 public:
TopologyList()1316     TopologyList()
1317   {
1318     First = NULL;
1319     Last = NULL;
1320     Count = 0;
1321   }
~TopologyList()1322    ~TopologyList()
1323   {
1324     Flush();
1325   }
1326   void Flush();
1327   void Add(class MyTableTree * tree, wxTreeItemId & root,
1328            TopologySet * topology);
1329   wxTreeItemId *FindNode(wxString & table);
GetCount()1330   int GetCount()
1331   {
1332     return Count;
1333   }
1334 };
1335 
1336 class RootNodes
1337 {
1338 //
1339 // a class wrapping root nodes for an Attached DB
1340 //
1341 private:
1342   wxString dbAlias;
1343   wxTreeItemId rootUserData;
1344   wxTreeItemId rootTopologies;
1345   wxTreeItemId rootStyling;
1346   wxTreeItemId rootIsoMetadata;
1347   wxTreeItemId rootMetadata;
1348   wxTreeItemId rootInternal;
1349   wxTreeItemId rootSpatialIndex;
1350 public:
RootNodes(wxString & alias,wxTreeItemId userData,wxTreeItemId topologies,wxTreeItemId styling,wxTreeItemId isoMetadata,wxTreeItemId metadata,wxTreeItemId internal,wxTreeItemId spatialIndex)1351     RootNodes(wxString & alias, wxTreeItemId userData, wxTreeItemId topologies,
1352               wxTreeItemId styling, wxTreeItemId isoMetadata,
1353               wxTreeItemId metadata, wxTreeItemId internal,
1354               wxTreeItemId spatialIndex)
1355   {
1356     dbAlias = alias;
1357     rootUserData = userData;
1358     rootTopologies = topologies;
1359     rootStyling = styling;
1360     rootIsoMetadata = isoMetadata;
1361     rootMetadata = metadata;
1362     rootInternal = internal;
1363     rootSpatialIndex = spatialIndex;
1364   }
~RootNodes()1365    ~RootNodes()
1366   {;
1367   }
GetDbAlias()1368   wxString & GetDbAlias()
1369   {
1370     return dbAlias;
1371   }
GetRootUserData()1372   wxTreeItemId & GetRootUserData()
1373   {
1374     return rootUserData;
1375   }
GetRootTopologies()1376   wxTreeItemId & GetRootTopologies()
1377   {
1378     return rootTopologies;
1379   }
GetRootStyling()1380   wxTreeItemId & GetRootStyling()
1381   {
1382     return rootStyling;
1383   }
GetRootIsoMetadata()1384   wxTreeItemId & GetRootIsoMetadata()
1385   {
1386     return rootIsoMetadata;
1387   }
GetRootMetadata()1388   wxTreeItemId & GetRootMetadata()
1389   {
1390     return rootMetadata;
1391   }
GetRootInternal()1392   wxTreeItemId & GetRootInternal()
1393   {
1394     return rootInternal;
1395   }
GetRootSpatialIndex()1396   wxTreeItemId & GetRootSpatialIndex()
1397   {
1398     return rootSpatialIndex;
1399   }
1400 };
1401 
1402 class MyTableTree:public wxTreeCtrl
1403 {
1404 //
1405 // a tree-control used for SQLite DB tables
1406 //
1407 private:
1408   class MyFrame * MainFrame;
1409   wxTreeItemId Root;            // the root node
1410   wxTreeItemId RootUserData;
1411   wxTreeItemId RootTopologies;
1412   wxTreeItemId RootStyling;
1413   wxTreeItemId RootIsoMetadata;
1414   TopologyList Topologies;
1415   wxTreeItemId RootMetadata;
1416   wxTreeItemId RootInternal;
1417   wxTreeItemId RootSpatialIndex;
1418   wxImageList *Images;          // the images list
1419   wxTreeItemId CurrentItem;     // the tree item holding the current context menu
1420   bool doDeleteDuplicates(wxString & sql1, wxString & sql2, DuplRow * values,
1421                           int *count);
1422   bool doDeleteDuplicates2(sqlite3_stmt * stmt1, DuplRow * values, int *count);
1423 public:
MyTableTree()1424     MyTableTree()
1425   {;
1426   }
1427   MyTableTree(class MyFrame * parent, wxWindowID id = wxID_ANY);
~MyTableTree()1428   virtual ~ MyTableTree()
1429   {;
1430   }
SetPath(wxString & path)1431   void SetPath(wxString & path)
1432   {
1433     SetItemText(Root, path);
1434   }
1435   void FlushAll();
1436   wxTreeItemId & GetRootNode(wxString & tableName);
1437   wxTreeItemId & GetRootNode(wxString & tableName, RootNodes * nodes);
1438   void AddTable(wxString & tableName, bool virtualTable, bool tmp);
1439   void AddView(wxString & viewName, bool tmp);
1440   wxTreeItemId & AddAttached(wxString & dbAlias, wxString & path);
1441   void AddTable(wxString & dbAlias, wxString & tableName,
1442                 bool virtualTable, RootNodes * list);
1443   void AddView(wxString & dbAlias, wxString & viewName, RootNodes * list);
ExpandRoot()1444   void ExpandRoot()
1445   {
1446     Expand(Root);
1447     Expand(RootUserData);
1448     CollapseAllChildren(RootTopologies);
1449     CollapseAllChildren(RootStyling);
1450     CollapseAllChildren(RootIsoMetadata);
1451     Collapse(RootMetadata);
1452     Collapse(RootInternal);
1453     Collapse(RootSpatialIndex);
1454   }
AddTopology(TopologySet * topology)1455   void AddTopology(TopologySet * topology)
1456   {
1457     Topologies.Add(this, RootTopologies, topology);
1458   }
AddTopology(wxTreeItemId & rootTopologies,TopologySet * topology)1459   void AddTopology(wxTreeItemId & rootTopologies, TopologySet * topology)
1460   {
1461     Topologies.Add(this, rootTopologies, topology);
1462   }
1463   void DeleteTopologies(wxTreeItemId & root_topologies);
1464   void OnSelChanged(wxTreeEvent & event);
1465   void OnRightClick(wxTreeEvent & event);
1466   void OnCmdQueryViewComposer(wxCommandEvent & event);
1467   void OnCmdNewTable(wxCommandEvent & event);
1468   void OnCmdNewView(wxCommandEvent & event);
1469   void OnCmdNewIndex(wxCommandEvent & event);
1470   void OnCmdNewTrigger(wxCommandEvent & event);
1471   void OnCmdNewColumn(wxCommandEvent & event);
1472   void OnCmdShow(wxCommandEvent & event);
1473   void OnCmdDrop(wxCommandEvent & event);
1474   void OnCmdRename(wxCommandEvent & event);
1475   void OnCmdSelect(wxCommandEvent & event);
1476   void OnCmdRefresh(wxCommandEvent & event);
1477   void OnCmdRecover(wxCommandEvent & event);
1478   void OnCmdShowSql(wxCommandEvent & event);
1479   void OnCmdSpatialIndex(wxCommandEvent & event);
1480   void OnCmdCheckSpatialIndex(wxCommandEvent & event);
1481   void OnCmdRecoverSpatialIndex(wxCommandEvent & event);
1482   void OnCmdMbrCache(wxCommandEvent & event);
1483   void OnCmdRebuildTriggers(wxCommandEvent & event);
1484   void OnCmdCheckGeometry(wxCommandEvent & event);
1485   void OnCmdExtent(wxCommandEvent & event);
1486   void OnCmdUpdateLayerStatistics(wxCommandEvent & event);
1487   void OnCmdUpdateLayerStatisticsAll(wxCommandEvent & event);
1488   void OnCmdElementaryGeometries(wxCommandEvent & event);
1489   void OnCmdMalformedGeometries(wxCommandEvent & event);
1490   void OnCmdRepairPolygons(wxCommandEvent & event);
1491   void OnCmdSetSrid(wxCommandEvent & event);
1492   void OnCmdDumpShp(wxCommandEvent & event);
1493   void OnCmdDumpKml(wxCommandEvent & event);
1494   void OnCmdDumpTxtTab(wxCommandEvent & event);
1495   void OnCmdDumpCsv(wxCommandEvent & event);
1496   void OnCmdDumpHtml(wxCommandEvent & event);
1497   void OnCmdDumpDif(wxCommandEvent & event);
1498   void OnCmdDumpSylk(wxCommandEvent & event);
1499   void OnCmdDumpDbf(wxCommandEvent & event);
1500   void OnCmdDumpPostGIS(wxCommandEvent & event);
1501   void OnCmdEdit(wxCommandEvent & event);
1502   bool DropRenameAux1(MyObject * obj, class GeomColsList * geometries,
1503                       bool * autoincrement);
1504   void DropRenameAux2(MyObject * obj, GeomColsList * geometries,
1505                       wxString & aliasTable, wxString & renameSql,
1506                       wxString & dropSql, wxString & disableSpatialIdxSql,
1507                       wxString & dropSpatialIdxSql,
1508                       wxString & createSpatialIdxSql,
1509                       wxString & discardGeometrySql);
1510   void DropRenameAux3(MyObject * obj, GeomColsList * geometries,
1511                       class TblIndexList * index, wxString & addGeometrySql);
1512   void OnCmdDropColumn(wxCommandEvent & event);
1513   void OnCmdRenameColumn(wxCommandEvent & event);
1514   void OnCmdGisLayerAuth(wxCommandEvent & event);
1515   void OnCmdColumnStats(wxCommandEvent & event);
1516   void OnCmdMapPreview(wxCommandEvent & event);
1517   void OnCmdCheckDuplicates(wxCommandEvent & event);
1518   void OnCmdRemoveDuplicates(wxCommandEvent & event);
1519   void OnCmdDetachDB(wxCommandEvent & event);
1520   void OnCmdCheckGeometries(wxCommandEvent & event);
1521   void OnCmdSanitizeGeometries(wxCommandEvent & event);
1522 };
1523 
1524 class SqlThreadParams
1525 {
1526 //
1527 // an auxiliary class used for SQL threaded queries
1528 //
1529 private:
1530   class MyResultSetView * Mother;
1531   wxString Sql;
1532   sqlite3_stmt *Stmt;
1533   int FromRow;
1534   int EndRow;
1535   int MaxRow;
1536   MyVariantList List;
1537   sqlite3 *Sqlite;
1538   clock_t Start;
1539   clock_t LastGuiUpdate;
1540   bool Error;
1541   int FetchedRows;
1542   int StatFullscanStep;
1543   int StatSort;
1544   int StatAutoindex;
1545   double ElapsedTime;
1546   bool AbortRequested;
1547   bool Valid;
1548 public:
SqlThreadParams()1549     SqlThreadParams()
1550   {
1551     Reset();
1552   }
~SqlThreadParams()1553    ~SqlThreadParams()
1554   {;
1555   }
1556   void Initialize(MyResultSetView * mother, wxString & sql, sqlite3_stmt * stmt,
1557                   int from, sqlite3 * sqlite, clock_t start);
1558   void Reset(void);
IsValid()1559   bool IsValid()
1560   {
1561     return Valid;
1562   }
GetMother()1563   MyResultSetView *GetMother()
1564   {
1565     return Mother;
1566   }
GetSql()1567   wxString & GetSql()
1568   {
1569     return Sql;
1570   }
GetStmt()1571   sqlite3_stmt *GetStmt()
1572   {
1573     return Stmt;
1574   }
GetFromRow()1575   int GetFromRow()
1576   {
1577     return FromRow;
1578   }
SetEndRow(int end)1579   void SetEndRow(int end)
1580   {
1581     EndRow = end;
1582   }
GetEndRow()1583   int GetEndRow()
1584   {
1585     return EndRow;
1586   }
SetMaxRow(int max)1587   void SetMaxRow(int max)
1588   {
1589     MaxRow = max;
1590   }
GetMaxRow()1591   int GetMaxRow()
1592   {
1593     return MaxRow;
1594   }
GetList()1595   MyVariantList *GetList()
1596   {
1597     return &List;
1598   }
GetSqlite()1599   sqlite3 *GetSqlite()
1600   {
1601     return Sqlite;
1602   }
GetStart()1603   clock_t GetStart()
1604   {
1605     return Start;
1606   }
FetchedRow()1607   void FetchedRow()
1608   {
1609     FetchedRows++;
1610   }
1611   void UpdateStats(int fullscan, int sort, int autoindex, clock_t now);
GetFetchedRows()1612   int GetFetchedRows()
1613   {
1614     return FetchedRows;
1615   }
GetStatFullscanStep()1616   int GetStatFullscanStep()
1617   {
1618     return StatFullscanStep;
1619   }
GetStatSort()1620   int GetStatSort()
1621   {
1622     return StatSort;
1623   }
GetStatAutoindex()1624   int GetStatAutoindex()
1625   {
1626     return StatAutoindex;
1627   }
GetElapsedTime()1628   double GetElapsedTime()
1629   {
1630     return ElapsedTime;
1631   }
1632   bool GuiHasToBeUpdated(clock_t now, int millisecs);
SetLastGuiUpdate(clock_t now)1633   void SetLastGuiUpdate(clock_t now)
1634   {
1635     LastGuiUpdate = now;
1636   }
SetError()1637   void SetError()
1638   {
1639     Error = true;
1640   }
IsError()1641   bool IsError()
1642   {
1643     return Error;
1644   }
Abort()1645   void Abort()
1646   {
1647     AbortRequested = true;
1648   }
IsAbortRequested()1649   bool IsAbortRequested()
1650   {
1651     return AbortRequested;
1652   }
1653 };
1654 
1655 class MyResultSetView:public wxPanel
1656 {
1657 //
1658 // a panel to be used for SQL Queries
1659 //
1660 private:
1661   class MyFrame * MainFrame;
1662   wxBitmapButton *BtnRsFirst;
1663   wxBitmapButton *BtnRsLast;
1664   wxBitmapButton *BtnRsNext;
1665   wxBitmapButton *BtnRsPrevious;
1666   wxBitmapButton *BtnRefresh;
1667   wxStaticText *RsCurrentBlock;
1668   int RsBlock;
1669   int RsBeginRow;
1670   int RsEndRow;
1671   int RsMaxRow;
1672   int CurrentEvtRow;
1673   int CurrentEvtColumn;
1674   MyVariant *CurrentBlob;
1675   wxGrid *TableView;
1676   MyBlobs *TableBlobs;
1677   MyValues *TableValues;
1678   bool ReadOnly;
1679   sqlite3_int64 *RowIds;
1680   int PrimaryKeys[1024];
1681   int BlobColumns[1024];
1682   wxString TableName;
1683   bool InsertPending;
1684   MyRowVariant *InsertRow;
1685   wxString SqlErrorMsg;
1686   SqlThreadParams ThreadParams;
1687   void XmlBlobOut(bool indented);
1688 public:
MyResultSetView()1689     MyResultSetView()
1690   {;
1691   }
1692   MyResultSetView(MyFrame * parent, wxWindowID id = wxID_ANY);
1693   virtual ~ MyResultSetView();
1694   void HideControls();
1695   void ShowControls();
GetSqlErrorMsg()1696   wxString & GetSqlErrorMsg()
1697   {
1698     return SqlErrorMsg;
1699   }
1700   bool IsPrimaryKey(int column);
1701   bool IsBlobColumn(int column);
1702   void EditTable(wxString & sql, int *primaryKeys, int *blobCols,
1703                  wxString & tableName);
1704   void CreateGrid(int rows, int cols);
1705   void CreateStatsGrid();
1706   bool ExecuteSqlPre(wxString & sql, int from, bool read_only);
1707   bool ExecuteSqlPost(void);
1708   void AbortRequested(void);
GetCurrentBlock()1709   wxStaticText *GetCurrentBlock()
1710   {
1711     return RsCurrentBlock;
1712   }
1713   void FormatElapsedTime(double seconds, char *elapsed, bool simple = false);
GetRsBlock()1714   int GetRsBlock()
1715   {
1716     return RsBlock;
1717   }
SetSqlErrorMsg(wxString & msg)1718   void SetSqlErrorMsg(wxString & msg)
1719   {
1720     SqlErrorMsg = msg;
1721   }
1722   void ResizeView(void);
1723   void DoInsert(bool confirmed);
1724   void HexBlobValue(unsigned char *blob, int size, wxString & hex);
1725   void OnSize(wxSizeEvent & event);
1726   void OnRsFirst(wxCommandEvent & event);
1727   void OnRsLast(wxCommandEvent & event);
1728   void OnRsNext(wxCommandEvent & event);
1729   void OnRsPrevious(wxCommandEvent & event);
1730   void OnRefresh(wxCommandEvent & event);
1731   void OnThreadFinished(wxCommandEvent & event);
1732   void OnStatsUpdate(wxCommandEvent & event);
1733   void OnCellSelected(wxGridEvent & event);
1734   void OnRightClick(wxGridEvent & event);
1735   void OnCellChanged(wxGridEvent & event);
1736   void OnCmdDelete(wxCommandEvent & event);
1737   void OnCmdInsert(wxCommandEvent & event);
1738   void OnCmdAbort(wxCommandEvent & event);
1739   void OnCmdClearSelection(wxCommandEvent & event);
1740   void OnCmdSelectAll(wxCommandEvent & event);
1741   void OnCmdSelectRow(wxCommandEvent & event);
1742   void OnCmdSelectColumn(wxCommandEvent & event);
1743   void OnCmdCopy(wxCommandEvent & event);
1744   void OnCmdBlob(wxCommandEvent & event);
1745   void OnCmdBlobIn(wxCommandEvent & event);
1746   void OnCmdBlobOut(wxCommandEvent & event);
1747   void OnCmdBlobNull(wxCommandEvent & event);
1748   void OnCmdXmlBlobIn(wxCommandEvent & event);
1749   void OnCmdXmlBlobOut(wxCommandEvent & event);
1750   void OnCmdXmlBlobOutIndented(wxCommandEvent & event);
1751   void OnCmdExpTxtTab(wxCommandEvent & event);
1752   void OnCmdExpCsv(wxCommandEvent & event);
1753   void OnCmdExpHtml(wxCommandEvent & event);
1754   void OnCmdExpShp(wxCommandEvent & event);
1755   void OnCmdExpDif(wxCommandEvent & event);
1756   void OnCmdExpSylk(wxCommandEvent & event);
1757   void OnCmdExpDbf(wxCommandEvent & event);
1758 };
1759 
1760 class MySqlControl:public wxTextCtrl
1761 {
1762 //
1763 // the SQL text control
1764 //
1765 private:
1766   class MyQueryView * Parent;
1767 public:
1768   MySqlControl(MyQueryView * parent, wxWindowID id, const wxString & value,
1769                const wxPoint & pos, const wxSize & size, long style);
~MySqlControl()1770     virtual ~ MySqlControl()
1771   {;
1772   }
1773   void OnSqlMousePosition(wxMouseEvent & event);
1774   void OnSqlArrowPosition(wxKeyEvent & event);
1775 };
1776 
1777 class SqlTokenizer
1778 {
1779 //
1780 // a class used for tokenizing SQL statements
1781 //
1782 private:
1783   wxString ** TokenList;
1784   int Block;
1785   int Max;
1786   int Index;
1787   void Expand();
1788   void Insert(wxString * token);
1789   wxString CurrentToken;
1790 public:
1791     SqlTokenizer(wxString & sql);
1792    ~SqlTokenizer();
1793   bool HasMoreTokens();
1794     wxString & GetNextToken();
1795 };
1796 
1797 class MyQueryView:public wxPanel
1798 {
1799 //
1800 // a panel to be used for SQL Queries
1801 //
1802 private:
1803   class MyFrame * MainFrame;
1804   MySqlHistory History;
1805   MySqlControl *SqlCtrl;
1806   wxBitmapButton *BtnSqlGo;
1807   wxBitmapButton *BtnSqlAbort;
1808   wxBitmapButton *BtnHistoryBack;
1809   wxBitmapButton *BtnHistoryForward;
1810   int BracketStart;
1811   int BracketEnd;
1812   bool IgnoreEvent;
1813 public:
MyQueryView()1814     MyQueryView()
1815   {;
1816   }
1817   MyQueryView(MyFrame * parent, wxWindowID id = wxID_ANY);
~MyQueryView()1818   virtual ~ MyQueryView()
1819   {;
1820   }
1821   void HideControls();
1822   void ShowControls();
1823   static bool IsSqliteExtra(wxString & str);
1824   static bool IsSqlString(wxString & str);
1825   static bool IsSqlNumber(wxString & str);
1826   static bool IsSqlFunction(wxString & str, char next_c);
1827   static bool IsSqlGeoFunction(wxString & str, char next_c);
IsIgnoreEvent()1828   bool IsIgnoreEvent()
1829   {
1830     return IgnoreEvent;
1831   }
1832   void EventBrackets();
1833   bool CheckBrackets(int pos, bool reverse_direction, int *on, int *off);
1834   void EvidBrackets(int on, int off);
1835   void DoSqlSyntaxColor();
EnableAbortButton()1836   void EnableAbortButton()
1837   {
1838     BtnSqlAbort->Enable(true);
1839   }
DisableAbortButton()1840   void DisableAbortButton()
1841   {
1842     BtnSqlAbort->Enable(false);
1843   }
GetSqlCtrl()1844   wxTextCtrl *GetSqlCtrl()
1845   {
1846     return SqlCtrl;
1847   }
GetHistory()1848   MySqlHistory *GetHistory()
1849   {
1850     return &History;
1851   }
1852   void SetSql(wxString & sql, bool execute);
1853   void SetHistoryStates();
1854   void OnSize(wxSizeEvent & event);
1855   void OnSqlGo(wxCommandEvent & event);
1856   void OnSqlAbort(wxCommandEvent & event);
1857   void OnHistoryBack(wxCommandEvent & event);
1858   void OnHistoryForward(wxCommandEvent & event);
1859   void OnSqlSyntaxColor(wxCommandEvent & event);
1860   void AddToHistory(wxString & sql);
1861 };
1862 
1863 class MalformedGeom
1864 {
1865 //
1866 // a malformed geometry item
1867 //
1868 private:
1869   sqlite3_int64 RowId;
1870   int Severity;
1871   wxString Error;
1872   wxString GeosMsg;
1873   bool CanFix;
1874   MalformedGeom *Next;
1875 public:
1876     MalformedGeom(sqlite3_int64 rowid, int severity, bool canFix,
1877                   wxString & error);
1878     MalformedGeom(sqlite3_int64 rowid, int severity, bool canFix,
1879                   wxString & error, wxString & geosMsg);
~MalformedGeom()1880    ~MalformedGeom()
1881   {;
1882   }
GetRowId()1883   sqlite3_int64 GetRowId()
1884   {
1885     return RowId;
1886   }
GetSeverity()1887   int GetSeverity()
1888   {
1889     return Severity;
1890   }
CanBeFixed()1891   bool CanBeFixed()
1892   {
1893     return CanFix;
1894   }
GetError()1895   wxString & GetError()
1896   {
1897     return Error;
1898   }
GetGeosMsg()1899   wxString & GetGeosMsg()
1900   {
1901     return GeosMsg;
1902   }
SetNext(MalformedGeom * next)1903   void SetNext(MalformedGeom * next)
1904   {
1905     Next = next;
1906   }
GetNext()1907   MalformedGeom *GetNext()
1908   {
1909     return Next;
1910   }
1911 };
1912 
1913 class MalformedGeomsList
1914 {
1915 //
1916 // a list of malformed geometries
1917 //
1918 private:
1919   MalformedGeom * First;
1920   MalformedGeom *Last;
1921 public:
MalformedGeomsList()1922     MalformedGeomsList()
1923   {
1924     First = NULL;
1925     Last = NULL;
1926   }
1927    ~MalformedGeomsList();
1928   void AddEntity(sqlite3_int64 rowid, int severity, bool canFix,
1929                  wxString & error);
1930   void AddEntity(sqlite3_int64 rowid, int severity, bool CanFix,
1931                  wxString & error, wxString & geosMsg);
GetFirst()1932   MalformedGeom *GetFirst()
1933   {
1934     return First;
1935   }
1936 };
1937 
1938 class SanitizeAllGeometriesDialog:public wxDialog
1939 {
1940 //
1941 // a dialog supporting Sanitize All Geometries
1942 //
1943 private:
1944   MyFrame * MainFrame;
1945   wxString TmpPrefix;
1946 public:
SanitizeAllGeometriesDialog()1947     SanitizeAllGeometriesDialog()
1948   {;
1949   }
~SanitizeAllGeometriesDialog()1950   virtual ~ SanitizeAllGeometriesDialog()
1951   {;
1952   }
1953   bool Create(MyFrame * parent);
1954   void CreateControls();
GetTmpPrefix()1955   wxString & GetTmpPrefix()
1956   {
1957     return TmpPrefix;
1958   }
1959   void OnYes(wxCommandEvent & event);
1960   void OnNo(wxCommandEvent & event);
1961 };
1962 
1963 class WfsParams
1964 {
1965 // parameters for WFS download
1966 private:
1967   class WfsDialog * Mother;
1968   wxGauge *ProgressCtrl;
1969   sqlite3 *sqlite;
1970   wxString url;
1971   wxString alt_describe;
1972   wxString layer_name;
1973   int swap_axes;
1974   wxString table;
1975   wxString primary_key;
1976   int spatial_index;
1977   int page_size;
1978   wxString extra;
1979   void (*callback) (int, void *);
1980   int ret;
1981   char *err_msg;
1982   int rows;
1983   int ProgressCount;
1984   int LastProgressCount;
1985 public:
WfsParams()1986     WfsParams()
1987   {;
1988   }
~WfsParams()1989    ~WfsParams()
1990   {;
1991   }
Initialize(WfsDialog * mother,sqlite3 * sqlite,wxString & url,wxString & alt_describe,wxString & layer_name,int swap_axes,wxString & table,wxString & primary_key,int spatial_index,int page_size,wxString & extra,void (* callback)(int,void *))1992   void Initialize(WfsDialog * mother, sqlite3 * sqlite, wxString & url,
1993                   wxString & alt_describe, wxString & layer_name, int swap_axes,
1994                   wxString & table, wxString & primary_key, int spatial_index,
1995                   int page_size, wxString & extra, void (*callback) (int,
1996                                                                      void *))
1997   {
1998     Mother = mother;
1999     this->sqlite = sqlite;
2000     this->url = url;
2001     this->alt_describe = alt_describe;
2002     this->layer_name = layer_name;
2003     this->swap_axes = swap_axes;
2004     this->table = table;
2005     this->primary_key = primary_key;
2006     this->spatial_index = spatial_index;
2007     this->page_size = page_size;
2008     this->extra = extra;
2009     this->callback = callback;
2010     ProgressCount = 0;
2011     LastProgressCount = 0;
2012   }
GetMother()2013   WfsDialog *GetMother()
2014   {
2015     return Mother;
2016   }
GetSqlite()2017   sqlite3 *GetSqlite()
2018   {
2019     return sqlite;
2020   }
GetUrl()2021   wxString & GetUrl()
2022   {
2023     return url;
2024   }
GetAltDescribeUri()2025   wxString & GetAltDescribeUri()
2026   {
2027     return alt_describe;
2028   }
GetLayerName()2029   wxString & GetLayerName()
2030   {
2031     return layer_name;
2032   }
GetSwapAxes()2033   int GetSwapAxes()
2034   {
2035     return swap_axes;
2036   }
GetTable()2037   wxString & GetTable()
2038   {
2039     return table;
2040   }
GetPrimaryKey()2041   wxString & GetPrimaryKey()
2042   {
2043     return primary_key;
2044   }
GetSpatialIndex()2045   int GetSpatialIndex()
2046   {
2047     return spatial_index;
2048   }
GetPageSize()2049   int GetPageSize()
2050   {
2051     return page_size;
2052   }
GetExtra()2053   wxString & GetExtra()
2054   {
2055     return extra;
2056   }
GetCallback()2057   void (*GetCallback()) (int, void *)
2058   {
2059     return callback;
2060   }
SetRet(int ret)2061   void SetRet(int ret)
2062   {
2063     this->ret = ret;
2064   }
GetRet()2065   int GetRet()
2066   {
2067     return ret;
2068   }
SetErrMsg(char * err_msg)2069   void SetErrMsg(char *err_msg)
2070   {
2071     this->err_msg = err_msg;
2072   }
GetErrMsg()2073   char *GetErrMsg()
2074   {
2075     return err_msg;
2076   }
SetRows(int rows)2077   void SetRows(int rows)
2078   {
2079     this->rows = rows;
2080   }
GetRows()2081   int GetRows()
2082   {
2083     return rows;
2084   }
GetProgressCountPtr()2085   int *GetProgressCountPtr()
2086   {
2087     return &ProgressCount;
2088   }
SetLastProgressCount(int last)2089   void SetLastProgressCount(int last)
2090   {
2091     LastProgressCount = 0;
2092   }
GetProgressCount()2093   int GetProgressCount()
2094   {
2095     return ProgressCount;
2096   }
GetLastProgressCount()2097   int GetLastProgressCount()
2098   {
2099     return LastProgressCount;
2100   }
2101 };
2102 
2103 class WfsKey
2104 {
2105 // a WFS Keyword
2106 private:
2107   wxString Keyword;
2108   WfsKey *Next;
2109 public:
WfsKey(wxString key)2110     WfsKey(wxString key)
2111   {
2112     Keyword = key;
2113     Next = NULL;
2114   }
~WfsKey()2115    ~WfsKey()
2116   {;
2117   }
GetKeyword()2118   wxString & GetKeyword()
2119   {
2120     return Keyword;
2121   }
SetNext(WfsKey * next)2122   void SetNext(WfsKey * next)
2123   {
2124     Next = next;
2125   }
GetNext()2126   WfsKey *GetNext()
2127   {
2128     return Next;
2129   }
2130 };
2131 
2132 class WfsKeywords
2133 {
2134 // an ancillary class storing the WFS Keywords dictionary
2135 private:
2136   WfsKey * First;
2137   WfsKey *Last;
2138   WfsKey **SortedArray;
2139   int MaxSorted;
2140 public:
WfsKeywords()2141     WfsKeywords()
2142   {
2143     First = NULL;
2144     Last = NULL;
2145     SortedArray = NULL;
2146     MaxSorted = 0;
2147   }
2148    ~WfsKeywords();
2149   void Add(const char *key);
2150   void Sort();
GetMaxSorted()2151   int GetMaxSorted()
2152   {
2153     return MaxSorted;
2154   }
2155   WfsKey *GetKey(int index);
2156 };
2157 
2158 class WfsDialog:public wxDialog
2159 {
2160 //
2161 // a dialog supporting data import from a WFS datasource
2162 //
2163 private:
2164   wxTimer * ProgressTimer;
2165   MyFrame *MainFrame;
2166   WfsParams Params;
2167   gaiaWFScatalogPtr Catalog;
2168   WfsKeywords *Keywords;
2169   wxGrid *WfsView;
2170   wxGauge *Progress;
2171   int CurrentEvtRow;
2172   int CurrentEvtColumn;
2173   gaiaWFSitemPtr FindLayerByName(wxString & name);
2174   void SelectLayer();
2175 public:
WfsDialog()2176     WfsDialog()
2177   {
2178     Catalog = NULL;
2179     WfsView = NULL;
2180     Keywords = NULL;
2181     ProgressTimer = NULL;
2182   }
~WfsDialog()2183   virtual ~ WfsDialog()
2184   {
2185     if (ProgressTimer)
2186       {
2187         ProgressTimer->Stop();
2188         delete ProgressTimer;
2189       }
2190     if (Catalog != NULL)
2191       destroy_wfs_catalog(Catalog);
2192     if (Keywords != NULL)
2193       delete Keywords;
2194   }
2195   void ResetProgress();
2196   void ProgressWait();
2197   void ProgressUpdate(int rows);
2198   bool Create(MyFrame * parent);
2199   void CreateControls();
2200   void OnPagingChanged(wxCommandEvent & event);
2201   void OnLeftClick(wxGridEvent & event);
2202   void OnRightClick(wxGridEvent & event);
2203   void OnKeyFilter(wxCommandEvent & event);
2204   void OnKeyReset(wxCommandEvent & event);
2205   void OnCatalog(wxCommandEvent & event);
2206   void OnReset(wxCommandEvent & event);
2207   void OnLoadFromWfs(wxCommandEvent & event);
2208   void OnQuit(wxCommandEvent & event);
2209   void OnCmdCopy(wxCommandEvent & event);
2210   void OnCmdSelectLayer(wxCommandEvent & event);
2211   void OnThreadFinished(wxCommandEvent & event);
2212   void OnRefreshTimer(wxTimerEvent & event);
2213 };
2214 
2215 class CheckGeometryDialog:public wxDialog
2216 {
2217 //
2218 // a dialog supporting Check Geometry Column
2219 //
2220 private:
2221   MyFrame * MainFrame;
2222   wxString Table;
2223   wxString Geometry;
2224 public:
CheckGeometryDialog()2225     CheckGeometryDialog()
2226   {;
2227   }
~CheckGeometryDialog()2228   virtual ~ CheckGeometryDialog()
2229   {;
2230   }
2231   bool Create(MyFrame * parent, wxString & table, wxString & geom);
2232   void CreateControls();
2233   void OnYes(wxCommandEvent & event);
2234   void OnNo(wxCommandEvent & event);
2235 };
2236 
2237 class SanitizeGeometryDialog:public wxDialog
2238 {
2239 //
2240 // a dialog supporting Sanitize Geometry Column
2241 //
2242 private:
2243   MyFrame * MainFrame;
2244   wxString TmpPrefix;
2245   wxString Table;
2246   wxString Geometry;
2247 public:
SanitizeGeometryDialog()2248     SanitizeGeometryDialog()
2249   {;
2250   }
~SanitizeGeometryDialog()2251   virtual ~ SanitizeGeometryDialog()
2252   {;
2253   }
2254   bool Create(MyFrame * parent, wxString & table, wxString & geom);
2255   void CreateControls();
GetTmpPrefix()2256   wxString & GetTmpPrefix()
2257   {
2258     return TmpPrefix;
2259   }
2260   void OnYes(wxCommandEvent & event);
2261   void OnNo(wxCommandEvent & event);
2262 };
2263 
2264 class MalformedGeomsDialog:public wxDialog
2265 {
2266 //
2267 // a dialog displaying a Malformed Geometries list
2268 //
2269 private:
2270   MyFrame * MainFrame;
2271   wxString Table;
2272   wxString Geometry;
2273   wxGrid *GridCtrl;
2274   MalformedGeomsList *List;
2275   int CurrentEvtRow;
2276   int CurrentEvtColumn;
2277 public:
MalformedGeomsDialog()2278     MalformedGeomsDialog()
2279   {
2280     List = NULL;
2281   }
2282   MalformedGeomsDialog(MyFrame * parent, wxString & table, wxString & column,
2283                        MalformedGeomsList * list);
2284   bool Create(MyFrame * parent, wxString & table, wxString & column,
2285               MalformedGeomsList * list);
~MalformedGeomsDialog()2286   virtual ~ MalformedGeomsDialog()
2287   {
2288     if (List)
2289       delete List;
2290   }
2291   void CreateControls();
2292   void OnClose(wxCommandEvent & event);
2293   void OnRepair(wxCommandEvent & event);
2294   void OnRightClick(wxGridEvent & event);
2295   void OnCmdClearSelection(wxCommandEvent & event);
2296   void OnCmdSelectAll(wxCommandEvent & event);
2297   void OnCmdSelectRow(wxCommandEvent & event);
2298   void OnCmdSelectColumn(wxCommandEvent & event);
2299   void OnCmdCopy(wxCommandEvent & event);
2300   void OnCmdBlob(wxCommandEvent & event);
2301 };
2302 
2303 class DbStatusDialog:public wxDialog
2304 {
2305 //
2306 // a dialog displaying DB Status infos
2307 //
2308 private:
2309   MyFrame * MainFrame;
2310   wxGrid *GridCtrl;
2311   wxStaticBitmap *Graph;
2312   int CurrentEvtRow;
2313   int CurrentEvtColumn;
2314   int *DynamicIds;
2315   int *DynamicModes;
2316   wxTimer *RefreshTimer;
2317   enum StatusModes
2318   {
2319     ModeNone,
2320     ModeStatusBoth,
2321     ModeStatusFirst,
2322     ModeStatusSecond,
2323     ModeStatusBothBytes,
2324     ModeStatusFirstBytes,
2325     ModeStatusSecondBytes,
2326     ModeDbStatusBoth,
2327     ModeDbStatusFirst,
2328     ModeDbStatusSecond,
2329     ModeDbStatusBothBytes,
2330     ModeDbStatusFirstBytes,
2331     ModeDbStatusSecondBytes
2332   };
2333 public:
2334     DbStatusDialog();
2335   bool Create(MyFrame * parent);
2336     virtual ~ DbStatusDialog();
2337   void CreateControls();
2338   void OnClose(wxCommandEvent & event);
2339   void OnReset(wxCommandEvent & event);
2340   void OnRightClick(wxGridEvent & event);
2341   void OnCmdClearSelection(wxCommandEvent & event);
2342   void OnCmdSelectAll(wxCommandEvent & event);
2343   void OnCmdSelectRow(wxCommandEvent & event);
2344   void OnCmdSelectColumn(wxCommandEvent & event);
2345   void OnCmdCopy(wxCommandEvent & event);
2346   void OnRefreshTimer(wxTimerEvent & event);
2347 };
2348 
2349 class MyFrame:public wxFrame
2350 {
2351 //
2352 // the main GUI frame
2353 //
2354 private:
2355   wxString AutoFDOmsg;
2356   bool SpatiaLiteMetadata;
2357   wxAuiManager Manager;         // the GUI manager
2358   wxString ConfigLayout;        // PERSISTENCY - the layout configuration
2359   int ConfigPaneX;              // PERSISTENCY - the main pane screen origin X
2360   int ConfigPaneY;              // PERSISTENCY - the main pane screen origin Y
2361   int ConfigPaneWidth;          // PERSISTENCY - the main pane screen width
2362   int ConfigPaneHeight;         // PERSISTENCY - the main pane screen height
2363   wxString ConfigDbPath;        // PERSISTENCY - the last opend DB path
2364   wxString ConfigDir;           // PERSISTENCY -  the last used directory
2365   MyTableTree *TableTree;       // the tables tree list
2366   MyQueryView *QueryView;       // the QueryResult panel
2367   MyResultSetView *RsView;      // the QueryResult panel
2368   bool HelpPane;                // is the HELP pane already opened ?
2369   sqlite3 *SqliteHandle;        // handle for SQLite DB
2370   wxString SqlitePath;          // path of SQLite DB
2371   void *InternalCache;          // pointer to the InternalCache supporting the DB connection
2372   wxString ExternalSqlitePath;  // path of external SQLite DB [LOAD/SAVE MEMORY database]
2373   bool MemoryDatabase;          // TRUE if we are currently working on the MEMORY database
2374   wxString LastDirectory;       // path of directory used
2375   int CharsetsLen;              // # charsets defined
2376   wxString *Charsets;           // table of charsets [code only]
2377   wxString *CharsetsNames;      // table of charsets [with description]
2378   wxString LocaleCharset;       // locale charset
2379   wxString DefaultCharset;      // default charset
2380   bool AskCharset;              // switch to set default charset for every output
2381   int TablesLen;                // # tables defined
2382   wxString *TableNames;         // array of tables
2383   wxBitmap *BtnCreateNew;       // button icon for DB CREATE&CONNECT
2384   wxBitmap *BtnConnect;         // button icon for DB CONNECT
2385   wxBitmap *BtnDisconnect;      // button icon for DB DISCONNECT
2386   wxBitmap *BtnMemDbLoad;       // button icon for MEMORY DB LOAD
2387   wxBitmap *BtnMemDbNew;        // button icon for MEMORY DB NEW
2388   wxBitmap *BtnMemDbClock;      // button icon for MEMORY DB CLOCK
2389   wxBitmap *BtnMemDbSave;       // button icon for MEMORY DB SAVE
2390   wxBitmap *BtnVacuum;          // button icon for DB VACUUM
2391   wxBitmap *BtnSqlScript;       // button icon for Execute SQL SCRIPT
2392   wxBitmap *BtnQueryComposer;   // button icon for Query/View Composer
2393   wxBitmap *BtnCharset;         // button icon for Default CHARSET
2394   wxBitmap *BtnLoadShp;         // button icon for LOAD SHP
2395   wxBitmap *BtnLoadTxt;         // button icon for LOAD TXT/CSV
2396   wxBitmap *BtnLoadDbf;         // button icon for LOAD DBF
2397   wxBitmap *BtnLoadXL;          // button icon for LOAD_XL
2398   wxBitmap *BtnVirtualShp;      // button icon for VIRTUAL SHP
2399   wxBitmap *BtnVirtualTxt;      // button icon for VIRTUAL TXT/CSV
2400   wxBitmap *BtnVirtualDbf;      // button icon for VIRTUAL DBF
2401   wxBitmap *BtnVirtualXL;       // button icon for VIRTUAL XL
2402   wxBitmap *BtnNetwork;         // button icon for BUILD NETWORK
2403   wxBitmap *BtnExif;            // button icon for EXIF LOAD
2404   wxBitmap *BtnLoadXml;         // button icon for XML LOAD
2405   wxBitmap *BtnSrids;           // button icon for SEARCH SRIDs
2406   wxBitmap *BtnHelp;            // button icon for HELP
2407   wxBitmap *BtnAbout;           // button icon for ABOUT
2408   wxBitmap *BtnExit;            // button icon for EXIT
2409   wxBitmap *BtnAttach;          // button icon for ATTACH
2410   wxBitmap *BtnSqlLog;          // button icon for SQL LOG
2411   wxBitmap *BtnDbStatus;        // button icon for DB STATUS
2412   wxBitmap *BtnCheckGeom;       // button icon for CheckGeom
2413   wxBitmap *BtnSaneGeom;        // button icon for SaneGeom
2414   wxBitmap *BtnWFS;             // button icon for WFS
2415   wxBitmap *BtnDXF;             // button icon for DXF
2416 // AutoSave timer
2417   int AutoSaveInterval;
2418   int LastTotalChanges;
2419   wxTimer *TimerAutoSave;
2420   gaiaGeomCollPtr GeomFromPoint(gaiaPointPtr pt, int srid);
2421   gaiaGeomCollPtr GeomFromLinestring(gaiaLinestringPtr ln, int srid);
2422   gaiaGeomCollPtr GeomFromPolygon(gaiaPolygonPtr pg, int srid);
2423   sqlite3_int64 LastSqlLogID;
2424   bool SqlLogEnabled;
2425   bool GetLwGeomVersion(char *buf);
2426   bool GetLibXml2Version(char *buf);
2427 public:
2428     MyFrame(const wxString & title, const wxPoint & pos, const wxSize & size);
2429     virtual ~ MyFrame();
2430 
2431   void UpdateStatusBar();
IsConnected()2432   bool IsConnected()
2433   {
2434     if (SqliteHandle)
2435       return true;
2436     else
2437       return false;
2438   }
2439 
2440   static void DoubleQuotedSql(char *str);
2441   static void CleanSqlString(char *sql);
2442 
2443   void InsertIntoLog(wxString & sql);
2444   void UpdateLog(void);
2445   void UpdateLog(wxString & error_msg);
2446   void UpdateAbortedLog(void);
2447   void EnableSqlLog();
2448 
2449   bool DoAttachDatabase(wxString & path);
2450   void GetNextAttachedSymbol(wxString & symbol);
2451 
2452   void CleanTxtTab(char *str);
2453   void CleanCsv(char *str);
2454   void CleanHtml(char *str);
2455   void DifQuote(char *str);
2456   void SylkQuote(char *str);
2457   void DecimalNumber(double num, char *str, char decimal_point);
2458   bool TestDateValue(char *date);
2459   bool TestDateTimeValue(char *datetime);
2460   bool TestTimeValue(char *time);
2461   int ComputeSpreadsheetDate(int yy, int mm, int dd);
2462   double ComputeSpreadsheetTime(int hh, int mm, int ss);
2463   int GetDateValue(char *date);
2464   double GetDateTimeValue(char *datetime);
2465   double GetTimeValue(char *time);
GetSqlitePath()2466   wxString & GetSqlitePath()
2467   {
2468     return SqlitePath;
2469   }
GetExternalSqlitePath()2470   wxString & GetExternalSqlitePath()
2471   {
2472     return ExternalSqlitePath;
2473   }
SetExternalSqlitePath(wxString & path)2474   void SetExternalSqlitePath(wxString & path)
2475   {
2476     ExternalSqlitePath = path;
2477   }
GetSqlite()2478   sqlite3 *GetSqlite()
2479   {
2480     return SqliteHandle;
2481   }
GetInternalCache()2482   void *GetInternalCache()
2483   {
2484     return InternalCache;
2485   }
CloseHelpPane()2486   void CloseHelpPane()
2487   {
2488     HelpPane = false;
2489   }
OpenHelpPane()2490   void OpenHelpPane()
2491   {
2492     HelpPane = true;
2493   }
2494 
2495   bool OpenDB();
2496   bool CreateDB();
2497   void CloseDB();
2498   void InitializeSpatialMetadata();
2499   void AutoFDOStart();
2500   void AutoFDOStop();
2501   void InitTableTree();
2502   void LoadHistory();
2503   bool HasHistory();
2504   void ListAttached();
2505   void InitTableTree(wxString & dbAlias, wxString & path);
2506   void ClearTableTree();
2507   int GetMetaDataType();
2508   bool HasViewsMetadata();
2509   bool HasVirtsMetadata();
2510   bool HasViewsMetadata(wxString & dbAlias);
2511   bool HasVirtsMetadata(wxString & dbAlias);
2512   void GetTableColumns(wxString & tableName, MyTableInfo * list);
2513   void GetTableIndices(wxString & tableName, MyTableInfo * list);
2514   void GetTableTriggers(wxString & tableName, MyTableInfo * list);
2515   void GetViewColumns(wxString & viewName, MyViewInfo * list);
2516   void GetViewTriggers(wxString & viewName, MyViewInfo * list);
2517   void GetIndexFields(wxString & indexName, wxTreeItemId & node);
2518   void GetPrimaryKeyFields(wxString & indexName, wxTreeItemId & node);
2519   void GetForeignKeys(wxString & tableName, wxTreeItemId & node);
2520   void GetTableColumns(wxString & dbAlias, wxString & tableName,
2521                        MyTableInfo * list);
2522   void GetTableIndices(wxString & dbAlias, wxString & tableName,
2523                        MyTableInfo * list);
2524   void GetTableTriggers(wxString & dbAlias, wxString & tableName,
2525                         MyTableInfo * list);
2526   void GetViewColumns(wxString & dbAlias, wxString & viewName,
2527                       MyViewInfo * list);
2528   void GetViewTriggers(wxString & dbAlias, wxString & viewName,
2529                        MyViewInfo * list);
2530   void GetIndexFields(wxString & dbAlias, wxString & indexName,
2531                       wxTreeItemId & node);
2532   void GetPrimaryKeyFields(wxString & dbAlias, wxString & indexName,
2533                            wxTreeItemId & node);
2534   void GetForeignKeys(wxString & dbAlias, wxString & tableName,
2535                       wxTreeItemId & node);
2536   bool ExistsTopologyMaster();
2537   bool ExistsTopologyMaster(wxString & dbAlias);
2538   void GetTopologyColumns(wxString * list);
2539   void GetTopologyColumns(wxString & dbAlias, wxString * list);
2540   void CheckIfExists(const char *name, bool * table, bool * view);
2541   void CheckIfExists(wxString & dbAlias, const char *name, bool * table,
2542                      bool * view);
2543   void ElementaryGeoms(wxString & inTable, wxString & geometry,
2544                        wxString & outTable, wxString & pKey, wxString & multiID,
2545                        wxString & type, int *srid, wxString & coordDims,
2546                        bool * spIdx);
2547   bool DoElementaryGeometries(wxString & inTable, wxString & geometry,
2548                               wxString & outTable, wxString & pKey,
2549                               wxString & multiID, wxString & type, int srid,
2550                               wxString & coordDims, bool spIdx);
EditTable(wxString & sql,int * primaryKeys,int * blobCols,wxString & table)2551   void EditTable(wxString & sql, int *primaryKeys, int *blobCols,
2552                  wxString & table)
2553   {
2554     RsView->EditTable(sql, primaryKeys, blobCols, table);
2555   }
2556   bool IsSpatialIndex(wxString & tableName);
2557   bool IsSpatialIndex(wxString & dbAlias, wxString & tableName);
SetSql(wxString & sql,bool execute)2558   void SetSql(wxString & sql, bool execute)
2559   {
2560     QueryView->SetSql(sql, execute);
2561   }
2562   bool ExecuteSql(const char *sql, int rowNo);
2563   void Rollback();
2564   bool TableAlreadyExists(wxString & name);
2565   bool SridNotExists(int srid);
2566   bool CheckMetadata();
2567   bool CheckMetadata(wxString & dbAlias);
2568   void SaveConfig();
2569   void LoadConfig(wxString & externalPath);
GetCharsets()2570   wxString *GetCharsets()
2571   {
2572     return Charsets;
2573   }
GetCharsetsNames()2574   wxString *GetCharsetsNames()
2575   {
2576     return CharsetsNames;
2577   }
GetCharsetsLen()2578   int GetCharsetsLen()
2579   {
2580     return CharsetsLen;
2581   }
2582   gaiaDbfFieldPtr GetDbfField(gaiaDbfListPtr list, char *name);
2583   void OutputPrjFile(wxString & path, int srid);
2584   void LoadText(wxString & path, wxString & table, wxString & charset,
2585                 bool first_titles, const char decimal_separator,
2586                 const char separator, const char text_separator);
2587   void DumpTxtTab(wxString & path, wxString & table, wxString & charset);
2588   void DumpCsv(wxString & path, wxString & table, wxString & charset);
2589   void DumpHtml(wxString & path, wxString & table, wxString & dbPath,
2590                 wxString & charset);
2591   void DumpDif(wxString & path, wxString & table, wxString & charset,
2592                char decimal_point, bool date_time);
2593   void DumpSylk(wxString & path, wxString & table, wxString & charset,
2594                 bool date_time);
2595   void DumpKml(wxString & path, wxString & table, wxString & column,
2596                int precision, wxString & name, bool isNameConst,
2597                wxString & desc, bool isDescConst);
2598   void ExportResultSetAsTxtTab(wxString & path, wxString & sql,
2599                                wxString & charset);
2600   void ExportResultSetAsCsv(wxString & path, wxString & sql,
2601                             wxString & charset);
2602   void ExportResultSetAsHtml(wxString & path, wxString & sql, wxString & dbPath,
2603                              wxString & charset);
2604   bool ExportHtmlColorSqlSyntax(FILE * out, wxString & sql, char *out_cs);
2605   void ExportResultSetAsShp(wxString & path, wxString & sql,
2606                             wxString & charset);
2607   void ExportResultSetAsDif(wxString & path, wxString & sql,
2608                             wxString & charset, char decimal_point,
2609                             bool date_time);
2610   void ExportResultSetAsSylk(wxString & path, wxString & sql,
2611                              wxString & charset, bool date_time);
2612   void ExportResultSetAsDbf(wxString & path, wxString & sql,
2613                             wxString & charset);
2614   void GetHelp(wxString & html);
2615   wxString *GetColumnNames(wxString & table, int *columns);
SetLastDirectory(wxString & path)2616   void SetLastDirectory(wxString & path)
2617   {
2618     LastDirectory = path;
2619   }
GetLastDirectory()2620   wxString & GetLastDirectory()
2621   {
2622     return LastDirectory;
2623   }
GetLocaleCharset()2624   wxString & GetLocaleCharset()
2625   {
2626     return LocaleCharset;
2627   }
GetDefaultCharset()2628   wxString & GetDefaultCharset()
2629   {
2630     return DefaultCharset;
2631   }
2632   wxString & GetCharsetName(wxString & charset);
2633   int GetCharsetIndex(wxString & charset);
IsSetAskCharset()2634   bool IsSetAskCharset()
2635   {
2636     return AskCharset;
2637   }
2638   char *ReadSqlLine(FILE * fl, int *len, int *eof);
GetQueryView()2639   MyQueryView *GetQueryView()
2640   {
2641     return QueryView;
2642   }
GetRsView()2643   MyResultSetView *GetRsView()
2644   {
2645     return RsView;
2646   }
2647   wxString *GetTables(int *cnt);
2648   void BuildNetwork(wxString & table, wxString & from, wxString & to,
2649                     wxString & geometry, wxString & name, bool cost_length,
2650                     wxString & cost, bool bidirectional, bool one_way,
2651                     wxString & one_way_from_to, wxString & one_way_to_from,
2652                     bool aStarSupported);
2653   bool CreateNetwork(class Network * net, wxString & table, wxString & from,
2654                      wxString & to, wxString & geometry, wxString & name,
2655                      bool aStarSupported, double aStarCoeff);
2656   void ImportExifPhotos(wxString & path, bool folder, bool metadata,
2657                         bool gps_only);
2658   void ImportXmlDocuments(wxString & path, bool folder, wxString & suffix,
2659                           wxString & table, wxString & pkName,
2660                           wxString & xmlColumn, wxString & inPathColumn,
2661                           wxString & schemaColumn, wxString & parseErrColumn,
2662                           wxString & validateErrColumn, int compressed,
2663                           const char *schemaURI, bool isInternaleSchemaUri);
2664   void ImportDXFfiles(wxString & path, bool folder, wxString & prefix,
2665                       wxString & layer, int srid, bool force2d, bool force3d,
2666                       bool mixed, bool linked, bool unlinked, bool append);
2667   void OutputNetNode(unsigned char *auxbuf, int *size, int ind, bool node_code,
2668                      int max_node_length, class NetNode * pN, int endian_arch,
2669                      bool aStarSupported);
2670   bool CheckExifTables();
2671   int ExifLoadDir(wxString & path, bool gps_only, bool metadata);
2672   int ExifLoadFile(wxString & path, bool gps_only, bool metadata);
2673   bool UpdateExifTables(unsigned char *blob, int sz,
2674                         gaiaExifTagListPtr tag_list, bool metadata,
2675                         wxString & path);
2676   bool IsExifGps(gaiaExifTagListPtr tag_list);
2677   int DxfLoadDir(wxString & path, wxString & prefix, wxString & layer, int srid,
2678                  bool force2d, bool force3d, bool mixed, bool linked,
2679                  bool unlinked, bool append, int *failed);
2680   int DxfLoadFile(wxString & path, wxString & prefix, wxString & layer,
2681                   int srid, bool force2d, bool force3d, bool mixed, bool linked,
2682                   bool unlinked, bool append, int *failed);
2683   bool CheckOrCreateXmlTable(wxString & table, wxString & pkName,
2684                              wxString & xmlColumn, wxString & inPathColumn,
2685                              wxString & schemaUriColumn,
2686                              wxString & parseErrColumn,
2687                              wxString & validateErrColumn);
2688   bool IsValidSuffix(const char *fileName, wxString & suffix);
2689   int XmlDocumentLoadDir(wxString & path, wxString & suffix, int compressed,
2690                          const char *schemaURI, bool isInternalSchemaUri,
2691                          wxString & inPathColumn, wxString & schemaUriColumn,
2692                          wxString & parseErrColumn,
2693                          wxString & validateErrColumn, sqlite3_stmt * stmt,
2694                          int *failed);
2695   int XmlDocumentLoadFile(wxString & path, int compressed,
2696                           const char *schemaURI, bool isInternalSchemaUri,
2697                           wxString & inPathColumn, wxString & parseErrColumn,
2698                           wxString & validateErrColumn,
2699                           wxString & schemaUriColumn, sqlite3_stmt * stmt,
2700                           int *failed);
2701   bool InsertIntoXmlTable(sqlite3_stmt * stmt, char *blob, int sz,
2702                           wxString & inPathColumn, wxString & path,
2703                           wxString & schemaUriColumn, const char *schemaUri,
2704                           wxString & parseErrColumn, const char *parseError,
2705                           wxString & validateErrColumn,
2706                           const char *validateError);
2707   void GetMake(gaiaExifTagListPtr tag_list, wxString & str, bool * ok);
2708   void GetModel(gaiaExifTagListPtr tag_list, wxString & str, bool * ok);
2709   void GetGpsTimestamp(gaiaExifTagListPtr tag_list, wxString & str, bool * ok);
2710   void GetDate(gaiaExifTagListPtr tag_list, wxString & str, bool * ok);
2711   double GetGpsDirection(gaiaExifTagListPtr tag_list, bool * ok);
2712   void GetGpsSatellites(gaiaExifTagListPtr tag_list, wxString & str, bool * ok);
2713   void GetGpsCoords(gaiaExifTagListPtr tag_list, double *longitude,
2714                     double *latitude, bool * ok);
2715   sqlite3_int64 GetPixelX(gaiaExifTagListPtr tag_list, bool * ok);
2716   sqlite3_int64 GetPixelY(gaiaExifTagListPtr tag_list, bool * ok);
2717 
2718   bool MemoryDbSave();
2719   void LastDitchMemoryDbSave();
2720   void QueryViewComposer();
2721   MalformedGeomsList *FindMalformedGeoms(wxString & table, wxString & geom,
2722                                          bool allowRepair);
2723   void PreRepairPolygons(wxString & table, wxString & geom, int *count);
2724   void RepairPolygons(wxString & table, wxString & geom, int *count);
2725 
2726   bool IsPrimaryKey(wxString & table, wxString & column);
2727   void DbPagesCount(int *total, int *frees);
2728 
2729 
2730   int TestDotCommand(const char *stmt);
2731   bool IsDotCommandLoadShp(const char *stmt, char *path, char *table,
2732                            char *charset, char *column, int *srid,
2733                            bool * coerce2D, bool * compressed);
2734   bool IsDotCommandLoadDbf(const char *stmt, char *path, char *table,
2735                            char *charset);
2736   bool IsDotCommandLoadXL(const char *stmt, char *path, char *table,
2737                           int *worksheetIndex, int *firstTitle);
2738   bool IsDotCommandDumpShp(const char *stmt, char *table,
2739                            char *column, char *path, char *charset, char *type);
2740   bool IsViewGeometry(wxString & table, wxString & column);
2741 
2742   void OnQuit(wxCommandEvent & event);
2743   void OnAbout(wxCommandEvent & event);
2744   void OnConnect(wxCommandEvent & event);
2745   void OnCreateNew(wxCommandEvent & event);
2746   void OnDisconnect(wxCommandEvent & event);
2747   void OnMemoryDbLoad(wxCommandEvent & event);
2748   void OnMemoryDbNew(wxCommandEvent & event);
2749   void OnMemoryDbClock(wxCommandEvent & event);
2750   void OnMemoryDbSave(wxCommandEvent & event);
2751   void OnVacuum(wxCommandEvent & event);
2752   void OnSqlScript(wxCommandEvent & event);
2753   void OnQueryViewComposer(wxCommandEvent & event);
2754   void OnCharset(wxCommandEvent & event);
2755   void OnLoadShp(wxCommandEvent & event);
2756   void OnLoadTxt(wxCommandEvent & event);
2757   void OnLoadDbf(wxCommandEvent & event);
2758   void OnLoadXL(wxCommandEvent & event);
2759   void OnVirtualShp(wxCommandEvent & event);
2760   void OnVirtualTxt(wxCommandEvent & event);
2761   void OnVirtualDbf(wxCommandEvent & event);
2762   void OnVirtualXL(wxCommandEvent & event);
2763   void OnNetwork(wxCommandEvent & event);
2764   void OnImportExifPhotos(wxCommandEvent & event);
2765   void OnImportXmlDocuments(wxCommandEvent & event);
2766   void OnImportWFS(wxCommandEvent & event);
2767   void OnImportDXF(wxCommandEvent & event);
2768   void OnSrids(wxCommandEvent & event);
2769   void OnAttachDatabase(wxCommandEvent & event);
2770   void OnSqlLog(wxCommandEvent & event);
2771   void OnDbStatus(wxCommandEvent & event);
2772   void OnCheckGeometries(wxCommandEvent & event);
2773   void OnSanitizeGeometries(wxCommandEvent & event);
2774   void OnHelp(wxCommandEvent & event);
2775   void OnMouseMove(wxMouseEvent & event);
2776   void OnTimerAutoSave(wxTimerEvent & event);
2777 };
2778 
2779 class HelpDialog:public wxDialog
2780 {
2781 //
2782 // the help dialog
2783 //
2784 private:
2785   MyFrame * MainFrame;
2786 public:
HelpDialog()2787   HelpDialog()
2788   {
2789     MainFrame = NULL;
2790   }
HelpDialog(MyFrame * parent)2791   HelpDialog(MyFrame * parent)
2792   {
2793     Create(parent);
2794   }
2795   bool Create(MyFrame * parent);
~HelpDialog()2796   virtual ~ HelpDialog()
2797   {;
2798   }
2799   void CreateControls();
2800   void OnClose(wxCloseEvent & event);
2801   void OnSize(wxSizeEvent & event);
2802 };
2803 
2804 class SearchSridDialog:public wxDialog
2805 {
2806 //
2807 // a dialog preparing a Search SRID by name
2808 //
2809 private:
2810   MyFrame * MainFrame;
2811   wxString String;              // search string [name]
2812   int Srid;                     // search id [srid]
2813   bool SearchBySrid;
2814 public:
SearchSridDialog()2815     SearchSridDialog()
2816   {;
2817   }
2818   SearchSridDialog(MyFrame * parent);
2819   bool Create(MyFrame * parent);
~SearchSridDialog()2820   virtual ~ SearchSridDialog()
2821   {;
2822   }
2823   void CreateControls();
GetString()2824   wxString & GetString()
2825   {
2826     return String;
2827   }
GetSrid()2828   int GetSrid()
2829   {
2830     return Srid;
2831   }
IsSearchBySrid()2832   bool IsSearchBySrid()
2833   {
2834     return SearchBySrid;
2835   }
2836   void OnOk(wxCommandEvent & event);
2837   void OnSearchBySrid(wxCommandEvent & event);
2838 };
2839 
2840 class SetSridDialog:public wxDialog
2841 {
2842 //
2843 // a dialog preparing a SET SRID
2844 //
2845 private:
2846   MyFrame * MainFrame;
2847   wxString Table;               // the table's name
2848   wxString Column;              // the column's name to be recovered
2849   int OldSrid;                  // SRID to substitute
2850   int Srid;                     // required SRID
2851 public:
SetSridDialog()2852     SetSridDialog()
2853   {;
2854   }
2855   SetSridDialog(MyFrame * parent, wxString & table, wxString & column);
2856   bool Create(MyFrame * parent, wxString & table, wxString & column);
~SetSridDialog()2857   virtual ~ SetSridDialog()
2858   {;
2859   }
2860   void CreateControls();
GetOldSrid()2861   int GetOldSrid()
2862   {
2863     return OldSrid;
2864   }
GetSrid()2865   int GetSrid()
2866   {
2867     return Srid;
2868   }
2869   void OnOk(wxCommandEvent & event);
2870 };
2871 
2872 class RecoverDialog:public wxDialog
2873 {
2874 //
2875 // a dialog preparing a RECOVER GEOMETRY
2876 //
2877 private:
2878   MyFrame * MainFrame;
2879   wxString Table;               // the table's name
2880   wxString Column;              // the column's name to be recovered
2881   int Srid;                     // required SRID
2882   wxString Type;                // required Geometry Type
2883   wxString Dimension;           // required CoordDimension
2884 public:
RecoverDialog()2885     RecoverDialog()
2886   {;
2887   }
2888   RecoverDialog(MyFrame * parent, wxString & table, wxString & column);
2889   bool Create(MyFrame * parent, wxString & table, wxString & column);
~RecoverDialog()2890   virtual ~ RecoverDialog()
2891   {;
2892   }
2893   void CreateControls();
GetType()2894   wxString & GetType()
2895   {
2896     return Type;
2897   }
GetDimension()2898   wxString & GetDimension()
2899   {
2900     return Dimension;
2901   }
GetSrid()2902   int GetSrid()
2903   {
2904     return Srid;
2905   }
2906   void OnOk(wxCommandEvent & event);
2907 };
2908 
2909 class ElementaryGeomsDialog:public wxDialog
2910 {
2911 //
2912 // a dialog asking ElementaryGeoms args
2913 //
2914 private:
2915   MyFrame * MainFrame;
2916   wxString InTable;
2917   wxString Geometry;
2918   wxString OutTable;
2919   wxString PrimaryKey;
2920   wxString MultiID;
2921   wxString Type;
2922   int Srid;
2923   wxString CoordDims;
2924   bool SpatialIndex;
2925 public:
ElementaryGeomsDialog()2926     ElementaryGeomsDialog()
2927   {;
2928   }
2929   ElementaryGeomsDialog(MyFrame * parent, wxString & table, wxString & column);
2930   bool Create(MyFrame * parent, wxString & table, wxString & column);
~ElementaryGeomsDialog()2931   virtual ~ ElementaryGeomsDialog()
2932   {;
2933   }
GetOutTable()2934   wxString & GetOutTable()
2935   {
2936     return OutTable;
2937   }
GetPrimaryKey()2938   wxString & GetPrimaryKey()
2939   {
2940     return PrimaryKey;
2941   }
GetMultiID()2942   wxString & GetMultiID()
2943   {
2944     return MultiID;
2945   }
GetType()2946   wxString & GetType()
2947   {
2948     return Type;
2949   }
GetSrid()2950   int GetSrid()
2951   {
2952     return Srid;
2953   }
GetCoordDims()2954   wxString & GetCoordDims()
2955   {
2956     return CoordDims;
2957   }
IsSpatialIndex()2958   bool IsSpatialIndex()
2959   {
2960     return SpatialIndex;
2961   }
2962   void CreateControls();
2963   void OnOk(wxCommandEvent & event);
2964 };
2965 
2966 class ColumnStatsDialog:public wxDialog
2967 {
2968 //
2969 // a dialog showing Column Stats
2970 //
2971 private:
2972   MyFrame * MainFrame;
2973   wxString Table;               // the table's name
2974   wxString Column;              // the column's name
2975   int NullValues;
2976   int TextValues;
2977   int IntegerValues;
2978   int RealValues;
2979   int BlobValues;
2980   double Min;
2981   double Max;
2982   double Avg;
2983   double StdDevPop;
2984   double StdDevSamp;
2985   double VarPop;
2986   double VarSamp;
2987   int DistinctValues;
2988   void CleanDecimals(char *number);
2989 public:
ColumnStatsDialog()2990     ColumnStatsDialog()
2991   {;
2992   }
2993   bool Create(MyFrame * parent, wxString & table, wxString & column,
2994               int null_count, int text_count, int integer_count, int real_count,
2995               int blob_count, double min, double max, double avg,
2996               double stddev_pop, double stddev_samp, double var_pop,
2997               double var_samp, int distinct_values);
~ColumnStatsDialog()2998   virtual ~ ColumnStatsDialog()
2999   {;
3000   }
3001   void CreateControls();
3002   void OnShowChart(wxCommandEvent & event);
3003   void OnExit(wxCommandEvent & event);
3004 };
3005 
3006 class MyChartIntervalClass
3007 {
3008 // a Chart interval class
3009 private:
3010   double Min;
3011   double Max;
3012   int Count;
3013 public:
MyChartIntervalClass()3014     MyChartIntervalClass()
3015   {;
3016   }
~MyChartIntervalClass()3017    ~MyChartIntervalClass()
3018   {;
3019   }
Create(double min,double max)3020   void Create(double min, double max)
3021   {
3022     Min = min;
3023     Max = max;
3024     Count = 0;
3025   }
GetMin()3026   double GetMin()
3027   {
3028     return Min;
3029   }
GetMax()3030   double GetMax()
3031   {
3032     return Max;
3033   }
Add()3034   void Add()
3035   {
3036     Count++;
3037   }
GetCount()3038   int GetCount()
3039   {
3040     return Count;
3041   }
3042 };
3043 
3044 class MyChartUniqueClass
3045 {
3046 // a Chart unique-value class
3047 private:
3048   wxString Value;
3049   int Count;
3050   MyChartUniqueClass *Next;
3051 public:
MyChartUniqueClass(wxString & value,int count)3052     MyChartUniqueClass(wxString & value, int count)
3053   {
3054     Value = value;
3055     Count = count;
3056     Next = NULL;
3057   }
~MyChartUniqueClass()3058    ~MyChartUniqueClass()
3059   {;
3060   }
GetValue()3061   wxString & GetValue()
3062   {
3063     return Value;
3064   }
GetCount()3065   int GetCount()
3066   {
3067     return Count;
3068   }
SetNext(MyChartUniqueClass * p)3069   void SetNext(MyChartUniqueClass * p)
3070   {
3071     Next = p;
3072   }
GetNext()3073   MyChartUniqueClass *GetNext()
3074   {
3075     return Next;
3076   }
3077 };
3078 
3079 class MyChartData
3080 {
3081 // a container storing Chart data classes
3082 private:
3083   bool Initialized;
3084   MyChartIntervalClass *Array;
3085   double Min;
3086   double Max;
3087   int MaxFreq;
3088   int TotFreq;
3089   MyChartUniqueClass *First;
3090   MyChartUniqueClass *Last;
3091   int MaxClasses;
3092   int NumClasses;
3093   int OtherUniquesFreq;
3094   int OtherUniquesCount;
3095   bool Valid;
3096   bool ByIntervals;
3097 public:
3098     MyChartData();
3099    ~MyChartData();
3100   bool Create(int max_classes);
3101   bool Create(double min, double max, int classes);
3102   void Add(wxString & value, int count);
3103   void Add(double value);
GetFirst()3104   MyChartUniqueClass *GetFirst()
3105   {
3106     return First;
3107   }
GetMaxFreq()3108   int GetMaxFreq()
3109   {
3110     return MaxFreq;
3111   }
GetTotFreq()3112   int GetTotFreq()
3113   {
3114     return TotFreq;
3115   }
GetNumClasses()3116   int GetNumClasses()
3117   {
3118     return NumClasses;
3119   }
GetOtherUniquesFreq()3120   int GetOtherUniquesFreq()
3121   {
3122     return OtherUniquesFreq;
3123   }
GetOtherUniquesCount()3124   int GetOtherUniquesCount()
3125   {
3126     return OtherUniquesCount;
3127   }
3128   MyChartIntervalClass *GetClass(int idx);
SetValid()3129   void SetValid()
3130   {
3131     Valid = true;
3132   }
IsValid()3133   bool IsValid()
3134   {
3135     return Valid;
3136   }
3137   void CleanData();
3138   bool Check(bool by_intervals, int classes);
3139 };
3140 
3141 class MyChartScaleLabel
3142 {
3143 // a Chart Scale label
3144 private:
3145   wxString Label;
3146   double Position;
3147   MyChartScaleLabel *Next;
3148 public:
MyChartScaleLabel(wxString & label,double pos)3149     MyChartScaleLabel(wxString & label, double pos)
3150   {
3151     Label = label;
3152     Position = pos;
3153     Next = NULL;
3154   }
~MyChartScaleLabel()3155    ~MyChartScaleLabel()
3156   {;
3157   }
GetLabel()3158   wxString & GetLabel()
3159   {
3160     return Label;
3161   }
GetPosition()3162   double GetPosition()
3163   {
3164     return Position;
3165   }
SetNext(MyChartScaleLabel * p)3166   void SetNext(MyChartScaleLabel * p)
3167   {
3168     Next = p;
3169   }
GetNext()3170   MyChartScaleLabel *GetNext()
3171   {
3172     return Next;
3173   }
3174 };
3175 
3176 class MyPieChartLabel
3177 {
3178 // a PieChart label
3179 private:
3180   wxString Label;
3181   double X;
3182   double Y;
3183   MyPieChartLabel *Next;
3184 public:
MyPieChartLabel(wxString & label,double x,double y)3185     MyPieChartLabel(wxString & label, double x, double y)
3186   {
3187     Label = label;
3188     X = x;
3189     Y = y;
3190     Next = NULL;
3191   }
~MyPieChartLabel()3192    ~MyPieChartLabel()
3193   {;
3194   }
GetLabel()3195   wxString & GetLabel()
3196   {
3197     return Label;
3198   }
GetX()3199   double GetX()
3200   {
3201     return X;
3202   }
GetY()3203   double GetY()
3204   {
3205     return Y;
3206   }
SetNext(MyPieChartLabel * p)3207   void SetNext(MyPieChartLabel * p)
3208   {
3209     Next = p;
3210   }
GetNext()3211   MyPieChartLabel *GetNext()
3212   {
3213     return Next;
3214   }
3215 };
3216 
3217 class MyChartScaleLabels
3218 {
3219 // a container storing Chart Scale labels
3220 private:
3221   MyChartScaleLabel * First;
3222   MyChartScaleLabel *Last;
3223 public:
MyChartScaleLabels()3224     MyChartScaleLabels()
3225   {
3226     First = NULL;
3227     Last = NULL;
3228   }
3229    ~MyChartScaleLabels();
3230   void Initialize(double span, int max_freq);
3231   void Add(const char *label, double pos);
GetFirst()3232   MyChartScaleLabel *GetFirst()
3233   {
3234     return First;
3235   }
3236 };
3237 
3238 class MyPieChartLabels
3239 {
3240 // a container storing PieChart labels
3241 private:
3242   MyPieChartLabel * First;
3243   MyPieChartLabel *Last;
3244   MyPieChartLabel **LeftLabels;
3245   int NumLeftLabels;
3246   MyPieChartLabel **RightLabels;
3247   int NumRightLabels;
3248 public:
3249     MyPieChartLabels();
3250    ~MyPieChartLabels();
3251   void Add(const char *label, double x, double y);
3252   void Sort(double cx);
GetNumLeftLabels()3253   int GetNumLeftLabels()
3254   {
3255     return NumLeftLabels;
3256   }
3257   MyPieChartLabel *GetLeftLabel(int idx);
GetNumRightLabels()3258   int GetNumRightLabels()
3259   {
3260     return NumRightLabels;
3261   }
3262   MyPieChartLabel *GetRightLabel(int idx);
3263 };
3264 
3265 class StatsChartDialog:public wxDialog
3266 {
3267 //
3268 // a dialog generating a Stat Chart
3269 //
3270 private:
3271   MyFrame * MainFrame;
3272   wxString Table;               // the table's name
3273   wxString Column;              // the column's name
3274   bool NumericData;
3275   double Min;
3276   double Max;
3277   wxRadioBox *TypeCtrl;
3278   wxRadioBox *SizeCtrl;
3279   wxRadioBox *ModeCtrl;
3280   wxSpinCtrl *ClassCtrl;
3281   wxStaticBitmap *ChartShow;
3282   bool Histogram;
3283   bool LineChart;
3284   bool PieChart;
3285   bool ByInterval;
3286   int Classes;
3287   MyChartData ChartData;
3288   wxString ExportPath;
3289   enum Targets
3290   {
3291     CHART_TARGET_IS_PREVIEW,
3292     CHART_TARGET_IS_COPY,
3293     CHART_TARGET_IS_PNG,
3294     CHART_TARGET_IS_SVG,
3295     CHART_TARGET_IS_PDF
3296   };
3297 public:
StatsChartDialog()3298     StatsChartDialog()
3299   {;
3300   }
3301   bool Create(ColumnStatsDialog * parent, MyFrame * granny, wxString & table,
3302               wxString & column, bool numeric, double min, double max);
~StatsChartDialog()3303   virtual ~ StatsChartDialog()
3304   {;
3305   }
3306   void CreateControls();
3307   void CleanDecimals(char *number);
3308   void ReloadData();
3309   void UpdatePreview();
3310   void PrepareDataByInterval(int classes);
3311   void PrepareDataByUniqueValue(int classes);
3312   void DoIntervalHistogram(int hsize, int vsize, int target, int font_size);
3313   void DoIntervalLineChart(int hsize, int vsize, int target, int font_size);
3314   void DoIntervalPieChart(int hsize, int vsize, int target, int font_size);
3315   void DoUniqueHistogram(int hsize, int vsize, int target, int font_size);
3316   void DoUniqueLineChart(int hsize, int vsize, int target, int font_size);
3317   void DoUniquePieChart(int hsize, int vsize, int target, int font_size);
3318   void OnChartTypeChanged(wxCommandEvent & event);
3319   void OnChartModeChanged(wxCommandEvent & event);
3320   void OnChartClassesChanged(wxCommandEvent & event);
3321   void OnChartCopy(wxCommandEvent & event);
3322   void OnChartPng(wxCommandEvent & event);
3323   void OnChartSvg(wxCommandEvent & event);
3324   void OnChartPdf(wxCommandEvent & event);
3325   void OnExit(wxCommandEvent & event);
3326 };
3327 
3328 class MapPreviewDialog:public wxDialog
3329 {
3330 //
3331 // a dialog generating a Map Preview
3332 //
3333 private:
3334   MyFrame * MainFrame;
3335   wxString Table;               // the table's name
3336   wxString Column;              // the column's name
3337   double MinX;
3338   double MinY;
3339   double MaxX;
3340   double MaxY;
3341   wxColour LineColor;
3342   wxColour FillColor;
3343   wxRadioBox *SizeCtrl;
3344   wxRadioBox *SymbolCtrl;
3345   wxRadioBox *FillCtrl;
3346   wxSpinCtrl *SymSizeCtrl;
3347   wxSpinCtrl *ThicknessCtrl;
3348   wxBitmapButton *LineColorCtrl;
3349   wxBitmapButton *FillColorCtrl;
3350   wxStaticBitmap *MapShow;
3351   wxString ExportPath;
3352   enum Targets
3353   {
3354     MAP_TARGET_IS_PREVIEW,
3355     MAP_TARGET_IS_COPY,
3356     MAP_TARGET_IS_PNG,
3357     MAP_TARGET_IS_SVG,
3358     MAP_TARGET_IS_PDF
3359   };
3360 public:
MapPreviewDialog()3361     MapPreviewDialog()
3362   {;
3363   }
3364   bool Create(MyFrame * parent, wxString & table, wxString & column,
3365               double minx, double mixy, double maxx, double maxy);
~MapPreviewDialog()3366   virtual ~ MapPreviewDialog()
3367   {;
3368   }
3369   void CreateControls();
3370   void UpdatePreview();
3371   void DoMap(int hsize, int vsize, int target);
3372   void GetButtonBitmap(wxColour & color, wxBitmap & bmp);
3373   void OnSizeChanged(wxCommandEvent & event);
3374   void OnSymbolTypeChanged(wxCommandEvent & event);
3375   void OnFillModeChanged(wxCommandEvent & event);
3376   void OnSymbolSizeChanged(wxCommandEvent & event);
3377   void OnLineThicknessChanged(wxCommandEvent & event);
3378   void OnLineColor(wxCommandEvent & event);
3379   void OnFillColor(wxCommandEvent & event);
3380   void OnMapCopy(wxCommandEvent & event);
3381   void OnMapPng(wxCommandEvent & event);
3382   void OnMapSvg(wxCommandEvent & event);
3383   void OnMapPdf(wxCommandEvent & event);
3384   void OnExit(wxCommandEvent & event);
3385 };
3386 
3387 class GisLayerAuthDialog:public wxDialog
3388 {
3389 //
3390 // a dialog to set GIS Layer auths
3391 //
3392 private:
3393   MyFrame * MainFrame;
3394   wxString Table;               // the table's name
3395   wxString Geometry;            // the geometry column's name
3396   bool ReadOnly;
3397   bool Hidden;
3398 public:
GisLayerAuthDialog()3399     GisLayerAuthDialog()
3400   {;
3401   }
3402   GisLayerAuthDialog(MyFrame * parent, wxString & table, wxString & geom,
3403                      bool rdOnly, bool hidden);
3404   bool Create(MyFrame * parent, wxString & table, wxString & geom, bool rdOnly,
3405               bool hidden);
~GisLayerAuthDialog()3406   virtual ~ GisLayerAuthDialog()
3407   {;
3408   }
3409   void CreateControls();
IsReadOnly()3410   bool IsReadOnly()
3411   {
3412     return ReadOnly;
3413   }
IsHidden()3414   bool IsHidden()
3415   {
3416     return Hidden;
3417   }
3418   void OnReadOnlyChanged(wxCommandEvent & event);
3419   void OnHiddenChanged(wxCommandEvent & event);
3420   void OnOk(wxCommandEvent & event);
3421 };
3422 
3423 class VirtualShpDialog:public wxDialog
3424 {
3425 //
3426 // a dialog preparing a CREATE VIRTUAL SHAPE
3427 //
3428 private:
3429   MyFrame * MainFrame;
3430   wxString Path;                // the SHP base path
3431   wxString Table;               // the table name
3432   wxString Default;             // the default charset
3433   wxString Charset;             // the SHP charset
3434   int Srid;                     // the SRID
3435 public:
VirtualShpDialog()3436     VirtualShpDialog()
3437   {;
3438   }
3439   VirtualShpDialog(MyFrame * parent, wxString & path, wxString & table,
3440                    wxString & defCs);
3441   bool Create(MyFrame * parent, wxString & path, wxString & table,
3442               wxString & defCs);
~VirtualShpDialog()3443   virtual ~ VirtualShpDialog()
3444   {;
3445   }
3446   void CreateControls();
GetTable()3447   wxString & GetTable()
3448   {
3449     return Table;
3450   }
GetCharset()3451   wxString & GetCharset()
3452   {
3453     return Charset;
3454   }
GetSrid()3455   int GetSrid()
3456   {
3457     return Srid;
3458   }
3459   void OnOk(wxCommandEvent & event);
3460 };
3461 
3462 class VirtualTxtDialog:public wxDialog
3463 {
3464 //
3465 // a dialog preparing a CREATE VIRTUAL TEXT
3466 //
3467 private:
3468   MyFrame * MainFrame;
3469   wxString Path;                // the CSV/TXT base path
3470   wxString Table;               // the table name
3471   wxString Default;             // the default charset
3472   wxString Charset;             // the CSV/TXT charset
3473   bool FirstLineTitles;         // TRUE if first line stores column titles
3474   char Separator;               // the character to be used as field separator
3475   char TextSeparator;           // the character to be used as text separator
3476   bool DecimalPointIsComma;     // TRUE if decimal separator is COMMA
3477 public:
VirtualTxtDialog()3478     VirtualTxtDialog()
3479   {;
3480   }
3481   VirtualTxtDialog(MyFrame * parent, wxString & path, wxString & table,
3482                    wxString & defCs);
3483   bool Create(MyFrame * parent, wxString & path, wxString & table,
3484               wxString & defCs);
~VirtualTxtDialog()3485   virtual ~ VirtualTxtDialog()
3486   {;
3487   }
3488   void CreateControls();
GetTable()3489   wxString & GetTable()
3490   {
3491     return Table;
3492   }
GetCharset()3493   wxString & GetCharset()
3494   {
3495     return Charset;
3496   }
IsFirstLineTitles()3497   bool IsFirstLineTitles()
3498   {
3499     return FirstLineTitles;
3500   }
GetSeparator()3501   char GetSeparator()
3502   {
3503     return Separator;
3504   }
GetTextSeparator()3505   char GetTextSeparator()
3506   {
3507     return TextSeparator;
3508   }
IsDecimalPointComma()3509   bool IsDecimalPointComma()
3510   {
3511     return DecimalPointIsComma;
3512   }
3513   void OnSeparator(wxCommandEvent & event);
3514   void OnDecimalSeparator(wxCommandEvent & event);
3515   void OnQuote(wxCommandEvent & event);
3516   void OnOk(wxCommandEvent & event);
3517 };
3518 
3519 class VirtualDbfDialog:public wxDialog
3520 {
3521 //
3522 // a dialog preparing a CREATE VIRTUAL DBF
3523 //
3524 private:
3525   MyFrame * MainFrame;
3526   wxString Path;                // the DBF path
3527   wxString Table;               // the table name
3528   wxString Default;             // the default charset
3529   wxString Charset;             // the DBF charset
3530 public:
VirtualDbfDialog()3531     VirtualDbfDialog()
3532   {;
3533   }
3534   VirtualDbfDialog(MyFrame * parent, wxString & path, wxString & table,
3535                    wxString & defCs);
3536   bool Create(MyFrame * parent, wxString & path, wxString & table,
3537               wxString & defCs);
~VirtualDbfDialog()3538   virtual ~ VirtualDbfDialog()
3539   {;
3540   }
3541   void CreateControls();
GetTable()3542   wxString & GetTable()
3543   {
3544     return Table;
3545   }
GetCharset()3546   wxString & GetCharset()
3547   {
3548     return Charset;
3549   }
3550   void OnOk(wxCommandEvent & event);
3551 };
3552 
3553 class LoadShpDialog:public wxDialog
3554 {
3555 //
3556 // a dialog preparing a LOAD SHAPE
3557 //
3558 private:
3559   MyFrame * MainFrame;
3560   wxString Path;                // the SHP base path
3561   wxString Table;               // the table's name to be created
3562   wxString Column;              // the column's name for Geometry
3563   wxString Default;             // the default charset
3564   wxString Charset;             // the SHP charset
3565   int Srid;                     // the SRID
3566   bool Coerce2D;                // coercing to 2D [x,y]
3567   bool Compressed;              // compressed geometries
3568   bool SpatialIndex;            // building the Spatial Index (or not)
3569   bool UserDefinedGType;        // mode: automatic / user defined Geometry Type
3570   wxString GeometryType;        // User Defined Geometry Type
3571   bool UserDefinedPKey;         // mode: automatic / user defined Primary Key
3572   wxString PKColumn;            // User Defined Primary Key
3573   int PKCount;                  // # Primary Key Columns
3574   wxString *PKFields;           // array of Primary Key Columns
3575   wxString *PKFieldsEx;         // array of Primary Key Columns (full detail)
3576 public:
LoadShpDialog()3577     LoadShpDialog()
3578   {;
3579   }
3580   LoadShpDialog(MyFrame * parent, wxString & path, wxString & table, int srid,
3581                 wxString & column, wxString & defCs);
3582   bool Create(MyFrame * parent, wxString & path, wxString & table, int srid,
3583               wxString & column, wxString & defCs);
3584   virtual ~ LoadShpDialog();
3585   void CreateControls();
GetTable()3586   wxString & GetTable()
3587   {
3588     return Table;
3589   }
GetColumn()3590   wxString & GetColumn()
3591   {
3592     return Column;
3593   }
GetCharset()3594   wxString & GetCharset()
3595   {
3596     return Charset;
3597   }
GetSrid()3598   int GetSrid()
3599   {
3600     return Srid;
3601   }
ApplyCoertion2D()3602   bool ApplyCoertion2D()
3603   {
3604     return Coerce2D;
3605   }
ApplyCompression()3606   bool ApplyCompression()
3607   {
3608     return Compressed;
3609   }
CreateSpatialIndex()3610   bool CreateSpatialIndex()
3611   {
3612     return SpatialIndex;
3613   }
IsUserDefinedGType()3614   bool IsUserDefinedGType()
3615   {
3616     return UserDefinedGType;
3617   }
GetGeometryType()3618   wxString & GetGeometryType()
3619   {
3620     return GeometryType;
3621   }
IsUserDefinedPKey()3622   bool IsUserDefinedPKey()
3623   {
3624     return UserDefinedPKey;
3625   }
GetPKColumn()3626   wxString & GetPKColumn()
3627   {
3628     return PKColumn;
3629   }
3630   void LoadPKFields();
3631   void OnOk(wxCommandEvent & event);
3632   void OnUserGType(wxCommandEvent & event);
3633   void OnUserPKey(wxCommandEvent & event);
3634 };
3635 
3636 class DumpPostGISDialog:public wxDialog
3637 {
3638 //
3639 // a dialog preparing a SQL DUMP for PostGIS
3640 //
3641 private:
3642   MyFrame * MainFrame;
3643   wxString SchemaName;          // the PostGIS target schema
3644   wxString TableName;           // the PostGIS table name
3645   bool Lowercase;               // column-names to lowercase
3646   bool CreateTable;             // creating (or not) the PostGIS table
3647   bool SpatialIndex;            // creating (or not) the PostGIS Spatial Index
3648 public:
DumpPostGISDialog()3649     DumpPostGISDialog()
3650   {;
3651   }
3652   DumpPostGISDialog(MyFrame * parent, wxString & table);
3653   bool Create(MyFrame * parent, wxString & table);
~DumpPostGISDialog()3654   virtual ~ DumpPostGISDialog()
3655   {;
3656   }
3657   void CreateControls();
GetSchemaName()3658   wxString & GetSchemaName()
3659   {
3660     return SchemaName;
3661   }
GetTableName()3662   wxString & GetTableName()
3663   {
3664     return TableName;
3665   }
IsLowercase()3666   bool IsLowercase()
3667   {
3668     return Lowercase;
3669   }
IsCreateTable()3670   bool IsCreateTable()
3671   {
3672     return CreateTable;
3673   }
IsSpatialIndex()3674   bool IsSpatialIndex()
3675   {
3676     return SpatialIndex;
3677   }
3678   void OnLowercase(wxCommandEvent & event);
3679   void OnCreateTable(wxCommandEvent & event);
3680   void OnSpatialIndex(wxCommandEvent & event);
3681   void OnOk(wxCommandEvent & event);
3682 };
3683 
3684 class DumpShpDialog:public wxDialog
3685 {
3686 //
3687 // a dialog preparing a DUMP SHAPE
3688 //
3689 private:
3690   MyFrame * MainFrame;
3691   wxString Path;                // the SHP base path
3692   wxString Table;               // the table's name to be created
3693   wxString Column;              // the column's name for Geometry
3694   wxString Default;             // the default charset
3695   wxString Charset;             // the SHP charset
3696 public:
DumpShpDialog()3697     DumpShpDialog()
3698   {;
3699   }
3700   DumpShpDialog(MyFrame * parent, wxString & path, wxString & table,
3701                 wxString & column, wxString & defCs);
3702   bool Create(MyFrame * parent, wxString & path, wxString & table,
3703               wxString & column, wxString & defCs);
~DumpShpDialog()3704   virtual ~ DumpShpDialog()
3705   {;
3706   }
3707   void CreateControls();
GetCharset()3708   wxString & GetCharset()
3709   {
3710     return Charset;
3711   }
3712   void OnOk(wxCommandEvent & event);
3713 };
3714 
3715 class LoadXLDialog:public wxDialog
3716 {
3717 //
3718 // a dialog preparing a LOAD XL
3719 //
3720 private:
3721   MyFrame * MainFrame;
3722   wxString Path;                // the XLS path
3723   wxString Table;               // the table name
3724   wxString *Worksheets;         // Worksheet array
3725   int WorksheetCount;           // array items
3726   int WorksheetIndex;           // selected Worksheet Index
3727   bool FirstLineTitles;         // first line contains column names
3728   bool Invalid;
3729   void GetWorksheets();
3730 public:
LoadXLDialog()3731     LoadXLDialog()
3732   {;
3733   }
3734   LoadXLDialog(MyFrame * parent, wxString & path, wxString & table);
3735   bool Create(MyFrame * parent, wxString & path, wxString & table);
~LoadXLDialog()3736   virtual ~ LoadXLDialog()
3737   {;
3738   }
3739   void CreateControls();
GetTable()3740   wxString & GetTable()
3741   {
3742     return Table;
3743   }
GetWorksheetIndex()3744   int GetWorksheetIndex()
3745   {
3746     return WorksheetIndex;
3747   }
IsFirstLineTitles()3748   bool IsFirstLineTitles()
3749   {
3750     return FirstLineTitles;
3751   }
3752   void OnOk(wxCommandEvent & event);
3753 };
3754 
3755 class VirtualXLDialog:public wxDialog
3756 {
3757 //
3758 // a dialog preparing a CREATE VIRTUAL XL
3759 //
3760 private:
3761   MyFrame * MainFrame;
3762   wxString Path;                // the XLS path
3763   wxString Table;               // the table name
3764   wxString *Worksheets;         // Worksheet array
3765   int WorksheetCount;           // array items
3766   int WorksheetIndex;           // selected Worksheet Index
3767   bool FirstLineTitles;         // first line contains column names
3768   bool Invalid;
3769   void GetWorksheets();
3770 public:
VirtualXLDialog()3771     VirtualXLDialog()
3772   {;
3773   }
3774   VirtualXLDialog(MyFrame * parent, wxString & path, wxString & table);
3775   bool Create(MyFrame * parent, wxString & path, wxString & table);
~VirtualXLDialog()3776   virtual ~ VirtualXLDialog()
3777   {;
3778   }
3779   void CreateControls();
GetTable()3780   wxString & GetTable()
3781   {
3782     return Table;
3783   }
GetWorksheetIndex()3784   int GetWorksheetIndex()
3785   {
3786     return WorksheetIndex;
3787   }
IsFirstLineTitles()3788   bool IsFirstLineTitles()
3789   {
3790     return FirstLineTitles;
3791   }
3792   void OnOk(wxCommandEvent & event);
3793 };
3794 
3795 class LoadTxtDialog:public wxDialog
3796 {
3797 //
3798 // a dialog preparing a LOAD TXT/CSV
3799 //
3800 private:
3801   MyFrame * MainFrame;
3802   wxString Path;                // the CSV/TXT base path
3803   wxString Table;               // the table name
3804   wxString Default;             // the default charset
3805   wxString Charset;             // the CSV/TXT charset
3806   bool FirstLineTitles;         // TRUE if first line stores column titles
3807   char Separator;               // the character to be used as field separator
3808   char TextSeparator;           // the character to be used as text separator
3809   bool DecimalPointIsComma;     // TRUE if decimal separator is COMMA
3810 public:
LoadTxtDialog()3811     LoadTxtDialog()
3812   {;
3813   }
3814   LoadTxtDialog(MyFrame * parent, wxString & path, wxString & table,
3815                 wxString & defCs);
3816   bool Create(MyFrame * parent, wxString & path, wxString & table,
3817               wxString & defCs);
~LoadTxtDialog()3818   virtual ~ LoadTxtDialog()
3819   {;
3820   }
3821   void CreateControls();
GetTable()3822   wxString & GetTable()
3823   {
3824     return Table;
3825   }
GetCharset()3826   wxString & GetCharset()
3827   {
3828     return Charset;
3829   }
IsFirstLineTitles()3830   bool IsFirstLineTitles()
3831   {
3832     return FirstLineTitles;
3833   }
GetSeparator()3834   char GetSeparator()
3835   {
3836     return Separator;
3837   }
GetTextSeparator()3838   char GetTextSeparator()
3839   {
3840     return TextSeparator;
3841   }
IsDecimalPointComma()3842   bool IsDecimalPointComma()
3843   {
3844     return DecimalPointIsComma;
3845   }
3846   void OnSeparator(wxCommandEvent & event);
3847   void OnDecimalSeparator(wxCommandEvent & event);
3848   void OnQuote(wxCommandEvent & event);
3849   void OnOk(wxCommandEvent & event);
3850 };
3851 
3852 class DumpTxtDialog:public wxDialog
3853 {
3854 //
3855 // a dialog preparing a DUMP generic text
3856 //
3857 private:
3858   MyFrame * MainFrame;
3859   wxString Path;                // the SHP base path
3860   wxString Default;             // the default charset
3861   wxString Charset;             // the target charset
3862 public:
DumpTxtDialog()3863     DumpTxtDialog()
3864   {;
3865   }
3866   DumpTxtDialog(MyFrame * parent, wxString & path, wxString & target,
3867                 wxString & defCs);
3868   bool Create(MyFrame * parent, wxString & path, wxString & target,
3869               wxString & defCs);
~DumpTxtDialog()3870   virtual ~ DumpTxtDialog()
3871   {;
3872   }
3873   void CreateControls();
GetCharset()3874   wxString & GetCharset()
3875   {
3876     return Charset;
3877   }
3878   void OnOk(wxCommandEvent & event);
3879 };
3880 
3881 class LoadDbfDialog:public wxDialog
3882 {
3883 //
3884 // a dialog preparing a LOAD DBF
3885 //
3886 private:
3887   MyFrame * MainFrame;
3888   wxString Path;                // the DBF base path
3889   wxString Table;               // the table name
3890   wxString Default;             // the default charset
3891   wxString Charset;             // the DBF charset
3892   bool UserDefinedPKey;         // mode: automatic / user defined Primary Key
3893   wxString PKColumn;            // User Defined Primary Key
3894   int PKCount;                  // # Primary Key Columns
3895   wxString *PKFields;           // array of Primary Key Columns
3896   wxString *PKFieldsEx;         // array of Primary Key Columns (full detail)
3897 public:
LoadDbfDialog()3898     LoadDbfDialog()
3899   {;
3900   }
3901   LoadDbfDialog(MyFrame * parent, wxString & path, wxString & table,
3902                 wxString & defCs);
3903   bool Create(MyFrame * parent, wxString & path, wxString & table,
3904               wxString & defCs);
3905   virtual ~ LoadDbfDialog();
3906   void CreateControls();
GetTable()3907   wxString & GetTable()
3908   {
3909     return Table;
3910   }
GetCharset()3911   wxString & GetCharset()
3912   {
3913     return Charset;
3914   }
IsUserDefinedPKey()3915   bool IsUserDefinedPKey()
3916   {
3917     return UserDefinedPKey;
3918   }
GetPKColumn()3919   wxString & GetPKColumn()
3920   {
3921     return PKColumn;
3922   }
3923   void LoadPKFields();
3924   void OnOk(wxCommandEvent & event);
3925   void OnUserPKey(wxCommandEvent & event);
3926 };
3927 
3928 class NetworkDialog:public wxDialog
3929 {
3930 //
3931 // a dialog preparing a BUILD NETWORK
3932 //
3933 private:
3934   MyFrame * MainFrame;
3935   wxString TableName;           // the table name
3936   wxString FromColumn;          // the NodeFrom column name
3937   wxString ToColumn;            // the NodeTo column name
3938   wxString GeomColumn;          // the Geometry column name
3939   bool GeomLength;              // Cost is Geometry Length
3940   wxString CostColumn;          // the Cost column name
3941   bool Bidirectional;           // Bidirectional arcs
3942   bool OneWays;                 // OneWays columns supported
3943   wxString OneWayToFrom;        // the OneWay To-From column
3944   wxString OneWayFromTo;        // the OneWay From-To column
3945   bool NameEnabled;             // Name column supported
3946   wxString NameColumn;          // the Name column name
3947   bool AStarSupported;          // A* algorithm supported
3948 public:
NetworkDialog()3949     NetworkDialog()
3950   {;
3951   }
3952   NetworkDialog(MyFrame * parent);
3953   bool Create(MyFrame * parent);
~NetworkDialog()3954   virtual ~ NetworkDialog()
3955   {;
3956   }
3957   void CreateControls();
GetTableName()3958   wxString & GetTableName()
3959   {
3960     return TableName;
3961   }
GetFromColumn()3962   wxString & GetFromColumn()
3963   {
3964     return FromColumn;
3965   }
GetToColumn()3966   wxString & GetToColumn()
3967   {
3968     return ToColumn;
3969   }
GetGeomColumn()3970   wxString & GetGeomColumn()
3971   {
3972     return GeomColumn;
3973   }
GetNameColumn()3974   wxString & GetNameColumn()
3975   {
3976     return NameColumn;
3977   }
IsGeomLength()3978   bool IsGeomLength()
3979   {
3980     return GeomLength;
3981   }
GetCostColumn()3982   wxString & GetCostColumn()
3983   {
3984     return CostColumn;
3985   }
IsBidirectional()3986   bool IsBidirectional()
3987   {
3988     return Bidirectional;
3989   }
IsOneWays()3990   bool IsOneWays()
3991   {
3992     return OneWays;
3993   }
GetOneWayFromTo()3994   wxString & GetOneWayFromTo()
3995   {
3996     return OneWayFromTo;
3997   }
GetOneWayToFrom()3998   wxString & GetOneWayToFrom()
3999   {
4000     return OneWayToFrom;
4001   }
IsNameEnabled()4002   bool IsNameEnabled()
4003   {
4004     return NameEnabled;
4005   }
IsAStarSupported()4006   bool IsAStarSupported()
4007   {
4008     return AStarSupported;
4009   }
4010   void OnTable(wxCommandEvent & event);
4011   void OnDirection(wxCommandEvent & event);
4012   void OnCost(wxCommandEvent & event);
4013   void OnOneWay(wxCommandEvent & event);
4014   void OnNameEnabled(wxCommandEvent & event);
4015   void OnOk(wxCommandEvent & event);
4016 };
4017 
4018 class ExifDialog:public wxDialog
4019 {
4020 //
4021 // a dialog preparing an IMPORT EXIF PHOTOS
4022 //
4023 private:
4024   MyFrame * MainFrame;
4025   wxString ImgPath;             // the file name
4026   wxString DirPath;             // the folder path
4027   bool Folder;                  // import a whole folder
4028   bool Metadata;                // feed Metadata tables
4029   bool GpsOnly;                 // import only if GpsExif present
4030 public:
ExifDialog()4031     ExifDialog()
4032   {;
4033   }
4034   ExifDialog(MyFrame * parent, wxString & dir_path, wxString & img_path);
4035   bool Create(MyFrame * parent, wxString & dir_path, wxString & img_path);
~ExifDialog()4036   virtual ~ ExifDialog()
4037   {;
4038   }
4039   void CreateControls();
GetImgPath()4040   wxString & GetImgPath()
4041   {
4042     return ImgPath;
4043   }
GetDirPath()4044   wxString & GetDirPath()
4045   {
4046     return DirPath;
4047   }
IsFolder()4048   bool IsFolder()
4049   {
4050     return Folder;
4051   }
IsMetadata()4052   bool IsMetadata()
4053   {
4054     return Metadata;
4055   }
IsGpsOnly()4056   bool IsGpsOnly()
4057   {
4058     return GpsOnly;
4059   }
4060   void OnFolder(wxCommandEvent & event);
4061   void OnMetadata(wxCommandEvent & event);
4062   void OnGpsOnly(wxCommandEvent & event);
4063   void OnOk(wxCommandEvent & event);
4064 };
4065 
4066 class XmlDocumentsDialog:public wxDialog
4067 {
4068 //
4069 // a dialog preparing an IMPORT XML DOCUMENTS
4070 //
4071 private:
4072   MyFrame * MainFrame;
4073   wxString XmlPath;             // the file name
4074   wxString DirPath;             // the folder path
4075   wxString Suffix;              // the optional file suffix
4076   wxString TargetTable;         // the target Table
4077   wxString PkName;              // the Primary Key name
4078   wxString XmlColumn;           // the XML Payload Column
4079   wxString SchemaUriColumn;     // the SchemaURI Column
4080   wxString InPathColumn;        // the InPath Column
4081   wxString ParseErrorColumn;    // the XmlParseError Column
4082   wxString ValidateErrorColumn; // the XmlValidateError Column
4083   bool Folder;                  // import a whole folder
4084   bool Compressed;              // compressed XmlBLOB
4085   bool Validated;               // apply Schema Validation
4086   bool InternalSchema;          // apply the Internally declared Schema URI
4087   bool OkSuffix;                // apply suffix restriction
4088   bool OkSchemaColumn;          // create a "schemaURI" column
4089   bool OkInPathColumn;          // create an "inPath" column
4090   bool OkParseErrorColumn;      // create the "XmlParseError" column
4091   bool OkValidateErrorColumn;   // create the "XmlSchemaValidateError" column
4092   wxString SchemaURI;           // the Schema URI for validation
4093 public:
XmlDocumentsDialog()4094     XmlDocumentsDialog()
4095   {;
4096   }
4097   bool Create(MyFrame * parent, wxString & dir_path, wxString & xml_path);
~XmlDocumentsDialog()4098   virtual ~ XmlDocumentsDialog()
4099   {;
4100   }
4101   void CreateControls();
GetXmlPath()4102   wxString & GetXmlPath()
4103   {
4104     return XmlPath;
4105   }
GetDirPath()4106   wxString & GetDirPath()
4107   {
4108     return DirPath;
4109   }
GetSuffix()4110   wxString & GetSuffix()
4111   {
4112     return Suffix;
4113   }
GetTargetTable()4114   wxString & GetTargetTable()
4115   {
4116     return TargetTable;
4117   }
GetPkName()4118   wxString & GetPkName()
4119   {
4120     return PkName;
4121   }
GetXmlColumn()4122   wxString & GetXmlColumn()
4123   {
4124     return XmlColumn;
4125   }
IsFolder()4126   bool IsFolder()
4127   {
4128     return Folder;
4129   }
IsCompressed()4130   bool IsCompressed()
4131   {
4132     return Compressed;
4133   }
IsInternalSchemaURI()4134   bool IsInternalSchemaURI()
4135   {
4136     return InternalSchema;
4137   }
GetSchemaURI()4138   wxString & GetSchemaURI()
4139   {
4140     return SchemaURI;
4141   }
GetSchemaUriColumn()4142   wxString & GetSchemaUriColumn()
4143   {
4144     return SchemaUriColumn;
4145   }
GetInPathColumn()4146   wxString & GetInPathColumn()
4147   {
4148     return InPathColumn;
4149   }
GetParseErrorColumn()4150   wxString & GetParseErrorColumn()
4151   {
4152     return ParseErrorColumn;
4153   }
GetValidateErrorColumn()4154   wxString & GetValidateErrorColumn()
4155   {
4156     return ValidateErrorColumn;
4157   }
4158   void OnFolder(wxCommandEvent & event);
4159   void OnSuffixChanged(wxCommandEvent & event);
4160   void OnCompressionChanged(wxCommandEvent & event);
4161   void OnValidationChanged(wxCommandEvent & event);
4162   void OnInternalSchemaChanged(wxCommandEvent & event);
4163   void OnSchemaColumnChanged(wxCommandEvent & event);
4164   void OnInPathColumnChanged(wxCommandEvent & event);
4165   void OnParseErrorColumnChanged(wxCommandEvent & event);
4166   void OnValidateErrorColumnChanged(wxCommandEvent & event);
4167   void OnOk(wxCommandEvent & event);
4168 };
4169 
4170 class DxfDialog:public wxDialog
4171 {
4172 //
4173 // a dialog preparing an IMPORT DXF FILE(s)
4174 //
4175 private:
4176   MyFrame * MainFrame;
4177   wxString DxfPath;             // the file name
4178   wxString DirPath;             // the folder path
4179   wxString Prefix;              // the optional table-name prefix
4180   wxString SingleLayer;         // filtering a single DXF layer by its name
4181   int Srid;                     // the SRID to be applied
4182   bool Folder;                  // import a whole folder
4183   bool OkPrefix;                // apply table-name prefix
4184   bool OkSingle;                // apply single layer filter
4185   bool Force2D;                 // always forcing 2D
4186   bool Force3D;                 // always forcing 3D
4187   bool LinkedRings;             // special - linked rings
4188   bool UnlinkedRings;           // special - unlinked rings
4189   bool ImportMixed;             // mixed layers mode
4190   bool AppendMode;              // append mode
4191 public:
DxfDialog()4192     DxfDialog()
4193   {;
4194   }
4195   bool Create(MyFrame * parent, wxString & dir_path, wxString & dxf_path);
~DxfDialog()4196   virtual ~ DxfDialog()
4197   {;
4198   }
4199   void CreateControls();
GetDxfPath()4200   wxString & GetDxfPath()
4201   {
4202     return DxfPath;
4203   }
GetDirPath()4204   wxString & GetDirPath()
4205   {
4206     return DirPath;
4207   }
GetPrefix()4208   wxString & GetPrefix()
4209   {
4210     return Prefix;
4211   }
GetSingleLayer()4212   wxString & GetSingleLayer()
4213   {
4214     return SingleLayer;
4215   }
GetSrid()4216   int GetSrid()
4217   {
4218     return Srid;
4219   }
IsFolder()4220   bool IsFolder()
4221   {
4222     return Folder;
4223   }
IsForce2D()4224   bool IsForce2D()
4225   {
4226     return Force2D;
4227   }
IsForce3D()4228   bool IsForce3D()
4229   {
4230     return Force3D;
4231   }
IsLinkedRings()4232   bool IsLinkedRings()
4233   {
4234     return LinkedRings;
4235   }
IsUnlinkedRings()4236   bool IsUnlinkedRings()
4237   {
4238     return UnlinkedRings;
4239   }
IsImportMixed()4240   bool IsImportMixed()
4241   {
4242     return ImportMixed;
4243   }
IsAppendMode()4244   bool IsAppendMode()
4245   {
4246     return AppendMode;
4247   }
4248   void OnFolder(wxCommandEvent & event);
4249   void OnPrefixChanged(wxCommandEvent & event);
4250   void OnSingleLayerChanged(wxCommandEvent & event);
4251   void OnDimensionChanged(wxCommandEvent & event);
4252   void OnModeChanged(wxCommandEvent & event);
4253   void OnRingsChanged(wxCommandEvent & event);
4254   void OnOk(wxCommandEvent & event);
4255 };
4256 
4257 class SqlScriptDialog:public wxDialog
4258 {
4259 //
4260 // a dialog preparing an SQL SCRIPT execute
4261 //
4262 private:
4263   MyFrame * MainFrame;
4264   wxString Path;                // the SHP base path
4265   wxString Default;             // the default charset
4266   wxString Charset;             // the target charset
4267 public:
SqlScriptDialog()4268     SqlScriptDialog()
4269   {;
4270   }
4271   SqlScriptDialog(MyFrame * parent, wxString & path, wxString & defCs);
4272   bool Create(MyFrame * parent, wxString & path, wxString & defCs);
~SqlScriptDialog()4273   virtual ~ SqlScriptDialog()
4274   {;
4275   }
4276   void CreateControls();
GetCharset()4277   wxString & GetCharset()
4278   {
4279     return Charset;
4280   }
4281   void OnOk(wxCommandEvent & event);
4282 };
4283 
4284 class DefaultCharsetDialog:public wxDialog
4285 {
4286 //
4287 // a dialog for selecting DEFAULT CHARSET
4288 //
4289 private:
4290   MyFrame * MainFrame;
4291   wxString Charset;             // the default charset
4292   bool AskCharset;              // true / false
4293 public:
DefaultCharsetDialog()4294     DefaultCharsetDialog()
4295   {;
4296   }
4297   DefaultCharsetDialog(MyFrame * parent, wxString & charset, bool ask);
4298   bool Create(MyFrame * parent, wxString & charset, bool ask);
~DefaultCharsetDialog()4299   virtual ~ DefaultCharsetDialog()
4300   {;
4301   }
4302   void CreateControls();
GetCharset()4303   wxString & GetCharset()
4304   {
4305     return Charset;
4306   }
IsSetAskCharset()4307   bool IsSetAskCharset()
4308   {
4309     return AskCharset;
4310   }
4311   void OnOk(wxCommandEvent & event);
4312 };
4313 
4314 class BlobExplorerDialog:public wxPropertySheetDialog
4315 {
4316 //
4317 // a dialog to explore a BLOB value
4318 //
4319 private:
4320   MyFrame * MainFrame;
4321   int BlobSize;                 // the BLOB size
4322   unsigned char *Blob;          // the BLOB value
4323   int BlobType;                 // the BLOB type
4324   bool IsSVG;
4325   double SvgWidth;
4326   double SvgHeight;
4327   int SvgSize;
4328   gaiaGeomCollPtr Geometry;     // the geometry [optional]
4329   wxString XMLDocument;         // the XMLDocument [optional]
4330   wxString XMLIndented;         // the XMLDocument (indented) [optional]
4331   wxImage *Image;               // the image [optional]
4332   wxBitmap GeomPreview;         // the geometry preview
4333   wxString WKTstring;           // the WKT Geometry notation
4334   wxString EWKTstring;          // the EWKT Geometry notation
4335   wxString SVGstring;           // the SVG Geometry notation
4336   wxString KMLstring;           // the KML Geometry notation
4337   wxString GMLstring;           // the GML Geometry notation
4338   wxString GeoJSONstring;       // the GeoJSON Geometry notation
4339   bool SVGrelative;             // SVG relative / absolute mode
4340   int SVGprecision;             // SVG precision
4341   int KMLprecision;             // KML precision
4342   bool GMLv2v3;                 // GML version (v2 / v3)
4343   int GMLprecision;             // GML precision
4344   int GeoJSONoptions;           // GeoJSON options
4345   int GeoJSONprecision;         // GeoJSON precision
4346   void FormatWKT(wxTextCtrl * txtCtrl, wxString & in, wxString & out);
4347   void FormatSVG(wxTextCtrl * txtCtrl, wxString & in, wxString & out);
4348 public:
BlobExplorerDialog()4349     BlobExplorerDialog()
4350   {;
4351   }
4352   BlobExplorerDialog(MyFrame * parent, int blob_size, unsigned char *blob);
4353   bool Create(MyFrame * parent, int blob_size, unsigned char *blob);
~BlobExplorerDialog()4354   virtual ~ BlobExplorerDialog()
4355   {
4356     if (Geometry)
4357       gaiaFreeGeomColl(Geometry);
4358     if (Image)
4359       delete Image;
4360   }
4361   void DrawGeometry(int horz, int vert);
4362   wxPanel *CreateHexadecimalPage(wxWindow * book);
4363   wxPanel *CreateGeometryPage(wxWindow * book);
4364   wxPanel *CreateWKTPage(wxWindow * book);
4365   wxPanel *CreateEWKTPage(wxWindow * book);
4366   wxPanel *CreateSVGPage(wxWindow * book);
4367   wxPanel *CreateKMLPage(wxWindow * book);
4368   wxPanel *CreateGMLPage(wxWindow * book);
4369   wxPanel *CreateGeoJSONPage(wxWindow * book);
4370   wxPanel *CreateImagePage(wxWindow * book);
4371   wxPanel *CreateXmlDocumentPage(wxWindow * book);
4372   wxPanel *CreateXmlIndentedPage(wxWindow * book);
4373   void UpdateHexadecimalPage();
4374   void UpdateGeometryPage();
4375   void UpdateImagePage();
4376   void UpdateXmlDocumentPage();
4377   void UpdateXmlIndentedPage();
4378   void UpdateWKTPage();
4379   void UpdateEWKTPage();
4380   void UpdateSVGPage();
4381   void UpdateKMLPage();
4382   void UpdateGMLPage();
4383   void UpdateGeoJSONPage();
GetGeometry()4384   gaiaGeomCollPtr GetGeometry()
4385   {
4386     return Geometry;
4387   }
GetImage()4388   wxImage *GetImage()
4389   {
4390     return Image;
4391   }
GetBlobType()4392   int GetBlobType()
4393   {
4394     return BlobType;
4395   }
4396   void OnOk(wxCommandEvent & event);
4397   void OnPageChanged(wxNotebookEvent & event);
4398   void OnCopyWKT(wxCommandEvent & event);
4399   void OnCopyEWKT(wxCommandEvent & event);
4400   void OnSVGRelative(wxCommandEvent & event);
4401   void OnSVGPrecision(wxCommandEvent & event);
4402   void OnCopySVG(wxCommandEvent & event);
4403   void OnKMLPrecision(wxCommandEvent & event);
4404   void OnCopyKML(wxCommandEvent & event);
4405   void OnGMLv2v3(wxCommandEvent & event);
4406   void OnGMLPrecision(wxCommandEvent & event);
4407   void OnCopyGML(wxCommandEvent & event);
4408   void OnGeoJSONOptions(wxCommandEvent & event);
4409   void OnGeoJSONPrecision(wxCommandEvent & event);
4410   void OnCopyGeoJSON(wxCommandEvent & event);
4411   void OnCopyXmlDocument(wxCommandEvent & event);
4412   void OnCopyXmlIndented(wxCommandEvent & event);
4413 };
4414 
4415 class GraphicsGeometry:public wxStaticBitmap
4416 {
4417 //
4418 // a window to show some Geometry in a graphical fashion
4419 //
4420 private:
4421   BlobExplorerDialog * Parent;
4422 public:
4423   GraphicsGeometry(BlobExplorerDialog * parent, wxWindow * panel, wxWindowID id,
4424                    const wxBitmap & bmp, wxSize const &size);
~GraphicsGeometry()4425     virtual ~ GraphicsGeometry()
4426   {;
4427   }
4428 };
4429 
4430 class ImageShow:public wxStaticBitmap
4431 {
4432 //
4433 // a window to show some Image [Jpeg-Png-Gif]
4434 //
4435 private:
4436   BlobExplorerDialog * Parent;
4437 public:
4438   ImageShow(BlobExplorerDialog * parent, wxWindow * panel, wxWindowID id,
4439             const wxBitmap & bmp, const wxSize & size);
~ImageShow()4440     virtual ~ ImageShow()
4441   {;
4442   }
4443   void OnRightClick(wxMouseEvent & event);
4444   void OnCmdCopy(wxCommandEvent & event);
4445 };
4446 
4447 class MyHexList:public wxListCtrl
4448 {
4449 //
4450 // a class for Hexdecimal dumps
4451 //
4452 private:
4453   BlobExplorerDialog * Parent;
4454   int BlobSize;                 // the BLOB size
4455   unsigned char *Blob;          // the BLOB value
4456 public:
4457     MyHexList(BlobExplorerDialog * parent, unsigned char *blob,
4458               int blob_size, wxWindow * panel, wxWindowID id,
4459               const wxPoint & pos = wxDefaultPosition, const wxSize & size =
4460               wxDefaultSize, long style = 0);
4461     virtual ~ MyHexList();
4462   virtual wxString OnGetItemText(long item, long column) const;
4463 };
4464 
4465 class NetNodePre
4466 {
4467 //
4468 // a class to store a temporary node for Network
4469 //
4470 private:
4471   sqlite3_int64 Id;
4472   wxString Code;
4473   NetNodePre *Next;
4474 public:
4475     NetNodePre(sqlite3_int64 id);
4476     NetNodePre(const char *code);
~NetNodePre()4477    ~NetNodePre()
4478   {;
4479   }
GetId()4480   sqlite3_int64 GetId()
4481   {
4482     return Id;
4483   }
GetCode()4484   wxString & GetCode()
4485   {
4486     return Code;
4487   }
SetNext(NetNodePre * next)4488   void SetNext(NetNodePre * next)
4489   {
4490     Next = next;
4491   }
GetNext()4492   NetNodePre *GetNext()
4493   {
4494     return Next;
4495   }
4496 };
4497 
4498 class NetNode
4499 {
4500 //
4501 // a class to store a final node for Network
4502 //
4503 private:
4504   int InternalIndex;
4505   sqlite3_int64 Id;
4506   wxString Code;
4507   double X;
4508   double Y;
4509   class NetArcRef *First;
4510   class NetArcRef *Last;
4511   NetNode *Next;
4512 public:
4513     NetNode(sqlite3_int64 id);
4514     NetNode(wxString & code);
4515    ~NetNode();
GetInternalIndex()4516   int GetInternalIndex()
4517   {
4518     return InternalIndex;
4519   }
SetInternalIndex(int idx)4520   void SetInternalIndex(int idx)
4521   {
4522     InternalIndex = idx;
4523   }
GetId()4524   sqlite3_int64 GetId()
4525   {
4526     return Id;
4527   }
GetCode()4528   wxString & GetCode()
4529   {
4530     return Code;
4531   }
GetX()4532   double GetX()
4533   {
4534     return X;
4535   }
SetX(double x)4536   void SetX(double x)
4537   {
4538     X = x;
4539   }
GetY()4540   double GetY()
4541   {
4542     return Y;
4543   }
SetY(double y)4544   void SetY(double y)
4545   {
4546     Y = y;
4547   }
4548   void AddOutcoming(class NetArc * pA);
GetFirst()4549   NetArcRef *GetFirst()
4550   {
4551     return First;
4552   }
4553   NetArc **PrepareOutcomings(int *count);
SetNext(NetNode * next)4554   void SetNext(NetNode * next)
4555   {
4556     Next = next;
4557   }
GetNext()4558   NetNode *GetNext()
4559   {
4560     return Next;
4561   }
4562 };
4563 
4564 class NetArc
4565 {
4566 //
4567 // a class to store an arc for Network
4568 //
4569 private:
4570   sqlite3_int64 RowId;
4571   NetNode *From;
4572   NetNode *To;
4573   double Cost;
4574   NetArc *Next;
4575 public:
4576     NetArc(sqlite3_int64 rowid, NetNode * from, NetNode * to, double cost);
~NetArc()4577    ~NetArc()
4578   {;
4579   }
GetRowId()4580   sqlite3_int64 GetRowId()
4581   {
4582     return RowId;
4583   }
GetFrom()4584   NetNode *GetFrom()
4585   {
4586     return From;
4587   }
GetTo()4588   NetNode *GetTo()
4589   {
4590     return To;
4591   }
GetCost()4592   double GetCost()
4593   {
4594     return Cost;
4595   }
SetNext(NetArc * next)4596   void SetNext(NetArc * next)
4597   {
4598     Next = next;
4599   }
GetNext()4600   NetArc *GetNext()
4601   {
4602     return Next;
4603   }
4604 };
4605 
4606 class NetArcRef
4607 {
4608 //
4609 // a class to store a reference to an arc for Network
4610 //
4611 private:
4612   NetArc * Reference;
4613   NetArcRef *Next;
4614 public:
NetArcRef(NetArc * arc)4615     NetArcRef(NetArc * arc)
4616   {
4617     Reference = arc;
4618     Next = NULL;
4619   }
~NetArcRef()4620    ~NetArcRef()
4621   {;
4622   }
GetReference()4623   NetArc *GetReference()
4624   {
4625     return Reference;
4626   }
SetNext(NetArcRef * next)4627   void SetNext(NetArcRef * next)
4628   {
4629     Next = next;
4630   }
GetNext()4631   NetArcRef *GetNext()
4632   {
4633     return Next;
4634   }
4635 };
4636 
4637 class Network
4638 {
4639 //
4640 // a class representing a Network
4641 //
4642 private:
4643   NetNodePre * FirstPre;
4644   NetNodePre *LastPre;
4645   int NumPreNodes;
4646   NetNodePre **SortedPreNodes;
4647   NetArc *FirstArc;
4648   NetArc *LastArc;
4649   NetNode *FirstNode;
4650   NetNode *LastNode;
4651   int NumNodes;
4652   NetNode **SortedNodes;
4653   bool Error;
4654   bool NodeCode;
4655   int MaxCodeLength;
4656 public:
4657     Network();
4658    ~Network();
4659   void CleanPreNodes();
4660   void InsertNode(sqlite3_int64 id);
4661   void InsertNode(const char *code);
4662   void AddNode(sqlite3_int64 id);
4663   void AddNode(wxString & code);
4664   NetNode *ProcessNode(sqlite3_int64 id, double x, double y, NetNode ** pOther);
4665   NetNode *ProcessNode(wxString & code, double x, double y, NetNode ** pOther);
4666   void Sort();
4667   NetNode *Find(sqlite3_int64 id);
4668   NetNode *Find(wxString & code);
4669   NetNode *GetSortedNode(sqlite3_int64 x);
4670   void AddArc(sqlite3_int64 rowid, sqlite3_int64 id_from, sqlite3_int64 id_to,
4671               double node_from_x, double node_from_y, double node_to_x,
4672               double node_to_y, double cost);
4673   void AddArc(sqlite3_int64 rowid, const char *code_from, const char *code_to,
4674               double node_from_x, double node_from_y, double node_to_x,
4675               double node_to_y, double cost);
4676   void InitNodes();
SetError()4677   void SetError()
4678   {
4679     Error = true;
4680   }
IsError()4681   bool IsError()
4682   {
4683     return Error;
4684   }
SetNodeCode(bool mode)4685   void SetNodeCode(bool mode)
4686   {
4687     NodeCode = mode;
4688   }
IsNodeCode()4689   bool IsNodeCode()
4690   {
4691     return NodeCode;
4692   }
GetNumNodes()4693   int GetNumNodes()
4694   {
4695     return NumNodes;
4696   }
GetMaxCodeLength()4697   int GetMaxCodeLength()
4698   {
4699     return MaxCodeLength;
4700   }
4701 };
4702 
4703 class AutoFDOTable
4704 {
4705 private:
4706   char *Name;
4707   AutoFDOTable *Next;
4708 public:
AutoFDOTable(const char * name,const int len)4709     AutoFDOTable(const char *name, const int len)
4710   {
4711     Name = new char[len+1];
4712       strcpy(Name, name);
4713       Next = NULL;
4714   }
~AutoFDOTable()4715    ~AutoFDOTable()
4716   {
4717     if (Name)
4718       delete[]Name;
4719   }
GetName()4720   char *GetName()
4721   {
4722     return Name;
4723   }
SetNext(AutoFDOTable * next)4724   void SetNext(AutoFDOTable * next)
4725   {
4726     Next = next;
4727   }
GetNext()4728   AutoFDOTable *GetNext()
4729   {
4730     return Next;
4731   }
4732 };
4733 
4734 class AutoFDOTables
4735 {
4736 private:
4737   AutoFDOTable * First;
4738   AutoFDOTable *Last;
4739 public:
AutoFDOTables()4740     AutoFDOTables()
4741   {
4742     First = NULL;
4743     Last = NULL;
4744   }
4745    ~AutoFDOTables();
4746   void Add(const char *name, const int len);
GetFirst()4747   AutoFDOTable *GetFirst()
4748   {
4749     return First;
4750   }
4751 };
4752 
4753 class AutoSaveDialog:public wxDialog
4754 {
4755 //
4756 // a dialog to manage AutoSave
4757 //
4758 private:
4759   MyFrame * MainFrame;
4760   wxString Path;                // the path to save
4761   int Seconds;                  // interval
4762   wxRadioBox *IntervalCtrl;
4763   wxTextCtrl *PathCtrl;
4764 public:
AutoSaveDialog()4765     AutoSaveDialog()
4766   {;
4767   }
4768   AutoSaveDialog(MyFrame * parent, wxString & path, int secs);
4769   bool Create(MyFrame * parent, wxString & path, int secs);
~AutoSaveDialog()4770   virtual ~ AutoSaveDialog()
4771   {;
4772   }
4773   void CreateControls();
GetSeconds()4774   int GetSeconds()
4775   {
4776     return Seconds;
4777   }
4778   void OnOk(wxCommandEvent & event);
GetPath()4779   wxString & GetPath()
4780   {
4781     return Path;
4782   }
4783   void OnIntervalChanged(wxCommandEvent & event);
4784   void OnChangePath(wxCommandEvent & event);
4785 };
4786 
4787 class LoadXmlDialog:public wxDialog
4788 {
4789 //
4790 // a dialog to load XML documents
4791 //
4792 private:
4793   MyFrame * MainFrame;
4794   wxString Path;                // the XML path
4795   bool Compressed;              // compressed XML
4796   bool Validate;                // Schema validation
4797   wxString SchemaURI;           // the Schema URI (if validation is required)
4798 public:
LoadXmlDialog()4799     LoadXmlDialog()
4800   {;
4801   }
4802   bool Create(MyFrame * parent, wxString & path);
~LoadXmlDialog()4803   virtual ~ LoadXmlDialog()
4804   {;
4805   }
4806   void CreateControls();
IsCompressed()4807   bool IsCompressed()
4808   {
4809     return Compressed;
4810   }
GetSchemaURI()4811   wxString & GetSchemaURI()
4812   {
4813     return SchemaURI;
4814   }
4815   void OnOk(wxCommandEvent & event);
4816   void OnCompressionChanged(wxCommandEvent & event);
4817   void OnValidationChanged(wxCommandEvent & event);
4818 };
4819 
4820 class AuxTable
4821 {
4822 // a class used by ComposerDialog [table item]
4823 private:
4824   wxString TableName;
4825   wxString Geometries[128];
4826   int MaxGeometryIndex;
4827   AuxTable *Next;
4828 public:
4829     AuxTable(wxString & table);
~AuxTable()4830    ~AuxTable()
4831   {;
4832   }
4833   void AddGeometryColumn(wxString & geom);
GetTableName()4834   wxString & GetTableName()
4835   {
4836     return TableName;
4837   }
4838   wxString & GetGeometryColumn(int ind);
GetGeometriesCount()4839   int GetGeometriesCount()
4840   {
4841     return MaxGeometryIndex;
4842   }
SetNext(AuxTable * next)4843   void SetNext(AuxTable * next)
4844   {
4845     Next = next;
4846   }
GetNext()4847   AuxTable *GetNext()
4848   {
4849     return Next;
4850   }
4851 };
4852 
4853 class AuxTableList
4854 {
4855 // a class used by ComposerDialog [tables list]
4856 private:
4857   AuxTable * First;
4858   AuxTable *Last;
4859   int Count;
4860 public:
4861     AuxTableList();
4862    ~AuxTableList();
4863   void Flush();
4864   void Populate(sqlite3 * handle);
GetCount()4865   int GetCount()
4866   {
4867     return Count;
4868   }
GetFirst()4869   AuxTable *GetFirst()
4870   {
4871     return First;
4872   }
4873 };
4874 
4875 class AuxColumn
4876 {
4877 // a class used by ComposerDialog [table item]
4878 private:
4879   wxString Name;
4880   wxString AliasName;
4881   bool Selected;
4882   AuxColumn *Next;
4883 public:
4884     AuxColumn(wxString & name);
~AuxColumn()4885    ~AuxColumn()
4886   {;
4887   }
GetName()4888   wxString & GetName()
4889   {
4890     return Name;
4891   }
SetState(bool mode)4892   void SetState(bool mode)
4893   {
4894     Selected = mode;
4895   }
IsSelected()4896   bool IsSelected()
4897   {
4898     return Selected;
4899   }
SetAliasName(wxString & alias)4900   void SetAliasName(wxString & alias)
4901   {
4902     AliasName = alias;
4903   }
GetAliasName()4904   wxString & GetAliasName()
4905   {
4906     return AliasName;
4907   }
SetNext(AuxColumn * next)4908   void SetNext(AuxColumn * next)
4909   {
4910     Next = next;
4911   }
GetNext()4912   AuxColumn *GetNext()
4913   {
4914     return Next;
4915   }
4916 };
4917 
4918 class AuxColumnList
4919 {
4920 // a class used by ComposerDialog [tables list]
4921 private:
4922   AuxColumn * First;
4923   AuxColumn *Last;
4924   int Count;
4925 public:
4926     AuxColumnList();
4927    ~AuxColumnList();
4928   void Flush();
4929   void Populate(sqlite3 * handle, wxString & table);
GetCount()4930   int GetCount()
4931   {
4932     return Count;
4933   }
GetFirst()4934   AuxColumn *GetFirst()
4935   {
4936     return First;
4937   }
4938   void SetState(int ind, bool mode);
4939   void SetState(wxString & column);
4940   void SetAlias(wxString & column, wxString & alias);
4941   bool HasSelectedColumns();
4942 };
4943 
4944 class DumpKmlDialog:public wxDialog
4945 {
4946 //
4947 // a dialog preparing a DUMP KML
4948 //
4949 private:
4950   MyFrame * MainFrame;
4951   wxString Table;               // the table's name
4952   wxString Column;              // the column's name for Geometry
4953   bool isNameConst;
4954   bool isDescConst;
4955   wxString Name;
4956   wxString Desc;
4957   int Precision;
4958   wxComboBox *NameCtrl;
4959   wxTextCtrl *NameConstCtrl;
4960   wxComboBox *DescCtrl;
4961   wxTextCtrl *DescConstCtrl;
4962   wxSpinCtrl *PrecisionCtrl;
4963   AuxColumnList ColumnList;
4964   void InitializeComboColumns(wxComboBox * ctrl);
4965 public:
DumpKmlDialog()4966     DumpKmlDialog()
4967   {;
4968   }
4969   DumpKmlDialog(MyFrame * parent, wxString & table, wxString & column);
4970   bool Create(MyFrame * parent, wxString & table, wxString & column);
~DumpKmlDialog()4971   virtual ~ DumpKmlDialog()
4972   {;
4973   }
4974   void CreateControls();
IsNameConst()4975   bool IsNameConst()
4976   {
4977     return isNameConst;
4978   }
GetName()4979   wxString & GetName()
4980   {
4981     return Name;
4982   }
IsDescConst()4983   bool IsDescConst()
4984   {
4985     return isDescConst;
4986   }
GetDesc()4987   wxString & GetDesc()
4988   {
4989     return Desc;
4990   }
GetPrecision()4991   int GetPrecision()
4992   {
4993     return Precision;
4994   }
4995   void OnNameSelected(wxCommandEvent & event);
4996   void OnDescSelected(wxCommandEvent & event);
4997   void OnOk(wxCommandEvent & event);
4998 };
4999 
5000 class DumpSpreadsheetDialog:public wxDialog
5001 {
5002 //
5003 // a dialog preparing a DUMP Speadsheet
5004 //
5005 private:
5006   MyFrame * MainFrame;
5007   char DecimalPoint;
5008   bool DateTimes;
5009 public:
DumpSpreadsheetDialog()5010     DumpSpreadsheetDialog()
5011   {;
5012   }
5013   DumpSpreadsheetDialog(MyFrame * parent);
5014   bool Create(MyFrame * parent);
~DumpSpreadsheetDialog()5015   virtual ~ DumpSpreadsheetDialog()
5016   {;
5017   }
5018   void CreateControls();
GetDecimalPoint()5019   char GetDecimalPoint()
5020   {
5021     return DecimalPoint;
5022   }
IsDateTimes()5023   bool IsDateTimes()
5024   {
5025     return DateTimes;
5026   }
5027   void OnDecimalPointSelected(wxCommandEvent & event);
5028   void OnDateTimesSelected(wxCommandEvent & event);
5029   void OnOk(wxCommandEvent & event);
5030 };
5031 
5032 class ComposerMainPage:public wxPanel
5033 {
5034 //
5035 // first page used by Query/View COMPOSER
5036 //
5037 private:
5038   class ComposerDialog * Parent;
5039   wxCheckBox *Table2Ctrl;
5040   wxComboBox *Table1NameCtrl;
5041   wxComboBox *Table2NameCtrl;
5042   wxTextCtrl *Table1AliasCtrl;
5043   wxTextCtrl *Table2AliasCtrl;
5044   wxListBox *Table1ColumnsCtrl;
5045   wxListBox *Table2ColumnsCtrl;
5046   wxRadioBox *JoinModeCtrl;
5047   wxCheckBox *Match2Ctrl;
5048   wxCheckBox *Match3Ctrl;
5049   wxComboBox *Match1Table1Ctrl;
5050   wxComboBox *Match1Table2Ctrl;
5051   wxComboBox *Match2Table1Ctrl;
5052   wxComboBox *Match2Table2Ctrl;
5053   wxComboBox *Match3Table1Ctrl;
5054   wxComboBox *Match3Table2Ctrl;
5055 public:
ComposerMainPage()5056     ComposerMainPage()
5057   {;
5058   }
5059   bool Create(ComposerDialog * parent);
~ComposerMainPage()5060   virtual ~ ComposerMainPage()
5061   {;
5062   }
5063   void CreateControls();
5064   void SelectGeometryColumn(wxString & column, bool table2);
5065   void InitializeComboColumns(wxComboBox * ctrl, bool table2);
5066   void InitializeListColumns(wxListBox * ctrl, bool table2);
5067   void OnTable2Enabled(wxCommandEvent & event);
5068   void OnTable1Selected(wxCommandEvent & event);
5069   void OnTable2Selected(wxCommandEvent & event);
5070   void OnColumns1Selected(wxCommandEvent & event);
5071   void OnColumns2Selected(wxCommandEvent & event);
5072   void OnTable1AliasChanged(wxCommandEvent & event);
5073   void OnTable2AliasChanged(wxCommandEvent & event);
5074   void OnJoinModeChanged(wxCommandEvent & event);
5075   void OnMatch2Enabled(wxCommandEvent & event);
5076   void OnMatch3Enabled(wxCommandEvent & event);
5077   void OnMatch1Table1Selected(wxCommandEvent & event);
5078   void OnMatch1Table2Selected(wxCommandEvent & event);
5079   void OnMatch2Table1Selected(wxCommandEvent & event);
5080   void OnMatch2Table2Selected(wxCommandEvent & event);
5081   void OnMatch3Table1Selected(wxCommandEvent & event);
5082   void OnMatch3Table2Selected(wxCommandEvent & event);
5083 };
5084 
5085 class ComposerFilterPage:public wxPanel
5086 {
5087 //
5088 // second page used by Query/View COMPOSER
5089 //
5090 private:
5091   class ComposerDialog * Parent;
5092   wxCheckBox *Where1EnabledCtrl;
5093   wxRadioBox *Where1TableCtrl;
5094   wxComboBox *Where1ColumnCtrl;
5095   wxComboBox *Where1OperatorCtrl;
5096   wxTextCtrl *Where1ValueCtrl;
5097   wxCheckBox *Where2EnabledCtrl;
5098   wxRadioBox *Where2TableCtrl;
5099   wxComboBox *Where2ColumnCtrl;
5100   wxComboBox *Where2OperatorCtrl;
5101   wxTextCtrl *Where2ValueCtrl;
5102   wxCheckBox *Where3EnabledCtrl;
5103   wxRadioBox *Where3TableCtrl;
5104   wxComboBox *Where3ColumnCtrl;
5105   wxComboBox *Where3OperatorCtrl;
5106   wxTextCtrl *Where3ValueCtrl;
5107   wxRadioBox *Connector12Ctrl;
5108   wxRadioBox *Connector23Ctrl;
5109 public:
ComposerFilterPage()5110     ComposerFilterPage()
5111   {;
5112   }
5113   bool Create(ComposerDialog * parent);
~ComposerFilterPage()5114   virtual ~ ComposerFilterPage()
5115   {;
5116   }
5117   void CreateControls();
5118   void Table1Status(bool ok);
5119   void Table2Status(bool ok);
5120   void InitializeColumns(wxComboBox * ctrl, bool table2);
5121   void InitializeOperators(wxComboBox * ctrl);
5122   void OnWhere1Enabled(wxCommandEvent & event);
5123   void OnWhere1TableChanged(wxCommandEvent & event);
5124   void OnWhere1ColumnSelected(wxCommandEvent & event);
5125   void OnWhere1OperatorSelected(wxCommandEvent & event);
5126   void OnWhere1ValueChanged(wxCommandEvent & event);
5127   void OnWhere2Enabled(wxCommandEvent & event);
5128   void OnWhere2TableChanged(wxCommandEvent & event);
5129   void OnWhere2ColumnSelected(wxCommandEvent & event);
5130   void OnWhere2OperatorSelected(wxCommandEvent & event);
5131   void OnWhere2ValueChanged(wxCommandEvent & event);
5132   void OnWhere3Enabled(wxCommandEvent & event);
5133   void OnWhere3TableChanged(wxCommandEvent & event);
5134   void OnWhere3ColumnSelected(wxCommandEvent & event);
5135   void OnWhere3OperatorSelected(wxCommandEvent & event);
5136   void OnWhere3ValueChanged(wxCommandEvent & event);
5137   void OnConnector12Changed(wxCommandEvent & event);
5138   void OnConnector23Changed(wxCommandEvent & event);
5139 };
5140 
5141 class ComposerOrderPage:public wxPanel
5142 {
5143 //
5144 // third page used by Query/View COMPOSER
5145 //
5146 private:
5147   class ComposerDialog * Parent;
5148   wxCheckBox *Order1EnabledCtrl;
5149   wxRadioBox *Order1TableCtrl;
5150   wxComboBox *Order1ColumnCtrl;
5151   wxRadioBox *Order1DescCtrl;
5152   wxCheckBox *Order2EnabledCtrl;
5153   wxRadioBox *Order2TableCtrl;
5154   wxComboBox *Order2ColumnCtrl;
5155   wxRadioBox *Order2DescCtrl;
5156   wxCheckBox *Order3EnabledCtrl;
5157   wxRadioBox *Order3TableCtrl;
5158   wxComboBox *Order3ColumnCtrl;
5159   wxRadioBox *Order3DescCtrl;
5160   wxCheckBox *Order4EnabledCtrl;
5161   wxRadioBox *Order4TableCtrl;
5162   wxComboBox *Order4ColumnCtrl;
5163   wxRadioBox *Order4DescCtrl;
5164 public:
ComposerOrderPage()5165     ComposerOrderPage()
5166   {;
5167   }
5168   bool Create(ComposerDialog * parent);
~ComposerOrderPage()5169   virtual ~ ComposerOrderPage()
5170   {;
5171   }
5172   void CreateControls();
5173   void Table1Status(bool ok);
5174   void Table2Status(bool ok);
5175   void InitializeColumns(wxComboBox * ctrl, bool table2);
5176   void OnOrder1Enabled(wxCommandEvent & event);
5177   void OnOrder1TableChanged(wxCommandEvent & event);
5178   void OnOrder1ColumnSelected(wxCommandEvent & event);
5179   void OnOrder1DescChanged(wxCommandEvent & event);
5180   void OnOrder2Enabled(wxCommandEvent & event);
5181   void OnOrder2TableChanged(wxCommandEvent & event);
5182   void OnOrder2ColumnSelected(wxCommandEvent & event);
5183   void OnOrder2DescChanged(wxCommandEvent & event);
5184   void OnOrder3Enabled(wxCommandEvent & event);
5185   void OnOrder3TableChanged(wxCommandEvent & event);
5186   void OnOrder3ColumnSelected(wxCommandEvent & event);
5187   void OnOrder3DescChanged(wxCommandEvent & event);
5188   void OnOrder4Enabled(wxCommandEvent & event);
5189   void OnOrder4TableChanged(wxCommandEvent & event);
5190   void OnOrder4ColumnSelected(wxCommandEvent & event);
5191   void OnOrder4DescChanged(wxCommandEvent & event);
5192 };
5193 
5194 class ComposerViewPage:public wxPanel
5195 {
5196 //
5197 // fourth page used by Query/View COMPOSER
5198 //
5199 private:
5200   class ComposerDialog * Parent;
5201   wxRadioBox *ViewTypeCtrl;
5202   wxTextCtrl *ViewNameCtrl;
5203   wxRadioBox *GeomTableCtrl;
5204   wxComboBox *GeometryColumnCtrl;
5205   wxCheckBox *Writable1Ctrl;
5206   wxCheckBox *Writable2Ctrl;
5207 public:
ComposerViewPage()5208     ComposerViewPage()
5209   {;
5210   }
5211   bool Create(ComposerDialog * parent);
~ComposerViewPage()5212   virtual ~ ComposerViewPage()
5213   {;
5214   }
5215   void CreateControls();
5216   void Table1Status(bool ok);
5217   void Table2Status(bool ok);
5218   void OnGeomTableChanged(wxCommandEvent & event);
5219   void InitializeGeometries(bool table2);
5220   void OnGeometryColumnSelected(wxCommandEvent & event);
5221   void OnViewTypeChanged(wxCommandEvent & event);
5222   void OnViewNameChanged(wxCommandEvent & event);
5223   void OnWritable1Changed(wxCommandEvent & event);
5224   void OnWritable2Changed(wxCommandEvent & event);
5225 };
5226 
5227 class ComposerDialog:public wxDialog
5228 {
5229 //
5230 // a dialog used by Query/View COMPOSER
5231 //
5232 private:
5233   MyFrame * MainFrame;
5234   AuxTableList TableList;
5235   AuxColumnList Column1List;
5236   AuxColumnList Column2List;
5237   bool IncompleteSql;
5238   bool Table2Enabled;
5239   wxString TableName1;
5240   wxString TableName2;
5241   wxString TableAlias1;
5242   wxString TableAlias2;
5243   bool LeftJoin;
5244   bool Match2Enabled;
5245   bool Match3Enabled;
5246   wxString Match1Table1;
5247   wxString Match1Table2;
5248   wxString Match2Table1;
5249   wxString Match2Table2;
5250   wxString Match3Table1;
5251   wxString Match3Table2;
5252   bool Where1Enabled;
5253   bool Where2Enabled;
5254   bool Where3Enabled;
5255   bool Where1Table2;
5256   bool Where2Table2;
5257   bool Where3Table2;
5258   bool AndOr12;
5259   bool AndOr23;
5260   wxString Where1Column;
5261   wxString Where2Column;
5262   wxString Where3Column;
5263   wxString Where1Operator;
5264   wxString Where2Operator;
5265   wxString Where3Operator;
5266   wxString Where1Value;
5267   wxString Where2Value;
5268   wxString Where3Value;
5269   bool Order1Enabled;
5270   bool Order2Enabled;
5271   bool Order3Enabled;
5272   bool Order4Enabled;
5273   bool Order1Table2;
5274   bool Order2Table2;
5275   bool Order3Table2;
5276   bool Order4Table2;
5277   wxString Order1Column;
5278   wxString Order2Column;
5279   wxString Order3Column;
5280   wxString Order4Column;
5281   bool Order1Desc;
5282   bool Order2Desc;
5283   bool Order3Desc;
5284   bool Order4Desc;
5285   bool PlainView;
5286   bool SpatialView;
5287   wxString ViewName;
5288   bool ViewGeomTable2;
5289   wxString GeometryColumn;
5290   bool Writable1;
5291   bool Writable2;
5292   wxString GeometryColumnAlias;
5293   wxString GeometryRowidAlias;
5294   wxString SqlSample;
5295   wxString SqlTriggerInsert;
5296   wxString SqlTriggerUpdate;
5297   wxString SqlTriggerDelete;
5298   wxTextCtrl *SqlCtrl;
5299   wxNotebook *TabCtrl;
5300   ComposerMainPage *Page1;
5301   ComposerFilterPage *Page2;
5302   ComposerOrderPage *Page3;
5303   ComposerViewPage *Page4;
5304 public:
ComposerDialog()5305     ComposerDialog()
5306   {;
5307   }
5308   bool Create(MyFrame * parent);
~ComposerDialog()5309   virtual ~ ComposerDialog()
5310   {;
5311   }
5312   void CreateControls();
GetTableList()5313   AuxTableList *GetTableList()
5314   {
5315     return &TableList;
5316   }
PopulateColumnList1()5317   void PopulateColumnList1()
5318   {
5319     Column1List.Populate(MainFrame->GetSqlite(), TableName1);
5320   }
PopulateColumnList2()5321   void PopulateColumnList2()
5322   {
5323     Column2List.Populate(MainFrame->GetSqlite(), TableName2);
5324   }
GetColumn1List()5325   AuxColumnList *GetColumn1List()
5326   {
5327     return &Column1List;
5328   }
GetColumn2List()5329   AuxColumnList *GetColumn2List()
5330   {
5331     return &Column2List;
5332   }
SetTable2Enabled(bool mode)5333   void SetTable2Enabled(bool mode)
5334   {
5335     Table2Enabled = mode;
5336   }
IsTable2Enabled()5337   bool IsTable2Enabled()
5338   {
5339     return Table2Enabled;
5340   }
SetTableName1(wxString name)5341   void SetTableName1(wxString name)
5342   {
5343     TableName1 = name;
5344   }
GetTableName1()5345   wxString & GetTableName1()
5346   {
5347     return TableName1;
5348   }
SetTableName2(wxString name)5349   void SetTableName2(wxString name)
5350   {
5351     TableName2 = name;
5352   }
GetTableAlias2()5353   wxString & GetTableAlias2()
5354   {
5355     return TableAlias2;
5356   }
SetTableAlias1(wxString alias)5357   void SetTableAlias1(wxString alias)
5358   {
5359     TableAlias1 = alias;
5360   }
GetTableAlias1()5361   wxString & GetTableAlias1()
5362   {
5363     return TableAlias1;
5364   }
SetTableAlias2(wxString alias)5365   void SetTableAlias2(wxString alias)
5366   {
5367     TableAlias2 = alias;
5368   }
GetTableName2()5369   wxString & GetTableName2()
5370   {
5371     return TableName2;
5372   }
SetLeftJoin(bool mode)5373   void SetLeftJoin(bool mode)
5374   {
5375     LeftJoin = mode;
5376   }
IsLeftJoin()5377   bool IsLeftJoin()
5378   {
5379     return LeftJoin;
5380   }
SetMatch2Enabled(bool mode)5381   void SetMatch2Enabled(bool mode)
5382   {
5383     Match2Enabled = mode;
5384   }
IsMatch2Enabled()5385   bool IsMatch2Enabled()
5386   {
5387     return Match2Enabled;
5388   }
SetMatch3Enabled(bool mode)5389   void SetMatch3Enabled(bool mode)
5390   {
5391     Match3Enabled = mode;
5392   }
IsMatch3Enabled()5393   bool IsMatch3Enabled()
5394   {
5395     return Match3Enabled;
5396   }
SetMatch1Table1(wxString name)5397   void SetMatch1Table1(wxString name)
5398   {
5399     Match1Table1 = name;
5400   }
GetMatch1Table1()5401   wxString & GetMatch1Table1()
5402   {
5403     return Match1Table1;
5404   }
SetMatch1Table2(wxString name)5405   void SetMatch1Table2(wxString name)
5406   {
5407     Match1Table2 = name;
5408   }
GetMatch1Table2()5409   wxString & GetMatch1Table2()
5410   {
5411     return Match1Table2;
5412   }
SetMatch2Table1(wxString name)5413   void SetMatch2Table1(wxString name)
5414   {
5415     Match2Table1 = name;
5416   }
GetMatch2Table1()5417   wxString & GetMatch2Table1()
5418   {
5419     return Match2Table1;
5420   }
SetMatch2Table2(wxString name)5421   void SetMatch2Table2(wxString name)
5422   {
5423     Match2Table2 = name;
5424   }
GetMatch2Table2()5425   wxString & GetMatch2Table2()
5426   {
5427     return Match2Table2;
5428   }
SetMatch3Table1(wxString name)5429   void SetMatch3Table1(wxString name)
5430   {
5431     Match3Table1 = name;
5432   }
GetMatch3Table1()5433   wxString & GetMatch3Table1()
5434   {
5435     return Match3Table1;
5436   }
SetMatch3Table2(wxString name)5437   void SetMatch3Table2(wxString name)
5438   {
5439     Match3Table2 = name;
5440   }
GetMatch3Table2()5441   wxString & GetMatch3Table2()
5442   {
5443     return Match3Table2;
5444   }
SetWhere1Enabled(bool mode)5445   void SetWhere1Enabled(bool mode)
5446   {
5447     Where1Enabled = mode;
5448   }
IsWhere1Enabled()5449   bool IsWhere1Enabled()
5450   {
5451     return Where1Enabled;
5452   }
SetWhere2Enabled(bool mode)5453   void SetWhere2Enabled(bool mode)
5454   {
5455     Where2Enabled = mode;
5456   }
IsWhere2Enabled()5457   bool IsWhere2Enabled()
5458   {
5459     return Where2Enabled;
5460   }
SetWhere3Enabled(bool mode)5461   void SetWhere3Enabled(bool mode)
5462   {
5463     Where3Enabled = mode;
5464   }
IsWhere3Enabled()5465   bool IsWhere3Enabled()
5466   {
5467     return Where3Enabled;
5468   }
SetWhere1Table2(bool mode)5469   void SetWhere1Table2(bool mode)
5470   {
5471     Where1Table2 = mode;
5472   }
IsWhere1Table2()5473   bool IsWhere1Table2()
5474   {
5475     return Where1Table2;
5476   }
SetWhere2Table2(bool mode)5477   void SetWhere2Table2(bool mode)
5478   {
5479     Where2Table2 = mode;
5480   }
IsWhere2Table2()5481   bool IsWhere2Table2()
5482   {
5483     return Where2Table2;
5484   }
SetWhere3Table2(bool mode)5485   void SetWhere3Table2(bool mode)
5486   {
5487     Where3Table2 = mode;
5488   }
IsWhere3Table2()5489   bool IsWhere3Table2()
5490   {
5491     return Where3Table2;
5492   }
SetAndOr12(bool mode)5493   void SetAndOr12(bool mode)
5494   {
5495     AndOr12 = mode;
5496   }
IsAndOr12()5497   bool IsAndOr12()
5498   {
5499     return AndOr12;
5500   }
SetAndOr23(bool mode)5501   void SetAndOr23(bool mode)
5502   {
5503     AndOr23 = mode;
5504   }
IsAndOr23()5505   bool IsAndOr23()
5506   {
5507     return AndOr23;
5508   }
SetWhere1Column(wxString name)5509   void SetWhere1Column(wxString name)
5510   {
5511     Where1Column = name;
5512   }
GetWhere1Column()5513   wxString & GetWhere1Column()
5514   {
5515     return Where1Column;
5516   }
SetWhere2Column(wxString name)5517   void SetWhere2Column(wxString name)
5518   {
5519     Where2Column = name;
5520   }
GetWhere2Column()5521   wxString & GetWhere2Column()
5522   {
5523     return Where2Column;
5524   }
SetWhere3Column(wxString name)5525   void SetWhere3Column(wxString name)
5526   {
5527     Where3Column = name;
5528   }
GetWhere3Column()5529   wxString & GetWhere3Column()
5530   {
5531     return Where3Column;
5532   }
SetWhere1Operator(wxString name)5533   void SetWhere1Operator(wxString name)
5534   {
5535     Where1Operator = name;
5536   }
GetWhere1Operator()5537   wxString & GetWhere1Operator()
5538   {
5539     return Where1Operator;
5540   }
SetWhere2Operator(wxString name)5541   void SetWhere2Operator(wxString name)
5542   {
5543     Where2Operator = name;
5544   }
GetWhere2Operator()5545   wxString & GetWhere2Operator()
5546   {
5547     return Where2Operator;
5548   }
SetWhere3Operator(wxString name)5549   void SetWhere3Operator(wxString name)
5550   {
5551     Where3Operator = name;
5552   }
GetWhere3Operator()5553   wxString & GetWhere3Operator()
5554   {
5555     return Where3Operator;
5556   }
SetWhere1Value(wxString name)5557   void SetWhere1Value(wxString name)
5558   {
5559     Where1Value = name;
5560   }
GetWhere1Value()5561   wxString & GetWhere1Value()
5562   {
5563     return Where1Value;
5564   }
SetWhere2Value(wxString name)5565   void SetWhere2Value(wxString name)
5566   {
5567     Where2Value = name;
5568   }
GetWhere2Value()5569   wxString & GetWhere2Value()
5570   {
5571     return Where2Value;
5572   }
SetWhere3Value(wxString name)5573   void SetWhere3Value(wxString name)
5574   {
5575     Where3Value = name;
5576   }
GetWhere3Value()5577   wxString & GetWhere3Value()
5578   {
5579     return Where3Value;
5580   }
SetOrder1Enabled(bool mode)5581   void SetOrder1Enabled(bool mode)
5582   {
5583     Order1Enabled = mode;
5584   }
IsOrder1Enabled()5585   bool IsOrder1Enabled()
5586   {
5587     return Order1Enabled;
5588   }
SetOrder2Enabled(bool mode)5589   void SetOrder2Enabled(bool mode)
5590   {
5591     Order2Enabled = mode;
5592   }
IsOrder2Enabled()5593   bool IsOrder2Enabled()
5594   {
5595     return Order2Enabled;
5596   }
SetOrder3Enabled(bool mode)5597   void SetOrder3Enabled(bool mode)
5598   {
5599     Order3Enabled = mode;
5600   }
IsOrder3Enabled()5601   bool IsOrder3Enabled()
5602   {
5603     return Order3Enabled;
5604   }
SetOrder4Enabled(bool mode)5605   void SetOrder4Enabled(bool mode)
5606   {
5607     Order4Enabled = mode;
5608   }
IsOrder4Enabled()5609   bool IsOrder4Enabled()
5610   {
5611     return Order4Enabled;
5612   }
SetOrder1Table2(bool mode)5613   void SetOrder1Table2(bool mode)
5614   {
5615     Order1Table2 = mode;
5616   }
IsOrder1Table2()5617   bool IsOrder1Table2()
5618   {
5619     return Order1Table2;
5620   }
SetOrder2Table2(bool mode)5621   void SetOrder2Table2(bool mode)
5622   {
5623     Order2Table2 = mode;
5624   }
IsOrder2Table2()5625   bool IsOrder2Table2()
5626   {
5627     return Order2Table2;
5628   }
SetOrder3Table2(bool mode)5629   void SetOrder3Table2(bool mode)
5630   {
5631     Order3Table2 = mode;
5632   }
IsOrder3Table2()5633   bool IsOrder3Table2()
5634   {
5635     return Order3Table2;
5636   }
SetOrder4Table2(bool mode)5637   void SetOrder4Table2(bool mode)
5638   {
5639     Order4Table2 = mode;
5640   }
IsOrder4Table2()5641   bool IsOrder4Table2()
5642   {
5643     return Order4Table2;
5644   }
SetOrder1Column(wxString name)5645   void SetOrder1Column(wxString name)
5646   {
5647     Order1Column = name;
5648   }
GetOrder1Column()5649   wxString & GetOrder1Column()
5650   {
5651     return Order1Column;
5652   }
SetOrder2Column(wxString name)5653   void SetOrder2Column(wxString name)
5654   {
5655     Order2Column = name;
5656   }
GetOrder2Column()5657   wxString & GetOrder2Column()
5658   {
5659     return Order2Column;
5660   }
SetOrder3Column(wxString name)5661   void SetOrder3Column(wxString name)
5662   {
5663     Order3Column = name;
5664   }
GetOrder3Column()5665   wxString & GetOrder3Column()
5666   {
5667     return Order3Column;
5668   }
SetOrder4Column(wxString name)5669   void SetOrder4Column(wxString name)
5670   {
5671     Order4Column = name;
5672   }
GetOrder4Column()5673   wxString & GetOrder4Column()
5674   {
5675     return Order4Column;
5676   }
SetOrder1Desc(bool mode)5677   void SetOrder1Desc(bool mode)
5678   {
5679     Order1Desc = mode;
5680   }
IsOrder1Desc()5681   bool IsOrder1Desc()
5682   {
5683     return Order1Desc;
5684   }
SetOrder2Desc(bool mode)5685   void SetOrder2Desc(bool mode)
5686   {
5687     Order2Desc = mode;
5688   }
IsOrder2Desc()5689   bool IsOrder2Desc()
5690   {
5691     return Order2Desc;
5692   }
SetOrder3Desc(bool mode)5693   void SetOrder3Desc(bool mode)
5694   {
5695     Order3Desc = mode;
5696   }
IsOrder3Desc()5697   bool IsOrder3Desc()
5698   {
5699     return Order3Desc;
5700   }
SetOrder4Desc(bool mode)5701   void SetOrder4Desc(bool mode)
5702   {
5703     Order4Desc = mode;
5704   }
IsOrder4Desc()5705   bool IsOrder4Desc()
5706   {
5707     return Order4Desc;
5708   }
SetPlainView(bool mode)5709   void SetPlainView(bool mode)
5710   {
5711     PlainView = mode;
5712   }
IsPlainView()5713   bool IsPlainView()
5714   {
5715     return PlainView;
5716   }
SetSpatialView(bool mode)5717   void SetSpatialView(bool mode)
5718   {
5719     SpatialView = mode;
5720   }
IsSpatialView()5721   bool IsSpatialView()
5722   {
5723     return SpatialView;
5724   }
SetViewName(wxString name)5725   void SetViewName(wxString name)
5726   {
5727     ViewName = name;
5728   }
GetViewName()5729   wxString & GetViewName()
5730   {
5731     return ViewName;
5732   }
SetViewGeomTable2(bool mode)5733   void SetViewGeomTable2(bool mode)
5734   {
5735     ViewGeomTable2 = mode;
5736   }
IsViewGeomTable2()5737   bool IsViewGeomTable2()
5738   {
5739     return ViewGeomTable2;
5740   }
SetGeometryColumn(wxString name)5741   void SetGeometryColumn(wxString name)
5742   {
5743     GeometryColumn = name;
5744   }
GetGeometryColumn()5745   wxString & GetGeometryColumn()
5746   {
5747     return GeometryColumn;
5748   }
SetWritable1(bool value)5749   void SetWritable1(bool value)
5750   {
5751     Writable1 = value;
5752   }
SetWritable2(bool value)5753   void SetWritable2(bool value)
5754   {
5755     Writable2 = value;
5756   }
IsWritable1()5757   bool IsWritable1()
5758   {
5759     return Writable1;
5760   }
IsWritable2()5761   bool IsWritable2()
5762   {
5763     return Writable2;
5764   }
5765   bool IsDuplicateAlias(wxString & alias);
5766   void SetAliases();
GetGeometryColumnAlias()5767   wxString & GetGeometryColumnAlias()
5768   {
5769     return GeometryColumnAlias;
5770   }
GetGeometryRowidAlias()5771   wxString & GetGeometryRowidAlias()
5772   {
5773     return GeometryRowidAlias;
5774   }
GetSqlSample()5775   wxString & GetSqlSample()
5776   {
5777     return SqlSample;
5778   }
GetSqlTriggerInsert()5779   wxString & GetSqlTriggerInsert()
5780   {
5781     return SqlTriggerInsert;
5782   }
GetSqlTriggerUpdate()5783   wxString & GetSqlTriggerUpdate()
5784   {
5785     return SqlTriggerUpdate;
5786   }
GetSqlTriggerDelete()5787   wxString & GetSqlTriggerDelete()
5788   {
5789     return SqlTriggerDelete;
5790   }
GetTabCtrl()5791   wxNotebook *GetTabCtrl()
5792   {
5793     return TabCtrl;
5794   }
5795   void Table1Status(bool ok);
5796   void Table2Status(bool ok);
5797   bool SqlCleanString(wxString & dirty, wxString & clean);
5798   void SqlCleanList(wxString & list, wxString & clean, int *style, int *start,
5799                     int *stop, int *next, int base);
5800   void SelectGeometryColumn();
5801   void UpdateSqlSample();
5802   void PrepareSqlTriggers();
5803   void OnOk(wxCommandEvent & event);
5804 };
5805 
5806 class GeomColumn
5807 {
5808 //
5809 // a class representing a Geometry Column
5810 //
5811 private:
5812   wxString GeometryName;
5813   wxString GeometryType;
5814   wxString CoordDims;
5815   int Srid;
5816   bool RTree;
5817   bool MbrCache;
5818   bool NotNull;
5819   GeomColumn *Next;
5820 public:
5821     GeomColumn(wxString & name, wxString & type, wxString & dims, int srid,
5822                int idx);
~GeomColumn()5823    ~GeomColumn()
5824   {;
5825   }
GetGeometryName()5826   wxString & GetGeometryName()
5827   {
5828     return GeometryName;
5829   }
GetGeometryType()5830   wxString & GetGeometryType()
5831   {
5832     return GeometryType;
5833   }
GetCoordDims()5834   wxString & GetCoordDims()
5835   {
5836     return CoordDims;
5837   }
GetSrid()5838   int GetSrid()
5839   {
5840     return Srid;
5841   }
IsRTree()5842   bool IsRTree()
5843   {
5844     return RTree;
5845   }
IsMbrCache()5846   bool IsMbrCache()
5847   {
5848     return MbrCache;
5849   }
SetNotNull()5850   void SetNotNull()
5851   {
5852     NotNull = true;
5853   }
IsNotNull()5854   bool IsNotNull()
5855   {
5856     return NotNull;
5857   }
SetNext(GeomColumn * next)5858   void SetNext(GeomColumn * next)
5859   {
5860     Next = next;
5861   }
GetNext()5862   GeomColumn *GetNext()
5863   {
5864     return Next;
5865   }
5866 };
5867 
5868 class GeomColsList
5869 {
5870 //
5871 // a class representing a Geometry Columns list
5872 //
5873 private:
5874   GeomColumn * First;
5875   GeomColumn *Last;
5876 public:
5877     GeomColsList();
5878    ~GeomColsList();
5879   void Add(wxString & name, wxString & type, wxString & dims, int srid,
5880            int idx);
GetFirst()5881   GeomColumn *GetFirst()
5882   {
5883     return First;
5884   }
5885   void SetNotNull(wxString & geom);
5886 };
5887 
5888 class IndexColumn
5889 {
5890 //
5891 // a class representing an Index Column
5892 //
5893 private:
5894   wxString ColumnName;
5895   bool Valid;
5896   IndexColumn *Next;
5897 public:
5898     IndexColumn(wxString & name);
~IndexColumn()5899    ~IndexColumn()
5900   {;
5901   }
GetColumnName()5902   wxString & GetColumnName()
5903   {
5904     return ColumnName;
5905   }
IsValid()5906   bool IsValid()
5907   {
5908     return Valid;
5909   }
Invalidate()5910   void Invalidate()
5911   {
5912     Valid = false;
5913   }
SetNext(IndexColumn * next)5914   void SetNext(IndexColumn * next)
5915   {
5916     Next = next;
5917   }
GetNext()5918   IndexColumn *GetNext()
5919   {
5920     return Next;
5921   }
5922 };
5923 
5924 class TblIndex
5925 {
5926 //
5927 // a class representing a Table Index
5928 //
5929 private:
5930   wxString IndexName;
5931   bool Unique;
5932   bool Valid;
5933   IndexColumn *First;
5934   IndexColumn *Last;
5935   TblIndex *Next;
5936 public:
5937     TblIndex(wxString & name, bool unique);
5938    ~TblIndex();
5939   void Add(wxString & column);
GetIndexName()5940     wxString & GetIndexName()
5941   {
5942     return IndexName;
5943   }
IsUnique()5944   bool IsUnique()
5945   {
5946     return Unique;
5947   }
5948   void Invalidate(wxString & colName);
IsValid()5949   bool IsValid()
5950   {
5951     return Valid;
5952   }
SetNext(TblIndex * next)5953   void SetNext(TblIndex * next)
5954   {
5955     Next = next;
5956   }
GetNext()5957   TblIndex *GetNext()
5958   {
5959     return Next;
5960   }
GetFirst()5961   IndexColumn *GetFirst()
5962   {
5963     return First;
5964   }
5965 };
5966 
5967 class TblIndexList
5968 {
5969 //
5970 // a class representing a Table Index list
5971 //
5972 private:
5973   TblIndex * First;
5974   TblIndex *Last;
5975 public:
5976     TblIndexList();
5977    ~TblIndexList();
5978   void Add(wxString & name, bool unique);
GetFirst()5979   TblIndex *GetFirst()
5980   {
5981     return First;
5982   }
5983   void Invalidate(wxString & colName);
5984 };
5985 
5986 class ResultSetShapefileGeometry
5987 {
5988 //
5989 // a class wrapping a (possible) Shapefile Geometry
5990 //
5991 private:
5992   int Type;
5993   int Dims;
5994   int Srid;
5995   int Count;
5996   ResultSetShapefileGeometry *Next;
5997 public:
ResultSetShapefileGeometry(int type,int dims,int srid)5998     ResultSetShapefileGeometry(int type, int dims, int srid)
5999   {
6000     Type = type;
6001     Dims = dims;
6002     Srid = srid;
6003     Count = 1;
6004     Next = NULL;
6005   }
~ResultSetShapefileGeometry()6006    ~ResultSetShapefileGeometry()
6007   {;
6008   }
GetType()6009   int GetType()
6010   {
6011     return Type;
6012   }
GetDims()6013   int GetDims()
6014   {
6015     return Dims;
6016   }
GetSrid()6017   int GetSrid()
6018   {
6019     return Srid;
6020   }
GetCount()6021   int GetCount()
6022   {
6023     return Count;
6024   }
Update()6025   void Update()
6026   {
6027     Count++;
6028   }
SetNext(ResultSetShapefileGeometry * next)6029   void SetNext(ResultSetShapefileGeometry * next)
6030   {
6031     Next = next;
6032   }
GetNext()6033   ResultSetShapefileGeometry *GetNext()
6034   {
6035     return Next;
6036   }
6037 };
6038 
6039 class ResultSetShapefileColumn
6040 {
6041 //
6042 // a class wrapping a (possible) Shapefile column
6043 //
6044 private:
6045   char *Name;
6046   int NullCount;
6047   int TextCount;
6048   int MaxTextLen;
6049   int IntCount;
6050   int DoubleCount;
6051   int BlobCount;
6052   int DbfType;
6053   ResultSetShapefileGeometry *First;
6054   ResultSetShapefileGeometry *Last;
6055 public:
6056     ResultSetShapefileColumn();
6057    ~ResultSetShapefileColumn();
6058   void SetName(const char *name);
GetName()6059   char *GetName()
6060   {
6061     return Name;
6062   }
UpdateNull()6063   void UpdateNull()
6064   {
6065     NullCount++;
6066   }
UpdateText(int len)6067   void UpdateText(int len)
6068   {
6069     TextCount++;
6070     if (len > MaxTextLen)
6071       MaxTextLen = len;
6072   }
UpdateInteger()6073   void UpdateInteger()
6074   {
6075     IntCount++;
6076   }
UpdateDouble()6077   void UpdateDouble()
6078   {
6079     DoubleCount++;
6080   }
UpdateBlob()6081   void UpdateBlob()
6082   {
6083     BlobCount++;
6084   }
6085   void UpdateGeometry(gaiaGeomCollPtr geom);
6086   bool Validate();
GetDbfType()6087   int GetDbfType()
6088   {
6089     return DbfType;
6090   }
GetMaxTextLen()6091   int GetMaxTextLen()
6092   {
6093     return MaxTextLen;
6094   }
GetFirst()6095   ResultSetShapefileGeometry *GetFirst()
6096   {
6097     return First;
6098   }
6099 
6100 };
6101 
6102 class ResultSetShapefileAnalyzer
6103 {
6104 //
6105 // a class representing a (possible) Shapefile
6106 // corresponding to some generic ResultSet
6107 //
6108 private:
6109   int ColumnCount;
6110   int GeometryColumn;
6111   ResultSetShapefileColumn *Columns;
6112 public:
ResultSetShapefileAnalyzer()6113     ResultSetShapefileAnalyzer()
6114   {
6115     ColumnCount = 0;
6116     GeometryColumn = -1;
6117     Columns = NULL;
6118   }
6119    ~ResultSetShapefileAnalyzer();
6120   bool Validate();
6121   void SetColumnName(int column, const char *name);
6122   void Init(int count);
GetColumnCount()6123   int GetColumnCount()
6124   {
6125     return ColumnCount;
6126   }
GetGeometryColumn()6127   int GetGeometryColumn()
6128   {
6129     return GeometryColumn;
6130   }
6131   void UpdateNull(int column);
6132   void UpdateText(int column, int len);
6133   void UpdateInteger(int column);
6134   void UpdateDouble(int column);
6135   void UpdateGeometry(int column, gaiaGeomCollPtr geom);
6136   void UpdateBlob(int column);
6137   ResultSetShapefileColumn *GetColumn(int column);
6138   ResultSetShapefileColumn *GetGeometry();
6139 };
6140 
6141 class PostGISColumn
6142 {
6143 //
6144 // a class wrapping a PostGIS column
6145 //
6146 private:
6147   wxString ColumnName;          // the column name
6148   bool PrimaryKey;              // Primary Key column
6149   bool Autoincrement;           // Autoincrement Primary Key
6150   bool Nullable;                // IS NULL
6151   int Null;
6152   int Boolean;
6153   int Int8;
6154   int UInt8;
6155   int Int16;
6156   int UInt16;
6157   int Int32;
6158   int UInt32;
6159   int Int64;
6160   int Double;
6161   int Text;
6162   int MaxTextLen;
6163   int Date;
6164   int DateTime;
6165   int Blob;
6166   int Point;
6167   int MultiPoint;
6168   int LineString;
6169   int MultiLineString;
6170   int Polygon;
6171   int MultiPolygon;
6172   int GeometryCollection;
6173   int Srid1;
6174   int Srid2;
6175   int CoordDims1;
6176   int CoordDims2;
6177   int DataType;
6178 public:
6179     PostGISColumn();
~PostGISColumn()6180    ~PostGISColumn()
6181   {;
6182   }
SetName(wxString & name)6183   void SetName(wxString & name)
6184   {
6185     ColumnName = name;
6186   }
GetName()6187   wxString & GetName()
6188   {
6189     return ColumnName;
6190   }
SetNotNull()6191   void SetNotNull()
6192   {
6193     Nullable = false;
6194   }
IsNotNull()6195   bool IsNotNull()
6196   {
6197     if (Nullable == true)
6198       return false;
6199     else
6200       return true;
6201   }
SetPrimaryKey()6202   void SetPrimaryKey()
6203   {
6204     PrimaryKey = true;
6205   }
IsPrimaryKey()6206   bool IsPrimaryKey()
6207   {
6208     return PrimaryKey;
6209   }
IncrNull()6210   void IncrNull()
6211   {
6212     Null++;
6213   }
IncrBoolean()6214   void IncrBoolean()
6215   {
6216     Boolean++;
6217   }
IncrInt8()6218   void IncrInt8()
6219   {
6220     Int8++;
6221   }
IncrUInt8()6222   void IncrUInt8()
6223   {
6224     UInt8++;
6225   }
IncrInt16()6226   void IncrInt16()
6227   {
6228     Int16++;
6229   }
IncrUInt16()6230   void IncrUInt16()
6231   {
6232     UInt16++;
6233   }
IncrInt32()6234   void IncrInt32()
6235   {
6236     Int32++;
6237   }
IncrUInt32()6238   void IncrUInt32()
6239   {
6240     UInt32++;
6241   }
IncrInt64()6242   void IncrInt64()
6243   {
6244     Int64++;
6245   }
IncrDouble()6246   void IncrDouble()
6247   {
6248     Double++;
6249   }
IncrText(int len)6250   void IncrText(int len)
6251   {
6252     Text++;
6253     if (len > MaxTextLen)
6254       MaxTextLen = len;
6255   }
IncrDate()6256   void IncrDate()
6257   {
6258     Date++;
6259   }
IncrDateTime()6260   void IncrDateTime()
6261   {
6262     DateTime++;
6263   }
IncrBlob()6264   void IncrBlob()
6265   {
6266     Blob++;
6267   }
6268   void IncrPoint(int srid, int coord_dims);
6269   void IncrMultiPoint(int srid, int coord_dims);
6270   void IncrLineString(int srid, int coord_dims);
6271   void IncrMultiLineString(int srid, int coord_dims);
6272   void IncrPolygon(int srid, int coord_dims);
6273   void IncrMultiPolygon(int srid, int coord_dims);
6274   void IncrGeometryCollection(int srid, int coord_dims);
6275   bool IsDate(const char *txt);
6276   bool IsDateTime(const char *txt);
GetMaxTextLen()6277   int GetMaxTextLen()
6278   {
6279     return MaxTextLen;
6280   }
6281   bool IsGeometry();
GetDataType()6282   int GetDataType()
6283   {
6284     return DataType;
6285   }
6286   void Prepare();
GetSrid()6287   int GetSrid()
6288   {
6289     return Srid1;
6290   }
GetCoordDims()6291   int GetCoordDims()
6292   {
6293     return CoordDims1;
6294   }
6295 };
6296 
6297 class PostGISIndexField
6298 {
6299 //
6300 // a class wrapping a PostGIS Index field
6301 private:
6302   int SeqNo;
6303   PostGISColumn *ColumnRef;
6304   PostGISIndexField *Next;
6305 public:
PostGISIndexField(int seq,PostGISColumn * col)6306     PostGISIndexField(int seq, PostGISColumn * col)
6307   {
6308     SeqNo = seq;
6309     ColumnRef = col;
6310     Next = NULL;
6311   }
~PostGISIndexField()6312    ~PostGISIndexField()
6313   {;
6314   }
GetSeqNo()6315   int GetSeqNo()
6316   {
6317     return SeqNo;
6318   }
GetColumnRef()6319   PostGISColumn *GetColumnRef()
6320   {
6321     return ColumnRef;
6322   }
SetNext(PostGISIndexField * next)6323   void SetNext(PostGISIndexField * next)
6324   {
6325     Next = next;
6326   }
GetNext()6327   PostGISIndexField *GetNext()
6328   {
6329     return Next;
6330   }
6331 };
6332 
6333 class PostGISIndex
6334 {
6335 //
6336 // a class wrapping a PostGIS Index
6337 private:
6338   bool PrimaryKey;
6339   bool Unique;
6340   wxString Name;
6341   PostGISIndexField *First;
6342   PostGISIndexField *Last;
6343   PostGISIndex *Next;
6344 public:
PostGISIndex(wxString & name)6345     PostGISIndex(wxString & name)
6346   {
6347     Name = name;
6348     PrimaryKey = true;
6349     Unique = true;
6350     First = NULL;
6351     Last = NULL;
6352     Next = NULL;
6353   }
PostGISIndex(wxString & name,bool unique)6354   PostGISIndex(wxString & name, bool unique)
6355   {
6356     Name = name;
6357     PrimaryKey = false;
6358     Unique = unique;
6359     First = NULL;
6360     Last = NULL;
6361     Next = NULL;
6362   }
6363   ~PostGISIndex();
GetName()6364   wxString & GetName()
6365   {
6366     return Name;
6367   }
IsPrimaryKey()6368   bool IsPrimaryKey()
6369   {
6370     return PrimaryKey;
6371   }
IsUnique()6372   bool IsUnique()
6373   {
6374     return Unique;
6375   }
6376   void AddField(int seq, PostGISColumn * column);
GetFirst()6377   PostGISIndexField *GetFirst()
6378   {
6379     return First;
6380   }
SetNext(PostGISIndex * next)6381   void SetNext(PostGISIndex * next)
6382   {
6383     Next = next;
6384   }
GetNext()6385   PostGISIndex *GetNext()
6386   {
6387     return Next;
6388   }
6389 };
6390 
6391 class PostGISHelper
6392 {
6393 //
6394 // a class wrapping a PostGIS table
6395 //
6396 private:
6397   wxString DumbName;
6398   int Count;                    // how many columns
6399   PostGISColumn *Columns;       // array of columns
6400   PostGISIndex *FirstIdx;
6401   PostGISIndex *LastIdx;
6402   bool Autoincrement;
6403 public:
6404     PostGISHelper();
6405    ~PostGISHelper();
6406   void Alloc(int count);
GetCount()6407   int GetCount()
6408   {
6409     return Count;
6410   }
6411   PostGISIndex *AddIndex(wxString & name, bool unique);
6412   PostGISIndex *AddIndex(wxString & name);
6413   PostGISColumn *Find(wxString & name);
GetFirstIndex()6414   PostGISIndex *GetFirstIndex()
6415   {
6416     return FirstIdx;
6417   }
6418   void ExpandIndexFields(MyFrame * mother, PostGISIndex * index,
6419                          wxString & name);
6420   bool IsSingleFieldPrimaryKey();
IsAutoincrement()6421   bool IsAutoincrement()
6422   {
6423     return Autoincrement;
6424   }
6425   void SetName(int pos, const char *name);
6426   void Eval(int pos, sqlite3_int64 val);
6427   void Eval(int pos, double val);
6428   void Eval(int pos, const char *val);
6429   void Eval(int pos, gaiaGeomCollPtr geom);
6430   void EvalBlob(int pos);
6431   void Eval(int pos);
6432   wxString & GetName(int pos, bool to_lower);
6433   bool IsGeometry(int pos);
6434   int GetDataType(int pos);
6435   void GetDataType(int pos, char *definition);
6436   int GetSrid(int pos);
6437   int GetCoordDims(int pos);
6438   void SetColumn(wxString & name, bool isNull, bool pKey);
6439   void GetKeys(MyFrame * mother, wxString & table);
6440   void Prepare();
6441   void OutputBooleanValue(FILE * out, sqlite3_int64 value);
6442   void OutputValue(FILE * out, sqlite3_int64 value);
6443   void OutputValue(FILE * out, double value);
6444   void OutputValue(FILE * out, const char *value);
6445   void OutputValue(FILE * out, gaiaGeomCollPtr value);
6446   void OutputValue(FILE * out, const unsigned char *value, int len);
6447   enum
6448   {
6449     // data types constants
6450     DATA_TYPE_UNDEFINED = 0,
6451     DATA_TYPE_BOOLEAN,
6452     DATA_TYPE_INT8,
6453     DATA_TYPE_UINT8,
6454     DATA_TYPE_INT16,
6455     DATA_TYPE_UINT16,
6456     DATA_TYPE_INT32,
6457     DATA_TYPE_UINT32,
6458     DATA_TYPE_INT64,
6459     DATA_TYPE_UINT64,
6460     DATA_TYPE_DOUBLE,
6461     DATA_TYPE_TEXT,
6462     DATA_TYPE_DATE,
6463     DATA_TYPE_DATETIME,
6464     DATA_TYPE_BLOB,
6465     DATA_TYPE_POINT,
6466     DATA_TYPE_LINESTRING,
6467     DATA_TYPE_POLYGON,
6468     DATA_TYPE_MULTIPOINT,
6469     DATA_TYPE_MULTILINESTRING,
6470     DATA_TYPE_MULTIPOLYGON,
6471     DATA_TYPE_GEOMETRYCOLLECTION,
6472     DATA_TYPE_GEOMETRY
6473   };
6474 };
6475