1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * Copyright (C) 2014 HUBzero Foundation, LLC |
---|
4 | * |
---|
5 | * Author: Leif Delgass <ldelgass@purdue.edu> |
---|
6 | */ |
---|
7 | |
---|
8 | #include "ScaleBar.h" |
---|
9 | |
---|
10 | using namespace GeoVis; |
---|
11 | |
---|
12 | double GeoVis::normalizeScaleMeters(double meters) |
---|
13 | { |
---|
14 | if (meters <= 3) { |
---|
15 | meters = 1; |
---|
16 | } else if (meters <= 7.5) { |
---|
17 | meters = 5; |
---|
18 | } else if (meters <= 15) { |
---|
19 | meters = 10; |
---|
20 | } else if (meters <= 35) { |
---|
21 | meters = 20; |
---|
22 | } else if (meters <= 75) { |
---|
23 | meters = 50; |
---|
24 | } else if (meters <= 150) { |
---|
25 | meters = 100; |
---|
26 | } else if (meters <= 350) { |
---|
27 | meters = 200; |
---|
28 | } else if (meters <= 750) { |
---|
29 | meters = 500; |
---|
30 | } else if (meters <= 1500) { |
---|
31 | meters = 1000; |
---|
32 | } else if (meters <= 3500) { |
---|
33 | meters = 2000; |
---|
34 | } else if (meters <= 7500) { |
---|
35 | meters = 5000; |
---|
36 | } else if (meters <= 15000) { |
---|
37 | meters = 10000; |
---|
38 | } else if (meters <= 35000) { |
---|
39 | meters = 20000; |
---|
40 | } else if (meters <= 55000) { |
---|
41 | meters = 50000; |
---|
42 | } else if (meters <= 150000) { |
---|
43 | meters = 100000; |
---|
44 | } else if (meters <= 350000) { |
---|
45 | meters = 200000; |
---|
46 | } else if (meters <= 750000) { |
---|
47 | meters = 500000; |
---|
48 | } else if (meters <= 1500000) { |
---|
49 | meters = 1000000; |
---|
50 | } else { |
---|
51 | meters = 2000000; |
---|
52 | } |
---|
53 | return meters; |
---|
54 | } |
---|
55 | |
---|
56 | double GeoVis::normalizeScaleFeet(double feet) |
---|
57 | { |
---|
58 | double feetPerMile = 5280.0; |
---|
59 | if (feet <= 7.5) { |
---|
60 | feet = 5; |
---|
61 | } else if (feet <= 15) { |
---|
62 | feet = 10; |
---|
63 | } else if (feet <= 35) { |
---|
64 | feet = 20; |
---|
65 | } else if (feet <= 75) { |
---|
66 | feet = 50; |
---|
67 | } else if (feet <= 150) { |
---|
68 | feet = 100; |
---|
69 | } else if (feet <= 350) { |
---|
70 | feet = 200; |
---|
71 | } else if (feet <= 750) { |
---|
72 | feet = 500; |
---|
73 | } else if (feet <= 1500) { |
---|
74 | feet = 1000; |
---|
75 | } else if (feet <= 3640) { |
---|
76 | feet = 2000; |
---|
77 | } else if (feet <= 1.5 * feetPerMile) { |
---|
78 | feet = 1 * feetPerMile; |
---|
79 | } else if (feet <= 3.5 * feetPerMile) { |
---|
80 | feet = 2 * feetPerMile; |
---|
81 | } else if (feet <= 7.5 * feetPerMile) { |
---|
82 | feet = 5 * feetPerMile; |
---|
83 | } else if (feet <= 15 * feetPerMile) { |
---|
84 | feet = 10 * feetPerMile; |
---|
85 | } else if (feet <= 35 * feetPerMile) { |
---|
86 | feet = 20 * feetPerMile; |
---|
87 | } else if (feet <= 75 * feetPerMile) { |
---|
88 | feet = 50 * feetPerMile; |
---|
89 | } else if (feet <= 150 * feetPerMile) { |
---|
90 | feet = 100 * feetPerMile; |
---|
91 | } else if (feet <= 350 * feetPerMile) { |
---|
92 | feet = 200 * feetPerMile; |
---|
93 | } else if (feet <= 750 * feetPerMile) { |
---|
94 | feet = 500 * feetPerMile; |
---|
95 | } else if (feet <= 1500 * feetPerMile) { |
---|
96 | feet = 1000 * feetPerMile; |
---|
97 | } else { |
---|
98 | feet = 2000 * feetPerMile; |
---|
99 | } |
---|
100 | return feet; |
---|
101 | } |
---|
102 | |
---|
103 | double GeoVis::normalizeScaleNauticalMiles(double nmi) |
---|
104 | { |
---|
105 | //double feetPerMile = 6076.12; |
---|
106 | if (nmi <= 0.0015) { |
---|
107 | nmi = 0.001; |
---|
108 | } else if (nmi <= 0.0035) { |
---|
109 | nmi = 0.002; |
---|
110 | } else if (nmi <= 0.0075) { |
---|
111 | nmi = 0.005; |
---|
112 | } else if (nmi <= 0.015) { |
---|
113 | nmi = 0.01; |
---|
114 | } else if (nmi <= 0.035) { |
---|
115 | nmi = 0.02; |
---|
116 | } else if (nmi <= 0.075) { |
---|
117 | nmi = 0.05; |
---|
118 | } else if (nmi <= 0.15) { |
---|
119 | nmi = 0.1; |
---|
120 | } else if (nmi <= 0.35) { |
---|
121 | nmi = 0.2; |
---|
122 | } else if (nmi <= 0.75) { |
---|
123 | nmi = 0.5; |
---|
124 | } else if (nmi <= 1.5) { |
---|
125 | nmi = 1; |
---|
126 | } else if (nmi <= 3.5) { |
---|
127 | nmi = 2; |
---|
128 | } else if (nmi <= 7.5) { |
---|
129 | nmi = 5; |
---|
130 | } else if (nmi <= 15) { |
---|
131 | nmi = 10; |
---|
132 | } else if (nmi <= 35) { |
---|
133 | nmi = 20; |
---|
134 | } else if (nmi <= 75) { |
---|
135 | nmi = 50; |
---|
136 | } else if (nmi <= 150) { |
---|
137 | nmi = 100; |
---|
138 | } else if (nmi <= 350) { |
---|
139 | nmi = 200; |
---|
140 | } else if (nmi <= 750) { |
---|
141 | nmi = 500; |
---|
142 | } else if (nmi <= 1500) { |
---|
143 | nmi = 1000; |
---|
144 | } else { |
---|
145 | nmi = 2000; |
---|
146 | } |
---|
147 | return nmi; |
---|
148 | } |
---|