-
Notifications
You must be signed in to change notification settings - Fork 1
/
Config.cs
82 lines (72 loc) · 2.16 KB
/
Config.cs
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
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.IO;
namespace RiverTrace
{
enum ImageSourceProtocol
{
bing,
tms,
wms
}
class ConfigData
{
public int zoom;
public double lat1;
public double lon1;
public double lat2;
public double lon2;
public int iterationCount;
public double shoreContrast;
public double scanRadiusScale;
public double angleRange;
public double advanceRate;
public double noiseReduction;
public double resamplingFactor;
public double simplificationStrength;
public bool generateDebugInfo;
public bool enableCaching;
public string imageSourceName;
[JsonConverter(typeof(StringEnumConverter))]
public ImageSourceProtocol imageSourceProtocol;
public string imageSourceUrl;
public ConfigData()
{
zoom = 15;
lat1 = 64.9035637;
lon1 = 52.2209239;
lat2 = 64.9032122;
lon2 = 52.2213061;
iterationCount = 300;
shoreContrast = 10.0;
scanRadiusScale = 2.0;
angleRange = 90.0;
advanceRate = 0.5;
noiseReduction = 0.5;
resamplingFactor = 1.5;
simplificationStrength = 0.1;
generateDebugInfo = false;
enableCaching = true;
imageSourceName = "Bing";
imageSourceProtocol = ImageSourceProtocol.bing;
imageSourceUrl = "";
}
}
class Config
{
public static ConfigData Data;
private static string fileName;
static Config()
{
fileName = "config.json";
Data = new ConfigData();
if (File.Exists(fileName))
Data = JsonConvert.DeserializeObject<ConfigData>(File.ReadAllText(fileName));
}
public static void Write()
{
File.WriteAllText(fileName,
JsonConvert.SerializeObject(Data, Formatting.Indented));
}
}
}