forked from GeoDaCenter/geoda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGdaConst.cpp
723 lines (648 loc) · 27.9 KB
/
GdaConst.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
/**
* GeoDa TM, Copyright (C) 2011-2015 by Luc Anselin - all rights reserved
*
* This file is part of GeoDa.
*
* GeoDa is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GeoDa is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GdaConst.h"
#include "GeneralWxUtils.h"
#include "GenUtils.h"
#include <wx/mstream.h>
char* GdaConst::raw_zoom_in[] = {
"16 16 48 1",
" g None",
". g #979797",
"+ g #787878",
"@ g #686868",
"# g #717171",
"$ g #8A8A8A",
"% g #909090",
"& g #D6D6D6",
"* g #EFEFEF",
"= g #DEDEDE",
"- g #A3A3A3",
"; g #6D6D6D",
"> g #9F9F9F",
", g #AAAAAA",
"' g #F8F8F8",
") g #C4C4C4",
"! g #929292",
"~ g #F5F5F5",
"{ g #F2F2F2",
"] g #444444",
"^ g #EEEEEE",
"/ g #F6F6F6",
"( g #8E8E8E",
"_ g #8F8F8F",
": g #D5D5D5",
"< g #E8E8E8",
"[ g #E1E1E1",
"} g #F3F3F3",
"| g #D0D0D0",
"1 g #707070",
"2 g #EDEDED",
"3 g #DCDCDC",
"4 g #676767",
"5 g #D8D8D8",
"6 g #C0C0C0",
"7 g #777777",
"8 g #A1A1A1",
"9 g #EBEBEB",
"0 g #828282",
"a g #6B6B6B",
"b g #B2B2B2",
"c g #696969",
"d g #949494",
"e g #CACACA",
"f g #BEBEBE",
"g g #848484",
"h g #747474",
"i g #666666",
" ",
" .+@#$ ",
" #%&*=-;> ",
" #,''''')@ ",
" .!~'{]^{/(_ ",
" +:'{<][<}|1 ",
" @2']]]]]^34 ",
" 15'^[]:[^67 ",
" _8'{<][<90. ",
" ab'}^^},; ",
" >cde3fg#hii ",
" _#@+. iii ",
" iii ",
" ii ",
" ",
" "
};
char* GdaConst::raw_zoom_out[] = {
"16 16 48 1",
" g None",
". g #979797",
"+ g #787878",
"@ g #686868",
"# g #717171",
"$ g #8A8A8A",
"% g #909090",
"& g #D6D6D6",
"* g #EFEFEF",
"= g #DEDEDE",
"- g #A3A3A3",
"; g #6D6D6D",
"> g #9F9F9F",
", g #AAAAAA",
"' g #F8F8F8",
") g #C4C4C4",
"! g #929292",
"~ g #F5F5F5",
"{ g #F2F2F2",
"] g #EDEDED",
"^ g #EEEEEE",
"/ g #F6F6F6",
"( g #8E8E8E",
"_ g #8F8F8F",
": g #D5D5D5",
"< g #E8E8E8",
"[ g #E1E1E1",
"} g #F3F3F3",
"| g #D0D0D0",
"1 g #707070",
"2 g #444444",
"3 g #DCDCDC",
"4 g #676767",
"5 g #D8D8D8",
"6 g #C0C0C0",
"7 g #777777",
"8 g #A1A1A1",
"9 g #EBEBEB",
"0 g #828282",
"a g #6B6B6B",
"b g #B2B2B2",
"c g #696969",
"d g #949494",
"e g #CACACA",
"f g #BEBEBE",
"g g #848484",
"h g #747474",
"i g #666666",
" ",
" .+@#$ ",
" #%&*=-;> ",
" #,''''')@ ",
" .!~'{]^{/(_ ",
" +:'{<[[<}|1 ",
" @]'22222^34 ",
" 15'^[::[^67 ",
" _8'{<[[<90. ",
" ab'}^^},; ",
" >cde3fg#hii ",
" _#@+. iii ",
" iii ",
" ii ",
" ",
" "};
wxString GdaConst::FieldTypeToStr(GdaConst::FieldType ft)
{
if (ft == GdaConst::double_type) return "real";
if (ft == GdaConst::long64_type) return "integer";
if (ft == GdaConst::string_type) return "string";
if (ft == GdaConst::date_type) return "date";
if (ft == GdaConst::placeholder_type) return "placeholder";
return "unknown";
}
std::map<std::string, GdaConst::DataSourceType> GdaConst::datasrc_str_to_type;
std::map<GdaConst::DataSourceType, std::string> GdaConst::datasrc_type_to_str;
std::map<GdaConst::DataSourceType,std::string> GdaConst::datasrc_type_to_prefix;
std::map<GdaConst::DataSourceType,std::string>
GdaConst::datasrc_type_to_fullname;
std::map<GdaConst::DataSourceType, std::set<std::string> >
GdaConst::datasrc_req_flds;
std::map<GdaConst::DataSourceType, std::set<std::string> >
GdaConst::datasrc_opt_flds;
wxString GdaConst::db_field_name_regex;
wxString GdaConst::db_field_name_illegal_regex;
wxString GdaConst::default_field_name_regex;
wxString GdaConst::default_field_name_illegal_regex;
wxString GdaConst::no_field_warning;
wxString GdaConst::db_field_warning;
wxString GdaConst::default_field_warning;
std::map<GdaConst::DataSourceType, int> GdaConst::datasrc_field_lens;
std::map<GdaConst::DataSourceType, int> GdaConst::datasrc_table_lens;
std::map<GdaConst::DataSourceType, wxString> GdaConst::datasrc_field_warning;
std::map<GdaConst::DataSourceType, wxString> GdaConst::datasrc_field_regex;
std::map<GdaConst::DataSourceType, wxString> GdaConst::datasrc_field_illegal_regex;
std::map<GdaConst::DataSourceType, bool> GdaConst::datasrc_field_casesensitive;
wxCursor GdaConst::zoomInCursor;
wxCursor GdaConst::zoomOutCursor;
// Resource Files
const wxString GdaConst::gda_prefs_fname_sqlite("geoda_prefs.sqlite");
const wxString GdaConst::gda_prefs_fname_json("geoda_prefs.json");
const wxString GdaConst::gda_prefs_html_table("html_entries");
const wxString GdaConst::gda_prefs_html_table_menu("menu_title");
const wxString GdaConst::gda_prefs_html_table_url("url");
wxFont* GdaConst::extra_small_font = 0;
wxFont* GdaConst::small_font = 0;
wxFont* GdaConst::medium_font = 0;
wxFont* GdaConst::large_font = 0;
const wxPen* GdaConst::default_myshape_pen=0;
const wxBrush* GdaConst::default_myshape_brush=0;
//background color -- this is light gray
const wxColour GdaConst::backColor(192, 192, 192);
// background color -- this is light gray
const wxColour GdaConst::darkColor(20, 20, 20);
// color of text, frames, points -- this is dark cherry
const wxColour GdaConst::textColor(128, 0, 64);
// outliers color (also used for regression, etc.) -- blue
const wxColour GdaConst::outliers_colour(0, 0, 255);
// envelope color (also used for regression, etc.) -- blue
const wxColour GdaConst::envelope_colour(0, 0, 255);
const wxColour GdaConst::selectable_outline_color(0, 0, 0); // black
const wxColour GdaConst::selectable_fill_color(49, 163, 84); // forest green
const wxColour GdaConst::highlight_color(255, 255, 0); // yellow
const wxColour GdaConst::canvas_background_color(255, 255, 255); // white
const wxColour GdaConst::legend_background_color(255, 255, 255); // white
// Map
const wxSize GdaConst::map_default_size(600, 400);
const int GdaConst::map_default_legend_width = 150;
// this is a light forest green
const wxColour GdaConst::map_default_fill_colour(49, 163, 84);
const wxColour GdaConst::map_default_outline_colour(0, 0, 0);
const wxColour GdaConst::map_default_highlight_colour(255, 255, 0); // yellow
// Connectivity Map
const wxSize GdaConst::conn_map_default_size(480, 350);
// HTML Tan
const wxColour GdaConst::conn_map_default_fill_colour(210, 180, 140);
const wxColour GdaConst::conn_map_default_outline_colour(0, 0, 0);
// HTML DarkBlue
const wxColour GdaConst::conn_map_default_highlight_colour(0, 0, 139);
// Map Movie
const wxColour GdaConst::map_movie_default_fill_colour(49, 163, 84);
const wxColour GdaConst::map_movie_default_highlight_colour(224, 113, 182);
// Histogram
const wxSize GdaConst::hist_default_size(600, 500);
// Table
const wxString GdaConst::placeholder_str("<placeholder>");
const wxString GdaConst::table_frame_title("Table");
const wxSize GdaConst::table_default_size(750, 500);
const wxColour GdaConst::table_no_edit_color(80, 80, 80); // grey
const wxColour GdaConst::table_row_sel_color(230, 220, 40); // golden
const wxColour GdaConst::table_col_sel_color(181, 213, 251); // light blue
// following is the combination of the above two. Light greenish
const wxColour GdaConst::table_row_and_col_sel_color(206, 217, 146);
// Scatterplot
const wxSize GdaConst::scatterplot_default_size(530, 530);
const wxColour GdaConst::scatterplot_scale_color(0, 0, 0);
//const wxColour GdaConst::scatterplot_regression_color(0, 79, 241);
//const wxColour GdaConst::scatterplot_regression_selected_color(204, 41, 44);
//const wxColour GdaConst::scatterplot_regression_excluded_color(0, 146, 31);
const wxColour GdaConst::scatterplot_regression_color(100, 0, 110);
const wxColour GdaConst::scatterplot_regression_selected_color(204, 41, 44);
const wxColour GdaConst::scatterplot_regression_excluded_color(0, 79, 241);
const wxColour GdaConst::scatterplot_origin_axes_color(120, 120, 120);
wxPen* GdaConst::scatterplot_reg_pen = 0;
wxPen* GdaConst::scatterplot_reg_selected_pen = 0;
wxPen* GdaConst::scatterplot_reg_excluded_pen = 0;
wxPen* GdaConst::scatterplot_scale_pen = 0;
wxPen* GdaConst::scatterplot_origin_axes_pen = 0;
// Bubble Chart
const wxSize GdaConst::bubble_chart_default_size(550, 400);
const int GdaConst::bubble_chart_default_legend_width = 150;
// 3D Plot
// yellow
const wxColour GdaConst::three_d_plot_default_highlight_colour(255, 255, 0);
// white
const wxColour GdaConst::three_d_plot_default_point_colour(255, 255, 255);
// black
const wxColour GdaConst::three_d_plot_default_background_colour(0, 0, 0);
const wxSize GdaConst::three_d_default_size(700, 500);
// Boxplot
const wxSize GdaConst::boxplot_default_size(300, 500);
const wxColour GdaConst::boxplot_point_color(0, 0, 255);
const wxColour GdaConst::boxplot_median_color(219, 99, 28); // orange
const wxColour GdaConst::boxplot_mean_point_color(20, 200, 20); // green
const wxColour GdaConst::boxplot_q1q2q3_color(128, 0, 64); // dark cherry
// PCP (Parallel Coordinate Plot)
const wxSize GdaConst::pcp_default_size(600, 450);
const wxColour GdaConst::pcp_line_color(128, 0, 64); // dark cherry
const wxColour GdaConst::pcp_horiz_line_color(0, 98, 0); // dark green
// Averages Chart
const wxSize GdaConst::line_chart_default_size(800, 620);
// colors defined in init()
wxColour GdaConst::ln_cht_clr_regimes_hl;
wxColour GdaConst::ln_cht_clr_sel_dark;
wxColour GdaConst::ln_cht_clr_exl_dark;
wxColour GdaConst::ln_cht_clr_tm1_dark;
wxColour GdaConst::ln_cht_clr_tm2_dark;
wxColour GdaConst::ln_cht_clr_sel_light;
wxColour GdaConst::ln_cht_clr_exl_light;
wxColour GdaConst::ln_cht_clr_tm1_light;
wxColour GdaConst::ln_cht_clr_tm2_light;
// Conditional View
const wxSize GdaConst::cond_view_default_size(700, 500);
// Category Classification
const wxSize GdaConst::cat_classif_default_size(780, 520);
const wxSize GdaConst::weights_man_dlg_default_size(700, 500);
const wxSize GdaConst::data_change_type_frame_default_size(600, 400);
std::vector<wxColour> GdaConst::qualitative_colors(10);
const wxString GdaConst::html_submenu_title("Web Plugins");
/**
Certain objects such as wxFont objects need to be created after
wxWidgets is sufficiently initialized. This function will be
called just once by GdaApp::OnInit() when the program begins.
*/
void GdaConst::init()
{
// standard GeoDa font creation. Through experimentation, as of the
// wxWidgets 2.9.1 release, it appears that neither wxFont::SetPixelSize()
// nor wxFont::SetPointSize() results in fonts of nearly similar vertical
// height on all of our three supported platforms, Mac, Linux and Windows.
// Therefore, at present we will specify sizes differently on each
// platform according to experimentation. When we specify the font
// using point size, it seems that Linux and Windows are very similar, but
// Mac is considerably smaller.
int ref_extra_small_pt_sz = 6;
int ref_small_pt_sz = 8;
int ref_medium_pt_sz = 12;
int ref_large_pt_sz = 16;
if (GeneralWxUtils::isMac()) {
ref_extra_small_pt_sz += 4;
ref_small_pt_sz += 4;
ref_medium_pt_sz += 5;
ref_large_pt_sz += 5;
}
extra_small_font = wxFont::New(ref_extra_small_pt_sz,
wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL,
wxFONTWEIGHT_NORMAL, false, wxEmptyString,
wxFONTENCODING_DEFAULT);
small_font = wxFont::New(ref_small_pt_sz, wxFONTFAMILY_SWISS,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false,
wxEmptyString, wxFONTENCODING_DEFAULT);
medium_font = wxFont::New(ref_medium_pt_sz, wxFONTFAMILY_SWISS,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false,
wxEmptyString, wxFONTENCODING_DEFAULT);
large_font = wxFont::New(ref_large_pt_sz, wxFONTFAMILY_SWISS,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false,
wxEmptyString, wxFONTENCODING_DEFAULT);
// GdaShape resources
default_myshape_pen = wxBLACK_PEN;
default_myshape_brush = wxTRANSPARENT_BRUSH;
//ScatterPlot and ScatterNewPlot resources
scatterplot_reg_pen = new wxPen(scatterplot_regression_color, 2);
scatterplot_reg_selected_pen =
new wxPen(scatterplot_regression_selected_color, 2);
scatterplot_reg_excluded_pen =
new wxPen(scatterplot_regression_excluded_color, 2);
scatterplot_scale_pen = new wxPen(scatterplot_scale_color);
scatterplot_origin_axes_pen =
new wxPen(scatterplot_origin_axes_color, 1, wxSHORT_DASH);
wxBitmap zoomin_bitmap(GdaConst::raw_zoom_in);
zoomInCursor = wxCursor(zoomin_bitmap.ConvertToImage());
wxBitmap zoomout_bitmap(GdaConst::raw_zoom_out);
zoomOutCursor = wxCursor(zoomout_bitmap.ConvertToImage());
// Averages Chart Colors
ln_cht_clr_regimes_hl = wxColour(255,255,102); // yellow #FFFF66
ln_cht_clr_sel_dark = wxColour(204, 41, 44); // red
ln_cht_clr_sel_light = GdaColorUtils::ChangeBrightness(ln_cht_clr_sel_dark,125);
ln_cht_clr_exl_dark = wxColour(0, 79, 241); // blue
ln_cht_clr_exl_light = GdaColorUtils::ChangeBrightness(ln_cht_clr_exl_dark, 125);
ln_cht_clr_tm1_dark = wxColour(147, 36, 255); // purple
ln_cht_clr_tm1_light = GdaColorUtils::ChangeBrightness(ln_cht_clr_tm1_dark, 125);
ln_cht_clr_tm2_dark = wxColour(115, 61, 26); // brown
ln_cht_clr_tm2_light = GdaColorUtils::ChangeBrightness(ln_cht_clr_tm2_dark, 125);
// Following 4 colors are colour-blind safe colors from Color Brewer 2.0
// LineChartStats::
// wxColour _sample0_clr_light(178,223,138); // light green
// wxColour _sample1_clr_light(166,206,227); // light blue
// wxColour _sample0_clr_dark(51,160,44); // dark green
// wxColour _sample1_clr_dark(31,120,180); // dark blue
// From Colorbrewer 2.0
qualitative_colors[0] = wxColour(166, 206, 227);
qualitative_colors[1] = wxColour(31, 120, 180);
qualitative_colors[2] = wxColour(178, 223, 138);
qualitative_colors[3] = wxColour(51, 160, 44);
qualitative_colors[4] = wxColour(251, 154, 153);
qualitative_colors[5] = wxColour(227, 26, 28);
qualitative_colors[6] = wxColour(253, 191, 111);
qualitative_colors[7] = wxColour(255, 127, 0);
qualitative_colors[8] = wxColour(202, 178, 214);
qualitative_colors[9] = wxColour(106, 61, 154);
// Filenames or field names start with a letter, and they can contain any
// combination of the letters A through Z, the digits 0 through 9,
// the colon (:) (in dBASE II field names only), and the underscore (_)
default_field_name_regex = "^[a-zA-Z][a-zA-Z0-9_]*$";
default_field_name_illegal_regex = "((^[^a-zA-Z]+)|[^a-zA-Z0-9_]+)";
// There might be a problem when field name contains ' or " when using
// INSERT sql clause to export/save table.
// Details: no problem in Postgresq; error in Oracle; unknown in MySQL
db_field_name_regex = "[^'\"]+";
db_field_name_illegal_regex = "['\"]+";
// Warning message for valid field name of different field type
no_field_warning = "There is no restriction of variable name.";
db_field_warning = "A valid variable name should not contains any\n"
"quotes (' or \").";
default_field_warning =
"A valid variable name should have the first character be a\n"
"letter, and the remaining characters be either letters,\n"
"numbers or underscores.";
datasrc_str_to_type["DBF"] = ds_dbf;
datasrc_type_to_prefix[ds_dbf] = "";
datasrc_type_to_fullname[ds_dbf] = "dBase";
datasrc_table_lens[ds_dbf] = 128;
datasrc_field_lens[ds_dbf] = 10;
datasrc_field_warning[ds_dbf] = default_field_warning;
datasrc_field_regex[ds_dbf] = default_field_name_regex;
datasrc_field_illegal_regex[ds_dbf] = default_field_name_illegal_regex;
datasrc_field_casesensitive[ds_dbf] = false;
datasrc_str_to_type["ESRI Shapefile"] = ds_shapefile;
datasrc_type_to_prefix[ds_shapefile] = "";
datasrc_type_to_fullname[ds_shapefile] = "ESRI Shapefile";
// share the same with DBF
datasrc_table_lens[ds_shapefile] = 128;
datasrc_field_lens[ds_shapefile] = 10;
datasrc_field_warning[ds_shapefile] = default_field_warning;
datasrc_field_regex[ds_shapefile] = default_field_name_regex;
datasrc_field_illegal_regex[ds_shapefile] = default_field_name_illegal_regex;
datasrc_field_casesensitive[ds_shapefile] = false;
datasrc_str_to_type["FileGDB"] = ds_esri_file_geodb;
datasrc_type_to_prefix[ds_esri_file_geodb] = "";
datasrc_type_to_fullname[ds_esri_file_geodb] = "ESRI File GeoDatabase";
//http://webhelp.esri.com/arcgisserver/9.3/java/index.htm#geodatabases/file_g-1445296021.htm
datasrc_table_lens[ds_esri_file_geodb] = 160;
datasrc_field_lens[ds_esri_file_geodb] = 64;
datasrc_field_warning[ds_esri_file_geodb] = no_field_warning;
datasrc_field_regex[ds_esri_file_geodb] = wxEmptyString;
datasrc_field_casesensitive[ds_esri_file_geodb] = true;
datasrc_str_to_type["PGeo"] = ds_esri_personal_gdb;
datasrc_type_to_prefix[ds_esri_personal_gdb] = "PGeo";
datasrc_type_to_fullname[ds_esri_personal_gdb] ="ESRI Personal GeoDatabase";
//follows Microsoft Access .mdb
datasrc_table_lens[ds_esri_personal_gdb] = 64;
datasrc_field_lens[ds_esri_personal_gdb] = 64;
datasrc_field_warning[ds_esri_personal_gdb] = no_field_warning;
datasrc_field_regex[ds_esri_personal_gdb] = wxEmptyString;
datasrc_field_casesensitive[ds_esri_personal_gdb] = true;
datasrc_str_to_type["SDE"] = ds_esri_arc_sde;
datasrc_type_to_prefix[ds_esri_arc_sde] = "SDE:";
datasrc_type_to_fullname[ds_esri_arc_sde] = "ESRI ArcSDE";
//http://help.arcgis.com/en/geodatabase/10.0/sdk/arcsde/api/constants_define_limits.htm
//ArcSDE doesn't support writing, so following will be ignored
datasrc_table_lens[ds_esri_arc_sde] = 32;
datasrc_field_lens[ds_esri_arc_sde] = 32;
datasrc_field_warning[ds_esri_arc_sde] = default_field_warning;
datasrc_field_regex[ds_esri_arc_sde] = default_field_name_regex;
datasrc_field_illegal_regex[ds_esri_arc_sde]=default_field_name_illegal_regex;
datasrc_field_casesensitive[ds_esri_arc_sde] = true;
datasrc_str_to_type["CSV"] = ds_csv;
datasrc_type_to_prefix[ds_csv] = "";
datasrc_type_to_fullname[ds_csv] = "Comma Separated Value";
//CSV should have no restriction except the comma character, but we give
//a limitation to a reasonable 128 length
datasrc_table_lens[ds_csv] = 128;
datasrc_field_lens[ds_csv] = 128;
datasrc_field_warning[ds_csv] = "Field name should not contains comma(,).";
datasrc_field_regex[ds_csv] = "[^,]+";
datasrc_field_illegal_regex[ds_csv] = "[,]+";
datasrc_field_casesensitive[ds_csv] = true;
datasrc_str_to_type["GeoJSON"] = ds_geo_json;
datasrc_type_to_prefix[ds_geo_json] = "";
datasrc_type_to_fullname[ds_geo_json] = "GeoJSON";
//GeoJSON seams like has no restriction
datasrc_table_lens[ds_geo_json] = 128;
datasrc_field_lens[ds_geo_json] = 128;
datasrc_field_warning[ds_geo_json] = db_field_warning;
datasrc_field_regex[ds_geo_json] = db_field_name_regex;
datasrc_field_illegal_regex[ds_geo_json] = db_field_name_illegal_regex;
datasrc_field_casesensitive[ds_geo_json] = true;
datasrc_str_to_type["GML"] = ds_gml;
datasrc_type_to_prefix[ds_gml] = "";
datasrc_type_to_fullname[ds_gml] = "Geography Markup Language";
//http://en.wikipedia.org/wiki/XML
datasrc_table_lens[ds_gml] = 128;
datasrc_field_lens[ds_gml] = 128;
datasrc_field_warning[ds_gml] =
"A valid variable name should only contains either letters,\n"
"numbers or underscores. Brackets (e.g. < or > ) are not allowed.";
datasrc_field_regex[ds_gml] = "[^<> ]+";
datasrc_field_illegal_regex[ds_gml] = "[<> ]+";
datasrc_field_casesensitive[ds_gml] = true;
datasrc_str_to_type["KML"] = ds_kml;
datasrc_str_to_type["LIBKML"] = ds_kml;
datasrc_type_to_prefix[ds_kml] = "";
datasrc_type_to_fullname[ds_kml] = "Keyhole Markup Language";
datasrc_table_lens[ds_kml] = 128;
datasrc_field_lens[ds_kml] = 128;
datasrc_field_warning[ds_kml] = db_field_warning;
datasrc_field_regex[ds_kml] = db_field_name_regex;
datasrc_field_illegal_regex[ds_kml] = db_field_name_illegal_regex;
datasrc_field_casesensitive[ds_kml] = true;
datasrc_str_to_type["MapInfo File"] = ds_mapinfo;
datasrc_type_to_prefix[ds_mapinfo] = "";
datasrc_type_to_fullname[ds_mapinfo] = "MapInfo File (TAB and MIF/MID)";
datasrc_table_lens[ds_mapinfo] = 128;
datasrc_field_lens[ds_mapinfo] = 32;
datasrc_field_warning[ds_mapinfo] = default_field_warning;
datasrc_field_regex[ds_mapinfo] = default_field_name_regex;
datasrc_field_illegal_regex[ds_mapinfo] = default_field_name_illegal_regex;
datasrc_field_casesensitive[ds_mapinfo] = true;
datasrc_str_to_type["MySQL"] = ds_mysql;
datasrc_type_to_prefix[ds_mysql] = "MYSQL:";
datasrc_type_to_fullname[ds_mysql] = "MySQL";
datasrc_table_lens[ds_mysql] = 64;
datasrc_field_lens[ds_mysql] = 64;
datasrc_field_warning[ds_mysql] = db_field_warning;
datasrc_field_regex[ds_mysql] = db_field_name_regex;
datasrc_field_illegal_regex[ds_mysql] = db_field_name_illegal_regex;
datasrc_field_casesensitive[ds_mysql] = true;
datasrc_str_to_type["OCI"] = ds_oci;
datasrc_type_to_prefix[ds_oci] = "OCI:";
datasrc_type_to_fullname[ds_oci] = "Oracle Spatial";
datasrc_table_lens[ds_oci] = 30;
datasrc_field_lens[ds_oci] = 30;
datasrc_field_warning[ds_oci] = db_field_warning;
datasrc_field_regex[ds_oci] = db_field_name_regex;
datasrc_field_illegal_regex[ds_oci] = db_field_name_illegal_regex;
datasrc_field_casesensitive[ds_oci] = false;
datasrc_str_to_type["PostgreSQL"] = ds_postgresql;
datasrc_type_to_prefix[ds_postgresql] = "PG:";
datasrc_type_to_fullname[ds_postgresql] = "PostgreSQL / PostGIS";
datasrc_table_lens[ds_postgresql] = 31;
datasrc_field_lens[ds_postgresql] = 31;
datasrc_field_warning[ds_postgresql] = db_field_warning;
datasrc_field_regex[ds_postgresql] = db_field_name_regex;
datasrc_field_illegal_regex[ds_postgresql] = db_field_name_illegal_regex;
datasrc_field_casesensitive[ds_postgresql] = true;
datasrc_str_to_type["CartoDB"] = ds_cartodb;
datasrc_type_to_prefix[ds_cartodb] = "CartoDB:";
datasrc_type_to_fullname[ds_cartodb] = "CartoDB";
datasrc_table_lens[ds_cartodb] = 31;
datasrc_field_lens[ds_cartodb] = 31;
datasrc_field_warning[ds_cartodb] = db_field_warning;
datasrc_field_regex[ds_cartodb] = db_field_name_regex;
datasrc_field_illegal_regex[ds_cartodb] = db_field_name_illegal_regex;
datasrc_field_casesensitive[ds_cartodb] = true;
datasrc_str_to_type["SQLite"] = ds_sqlite;
datasrc_type_to_prefix[ds_sqlite] = "";
datasrc_type_to_fullname[ds_sqlite] = "SQLite / Spatialite";
datasrc_table_lens[ds_sqlite] = 128;
datasrc_field_lens[ds_sqlite] = 128;
datasrc_field_warning[ds_sqlite] = no_field_warning;
datasrc_field_regex[ds_sqlite] = wxEmptyString;
datasrc_field_illegal_regex[ds_sqlite] = wxEmptyString;
datasrc_field_casesensitive[ds_sqlite] = true;
datasrc_str_to_type["GPKG"] = ds_gpkg;
datasrc_type_to_prefix[ds_gpkg] = "";
datasrc_type_to_fullname[ds_gpkg] = "GeoPackage";
datasrc_table_lens[ds_gpkg] = 128;
datasrc_field_lens[ds_gpkg] = 128;
datasrc_field_warning[ds_gpkg] = no_field_warning;
datasrc_field_regex[ds_gpkg] = wxEmptyString;
datasrc_field_illegal_regex[ds_gpkg] = wxEmptyString;
datasrc_field_casesensitive[ds_gpkg] = true;
datasrc_str_to_type["WFS"] = ds_wfs;
datasrc_type_to_prefix[ds_wfs] = "WFS:";
datasrc_type_to_fullname[ds_wfs] = "OGC Web Feature Service";
datasrc_table_lens[ds_wfs] = 128;
datasrc_field_lens[ds_wfs] = 128;
datasrc_field_warning[ds_wfs] = no_field_warning;
datasrc_field_regex[ds_wfs] = wxEmptyString;
datasrc_field_illegal_regex[ds_wfs] = wxEmptyString;
datasrc_field_casesensitive[ds_wfs] = true;
// Since XLS can be dBase, we use dBase as its field name limitation
datasrc_str_to_type["XLS"] = ds_xls;
datasrc_type_to_prefix[ds_xls] = "";
datasrc_type_to_fullname[ds_xls] = "Microsoft Excel";
datasrc_table_lens[ds_xls] = 128;
datasrc_field_lens[ds_xls] = 10;
datasrc_field_warning[ds_xls] = default_field_warning;
datasrc_field_regex[ds_xls] = default_field_name_regex;
datasrc_field_illegal_regex[ds_xls] = default_field_name_illegal_regex;
datasrc_field_casesensitive[ds_xls] = false;
datasrc_str_to_type["XLSX"] = ds_xlsx;
datasrc_type_to_prefix[ds_xlsx] = "";
datasrc_type_to_fullname[ds_xlsx] = "Microsoft Excel Extensions";
datasrc_table_lens[ds_xlsx] = 128;
datasrc_field_lens[ds_xlsx] = 10;
datasrc_field_warning[ds_xlsx] = default_field_warning;
datasrc_field_regex[ds_xlsx] = default_field_name_regex;
datasrc_field_illegal_regex[ds_xlsx] = default_field_name_illegal_regex;
datasrc_field_casesensitive[ds_xlsx] = false;
datasrc_str_to_type["ODS"] = ds_ods;
datasrc_type_to_prefix[ds_ods] = "";
datasrc_type_to_fullname[ds_ods] = "Open Office Spreadsheet";
datasrc_table_lens[ds_ods] = 128;
datasrc_field_lens[ds_ods] = 128;
datasrc_field_warning[ds_ods] = default_field_warning;
datasrc_field_regex[ds_ods] = default_field_name_regex;
datasrc_field_illegal_regex[ds_ods] = default_field_name_illegal_regex;
datasrc_field_casesensitive[ds_ods] = false;
//not supported yet
//datasrc_str_to_type["OSM"] = ds_osm;
//datasrc_type_to_prefix[ds_xls] = "";
//datasrc_type_to_fullname[ds_xls] = "OSM";
//datasrc_str_to_type["MSSQLSpatial"] = ds_ms_sql;
//datasrc_type_to_prefix[ds_ms_sql] = "MSSQL:";
//datasrc_type_to_fullname[ds_ms_sql] = "Microsoft SQL Server";
//datasrc_str_to_type["ArcObjects"] = ds_esri_arc_obj;
//datasrc_type_to_prefix[ds_esri_arc_obj] = "AO";
//datasrc_type_to_fullname[ds_esri_arc_obj] = "ESRI ArcObjects";
//datasrc_str_to_type["ODBC"] = ds_odbc;
//datasrc_type_to_prefix[ds_odbc] = "ODBC:";
//datasrc_type_to_fullname[ds_odbc] = "ODBC";
typedef std::map<std::string, DataSourceType> ds_map;
for (ds_map::iterator it=datasrc_str_to_type.begin();
it != datasrc_str_to_type.end(); it++) {
datasrc_type_to_str[it->second] = it->first;
datasrc_req_flds[it->second] = std::set<std::string>();
datasrc_opt_flds[it->second] = std::set<std::string>();
}
typedef std::map<DataSourceType, std::set<std::string> > ds_fld_map;
for (ds_fld_map::iterator it=datasrc_req_flds.begin();
it != datasrc_req_flds.end(); it++) {
DataSourceType type = it->first;
if (type == ds_esri_file_geodb || type == ds_csv ||
type == ds_dbf || type == ds_gml ||
type == ds_kml || type == ds_mapinfo ||
type == ds_shapefile || type == ds_sqlite ||
type == ds_gpkg || type == ds_xls ||
type == ds_geo_json || type == ds_osm)
{
// These are simple files, and a file name must be supplied
it->second.insert("file");
} else if (type == ds_esri_arc_obj || type == ds_esri_personal_gdb ||
type == ds_esri_arc_sde || type == ds_mysql ||
type == ds_ms_sql || type == ds_oci || type == ds_odbc)
{
it->second.insert("user");
it->second.insert("pwd");
it->second.insert("host");
it->second.insert("port");
it->second.insert("db_name");
} else if ( type == ds_wfs) {
it->second.insert("url");
} else if (type == ds_postgresql) {
it->second.insert("db_name");
}
}
for (ds_fld_map::iterator it=datasrc_opt_flds.begin();
it != datasrc_opt_flds.end(); it++) {
DataSourceType type = it->first;
if (type == ds_postgresql) {
it->second.insert("user");
it->second.insert("pwd");
it->second.insert("host");
it->second.insert("port");
}
}
}