forked from wp-plugins/osm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathosm-args-class.php
More file actions
349 lines (313 loc) · 10.5 KB
/
osm-args-class.php
File metadata and controls
349 lines (313 loc) · 10.5 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
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
<?php
/* (c) Copyright 2017 MiKa (wp-osm-plugin.HanBlog.Net)
This program 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 2 of the License, or
(at your option) any later version.
This program 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, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class cOsm_arguments
{
private $width_str = '100%';
private $height_str = '300';
private $map_Lat = '58.213';
private $map_Lon = '6.378';
private $zoom = '4';
private $map_api_key = 'NoKey';
private $file_list = 'NoFile';
private $file_color_list = 'NoColor';
private $map_type = 'Osm';
private $jsname = 'dummy';
private $marker_latlon = 'No';
private $map_border = '2px solid grey';
private $marker_name = 'NoName';
private $mapControl_array = '';
private $wms_type = 'wms_type';
private $wms_address = 'wms_address';
private $wms_param = 'wms_param';
private $wms_attr_name = 'wms_attr_name';
private $wms_attr_url = 'wms_attr_url';
private $tagged_type = 'no';
private $tagged_filter_type = 'category';
private $tagged_filter = 'osm_all';
private $mwz = 'false';
private $marker_height = '32';
private $marker_width = '32';
private $marker_focus = '0';
private $post_markers = 'no';
private $cntrl_fullscreen = 0;
private $cntrl_mouseposition = 0;
private $cntrl_scaleline = 0;
private $show_kml_marker_name = "false";
private $tagged_cluster = "false";
private $tagged_border_color = "[0, 0, 255, 0.5]";
private $tagged_inner_color = "[0, 0, 255, 0.5]";
private $map_event = 'no';
private function setMarkersize($a_marker_size){
if ($a_marker_size == "no"){
}
else{
$marker_size_array = explode(',', $a_marker_size);
if(count($marker_size_array) == 3) {
$this->marker_height = $marker_size_array[0];
$this->marker_width = $marker_size_array[1];
$this->marker_focus = $marker_size_array[2];
}
else{
Osm::traceText(DEBUG_ERROR, "marker_size error!");
Osm::traceText(DEBUG_ERROR, $a_marker_size);
}
}
}
private function setLatLon($a_map_center){
$map_center = preg_replace('/\s*,\s*/', ',',$a_map_center);
// get pairs of coordination
$map_center_Array = explode( ' ', $map_center );
list($this->map_Lat, $this->map_Lon) = explode(',', $map_center_Array[0]);
}
private function setMapSize($a_width, $a_height){
$pos = strpos($a_width, "%");
if ($pos == false) {
if ($a_width < 1){
Osm::traceText(DEBUG_ERROR, (sprintf(__(' width = %s is out of range [pix]!'), $a_width)));
$a_width = 450;
}
$this->width_str = $a_width."px"; // make it 30px
} else {// it's 30%
$width_perc = substr($a_width, 0, $pos ); // make it 30
if (($width_perc < 1) || ($width_perc >100)){
Osm::traceText(DEBUG_ERROR, (sprintf(__('width = %s is out of range [perc]!'), $a_width)));
$a_width = "100%";
}
$this->width_str = substr($a_width, 0, $pos+1 ); // make it 30%
}
$pos = strpos($a_height, "%");
if ($pos == false) {
if ($a_height < 1){
Osm::traceText(DEBUG_ERROR, (sprintf(__('height = %s is out of range [pix]!'), $a_height)));
$a_height = 300;
}
$this->height_str = $a_height."px"; // make it 30px
} else {// it's 30%
$height_perc = substr($a_height, 0, $pos ); // make it 30
if (($height_perc < 1) || ($height_perc >100)){
Osm::traceText(DEBUG_ERROR, (sprintf(__('height = %s is out of range [perc]!'), $a_height)));
$a_height = "100%";
}
$this->height_str = substr($a_height, 0, $pos+1 ); // make it 30%
}
}
private function setControlArray($a_MapControl){
$mapControl_array = explode( ',',$a_MapControl);
foreach ($mapControl_array as $MapControl ){
$MapControl = strtolower($MapControl);
if ($MapControl == 'fullscreen'){
$this->cntrl_fullscreen = true;
}
else if($MapControl == 'mouseposition'){
$this->cntrl_mouseposition = true;
}
else if($MapControl == 'scaleline'){
$this->cntrl_scaleline = true;
}
}
return $this->mapControl_array;
}
private function setPostMarkers($a_post_markers){
if (($a_post_markers == "1") || ($a_post_markers == "2") || ($a_post_markers == "3") || ($a_post_markers == "4") || ($a_post_markers == "5") || ($a_post_markers == "6") || ($a_post_markers == "7") || ($a_post_markers == "8") || ($a_post_markers == "9") || ($a_post_markers == "all")){
$this->post_markers = $a_post_markers;
}
else {
$this->post_markers = 'no';
}
}
private function setMapType($a_type){
$map_type = strtolower($a_type);
if ((($map_type == "outdoor") || ($map_type == "landscape") || ($map_type == "spinal") || ($map_type == "pioneer") || ($map_type == "cyclemap")) && ($this->getMapAPIkey() == "NoKey")){
$this->map_type = "osm";
}
else {
$this->map_type = $map_type;
}
}
private function setDisplayMarker($a_display_marker_name){
if ($a_display_marker_name == "kml"){
$this->show_kml_marker_name = "true";
}
}
private function setTaggedParam($a_tagged_param){
if ($a_tagged_param == "cluster"){
$this->tagged_cluster = "true";
}
}
private function setTaggedColor($a_tagged_color){
if ($a_tagged_color == "blue"){
$this->tagged_border_color = "[0, 0, 255, 0.5]";
$this->tagged_inner_color = "[0, 0, 255, 0.85]";
}
elseif($a_tagged_color == "red"){
$this->tagged_border_color = "[255,0,0, 0.5]";
$this->tagged_inner_color = "[255,0,0, 0.85]";
}
elseif($a_tagged_color == "yellow"){
$this->tagged_border_color = "[255,255,0, 0.5]";
$this->tagged_inner_color = "[255,255,0, 0.85]";
}
elseif($a_tagged_color == "green"){
$this->tagged_border_color = "[0,255,0, 0.5]";
$this->tagged_inner_color = "[0,255,0, 0.85]";
}
elseif($a_tagged_color == "black"){
$this->tagged_border_color = "[0,0,0, 0.5]";
$this->tagged_inner_color = "[0,0,0, 0.85]";
}
elseif($a_tagged_color == "purple"){
$this->tagged_border_color = "[128,0,128, 0.5]";
$this->tagged_inner_color = "[128,0,128, 0.85]";
}
elseif(($a_tagged_color == "grey") || ($a_tagged_color == "gray")) {
$this->tagged_border_color = "[128,128,128, 0.5]";
$this->tagged_inner_color = "[128,128,128, 0.85]";
}
elseif($a_tagged_color == "orange") {
$this->tagged_border_color = "[255,128,64, 0.5]";
$this->tagged_inner_color = "[255,128,64, 0.85]";
}
else {
$this->tagged_border_color = "[0, 0, 255, 0.5]";
$this->tagged_inner_color = "[0, 0, 255, 0.85]";
}
}
private function setMapAPIkey($a_map_api_key){
$this->map_api_key = $a_map_api_key;
}
private function setMapZoom($a_map_zoom){
$this->zoom = $a_map_zoom;
}
public function setMap_event($a_map_event){
$this->map_event = $a_map_event;
}
public function setTaxonomy($a_tagged_filter_type){
$this->tagged_filter_type = $a_tagged_filter_type;
}
function __construct($a_width, $a_height, $a_map_center, $a_zoom, $a_map_api_key, $file_list, $file_color_list, $a_type, $jsname, $marker_latlon, $map_border, $a_map_event,
$marker_name, $a_marker_size, $control, $wms_address, $wms_param, $wms_attr_name, $wms_type, $wms_attr_url,
$tagged_type, $a_tagged_filter_type, $tagged_filter, $mwz, $a_post_markers, $a_display_marker_name, $a_tagged_param, $a_tagged_color,
$file_title, $file_link, $setup_zoom, $setup_layer, $setup_center, $setup_trigger, $setup_map_name, $file_select_box, $bckgrndimg
){
$this->setLatLon($a_map_center) ;
$this->setMapSize($a_width, $a_height);
$this->setControlArray($control);
$this->setMarkersize($a_marker_size);
$this->setPostMarkers($a_post_markers);
$this->setDisplayMarker($a_display_marker_name);
$this->setTaggedParam($a_tagged_param);
$this->setTaggedColor($a_tagged_color);
$this->setMapAPIkey($a_map_api_key);
$this->setMapType($a_type); // needs to be done after setMapAPIkey
$this->setMap_event($a_map_event);
$this->setTaxonomy($a_tagged_filter_type);
$this-> setMapZoom($a_zoom);
}
public function getPostMarkers(){
return $this->post_markers;
}
public function getMapCenterLat(){
if ($this->map_Lat == "autolat"){
return 58.213;
}
else{
return $this->map_Lat;
}
}
public function getMapCenterLon(){
if ($this->map_Lon == "autolon"){
return 6.378;
}
else{
return $this->map_Lon;
}
}
public function getMapZoom(){
if ($this->zoom == "autozoom"){
return 9;
}
else{
return $this->zoom;
}
}
public function isAutozoom(){
if ($this->zoom == "autozoom"){
return true;
}
else {
return false;
}
}
public function isAutocenter(){
if (($this->map_Lat == "autolat")||($this->map_Lon == "autolon")||($this->zoom == "autozoom")){
return true;
}
else {
return false;
}
}
public function getMapAPIkey(){
return $this->map_api_key;
}
public function getMapWidth_str(){
return $this->width_str;
}
public function getMapHeight_str(){
return $this->height_str;
}
public function getMapControl(){
return $this->mapControl_array;
}
public function getMapType(){
return $this->map_type;
}
public function getMarkerHeight(){
return $this->marker_height;
}
public function getMarkerWidth(){
return $this->marker_width;
}
public function getMarkerFocus(){
return $this->marker_focus;
}
public function issetFullScreen(){
return $this->cntrl_fullscreen;
}
public function issetMouseposition(){
return $this->cntrl_mouseposition;
}
public function issetScaleline(){
return $this->cntrl_scaleline;
}
public function showKmlMarkerName(){
return $this->show_kml_marker_name;
}
public function isclustered(){
return $this->$tagged_cluster;
}
public function getTaggedBorderColor(){
return $this->tagged_border_color;
}
public function getTaggedInnerColor(){
return $this->tagged_inner_color;
}
public function getMap_event(){
return $this->map_event;
}
public function getTaxonomy(){
return $this->tagged_filter_type;
}
}
?>