-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy pathGlobalSettingsInfo.h
More file actions
275 lines (259 loc) · 9.25 KB
/
GlobalSettingsInfo.h
File metadata and controls
275 lines (259 loc) · 9.25 KB
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
#pragma once
#include "MapWinGIS_i.h"
#include <map>
#pragma warning(disable:4482) // non-standard extension used - for names of enumerations
struct GlobalSettingsInfo
{
const double METERS_PER_DEGREE = 110899.999942;
tkProxyAuthentication proxyAuthentication;
bool forceHideLabels;
bool ogrLayerForceUpdateMode;
bool autoChooseRenderingHintForLabels;
long maxReprojectionShapeCount;
ICallback* callback;
double minPolygonArea;
double minAreaToPerimeterRatio;
double clipperGcsMultiplicationFactor;
bool shapefileFastMode;
double invalidShapesBufferDistance;
tkGridProxyMode gridProxyMode;
bool shapefileFastUnion;
CString gdalErrorMessage;
tkCompositingQuality labelsCompositingQuality;
tkSmoothingMode labelsSmoothingMode;
std::map<tkLocalizedStrings, CStringW> shortUnitStrings;
bool zoomToFirstLayer;
tkCollisionMode labelsCollisionMode;
tkGridProxyFormat gridProxyFormat;
double MaxDirectGridSizeMb;
int maxUniqueValuesCount;
bool randomColorSchemeForGrids;
PredefinedColorScheme defaultColorSchemeForGrids;
tkShapeValidationMode inputValidation;
tkShapeValidationMode outputValidation;
tkGeometryEngine geometryEngine;
bool saveGridColorSchemeToFile;
int xmlFileVersion;
CString xmlFilenameEncoding;
tkTiffCompression tiffCompression;
tkRasterOverviewCreation rasterOverviewCreation;
int minOverviewWidth;
tkGDALResamplingMethod rasterOverviewResampling;
int tilesThreadPoolSize;
bool loadSymbologyOnAddLayer;
int tilesMaxZoomOnProjectionMismatch;
tkInterpolationMode imageUpsamplingMode;
tkInterpolationMode imageDownsamplingMode;
tkInterpolationMode gridUpsamplingMode; // currently not used
tkInterpolationMode gridDownsamplingMode;
tkOgrEncoding ogrEncoding;
int ogrLayerMaxFeatureCount;
bool autoChooseOgrLoadingMode;
bool useSchemesForStyles;
bool saveOgrLabels;
int getOgrMaxLabelCount() { return ogrLayerMaxFeatureCount; }
int ctorCount;
int dtorCount;
bool attachMapCallbackToLayers;
int hotTrackingMaxShapeCount;
OLE_COLOR identifierColor;
BSTR emptyBstr;
BSTR gdalBstr;
bool allowLayersWithoutProjection;
bool allowProjectionMismatch;
bool reprojectLayersOnAdding;
double mouseTolerance;
bool commonCollisionListForCharts;
bool commonCollisionListForLabels;
bool useShortUrlForTiles;
CString floatNumberFormat;
tkPixelOffsetMode pixelOffsetMode;
bool suppressGdalErrors;
bool forceReadOnlyModeForGdalRasters;
CString bingApiKey;
CString hereAppId;
CString hereAppCode;
bool gridFavorGreyScale;
bool gridUseHistogram;
bool overrideLocalCallback;
bool cacheDbfRecords;
bool cacheShapeRenderingData;
bool wmsDiskCaching;
tkCallbackVerbosity callbackVerbosity;
bool ogrShareConnection;
bool ogrListAllGeometryTypes;
bool ogrInterpretYNStringAsBoolean;
bool allowLayersWithIncompleteReprojection;
CString httpUserAgent;
~GlobalSettingsInfo()
{
SysFreeString(emptyBstr);
SysFreeString(gdalBstr);
if (callback)
callback->Release();
}
GlobalSettingsInfo::GlobalSettingsInfo()
{
allowLayersWithIncompleteReprojection = false;
ogrInterpretYNStringAsBoolean = true;
ogrListAllGeometryTypes = true;
ogrShareConnection = false;
callbackVerbosity = cvAll;
wmsDiskCaching = true;
cacheShapeRenderingData = false;
cacheDbfRecords = true;
overrideLocalCallback = true;
proxyAuthentication = asBasic;
httpUserAgent = "MapWinGIS/5.4"; // TODO Use VERSION Macros
hereAppId = "";
hereAppCode = "";
bingApiKey = "";
forceReadOnlyModeForGdalRasters = false;
forceHideLabels = false;
ogrLayerForceUpdateMode = false;
autoChooseRenderingHintForLabels = true;
suppressGdalErrors = false;
pixelOffsetMode = pomDefault;
floatNumberFormat = "%g";
maxReprojectionShapeCount = 50000;
useShortUrlForTiles = false;
callback = nullptr;
mouseTolerance = 20;
allowLayersWithoutProjection = true;
allowProjectionMismatch = true;
reprojectLayersOnAdding = false;
emptyBstr = SysAllocString(L"");
gdalBstr = SysAllocString(L"GDAL");
identifierColor = RGB(30, 144, 255);
hotTrackingMaxShapeCount = 200;
attachMapCallbackToLayers = true;
ctorCount = 0;
dtorCount = 0;
saveOgrLabels = false;
useSchemesForStyles = false;
autoChooseOgrLoadingMode = true;
ogrLayerMaxFeatureCount = 50000;
ogrEncoding = oseUtf8;
imageUpsamplingMode = imNone;
imageDownsamplingMode = imBilinear;
gridUpsamplingMode = imNone;
gridDownsamplingMode = imBilinear;
rasterOverviewResampling = tkGDALResamplingMethod::grmNearest;
minOverviewWidth = 512;
rasterOverviewCreation = tkRasterOverviewCreation::rocAuto;
tiffCompression = tkTiffCompression::tkmLZW;
labelsCollisionMode = tkCollisionMode::LocalList;
minPolygonArea = 1.0;
minAreaToPerimeterRatio = 0.0001;
clipperGcsMultiplicationFactor = 100000.0;
shapefileFastMode = false;
invalidShapesBufferDistance = 0.001;
shapefileFastUnion = true;
labelsCompositingQuality = HighQuality;
labelsSmoothingMode = HighQualityMode;
zoomToFirstLayer = true;
gridProxyFormat = gpfBmpProxy;
MaxDirectGridSizeMb = 20.0;
gridProxyMode = gpmAuto;
maxUniqueValuesCount = 100;
randomColorSchemeForGrids = true;
defaultColorSchemeForGrids = SummerMountains;
inputValidation = tkShapeValidationMode::NoValidation;
outputValidation = tkShapeValidationMode::NoValidation;
geometryEngine = tkGeometryEngine::engineGeos;
saveGridColorSchemeToFile = true;
xmlFileVersion = 2;
xmlFilenameEncoding = "utf8";
tilesThreadPoolSize = 5;
loadSymbologyOnAddLayer = true;
tilesMaxZoomOnProjectionMismatch = 6;
commonCollisionListForCharts = true;
commonCollisionListForLabels = true;
gridFavorGreyScale = true;
gridUseHistogram = true;
shortUnitStrings[lsHectars] = L"ha";
shortUnitStrings[lsMeters] = L"m";
shortUnitStrings[lsKilometers] = L"km";
shortUnitStrings[lsSquareKilometers] = L"sq.km";
shortUnitStrings[lsSquareMeters] = L"sq.m";
shortUnitStrings[lsMapUnits] = L"mu";
shortUnitStrings[lsSquareMapUnits] = L"sq.mu";
shortUnitStrings[lsMiles] = L"mi";
shortUnitStrings[lsFeet] = L"ft";
shortUnitStrings[lsLatitude] = L"Lat";
shortUnitStrings[lsLongitude] = L"Lng";
shortUnitStrings[lsRadians] = L"rad";
shortUnitStrings[lsNorthEast] = L"NE";
shortUnitStrings[lsSouthEast] = L"SE";
shortUnitStrings[lsSouthWest] = L"SW";
shortUnitStrings[lsNorthWest] = L"NW";
shortUnitStrings[lsNorth] = L"N";
shortUnitStrings[lsEast] = L"E";
shortUnitStrings[lsSouth] = L"S";
shortUnitStrings[lsWest] = L"W";
shortUnitStrings[lsSquareFeet] = L"sq.ft";
shortUnitStrings[lsAcres] = L"ac";
shortUnitStrings[lsSquareMiles] = L"sq.mi";
}
static BSTR CreateEmptyBSTR()
{
//USES_CONVERSION;
return A2BSTR("");
}
// *******************************************************
// GetTiffCompression()
// *******************************************************
CString GetTiffCompression()
{
return GdalHelper::TiffCompressionToString(tiffCompression);
}
PredefinedColorScheme GetGridColorScheme()
{
PredefinedColorScheme coloring = defaultColorSchemeForGrids;
if (randomColorSchemeForGrids)
{
srand(static_cast<unsigned>(time(nullptr)));
const int r = rand();
coloring = static_cast<PredefinedColorScheme>(r % 7);
}
return coloring;
}
CStringW GetLocalizedString(const tkLocalizedStrings s)
{
return shortUnitStrings.find(s) != shortUnitStrings.end() ? shortUnitStrings[s] : L"";
}
double GetMinPolygonArea(IGeoProjection* proj)
{
VARIANT_BOOL isGeographic;
if (proj == nullptr)
return minPolygonArea;
proj->get_IsGeographic(&isGeographic);
return this->GetMinPolygonArea(isGeographic);
}
double GetMinPolygonArea(const VARIANT_BOOL isGeographic)
{
if (isGeographic)
{
return minPolygonArea / pow(METERS_PER_DEGREE, 2.0); // degrees to meters
}
return minPolygonArea;
}
void SetGdalUtf8(const bool turnOn)
{
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", turnOn ? "YES" : "NO");
}
int GetTilesThreadPoolSize()
{
const int size = tilesThreadPoolSize > 20 ? 20 : tilesThreadPoolSize;
return size;
}
double GetInvalidShapeBufferDistance(const tkUnitsOfMeasure units)
{
double val = invalidShapesBufferDistance;
if (Utility::ConvertDistance(units, umMeters, val))
{
return invalidShapesBufferDistance / val;
}
return invalidShapesBufferDistance;
}
};