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