├── client ├── commons-on-osm.php ├── geo_param.php ├── kml-on-ol-json3.php ├── kml-on-ol.i18n.php ├── kml-on-ol.php ├── lang-select.php ├── mapsources.php └── wiwosm-list.php └── server ├── class.Wiwosm.php ├── cleanup.sh ├── gen_json_files.php ├── public_html ├── osmjson │ └── getGeoJSON.php └── wiwosmlog │ ├── broken.html │ └── broken.php └── wiwosm.sh /client/commons-on-osm.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | Commons on OSM 4 | 5 | 14 | 15 | londeg ; 22 | $y = $p->latdeg ; 23 | $position= "args.lon = $x; args.lat = $y;"; 24 | echo "\n"; 25 | } 26 | 27 | ?> 28 | 29 | 30 | 31 | 32 | 33 | 317 | 318 | 319 | 320 | 321 | 322 | -------------------------------------------------------------------------------- /client/geo_param.php: -------------------------------------------------------------------------------- 1 | pieces = explode(" ", str_replace ( ' O' , ' E' , str_replace( '_', ' ', $param ))); 28 | $this->get_coor( ); 29 | 30 | $this->latdeg_min = $this->latdeg_max = $this->latdeg; 31 | $this->londeg_min = $this->londeg_max = $this->londeg; 32 | if ( isset( $this->pieces[0] ) && $this->pieces[0] == "to") { 33 | array_shift($this->pieces); 34 | $this->get_coor(); 35 | if ($this->latdeg < $this->latdeg_max) { 36 | $this->latdeg_min = $this->latdeg; 37 | } else { 38 | $this->latdeg_max = $this->latdeg; 39 | } 40 | if ($this->londeg < $this->londeg_max) { 41 | $this->londeg_min = $this->londeg; 42 | } else { 43 | $this->londeg_max = $this->londeg; 44 | } 45 | $this->latdeg = ($this->latdeg_max+$this->latdeg_min) / 2; 46 | $this->londeg = ($this->londeg_max+$this->londeg_min) / 2; 47 | $this->coor = array(); 48 | } 49 | } 50 | 51 | /** 52 | * Private: 53 | * Get a set of coordinates from parameters 54 | */ 55 | function get_coor( ) { 56 | if ($i = strpos($this->pieces[0],';')) { 57 | /* two values seperated by a semicolon */ 58 | $this->coor = array( 59 | $this->latdeg = substr($this->pieces[0],0,$i), 60 | $this->londeg = substr($this->pieces[0],$i+1)); 61 | array_shift($this->pieces); 62 | $latNS = 'N'; 63 | $lonEW = 'E'; 64 | $latmin = $lonmin = $latsec = $lonsec = 0; 65 | } elseif ($this->is_coor($this->pieces[1],$this->pieces[3])) { 66 | $this->coor = array( 67 | $this->latdeg = array_shift($this->pieces), 68 | $latNS = array_shift($this->pieces), 69 | $this->londeg = array_shift($this->pieces), 70 | $lonEW = array_shift($this->pieces)); 71 | $latmin = $lonmin = $latsec = $lonsec = 0; 72 | } elseif ($this->is_coor($this->pieces[2],$this->pieces[5])) { 73 | $this->coor = array( 74 | $this->latdeg = array_shift($this->pieces), 75 | $latmin = array_shift($this->pieces), 76 | $latNS = array_shift($this->pieces), 77 | $this->londeg = array_shift($this->pieces), 78 | $lonmin = array_shift($this->pieces), 79 | $lonEW = array_shift($this->pieces)); 80 | $latsec = $lonsec = 0; 81 | } elseif ($this->is_coor($this->pieces[3],$this->pieces[7])) { 82 | $this->coor = array( 83 | $this->latdeg = array_shift($this->pieces), 84 | $latmin = array_shift($this->pieces), 85 | $latsec = array_shift($this->pieces), 86 | $latNS = array_shift($this->pieces), 87 | $this->londeg = array_shift($this->pieces), 88 | $lonmin = array_shift($this->pieces), 89 | $lonsec = array_shift($this->pieces), 90 | $lonEW = array_shift($this->pieces)); 91 | } else { 92 | # support decimal, signed lat, lon 93 | $this->error = "Unrecognized format"; 94 | print $this->error ; 95 | } 96 | 97 | 98 | if ($this->latdeg > 90 or $this->latdeg < -90 99 | or $this->londeg > 180 or $this->londeg < -180 100 | or $latmin > 60 or $latmin < 0 101 | or $lonmin > 60 or $lonmin < 0 102 | or $latsec > 60 or $latsec < 0 103 | or $lonsec > 60 or $lonsec < 0) { 104 | $this->error = "Out of range"; 105 | } 106 | 107 | $latfactor = 1.0 ; 108 | $lonfactor = 1.0 ; 109 | if (strtoupper($latNS) == "S") { 110 | $latfactor = -1.0 ; 111 | #$this->latdeg = -$this->latdeg; 112 | } 113 | 114 | if (strtoupper($lonEW) == "W") { 115 | $lonfactor = -1.0 ; 116 | #$this->londeg = -$this->londeg; 117 | } 118 | 119 | # Make decimal degree, if not already 120 | $latmin += $latsec/60.0; 121 | $lonmin += $lonsec/60.0; 122 | if ($this->latdeg < 0) { 123 | $this->latdeg -= $latmin/60.0; 124 | } else { 125 | $this->latdeg += $latmin/60.0; 126 | } 127 | if ($this->londeg < 0) { 128 | $this->londeg -= $lonmin/60.0; 129 | } else { 130 | $this->londeg += $lonmin/60.0; 131 | } 132 | $this->latdeg *= $latfactor ; 133 | $this->londeg *= $lonfactor ; 134 | } 135 | 136 | /** 137 | * Given decimal degrees, convert to 138 | * minutes, seconds and direction 139 | */ 140 | function make_minsec( $deg ) 141 | { 142 | if ( $deg >= 0) { 143 | $NS = "N"; 144 | $EW = "E"; 145 | } else { 146 | $NS = "S"; 147 | $EW = "W"; 148 | } 149 | # Round to a suitable number of digits 150 | # FIXME: should reflect precision 151 | $deg = round($deg, 6); 152 | $min = 60.0 * (abs($deg) - intval(abs($deg))); 153 | $min = round($min, 4); 154 | $sec = 60.0 * ($min - intval($min)); 155 | $sec = round($sec, 2); 156 | 157 | return array( 158 | 'deg' => $deg, 159 | 'min' => $min, 160 | 'sec' => $sec, 161 | 'NS' => $NS, 162 | 'EW' => $EW); 163 | } 164 | 165 | /** 166 | * Given decimal degrees latitude and longitude, convert to 167 | * string 168 | */ 169 | function make_position( $lat, $lon ) 170 | { 171 | $latdms = geo_param::make_minsec( $lat ); 172 | $londms = geo_param::make_minsec( $lon ); 173 | $outlat = intval(abs($latdms['deg'])) . "° "; 174 | $outlon = intval(abs($londms['deg'])) . "° "; 175 | if ($latdms['min'] != 0 or $londms['min'] != 0 176 | or $latdms['sec'] != 0 or $londms['sec'] != 0) { 177 | $outlat .= intval($latdms['min']) . "′ "; 178 | $outlon .= intval($londms['min']) . "′ "; 179 | if ($latdms['sec'] != 0 or $londms['sec'] != 0) { 180 | $outlat .= $latdms['sec']. "″ "; 181 | $outlon .= $londms['sec']. "″ "; 182 | } 183 | } 184 | return $outlat . $latdms['NS'] . " " . $outlon . $londms['EW']; 185 | } 186 | 187 | /** 188 | * Get the additional attributes in an associative array 189 | */ 190 | function get_attr() 191 | { 192 | $a = array(); 193 | while (($s = array_shift($this->pieces))) { 194 | if (($i = strpos($s,":")) >= 1) { 195 | $attr = substr($s,0,$i); 196 | $val = substr($s,$i+1); 197 | if (($j = strpos($val,"(")) 198 | && ($k = strpos($val,")")) 199 | && ($k > $j)) { 200 | $a["arg:".$attr] = substr($val,$j+1,$k-($j+1)); 201 | $val = substr($val,0,$j); 202 | } 203 | $a[$attr] = $val; 204 | } elseif (intval($s) > 0) { 205 | if ($a['$scale'] != "") 206 | $a['scale'] = intval($s); 207 | } 208 | } 209 | return $a; 210 | } 211 | 212 | function is_coor( $ns,$ew ) 213 | { 214 | $ns = strtoupper($ns); 215 | $ew = strtoupper($ew); 216 | return (($ns=="N" or $ns=="S") and 217 | ($ew=="E" or $ew=="W")); 218 | } 219 | 220 | function frac( $f) 221 | { 222 | return abs($f) - abs(intval($f)); 223 | } 224 | 225 | /** 226 | * Get composite position in RFC2045 format 227 | */ 228 | function get_position( ) 229 | { 230 | return $this->latdeg.";".$this->londeg; 231 | } 232 | 233 | /** 234 | * Get error message that applies, or "" of all is well 235 | */ 236 | function get_error() 237 | { 238 | if ($this->error != "") { 239 | return "Error:".$this->error; 240 | } 241 | return ""; 242 | } 243 | 244 | /** 245 | * Produce markup suitable for use in page 246 | * Use original content as much as possible 247 | */ 248 | function get_markup() 249 | { 250 | $n = count($this->coor); 251 | 252 | if ($n == 0) { 253 | # Range is special case 254 | return $this->make_position( $this->latdeg_min, 255 | $this->londeg_min ) 256 | . " to " 257 | . $this->make_position( $this->latdeg_max, 258 | $this->londeg_max ); 259 | } elseif ($n == 2) { 260 | return $this->coor[0].';'. 261 | $this->coor[1]; 262 | 263 | } elseif ($n == 4) { 264 | return $this->coor[0].'° '. 265 | $this->coor[1].' '. 266 | $this->coor[2].'° '. 267 | $this->coor[3]; 268 | 269 | } elseif ($n == 6) { 270 | return $this->coor[0].'°'. 271 | $this->coor[1].'′ '. 272 | $this->coor[2].' '. 273 | $this->coor[3].'°'. 274 | $this->coor[4].'′ '. 275 | $this->coor[5]; 276 | 277 | } elseif ($n == 8) { 278 | return $this->coor[0].'°'. 279 | $this->coor[1].'′'. 280 | $this->coor[2].'″ '. 281 | $this->coor[3].' '. 282 | $this->coor[4].'°'. 283 | $this->coor[5].'′'. 284 | $this->coor[6].'″ '. 285 | $this->coor[7]; 286 | } else { 287 | return $this->get_error(); 288 | } 289 | } 290 | } 291 | 292 | ?> 293 | -------------------------------------------------------------------------------- /client/kml-on-ol-json3.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Wikipedia on OpenStreetMap 6 | 7 | 8 | 9 | "; 25 | return $a; 26 | } 27 | 28 | function detect_not_ie() 29 | { 30 | if (isset($_SERVER['HTTP_USER_AGENT']) && 31 | (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) 32 | return false; 33 | else 34 | return true; 35 | } 36 | 37 | $lang=addslashes(urldecode($_GET[lang])); 38 | $uselang=addslashes(urldecode($_GET[uselang])); 39 | if ($uselang=="") {$uselang=$lang;} 40 | 41 | $thumbs=addslashes($_GET[thumbs]); 42 | if (($thumbs=="no") or ($thumbs=="yes")) {$thumbsinsert=", 'thumbs' : '$thumbs'";} else {$thumbsinsert=", 'thumbs' : '0'";} 43 | $pop=addslashes($_GET[pop]); 44 | if (($pop<>"")) {$popinsert=", 'pop' : '$pop'";} 45 | $style=addslashes($_GET[style]); 46 | if (($style<>"")) {$styleinsert=", 'style' : '$style'";} 47 | $photo=addslashes($_GET[photo]); 48 | if (($photo=="no") or ($photo=="yes")) {$photoinsert=", 'photo' : '$photo'";} 49 | $source=addslashes($_GET[source]); 50 | if (($source<>"")) {$sourceinsert=", 'source' : '$source'";} 51 | $notsource=addslashes($_GET[notsource]); 52 | if (($notsource<>"")) {$notsourceinsert=", 'notsource' : '$notsource'";} 53 | $secure=addslashes($_GET[secure]); 54 | if ($secure==1) {$secureinsert=", 'secure' : '1'";} 55 | 56 | $title=urldecode($_GET[title]); 57 | $action=addslashes(urldecode($_GET[action])); 58 | 59 | // Geohack 60 | 61 | if ( isset ( $_REQUEST['params'] ) ) { 62 | $p = new geo_param( $_REQUEST['params'] , "Dummy" ); ; 63 | $x = $p->londeg ; 64 | $y = $p->latdeg ; 65 | 66 | $type = $p->type ; 67 | $dim= $p->dim ; 68 | 69 | } 70 | 71 | $theparams =$_REQUEST['params']; 72 | $typeleftcut = strstr($theparams,"type:"); 73 | $type = substr ($typeleftcut, 5 ); 74 | if (strpos($type,"(")>0) {$type = substr($type,0,strpos($type,"("));} 75 | if (strpos($type,"_")>0) {$type = substr($type,0,strpos($type,"_"));} 76 | 77 | $default_scale = array( 78 | 'country' => 10000000, # 10 mill 79 | 'satellite' => 10000000, # 10 mill 80 | 'state' => 3000000, # 3 mill 81 | 'adm1st' => 1000000, # 1 mill 82 | 'adm2nd' => 300000, # 300 thousand 83 | 'adm3rd' => 100000, # 100 thousand 84 | 'city' => 100000, # 100 thousand 85 | 'isle' => 100000, # 100 thousand 86 | 'mountain' => 100000, # 100 thousand 87 | 'river' => 100000, # 100 thousand 88 | 'waterbody' => 100000, # 100 thousand 89 | 'event' => 50000, # 50 thousand 90 | 'forest' => 50000, # 50 thousand 91 | 'glacier' => 50000, # 50 thousand 92 | 'airport' => 30000, # 30 thousand 93 | 'railwaystation' => 10000, # 10 thousand 94 | 'edu' => 10000, # 10 thousand 95 | 'pass' => 10000, # 10 thousand 96 | 'landmark' => 10000 # 10 thousand 97 | ); 98 | $zoomtype=18 - ( round(log($default_scale[$type],2) - log(1693,2)) ); 99 | 100 | $dimleftcut = strstr($theparams,"dim:"); 101 | $dim = substr ($dimleftcut, 4 ); 102 | if (strpos($dim,"(")>0) {$dim = substr($dim,0,strpos($dim,"("));} 103 | if (strpos($dim,"_")>0) {$dim = substr($dim,0,strpos($dim,"_"));} 104 | $dim = str_replace(array("km","m"),array("000",""),$dim); 105 | 106 | if ($dim>0) 107 | {$zoomtype=18 - ( round(log($dim/0.1,2) - log(1693,2)) );} 108 | 109 | if ($zoomtype>18) {$zoom=18;$zoomtype=18;} 110 | if ($zoomtype>2 ) {$zoom=$zoomtype;} else {$zoom=12;} 111 | 112 | $position= " var zoom = $zoom;"; 113 | if ($x<>""){$position.=" 114 | args.lon = $x; 115 | args.lat = $y; ";} 116 | 117 | echo "\n"; 118 | // Geohack end 119 | ?> 120 | 121 | 122 | 123 | 124 | 125 | 126 | 651 | 652 | 771 | 772 | 773 | 774 | 775 | 776 |
777 |
778 | 779 |
780 | 781 |
782 |
783 | 784 |
785 |
786 | 787 | 788 |

789 |
790 | 791 |
792 | 793 | 794 |
795 | 800 |

801 | 802 |
803 | 804 |
805 | 806 | 807 | 808 | -------------------------------------------------------------------------------- /client/kml-on-ol.i18n.php: -------------------------------------------------------------------------------- 1 | 'Options', 21 | 'ts-kml-on-ol-languages' => 'Languages', 22 | 'ts-kml-on-ol-thumbnails' => 'Thumbnails', 23 | 'ts-kml-on-ol-help' => 'Help', 24 | 'ts-kml-on-ol-all' => 'All', 25 | 'ts-kml-on-ol-map-by' => 'Map by', 26 | 'ts-kml-on-ol-openstreetmap' => 'OpenStreetMap', 27 | 'ts-kml-on-ol-wikipedia' => 'Wikipedia', 28 | 'ts-kml-on-ol-coat-of-arms' => 'Coat of arms' 29 | ); 30 | 31 | /** Message documentation (Message documentation) 32 | * @author EugeneZelenko 33 | * @author Umherirrender 34 | */ 35 | $messages['qqq'] = array( 36 | 'ts-kml-on-ol-options' => '{{Identical|Options}}', 37 | 'ts-kml-on-ol-languages' => '{{Identical|Language}}', 38 | 'ts-kml-on-ol-thumbnails' => '{{Identical|Thumbnail}}', 39 | 'ts-kml-on-ol-help' => '{{Identical|Help}}', 40 | 'ts-kml-on-ol-all' => '{{Identical|All}}', 41 | 'ts-kml-on-ol-openstreetmap' => '{{optional}}', 42 | 'ts-kml-on-ol-wikipedia' => '{{optional}}', 43 | ); 44 | 45 | /** Turoyo (Ṫuroyo) 46 | * @author Ariyo 47 | */ 48 | $messages['tru'] = array( 49 | 'ts-kml-on-ol-languages' => 'Leşone', 50 | ); 51 | 52 | /** Afrikaans (Afrikaans) 53 | * @author Naudefj 54 | */ 55 | $messages['af'] = array( 56 | 'ts-kml-on-ol-options' => 'Voorkeure', 57 | 'ts-kml-on-ol-languages' => 'Tale', 58 | 'ts-kml-on-ol-thumbnails' => 'Duimnaels', 59 | 'ts-kml-on-ol-help' => 'Help', 60 | 'ts-kml-on-ol-all' => 'Alle', 61 | 'ts-kml-on-ol-map-by' => 'Kaart deur', 62 | ); 63 | 64 | /** Aragonese (aragonés) 65 | * @author Juanpabl 66 | */ 67 | $messages['an'] = array( 68 | 'ts-kml-on-ol-thumbnails' => 'Miniatura', 69 | ); 70 | 71 | /** Arabic (العربية) 72 | * @author Meno25 73 | */ 74 | $messages['ar'] = array( 75 | 'ts-kml-on-ol-options' => 'خيارات', 76 | 'ts-kml-on-ol-languages' => 'اللغات', 77 | 'ts-kml-on-ol-thumbnails' => 'الصور المصغرة', 78 | 'ts-kml-on-ol-help' => 'مساعدة', 79 | 'ts-kml-on-ol-all' => 'الكل', 80 | 'ts-kml-on-ol-map-by' => 'الخريطة بواسطة', 81 | 'ts-kml-on-ol-openstreetmap' => 'أوبن ستريت ماب', 82 | 'ts-kml-on-ol-wikipedia' => 'ويكيبيديا', 83 | ); 84 | 85 | /** Asturian (asturianu) 86 | * @author Xuacu 87 | */ 88 | $messages['ast'] = array( 89 | 'ts-kml-on-ol-options' => 'Opciones', 90 | 'ts-kml-on-ol-languages' => 'Llingües', 91 | 'ts-kml-on-ol-thumbnails' => 'Miniatures', 92 | 'ts-kml-on-ol-help' => 'Ayuda', 93 | 'ts-kml-on-ol-all' => 'Toes', 94 | 'ts-kml-on-ol-map-by' => 'Mapa de', 95 | ); 96 | 97 | /** Belarusian (Taraškievica orthography) (беларуская (тарашкевіца)‎) 98 | * @author Jim-by 99 | * @author Zedlik 100 | */ 101 | $messages['be-tarask'] = array( 102 | 'ts-kml-on-ol-options' => 'Налады', 103 | 'ts-kml-on-ol-languages' => 'Мовы', 104 | 'ts-kml-on-ol-thumbnails' => 'Мініятуры', 105 | 'ts-kml-on-ol-help' => 'Дапамога', 106 | 'ts-kml-on-ol-all' => 'Усе', 107 | 'ts-kml-on-ol-map-by' => 'Мапа', 108 | ); 109 | 110 | /** Breton (brezhoneg) 111 | * @author Y-M D 112 | */ 113 | $messages['br'] = array( 114 | 'ts-kml-on-ol-options' => 'Dibarzhioù', 115 | 'ts-kml-on-ol-languages' => 'Yezhoù', 116 | 'ts-kml-on-ol-thumbnails' => 'Munudoù', 117 | 'ts-kml-on-ol-help' => 'Skoazell', 118 | 'ts-kml-on-ol-all' => 'Pep tra', 119 | 'ts-kml-on-ol-map-by' => 'Kartenn savet gant', 120 | ); 121 | 122 | /** Bosnian (bosanski) 123 | * @author CERminator 124 | */ 125 | $messages['bs'] = array( 126 | 'ts-kml-on-ol-options' => 'Opcije', 127 | 'ts-kml-on-ol-languages' => 'Jezici', 128 | 'ts-kml-on-ol-thumbnails' => 'Smanjeni pregledi', 129 | 'ts-kml-on-ol-help' => 'Pomoć', 130 | 'ts-kml-on-ol-all' => 'Sve', 131 | 'ts-kml-on-ol-map-by' => 'Karta od', 132 | ); 133 | 134 | /** Catalan (català) 135 | * @author Vriullop 136 | */ 137 | $messages['ca'] = array( 138 | 'ts-kml-on-ol-options' => 'Opcions', 139 | 'ts-kml-on-ol-languages' => 'Llengües', 140 | 'ts-kml-on-ol-thumbnails' => 'Miniatures', 141 | 'ts-kml-on-ol-help' => 'Ajuda', 142 | 'ts-kml-on-ol-all' => 'Totes', 143 | 'ts-kml-on-ol-map-by' => 'Mapa fet per', 144 | ); 145 | 146 | /** Czech (česky) 147 | * @author Mormegil 148 | */ 149 | $messages['cs'] = array( 150 | 'ts-kml-on-ol-options' => 'Možnosti', 151 | 'ts-kml-on-ol-languages' => 'Jazyky', 152 | 'ts-kml-on-ol-thumbnails' => 'Náhledy', 153 | 'ts-kml-on-ol-help' => 'Nápověda', 154 | 'ts-kml-on-ol-all' => 'Všechny', 155 | 'ts-kml-on-ol-map-by' => 'Mapa z', 156 | ); 157 | 158 | /** German (Deutsch) 159 | * @author Kolossos 160 | */ 161 | $messages['de'] = array( 162 | 'ts-kml-on-ol-options' => 'Optionen', 163 | 'ts-kml-on-ol-languages' => 'Sprachauswahl', 164 | 'ts-kml-on-ol-thumbnails' => 'Miniaturbilder', 165 | 'ts-kml-on-ol-help' => 'Hilfe', 166 | 'ts-kml-on-ol-all' => 'Alle', 167 | 'ts-kml-on-ol-map-by' => 'Karte von', 168 | 'ts-kml-on-ol-openstreetmap' => 'OpenStreetMap', 169 | 'ts-kml-on-ol-wikipedia' => 'Wikipedia', 170 | 'ts-kml-on-ol-coat-of-arms' => 'Wappen' 171 | ); 172 | 173 | /** Zazaki (Zazaki) 174 | * @author Erdemaslancan 175 | */ 176 | $messages['diq'] = array( 177 | 'ts-kml-on-ol-options' => 'Weçinegi', 178 | 'ts-kml-on-ol-help' => 'Peşti', 179 | 'ts-kml-on-ol-all' => 'Pêro', 180 | ); 181 | 182 | /** Lower Sorbian (dolnoserbski) 183 | * @author Michawiki 184 | */ 185 | $messages['dsb'] = array( 186 | 'ts-kml-on-ol-options' => 'Opcije', 187 | 'ts-kml-on-ol-languages' => 'Rěcy', 188 | 'ts-kml-on-ol-thumbnails' => 'Wobrazki', 189 | 'ts-kml-on-ol-help' => 'Pomoc', 190 | 'ts-kml-on-ol-all' => 'Wšykne', 191 | 'ts-kml-on-ol-map-by' => 'Kórta wót', 192 | ); 193 | 194 | /** Greek (Ελληνικά) 195 | * @author Geraki 196 | */ 197 | $messages['el'] = array( 198 | 'ts-kml-on-ol-options' => 'Επιλογές', 199 | 'ts-kml-on-ol-languages' => 'Γλώσσες', 200 | 'ts-kml-on-ol-thumbnails' => 'Μικρογραφίες', 201 | 'ts-kml-on-ol-help' => 'Βοήθεια', 202 | 'ts-kml-on-ol-all' => 'Ὀλα', 203 | 'ts-kml-on-ol-map-by' => 'Χάρτης από', 204 | ); 205 | 206 | /** Spanish (español) 207 | * @author Dferg 208 | */ 209 | $messages['es'] = array( 210 | 'ts-kml-on-ol-options' => 'Opciones', 211 | 'ts-kml-on-ol-languages' => 'Idiomas', 212 | 'ts-kml-on-ol-thumbnails' => 'Miniaturas', 213 | 'ts-kml-on-ol-help' => 'Ayuda', 214 | 'ts-kml-on-ol-all' => 'Todo', 215 | 'ts-kml-on-ol-map-by' => 'Mapa por', 216 | ); 217 | 218 | /** Estonian (eesti) 219 | * @author WikedKentaur 220 | */ 221 | $messages['et'] = array( 222 | 'ts-kml-on-ol-options' => 'Sätted', 223 | 'ts-kml-on-ol-languages' => 'Keeled', 224 | 'ts-kml-on-ol-thumbnails' => 'Pisipildid', 225 | 'ts-kml-on-ol-help' => 'Juhend', 226 | 'ts-kml-on-ol-all' => 'Kõik', 227 | 'ts-kml-on-ol-map-by' => 'Kaart:', 228 | ); 229 | 230 | /** Basque (euskara) 231 | * @author Theklan 232 | */ 233 | $messages['eu'] = array( 234 | 'ts-kml-on-ol-options' => 'Aukerak', 235 | 'ts-kml-on-ol-languages' => 'Hizkuntzak', 236 | 'ts-kml-on-ol-thumbnails' => 'Iruditxoak', 237 | 'ts-kml-on-ol-help' => 'Laguntza', 238 | 'ts-kml-on-ol-all' => 'Guztiak', 239 | 'ts-kml-on-ol-map-by' => 'Maparen egilea', 240 | ); 241 | 242 | /** Persian (فارسی) 243 | * @author Mjbmr 244 | */ 245 | $messages['fa'] = array( 246 | 'ts-kml-on-ol-options' => 'گزینه‌ها', 247 | 'ts-kml-on-ol-languages' => 'زبان‌ها', 248 | 'ts-kml-on-ol-thumbnails' => 'تصاویر بندانگشتی', 249 | 'ts-kml-on-ol-help' => 'راهنما', 250 | 'ts-kml-on-ol-all' => 'همه', 251 | 'ts-kml-on-ol-map-by' => 'نقشه توسط', 252 | ); 253 | 254 | /** Finnish (suomi) 255 | * @author Crt 256 | * @author Nike 257 | * @author Olli 258 | */ 259 | $messages['fi'] = array( 260 | 'ts-kml-on-ol-options' => 'Asetukset', 261 | 'ts-kml-on-ol-languages' => 'Kielet', 262 | 'ts-kml-on-ol-thumbnails' => 'Pienoiskuvat', 263 | 'ts-kml-on-ol-help' => 'Ohje', 264 | 'ts-kml-on-ol-all' => 'Kaikki', 265 | 'ts-kml-on-ol-map-by' => 'Kartan teki', 266 | ); 267 | 268 | /** French (français) 269 | * @author Gribeco 270 | * @author Zetud 271 | */ 272 | $messages['fr'] = array( 273 | 'ts-kml-on-ol-options' => 'Options', 274 | 'ts-kml-on-ol-languages' => 'Langues', 275 | 'ts-kml-on-ol-thumbnails' => 'Miniatures', 276 | 'ts-kml-on-ol-help' => 'Aide', 277 | 'ts-kml-on-ol-all' => 'Tout', 278 | 'ts-kml-on-ol-map-by' => 'Carte créée par', 279 | ); 280 | 281 | /** Franco-Provençal (arpetan) 282 | * @author ChrisPtDe 283 | */ 284 | $messages['frp'] = array( 285 | 'ts-kml-on-ol-options' => 'Chouèx', 286 | 'ts-kml-on-ol-languages' => 'Lengoues', 287 | 'ts-kml-on-ol-thumbnails' => 'Figures', 288 | 'ts-kml-on-ol-help' => 'Éde', 289 | 'ts-kml-on-ol-all' => 'Tot', 290 | 'ts-kml-on-ol-map-by' => 'Mapa fêta per', 291 | ); 292 | 293 | /** Irish (Gaeilge) 294 | * @author පසිඳු කාවින්ද 295 | */ 296 | $messages['ga'] = array( 297 | 'ts-kml-on-ol-options' => 'Roghanna', 298 | 'ts-kml-on-ol-help' => 'Cuidiú', 299 | 'ts-kml-on-ol-all' => 'Uile', 300 | ); 301 | 302 | /** Galician (galego) 303 | * @author Toliño 304 | */ 305 | $messages['gl'] = array( 306 | 'ts-kml-on-ol-options' => 'Opcións', 307 | 'ts-kml-on-ol-languages' => 'Linguas', 308 | 'ts-kml-on-ol-thumbnails' => 'Miniaturas', 309 | 'ts-kml-on-ol-help' => 'Axuda', 310 | 'ts-kml-on-ol-all' => 'Todas', 311 | 'ts-kml-on-ol-map-by' => 'Mapa de', 312 | ); 313 | 314 | /** Ancient Greek (Ἀρχαία ἑλληνικὴ) 315 | * @author Crazymadlover 316 | */ 317 | $messages['grc'] = array( 318 | 'ts-kml-on-ol-languages' => 'Γλῶτται', 319 | ); 320 | 321 | /** Swiss German (Alemannisch) 322 | * @author Als-Holder 323 | */ 324 | $messages['gsw'] = array( 325 | 'ts-kml-on-ol-options' => 'Optione', 326 | 'ts-kml-on-ol-languages' => 'Sproche', 327 | 'ts-kml-on-ol-thumbnails' => 'Vorschaubilder', 328 | 'ts-kml-on-ol-help' => 'Hilf', 329 | 'ts-kml-on-ol-all' => 'Alli', 330 | 'ts-kml-on-ol-map-by' => 'Charte vu', 331 | ); 332 | 333 | /** Hebrew (עברית) 334 | * @author Amire80 335 | */ 336 | $messages['he'] = array( 337 | 'ts-kml-on-ol-options' => 'אפשרויות', 338 | 'ts-kml-on-ol-languages' => 'שפות', 339 | 'ts-kml-on-ol-thumbnails' => 'תמונות ממוזערות', 340 | 'ts-kml-on-ol-help' => 'עזרה', 341 | 'ts-kml-on-ol-all' => 'הכול', 342 | 'ts-kml-on-ol-map-by' => 'למפות לפי', 343 | ); 344 | 345 | /** Upper Sorbian (hornjoserbsce) 346 | * @author Michawiki 347 | */ 348 | $messages['hsb'] = array( 349 | 'ts-kml-on-ol-options' => 'Opcije', 350 | 'ts-kml-on-ol-languages' => 'Rěče', 351 | 'ts-kml-on-ol-thumbnails' => 'Wobrazki', 352 | 'ts-kml-on-ol-help' => 'Pomoc', 353 | 'ts-kml-on-ol-all' => 'Wšě', 354 | 'ts-kml-on-ol-map-by' => 'Karta wot', 355 | ); 356 | 357 | /** Hungarian (magyar) 358 | * @author Dani 359 | */ 360 | $messages['hu'] = array( 361 | 'ts-kml-on-ol-options' => 'Beállítások', 362 | 'ts-kml-on-ol-languages' => 'Nyelvek', 363 | 'ts-kml-on-ol-thumbnails' => 'Bélyegképek', 364 | 'ts-kml-on-ol-help' => 'Segítség', 365 | 'ts-kml-on-ol-all' => 'Összes', 366 | ); 367 | 368 | /** Interlingua (interlingua) 369 | * @author McDutchie 370 | */ 371 | $messages['ia'] = array( 372 | 'ts-kml-on-ol-options' => 'Optiones', 373 | 'ts-kml-on-ol-languages' => 'Linguas', 374 | 'ts-kml-on-ol-thumbnails' => 'Miniaturas', 375 | 'ts-kml-on-ol-help' => 'Adjuta', 376 | 'ts-kml-on-ol-all' => 'Totes', 377 | 'ts-kml-on-ol-map-by' => 'Carta per', 378 | ); 379 | 380 | /** Indonesian (Bahasa Indonesia) 381 | * @author IvanLanin 382 | */ 383 | $messages['id'] = array( 384 | 'ts-kml-on-ol-options' => 'Pilihan', 385 | 'ts-kml-on-ol-languages' => 'Bahasa', 386 | 'ts-kml-on-ol-thumbnails' => 'Gambar mini', 387 | 'ts-kml-on-ol-help' => 'Bantuan', 388 | 'ts-kml-on-ol-all' => 'Semua', 389 | 'ts-kml-on-ol-map-by' => 'Peta dari', 390 | ); 391 | 392 | /** Italian (italiano) 393 | * @author Beta16 394 | */ 395 | $messages['it'] = array( 396 | 'ts-kml-on-ol-options' => 'Opzioni', 397 | 'ts-kml-on-ol-languages' => 'Lingue', 398 | 'ts-kml-on-ol-thumbnails' => 'Miniature', 399 | 'ts-kml-on-ol-help' => 'Aiuto', 400 | 'ts-kml-on-ol-all' => 'Tutti', 401 | 'ts-kml-on-ol-map-by' => 'Mappa di', 402 | ); 403 | 404 | /** Japanese (日本語) 405 | * @author 青子守歌 406 | */ 407 | $messages['ja'] = array( 408 | 'ts-kml-on-ol-options' => 'オプション', 409 | 'ts-kml-on-ol-languages' => '言語', 410 | 'ts-kml-on-ol-thumbnails' => 'サムネイル', 411 | 'ts-kml-on-ol-help' => 'ヘルプ', 412 | 'ts-kml-on-ol-all' => 'すべて', 413 | 'ts-kml-on-ol-map-by' => '地図から', 414 | ); 415 | 416 | /** Georgian (ქართული) 417 | * @author David1010 418 | */ 419 | $messages['ka'] = array( 420 | 'ts-kml-on-ol-options' => 'პარამეტრები', 421 | 'ts-kml-on-ol-languages' => 'ენები', 422 | 'ts-kml-on-ol-thumbnails' => 'მინიატიურები', 423 | 'ts-kml-on-ol-help' => 'დახმარება', 424 | 'ts-kml-on-ol-all' => 'ყველა', 425 | 'ts-kml-on-ol-map-by' => 'რუკა', 426 | ); 427 | 428 | /** Khmer (ភាសាខ្មែរ) 429 | * @author វ័ណថារិទ្ធ 430 | */ 431 | $messages['km'] = array( 432 | 'ts-kml-on-ol-options' => 'ជម្រើស', 433 | 'ts-kml-on-ol-languages' => 'ភាសា', 434 | 'ts-kml-on-ol-help' => 'ជំនួយ', 435 | 'ts-kml-on-ol-all' => 'ទាំងអស់', 436 | 'ts-kml-on-ol-map-by' => 'ផែនទីដោយ', 437 | ); 438 | 439 | /** Korean (한국어) 440 | * @author 아라 441 | */ 442 | $messages['ko'] = array( 443 | 'ts-kml-on-ol-wikipedia' => '위키백과', 444 | ); 445 | 446 | /** Colognian (Ripoarisch) 447 | * @author Purodha 448 | */ 449 | $messages['ksh'] = array( 450 | 'ts-kml-on-ol-options' => 'Enstellunge', 451 | 'ts-kml-on-ol-languages' => 'Schprooch', 452 | 'ts-kml-on-ol-thumbnails' => 'Minni-Belldsche', 453 | 'ts-kml-on-ol-help' => 'Hölp', 454 | 'ts-kml-on-ol-all' => 'All', 455 | 'ts-kml-on-ol-map-by' => 'Kaat vum', 456 | ); 457 | 458 | /** Kurdish (Latin script) (Kurdî (latînî)‎) 459 | * @author George Animal 460 | * @author Ghybu 461 | * @author Gomada 462 | */ 463 | $messages['ku-latn'] = array( 464 | 'ts-kml-on-ol-options' => 'Vebijêrk', 465 | 'ts-kml-on-ol-languages' => 'Ziman', 466 | 'ts-kml-on-ol-thumbnails' => 'Wêneyên biçûk', 467 | 'ts-kml-on-ol-help' => 'Alîkarî', 468 | 'ts-kml-on-ol-all' => 'Hemû', 469 | ); 470 | 471 | /** Luxembourgish (Lëtzebuergesch) 472 | * @author Robby 473 | */ 474 | $messages['lb'] = array( 475 | 'ts-kml-on-ol-options' => 'Optiounen', 476 | 'ts-kml-on-ol-languages' => 'Sproochen', 477 | 'ts-kml-on-ol-thumbnails' => 'Miniaturbiller', 478 | 'ts-kml-on-ol-help' => 'Hëllef', 479 | 'ts-kml-on-ol-all' => 'All', 480 | 'ts-kml-on-ol-map-by' => 'Kaart vum', 481 | ); 482 | 483 | /** Lingala (lingála) 484 | * @author Eruedin 485 | */ 486 | $messages['ln'] = array( 487 | 'ts-kml-on-ol-languages' => 'Na nkótá isúsu', 488 | 'ts-kml-on-ol-thumbnails' => 'Miniátilɛ', 489 | 'ts-kml-on-ol-help' => 'Bosálisi', 490 | 'ts-kml-on-ol-all' => 'Nyɔ́nsɔ', 491 | 'ts-kml-on-ol-map-by' => 'Carte créée par', 492 | ); 493 | 494 | /** Latgalian (latgaļu) 495 | * @author Dark Eagle 496 | */ 497 | $messages['ltg'] = array( 498 | 'ts-kml-on-ol-all' => 'Vysi', 499 | ); 500 | 501 | /** Latvian (latviešu) 502 | * @author Papuass 503 | */ 504 | $messages['lv'] = array( 505 | 'ts-kml-on-ol-options' => 'Iespējas', 506 | 'ts-kml-on-ol-languages' => 'Valodas', 507 | 'ts-kml-on-ol-thumbnails' => 'Sīktēli', 508 | 'ts-kml-on-ol-help' => 'Palīdzība', 509 | 'ts-kml-on-ol-all' => 'Visas', 510 | 'ts-kml-on-ol-map-by' => 'Karte no', 511 | ); 512 | 513 | /** Macedonian (македонски) 514 | * @author Bjankuloski06 515 | */ 516 | $messages['mk'] = array( 517 | 'ts-kml-on-ol-options' => 'Нагодувања', 518 | 'ts-kml-on-ol-languages' => 'Јазици', 519 | 'ts-kml-on-ol-thumbnails' => 'Минијатури', 520 | 'ts-kml-on-ol-help' => 'Помош', 521 | 'ts-kml-on-ol-all' => 'Сите', 522 | 'ts-kml-on-ol-map-by' => 'Карта:', 523 | 'ts-kml-on-ol-wikipedia' => 'Википедија', 524 | ); 525 | 526 | /** Malayalam (മലയാളം) 527 | * @author Praveenp 528 | */ 529 | $messages['ml'] = array( 530 | 'ts-kml-on-ol-options' => 'ഐച്ഛികങ്ങൾ', 531 | 'ts-kml-on-ol-languages' => 'ഭാഷകൾ', 532 | 'ts-kml-on-ol-thumbnails' => 'ലഘുചിത്രങ്ങൾ', 533 | 'ts-kml-on-ol-help' => 'സഹായം', 534 | 'ts-kml-on-ol-all' => 'എല്ലാം', 535 | 'ts-kml-on-ol-map-by' => 'ഭൂപട ഉടമ', 536 | ); 537 | 538 | /** Malay (Bahasa Melayu) 539 | * @author Anakmalaysia 540 | */ 541 | $messages['ms'] = array( 542 | 'ts-kml-on-ol-options' => 'Pilihan', 543 | 'ts-kml-on-ol-languages' => 'Bahasa', 544 | 'ts-kml-on-ol-thumbnails' => 'Lakaran kenit', 545 | 'ts-kml-on-ol-help' => 'Bantuan', 546 | 'ts-kml-on-ol-all' => 'Semua', 547 | 'ts-kml-on-ol-map-by' => 'Peta oleh', 548 | ); 549 | 550 | /** Mazanderani (مازِرونی) 551 | * @author محک 552 | */ 553 | $messages['mzn'] = array( 554 | 'ts-kml-on-ol-help' => 'راهنما', 555 | ); 556 | 557 | /** Norwegian Bokmål (norsk (bokmål)‎) 558 | * @author Nghtwlkr 559 | */ 560 | $messages['nb'] = array( 561 | 'ts-kml-on-ol-options' => 'Alternativer', 562 | 'ts-kml-on-ol-languages' => 'Språk', 563 | 'ts-kml-on-ol-thumbnails' => 'Miniatyrbilder', 564 | 'ts-kml-on-ol-help' => 'Hjelp', 565 | 'ts-kml-on-ol-all' => 'Alle', 566 | 'ts-kml-on-ol-map-by' => 'Kart av', 567 | ); 568 | 569 | /** Low German (Plattdüütsch) 570 | * @author Slomox 571 | */ 572 | $messages['nds'] = array( 573 | 'ts-kml-on-ol-options' => 'Instellen', 574 | 'ts-kml-on-ol-languages' => 'Spraken', 575 | 'ts-kml-on-ol-thumbnails' => 'Duumnagelbiller', 576 | 'ts-kml-on-ol-help' => 'Hülp', 577 | 'ts-kml-on-ol-all' => 'All', 578 | 'ts-kml-on-ol-map-by' => 'Koort von', 579 | ); 580 | 581 | /** Dutch (Nederlands) 582 | * @author Siebrand 583 | */ 584 | $messages['nl'] = array( 585 | 'ts-kml-on-ol-options' => 'Instellingen', 586 | 'ts-kml-on-ol-languages' => 'Talen', 587 | 'ts-kml-on-ol-thumbnails' => 'Miniaturen', 588 | 'ts-kml-on-ol-help' => 'Hulp', 589 | 'ts-kml-on-ol-all' => 'Alle', 590 | 'ts-kml-on-ol-map-by' => 'Kaart door', 591 | ); 592 | 593 | /** Norwegian Nynorsk (norsk (nynorsk)‎) 594 | * @author Harald Khan 595 | * @author Njardarlogar 596 | */ 597 | $messages['nn'] = array( 598 | 'ts-kml-on-ol-options' => 'Val', 599 | 'ts-kml-on-ol-languages' => 'Språk', 600 | 'ts-kml-on-ol-thumbnails' => 'Miniatyrbilete', 601 | 'ts-kml-on-ol-help' => 'Hjelp', 602 | 'ts-kml-on-ol-all' => 'Alle', 603 | 'ts-kml-on-ol-map-by' => 'Kartet er frå', 604 | ); 605 | 606 | /** Deitsch (Deitsch) 607 | * @author Xqt 608 | */ 609 | $messages['pdc'] = array( 610 | 'ts-kml-on-ol-languages' => 'Schprooche', 611 | 'ts-kml-on-ol-help' => 'Hilf', 612 | 'ts-kml-on-ol-all' => 'All', 613 | ); 614 | 615 | /** Polish (polski) 616 | * @author Sp5uhe 617 | */ 618 | $messages['pl'] = array( 619 | 'ts-kml-on-ol-options' => 'Opcje', 620 | 'ts-kml-on-ol-languages' => 'Języki', 621 | 'ts-kml-on-ol-thumbnails' => 'Miniatury', 622 | 'ts-kml-on-ol-help' => 'Pomoc', 623 | 'ts-kml-on-ol-all' => 'Wszystko', 624 | 'ts-kml-on-ol-map-by' => 'Mapa', 625 | ); 626 | 627 | /** Piedmontese (Piemontèis) 628 | * @author Borichèt 629 | * @author Dragonòt 630 | */ 631 | $messages['pms'] = array( 632 | 'ts-kml-on-ol-options' => 'Opsion', 633 | 'ts-kml-on-ol-languages' => 'Lenghe', 634 | 'ts-kml-on-ol-thumbnails' => 'Miniadure', 635 | 'ts-kml-on-ol-help' => 'Agiut', 636 | 'ts-kml-on-ol-all' => 'Tùit', 637 | 'ts-kml-on-ol-map-by' => 'Carta creà da', 638 | ); 639 | 640 | /** Pashto (پښتو) 641 | * @author Ahmed-Najib-Biabani-Ibrahimkhel 642 | */ 643 | $messages['ps'] = array( 644 | 'ts-kml-on-ol-options' => 'خوښنې', 645 | 'ts-kml-on-ol-languages' => 'ژبې', 646 | 'ts-kml-on-ol-help' => 'لارښود', 647 | 'ts-kml-on-ol-all' => 'ټول', 648 | ); 649 | 650 | /** Portuguese (português) 651 | * @author Hamilton Abreu 652 | */ 653 | $messages['pt'] = array( 654 | 'ts-kml-on-ol-options' => 'Opções', 655 | 'ts-kml-on-ol-languages' => 'Línguas', 656 | 'ts-kml-on-ol-thumbnails' => 'Miniaturas', 657 | 'ts-kml-on-ol-help' => 'Ajuda', 658 | 'ts-kml-on-ol-all' => 'Todas', 659 | 'ts-kml-on-ol-map-by' => 'Mapa de', 660 | ); 661 | 662 | /** Brazilian Portuguese (português do Brasil) 663 | * @author Giro720 664 | */ 665 | $messages['pt-br'] = array( 666 | 'ts-kml-on-ol-options' => 'Opções', 667 | 'ts-kml-on-ol-languages' => 'Línguas', 668 | 'ts-kml-on-ol-thumbnails' => 'Miniaturas', 669 | 'ts-kml-on-ol-help' => 'Ajuda', 670 | 'ts-kml-on-ol-all' => 'Todas', 671 | 'ts-kml-on-ol-map-by' => 'Mapa criado por', 672 | ); 673 | 674 | /** Romanian (română) 675 | * @author Minisarm 676 | * @author Stelistcristi 677 | */ 678 | $messages['ro'] = array( 679 | 'ts-kml-on-ol-options' => 'Opțiuni', 680 | 'ts-kml-on-ol-languages' => 'Limbi', 681 | 'ts-kml-on-ol-thumbnails' => 'Miniaturi', 682 | 'ts-kml-on-ol-help' => 'Ajutor', 683 | 'ts-kml-on-ol-all' => 'Toate', 684 | 'ts-kml-on-ol-map-by' => 'Hartă creată de', 685 | ); 686 | 687 | /** Russian (русский) 688 | * @author Александр Сигачёв 689 | */ 690 | $messages['ru'] = array( 691 | 'ts-kml-on-ol-options' => 'Настройки', 692 | 'ts-kml-on-ol-languages' => 'Языки', 693 | 'ts-kml-on-ol-thumbnails' => 'Миниатюры', 694 | 'ts-kml-on-ol-help' => 'Справка', 695 | 'ts-kml-on-ol-all' => 'Все', 696 | 'ts-kml-on-ol-map-by' => 'Карта от', 697 | ); 698 | 699 | /** Sinhala (සිංහල) 700 | * @author පසිඳු කාවින්ද 701 | */ 702 | $messages['si'] = array( 703 | 'ts-kml-on-ol-options' => 'විකල්පයන්', 704 | 'ts-kml-on-ol-languages' => 'භාෂාවන්', 705 | 'ts-kml-on-ol-thumbnails' => 'සිඟිතිරූ', 706 | 'ts-kml-on-ol-help' => 'උදව්', 707 | 'ts-kml-on-ol-all' => 'සියල්ල', 708 | ); 709 | 710 | /** Slovak (slovenčina) 711 | * @author Teslaton 712 | */ 713 | $messages['sk'] = array( 714 | 'ts-kml-on-ol-options' => 'Voľby', 715 | 'ts-kml-on-ol-languages' => 'Jazyky', 716 | 'ts-kml-on-ol-thumbnails' => 'Náhľady', 717 | 'ts-kml-on-ol-help' => 'Pomoc', 718 | 'ts-kml-on-ol-all' => 'Všetky', 719 | 'ts-kml-on-ol-map-by' => 'Mapa z', 720 | 'ts-kml-on-ol-wikipedia' => 'Wikipédia', 721 | ); 722 | 723 | /** Slovenian (slovenščina) 724 | * @author Dbc334 725 | */ 726 | $messages['sl'] = array( 727 | 'ts-kml-on-ol-options' => 'Možnosti', 728 | 'ts-kml-on-ol-languages' => 'Jeziki', 729 | 'ts-kml-on-ol-thumbnails' => 'Sličice', 730 | 'ts-kml-on-ol-help' => 'Pomoč', 731 | 'ts-kml-on-ol-all' => 'Vse', 732 | 'ts-kml-on-ol-map-by' => 'Zemljevid od', 733 | ); 734 | 735 | /** Somali (Soomaaliga) 736 | * @author Euriditi 737 | * @author Maax 738 | */ 739 | $messages['so'] = array( 740 | 'ts-kml-on-ol-options' => '', 741 | 'ts-kml-on-ol-languages' => '', 742 | 'ts-kml-on-ol-thumbnails' => '', 743 | 'ts-kml-on-ol-help' => '', 744 | 'ts-kml-on-ol-all' => 'Dhamaan', 745 | 'ts-kml-on-ol-map-by' => '', 746 | ); 747 | 748 | /** Albanian (shqip) 749 | * @author Euriditi 750 | */ 751 | $messages['sq'] = array( 752 | 'ts-kml-on-ol-options' => 'Opsione', 753 | 'ts-kml-on-ol-languages' => 'Gjuhët', 754 | 'ts-kml-on-ol-thumbnails' => 'Foto në miniaturë', 755 | 'ts-kml-on-ol-help' => 'Ndihmë', 756 | 'ts-kml-on-ol-all' => 'Të gjitha', 757 | 'ts-kml-on-ol-map-by' => 'Harta nga', 758 | 'ts-kml-on-ol-openstreetmap' => 'OpenStreetMap', 759 | 'ts-kml-on-ol-wikipedia' => 'Wikipedia', 760 | ); 761 | 762 | /** Serbian (Cyrillic script) (српски (ћирилица)‎) 763 | * @author Rancher 764 | */ 765 | $messages['sr-ec'] = array( 766 | 'ts-kml-on-ol-openstreetmap' => 'Опенстритмап', 767 | 'ts-kml-on-ol-wikipedia' => 'Википедија', 768 | ); 769 | 770 | /** Serbian (Latin script) (srpski (latinica)‎) */ 771 | $messages['sr-el'] = array( 772 | 'ts-kml-on-ol-openstreetmap' => 'Openstritmap', 773 | 'ts-kml-on-ol-wikipedia' => 'Vikipedija', 774 | ); 775 | 776 | /** Swedish (svenska) 777 | * @author Ainali 778 | */ 779 | $messages['sv'] = array( 780 | 'ts-kml-on-ol-options' => 'Alternativ', 781 | 'ts-kml-on-ol-languages' => 'Språk', 782 | 'ts-kml-on-ol-thumbnails' => 'Miniatyrbilder', 783 | 'ts-kml-on-ol-help' => 'Hjälp', 784 | 'ts-kml-on-ol-all' => 'Alla', 785 | 'ts-kml-on-ol-map-by' => 'Karta av', 786 | ); 787 | 788 | /** Tamil (தமிழ்) 789 | * @author Karthi.dr 790 | */ 791 | $messages['ta'] = array( 792 | 'ts-kml-on-ol-options' => 'விருப்பத்தேர்வுகள்', 793 | 'ts-kml-on-ol-languages' => 'மொழிகள்', 794 | 'ts-kml-on-ol-help' => 'உதவி', 795 | ); 796 | 797 | /** Telugu (తెలుగు) 798 | * @author Veeven 799 | */ 800 | $messages['te'] = array( 801 | 'ts-kml-on-ol-options' => 'ఎంపికలు', 802 | 'ts-kml-on-ol-languages' => 'భాషలు', 803 | 'ts-kml-on-ol-thumbnails' => 'నఖచిత్రాలు', 804 | 'ts-kml-on-ol-help' => 'సహాయం', 805 | 'ts-kml-on-ol-all' => 'అన్నీ', 806 | 'ts-kml-on-ol-map-by' => 'పటపు సౌజన్యం', 807 | ); 808 | 809 | /** Tetum (tetun) 810 | * @author MF-Warburg 811 | */ 812 | $messages['tet'] = array( 813 | 'ts-kml-on-ol-languages' => 'Lian sira', 814 | 'ts-kml-on-ol-all' => 'Hotu', 815 | ); 816 | 817 | /** Tagalog (Tagalog) 818 | * @author AnakngAraw 819 | */ 820 | $messages['tl'] = array( 821 | 'ts-kml-on-ol-options' => 'Mga mapipili', 822 | 'ts-kml-on-ol-languages' => 'Mga wika', 823 | 'ts-kml-on-ol-thumbnails' => 'Mga kagyat', 824 | 'ts-kml-on-ol-help' => 'Saklolo', 825 | 'ts-kml-on-ol-all' => 'Lahat', 826 | 'ts-kml-on-ol-map-by' => 'Imapa ayon sa', 827 | 'ts-kml-on-ol-openstreetmap' => 'OpenStreetMap', 828 | 'ts-kml-on-ol-wikipedia' => 'Wikipedia', 829 | ); 830 | 831 | /** толышә зывон (толышә зывон) 832 | * @author Erdemaslancan 833 | */ 834 | $messages['tly'] = array( 835 | 'ts-kml-on-ol-options' => 'Кукон', 836 | 'ts-kml-on-ol-help' => 'Арајиш', 837 | ); 838 | 839 | /** Turkish (Türkçe) 840 | * @author Katpatuka 841 | */ 842 | $messages['tr'] = array( 843 | 'ts-kml-on-ol-options' => 'Seçenekler', 844 | 'ts-kml-on-ol-languages' => 'Diller', 845 | 'ts-kml-on-ol-thumbnails' => 'Tırnak resimler', 846 | 'ts-kml-on-ol-help' => 'Yardım', 847 | 'ts-kml-on-ol-all' => 'Hepsi', 848 | 'ts-kml-on-ol-map-by' => 'Haritayı sunan', 849 | ); 850 | 851 | /** Ukrainian (українська) 852 | * @author Тест 853 | */ 854 | $messages['uk'] = array( 855 | 'ts-kml-on-ol-languages' => 'Мови', 856 | 'ts-kml-on-ol-help' => 'Довідка', 857 | ); 858 | 859 | /** Urdu (اردو) 860 | * @author පසිඳු කාවින්ද 861 | */ 862 | $messages['ur'] = array( 863 | 'ts-kml-on-ol-options' => 'اختیارات', 864 | 'ts-kml-on-ol-languages' => 'زبانوں میں', 865 | 'ts-kml-on-ol-help' => 'مدد', 866 | 'ts-kml-on-ol-all' => 'سب', 867 | ); 868 | 869 | /** vèneto (vèneto) 870 | * @author GatoSelvadego 871 | */ 872 | $messages['vec'] = array( 873 | 'ts-kml-on-ol-options' => 'Opsion', 874 | 'ts-kml-on-ol-languages' => 'Lengue', 875 | 'ts-kml-on-ol-thumbnails' => 'Miniadura', 876 | 'ts-kml-on-ol-help' => 'Ajuto', 877 | 'ts-kml-on-ol-all' => 'Tuti', 878 | 'ts-kml-on-ol-map-by' => 'Mapa de', 879 | ); 880 | 881 | /** Vietnamese (Tiếng Việt) 882 | * @author Minh Nguyen 883 | */ 884 | $messages['vi'] = array( 885 | 'ts-kml-on-ol-options' => 'Tùy chọn', 886 | 'ts-kml-on-ol-languages' => 'Ngôn ngữ', 887 | 'ts-kml-on-ol-thumbnails' => 'Hình nhỏ', 888 | 'ts-kml-on-ol-help' => 'Trợ giúp', 889 | 'ts-kml-on-ol-all' => 'Tất cả', 890 | 'ts-kml-on-ol-map-by' => 'Bản đồ', 891 | ); 892 | 893 | /** Yiddish (ייִדיש) 894 | * @author פוילישער 895 | * @author පසිඳු කාවින්ද 896 | */ 897 | $messages['yi'] = array( 898 | 'ts-kml-on-ol-options' => 'ברירות', 899 | 'ts-kml-on-ol-languages' => 'שפּראַכן', 900 | 'ts-kml-on-ol-help' => 'הילף', 901 | 'ts-kml-on-ol-all' => 'אַלע', 902 | ); 903 | 904 | /** Simplified Chinese (中文(简体)‎) 905 | * @author Hydra 906 | * @author Shirayuki 907 | */ 908 | $messages['zh-hans'] = array( 909 | 'ts-kml-on-ol-options' => '选项', 910 | 'ts-kml-on-ol-languages' => '语言', 911 | 'ts-kml-on-ol-wikipedia' => '维基百科', 912 | ); 913 | 914 | /** Traditional Chinese (中文(繁體)‎) */ 915 | $messages['zh-hant'] = array( 916 | 'ts-kml-on-ol-options' => '選項', 917 | 'ts-kml-on-ol-languages' => '語言', 918 | 'ts-kml-on-ol-wikipedia' => '維基百科', 919 | ); 920 | 921 | -------------------------------------------------------------------------------- /client/kml-on-ol.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Wikipedia on OpenStreetMap 6 | 7 | 8 | 9 | "; 28 | return $a; 29 | } 30 | 31 | function detect_not_ie() 32 | { 33 | if (isset($_SERVER['HTTP_USER_AGENT']) && 34 | (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) 35 | return false; 36 | else 37 | return true; 38 | } 39 | 40 | $lang=addslashes(urldecode($_GET[lang])); 41 | $uselang=addslashes(urldecode($_GET[uselang])); 42 | if ($uselang=="") {$uselang=$lang;} 43 | if ($lang=="wikidata") {$langwiki=$uselang;} else {$langwiki=$lang;} 44 | 45 | $thumbs=addslashes($_GET[thumbs]); 46 | if (($thumbs=="no") or ($thumbs=="yes")) {$thumbsinsert=", 'thumbs' : '$thumbs'";} else {$thumbsinsert=", 'thumbs' : '0'";} 47 | $coats=addslashes($_GET[coats]); 48 | if (($coats=="no") or ($coats=="yes")) {$coatsinsert=", 'coats' : '$coats'";} else {$coatsinsert=", 'coats' : '0'";} 49 | $pop=addslashes($_GET[pop]); 50 | if (($pop<>"")) {$popinsert=", 'pop' : '$pop'";} 51 | $style=addslashes($_GET[style]); 52 | if (($style<>"")) {$styleinsert=", 'style' : '$style'";} 53 | $photo=addslashes($_GET[photo]); 54 | if (($photo=="no") or ($photo=="yes")) {$photoinsert=", 'photo' : '$photo'";} 55 | $source=addslashes($_GET[source]); 56 | if (($source<>"")) {$sourceinsert=", 'source' : '$source'";} 57 | $notsource=addslashes($_GET[notsource]); 58 | if (($notsource<>"")) {$notsourceinsert=", 'notsource' : '$notsource'";} 59 | 60 | $title=urldecode($_GET[title]); 61 | $action=addslashes(urldecode($_GET[action])); 62 | 63 | $title=urldecode($_GET[title]); 64 | if ($title=="") {$title=urldecode($_GET[pagename]);} #hack for nl.wp 65 | 66 | $classes=urldecode($_GET[classes]); 67 | if ($classes<>"") {$classesinsert=", 'classes' : '$classes'";} 68 | 69 | // Geohack 70 | 71 | if ( isset ( $_REQUEST['params'] ) ) { 72 | $p = new geo_param( $_REQUEST['params'] , "Dummy" ); ; 73 | $x = floatval($p->londeg) ; 74 | $y = floatval($p->latdeg) ; 75 | 76 | $type = substr($p->type,0,10) ; 77 | $dim= floatval($p->dim) ; 78 | 79 | } 80 | 81 | $theparams =$_REQUEST['params']; 82 | $typeleftcut = strstr($theparams,"type:"); 83 | $type = substr ($typeleftcut, 5 ); 84 | if (strpos($type,"(")>0) {$type = substr($type,0,strpos($type,"("));} 85 | if (strpos($type,"_")>0) {$type = substr($type,0,strpos($type,"_"));} 86 | 87 | $default_scale = array( 88 | 'country' => 10000000, # 10 mill 89 | 'satellite' => 10000000, # 10 mill 90 | 'state' => 3000000, # 3 mill 91 | 'adm1st' => 1000000, # 1 mill 92 | 'adm2nd' => 300000, # 300 thousand 93 | 'adm3rd' => 100000, # 100 thousand 94 | 'city' => 100000, # 100 thousand 95 | 'isle' => 100000, # 100 thousand 96 | 'mountain' => 100000, # 100 thousand 97 | 'river' => 100000, # 100 thousand 98 | 'waterbody' => 100000, # 100 thousand 99 | 'event' => 50000, # 50 thousand 100 | 'forest' => 50000, # 50 thousand 101 | 'glacier' => 50000, # 50 thousand 102 | 'airport' => 30000, # 30 thousand 103 | 'railwaystation' => 10000, # 10 thousand 104 | 'edu' => 10000, # 10 thousand 105 | 'pass' => 10000, # 10 thousand 106 | 'landmark' => 10000 # 10 thousand 107 | ); 108 | $zoomtype=18 - ( round(log($default_scale[$type],2) - log(1693,2)) ); 109 | 110 | $dimleftcut = strstr($theparams,"dim:"); 111 | $dim = substr ($dimleftcut, 4 ); 112 | if (strpos($dim,"(")>0) {$dim = substr($dim,0,strpos($dim,"("));} 113 | if (strpos($dim,"_")>0) {$dim = substr($dim,0,strpos($dim,"_"));} 114 | $dim = floatval(str_replace(array("km","m"),array("000",""),$dim)); 115 | 116 | if ($dim>0) 117 | {$zoomtype=18 - ( round(log($dim/0.1,2) - log(1693,2)) );} 118 | 119 | if ($zoomtype>18) {$zoom=18;$zoomtype=18;} 120 | if ($zoomtype>2 ) {$zoom=$zoomtype;} else {$zoom=12;} 121 | 122 | $position= " var zoom = $zoom;"; 123 | if ($x<>""){$position.=" 124 | args.lon = $x; 125 | args.lat = $y; ";} 126 | 127 | echo "\n"; 128 | // Geohack end 129 | ?> 130 | 131 | 132 | 133 | 134 | 135 | 136 | 713 | 714 | 833 | 834 | 835 | 836 | 837 | 838 |
839 |
840 | 841 |
842 | 843 |
844 |
845 | 846 |
847 |
848 | 849 | 850 |

851 |
852 | 853 |

854 |
855 | 856 |
857 | 858 | 859 |
860 | 865 |

866 | 867 |
868 | 869 |
870 | 871 | 872 | 873 | 874 | -------------------------------------------------------------------------------- /client/lang-select.php: -------------------------------------------------------------------------------- 1 | "; 11 | return $a; 12 | } 13 | 14 | $uselang=addslashes(urldecode($_GET[lang])); 15 | 16 | $langCapital=ucwords($uselang); 17 | 18 | $alllangs=array("wikidata","aa","ab","ace","af","ak","als","am","an","ang","ar","arc","arz","ast","av","ay","az","ba", 19 | "bar","bat-smg","bcl","be","be-x-old","bg","bh","bi","bm","bn","bo","bpy","br","bs","bug","bxr","ca","cbk-zam","cdo", 20 | "ce","ceb","ch","cho","chr","chy","ckb","co","cr","crh","cs","csb","cu","cv","cy","da","de","diq","dsb","dv","dz","ee", 21 | "el","eml","en","en-simple","eo","es","et","eu","ext","fa","ff","fi","fiu-vro","fj","fo","fr","frp","fur","fy","ga", 22 | "gan","gd","gl","glk","gn","got","gu","gv","ha","hak","haw","he","hi","hif","ho","hr","hsb","ht","hu","hy","hz","ia", 23 | "id","ie","ig","ii","ik","ilo","io","is","it","iu","ja","jbo","jv","ka","kaa","kab","kg","ki","kj","kk","kl","km", 24 | "kn","ko","kr","ks","ksh","ku","kv","kw","ky","la","lad","lb","lbe","lg","li","lij","lmo","ln","lo","lt","lv", 25 | "map-bms","mdf","mg","mh","mhr","mi","mk","ml","mn","mo","mr","ms","mt","mus","mwl","my","myv","mzn","na","nah", 26 | "nap","nds","nds-nl","ne","new","ng","nl","nn","no","nostalgia","nov","nrm","nv","ny","oc","om","or", 27 | "os","pa","pag","pam","pap","pcd","pdc","pi","pih","pl","pms","pnb","pnt","ps","pt","qu","rm","rmy","rn","ro", 28 | "roa-rup","roa-tara","ru","rw","sa","sah","sc","scn","sco","sd","se","sg","sh","si","simple","sk","sl","sm","sn", 29 | "so","sq","sr","srn","ss","st","stq","su","sv","sw","szl","ta","te","tet","tg","th","ti","tk","tl","tlh","tn","to", 30 | "tokipona","tpi","tr","ts","tt","tum","tw","ty","udm","ug","uk","ur","uz","ve","vec","vi","vls","vo","wa","war","wo", 31 | "wuu","xal","xh","yi","yo","za","zea","zh","zh-classical","zh-min-nan","zh-yue","zu"); 32 | #Wikipedias with >1000 articles 33 | $alllangs_red=array("wikidata","ace","af","als","am","an","ang","ar","arc","arz","ast","ay","az","bar","bat-smg","bcl","be", 34 | "be-x-old","bg","bh","bn","bo","bpy","br","bs","ca","cbk-zam","ceb","ckb","co","crh","cs","csb","cv","cy","da","de","diq","dv", 35 | "el","eml","en","eo","es","et","eu","ext","fa","fi","fiu-vro","fj","fo","fr","frp","fur","fy","ga","gan","gd","gl","glk","gn", 36 | "gu","gv","hak","haw","he","hi","hif","hr","hsb","ht","hu","hy","ia","id","ie","ilo","io","is","it","ja","jbo","jv","ka","kk", 37 | "km","kn","ko","krc","ksh","ku","kv","kw","ky","la","lad","lb","li","lij","lmo","ln","lt","lv","map-bms","mg","mhr","mi","mk", 38 | "ml","mn","mr","ms","mt","my","myv","mzn","nah","nap","nds","nds-nl","ne","new","nl","nn","no","nov","nrm","nv","oc","os","pa", 39 | "pag","pam","pcd","pdc","pi","pl","pms","pnb","ps","pt","qu","rm","ro","roa-rup","roa-tara","ru","sa","sah","sc","scn","sco", 40 | "se","sg","sh","si","simple","sk","sl","so","sq","sr","stq","su","sv","sw","szl","ta","te","tg","th","tk","tl","to","tr","tt", 41 | "ug","uk","ur","uz","vec","vi","vls","vo","wa","war","wo","wuu","xal","yi","yo","zh","zh-classical","zh-min-nan","zh-yue"); 42 | 43 | 44 | include "./cldr/LanguageNames".$langCapital.".php";?> 45 | 46 | 47 |
48 | 50 | '; 51 | foreach ($alllangs_red as $key => $la) { 52 | if ($la==$uselang) {$select=" selected ";} else {$select="";} 53 | echo '\n"; 54 | } 55 | echo ''; 56 | ?> 57 | 58 |

59 | 60 | 61 | 62 | 63 |
64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /client/mapsources.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * This program is free software; you can redistribute it and/or modify 18 | * it under the terms of the GNU General Public License as published by 19 | * the Free Software Foundation; either version 2 of the License, or 20 | * (at your option) any later version. 21 | * 22 | * This program is distributed in the hope that it will be useful, 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 | * GNU General Public License for more details. 26 | * 27 | * You should have received a copy of the GNU General Public License 28 | * along with this program; if not, write to the Free Software 29 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 30 | */ 31 | 32 | require_once( 'transversemercator.php' ); 33 | 34 | /** 35 | * Base class 36 | */ 37 | class map_sources { 38 | var $p; 39 | var $mapsources; 40 | var $thetext ; 41 | 42 | function map_sources( $coor, $title ) { 43 | $this->p = new geo_param( $coor, $title ); 44 | $this->p->title = $title; 45 | 46 | $this->mapsources = "Map sources"; 47 | # FIXME: translate via wfMsg( "mapsources" ) 48 | } 49 | /* 50 | function show() { 51 | global $wgOut; 52 | 53 | // No reason for robots to follow map links 54 | $wgOut->setRobotpolicy( 'noindex,nofollow' ); 55 | 56 | $wgOut->setPagetitle( $this->mapsources ); 57 | $wgOut->addWikiText( $this->build_output() ); 58 | } 59 | */ 60 | function build_output() { 61 | # global $wgOut, $wgUser, $wgContLang, $wgRequest; 62 | /* 63 | if (($e = $this->p->get_error()) != "") { 64 | $wgOut->addHTML( 65 | "

" . htmlspecialchars( $e ) . "

"); 66 | $wgOut->output(); 67 | wfErrorExit(); 68 | return ""; 69 | } 70 | */ 71 | $attr = $this->p->get_attr(); 72 | 73 | #$sk = $wgUser->getSkin(); 74 | 75 | # 76 | # dim: to scale: convertion 77 | # 78 | if ( !isset( $attr['scale'] ) && isset( $attr['dim'] ) ) { 79 | # dia (m) [ (in per m) * (pixels per in) * screen size ] 80 | # Assume viewport size is 10 cm by 10 cm 81 | # FIXME document numbers 82 | # FIXME better convertion 83 | $attr['scale'] = str_replace(array("km","m"),array("000",""),$attr['dim']) / 0.1; 84 | } 85 | 86 | # 87 | # Default scale 88 | # 89 | if ( !isset( $attr['scale'] ) || $attr['scale'] <= 0) { 90 | if ( !isset( $attr['default'] ) || $attr['default'] == 0) { 91 | $default_scale = array( 92 | 'country' => 10000000, # 10 mill 93 | 'satellite' => 10000000, # 10 mill 94 | 'state' => 3000000, # 3 mill 95 | 'adm1st' => 1000000, # 1 mill 96 | 'adm2nd' => 300000, # 300 thousand 97 | 'adm3rd' => 100000, # 100 thousand 98 | 'city' => 100000, # 100 thousand 99 | 'isle' => 100000, # 100 thousand 100 | 'mountain' => 100000, # 100 thousand 101 | 'river' => 100000, # 100 thousand 102 | 'waterbody' => 100000, # 100 thousand 103 | 'event' => 50000, # 50 thousand 104 | 'forest' => 50000, # 50 thousand 105 | 'glacier' => 50000, # 50 thousand 106 | 'airport' => 30000, # 30 thousand 107 | 'railwaystation' => 10000, # 10 thousand 108 | 'edu' => 10000, # 10 thousand 109 | 'pass' => 10000, # 10 thousand 110 | 'landmark' => 10000 # 10 thousand 111 | ); 112 | 113 | 114 | if( isset ( $attr['type'] ) ) { 115 | $attr['default'] = $default_scale[$attr['type']]; 116 | } else { 117 | $attr['default'] = 0; 118 | } 119 | 120 | # FIXME: Scale according to city size, if available 121 | } 122 | if ($attr['default'] == 0) { 123 | /* No type and no default, make an assumption */ 124 | # FIXME: scale to input precision 125 | if ( count($this->p->coor) == 8 ) { # DMS 126 | $attr['default'] = 10000; # 10 thousand 127 | } else if ( count($this->p->coor) == 6 ){ # DM 128 | $attr['default'] = 100000; # 500 thousand 129 | } else { 130 | $attr['default'] = 300000; # 3000 thousand 131 | } 132 | } 133 | $attr['scale'] = $attr['default']; 134 | } 135 | 136 | /* 137 | * Convert coordinates to various Transverse Mercator forms 138 | */ 139 | 140 | /* standard UTM */ 141 | $utm = new transversemercator(); 142 | $utm->LatLon2UTM( $this->p->latdeg, $this->p->londeg ); 143 | $utm->Zone = $utm->LatLon2UTMZone( $this->p->latdeg, $this->p->londeg ); 144 | 145 | /* fixed UTM as used by iNatur */ 146 | $utm33 = new transversemercator(); 147 | $utm33->LatLonZone2UTM( $this->p->latdeg, $this->p->londeg, "33V" ); 148 | 149 | /* UK National Grid, see http://www.gps.gov.uk/guide7.asp 150 | * central meridian 47N 2W, offset 100km N 400km W */ 151 | $osgb36 = new transversemercator(); 152 | $osgb36ref = $osgb36->LatLon2OSGB36( $this->p->latdeg, $this->p->londeg ); 153 | 154 | /* Swiss traditional national grid */ 155 | $ch1903 = new transversemercator(); 156 | $ch1903->LatLon2CH1903( $this->p->latdeg, $this->p->londeg ); 157 | 158 | /* 159 | * Mapquest style zoom 160 | * 9 is approx 1:6,000 161 | * 5 (default) is approx 1:333,000 162 | * 2 is approx 1:8,570,000 163 | * 0 is minimum 164 | */ 165 | if ( isset( $attr['scale'] ) && $attr['scale'] > 0) { 166 | $zoom = intval(18.0 - log($attr['scale'])); 167 | } else { 168 | $zoom = 9; 169 | } 170 | if ($zoom < 0) $zoom = 0; 171 | if ($zoom > 9) $zoom = 9; 172 | 173 | /* 174 | * Openstreetmap style zoom 175 | * 18 (max) is 1:1,693 176 | * n-1 is half of n 177 | * 2 (min) is about 1:111,000,000 178 | */ 179 | if ( isset( $attr['scale'] ) && $attr['scale'] > 0) { 180 | $osmzoom = 18 - ( round(log($attr['scale'],2) - log(1693,2)) ); 181 | } else { 182 | $osmzoom = 12; 183 | } 184 | if ($osmzoom < 0) $osmzoom = 0; 185 | if ($osmzoom > 18) $osmzoom = 18; 186 | 187 | /* 188 | 189 | /* 190 | * MSN uses an altitude equivalent 191 | * instead of a scale: 192 | * 143 == 1:1000000 scale 193 | */ 194 | $altitude = intval( $attr['scale'] * 143/1000000 ); 195 | if ($altitude < 1) $altitude = 1; 196 | 197 | /* 198 | * Tiger and Google uses a span 199 | * FIXME calibration 200 | * 1.0 for 1:1000000 201 | */ 202 | $span = $attr['scale'] * 1.0 / 1000000; 203 | 204 | /* 205 | * Multimap has a fixed set of scales 206 | * and will choke unless one of them are specified 207 | */ 208 | if ($attr['scale'] >= 30000000) $mmscale = 40000000; 209 | elseif ($attr['scale'] >= 14000000) $mmscale = 20000000; 210 | elseif ($attr['scale'] >= 6300000) $mmscale = 10000000; 211 | elseif ($attr['scale'] >= 2800000) $mmscale = 4000000; 212 | elseif ($attr['scale'] >= 1400000) $mmscale = 2000000; 213 | elseif ($attr['scale'] >= 700000) $mmscale = 1000000; 214 | elseif ($attr['scale'] >= 310000) $mmscale = 500000; 215 | elseif ($attr['scale'] >= 140000) $mmscale = 200000; 216 | elseif ($attr['scale'] >= 70000) $mmscale = 100000; 217 | elseif ($attr['scale'] >= 35000) $mmscale = 50000; 218 | elseif ($attr['scale'] >= 15000) $mmscale = 25000; 219 | elseif ($attr['scale'] >= 7000) $mmscale = 10000; 220 | else $mmscale = 5000; 221 | 222 | /* 223 | * Make minutes and seconds, and round 224 | */ 225 | $lat = $this->p->make_minsec($this->p->latdeg); 226 | $lon = $this->p->make_minsec($this->p->londeg); 227 | # print "?{$this->p->latdeg}/{$this->p->londeg}?" ; 228 | # print "!" . implode ( ',' , $lat ) . "/" . implode ( ',' , $long ) . "!" ; 229 | 230 | /* 231 | * Hack for negative, small degrees 232 | */ 233 | $latdegint = intval($lat['deg']); 234 | $londegint = intval($lon['deg']); 235 | if ($this->p->latdeg < 0 and $latdegint == 0) { 236 | $latdegint = "-0"; 237 | } 238 | if ($this->p->londeg < 0 and $londegint == 0) { 239 | $londegint = "-0"; 240 | } 241 | 242 | $latdeground = round($lat['deg']); 243 | $londeground = round($lon['deg']); 244 | if ($this->p->latdeg < 0 and $latdeground == 0) { 245 | $latdeground = "-0"; 246 | } 247 | if ($this->p->londeg < 0 and $londeground == 0) { 248 | $londeground = "-0"; 249 | } 250 | 251 | $latdeg_outer_abs = ceil ( abs ( $lat['deg'] ) ) ; 252 | $londeg_outer_abs = ceil ( abs ( $lon['deg'] ) ) ; 253 | 254 | 255 | /* 256 | * Look up page from Wikipedia 257 | * See if we have something in 258 | * [[Wikipedia:Map sources]] or equivalent. 259 | * A subpage can be specified 260 | */ 261 | $src = $this->mapsources; 262 | $region = ""; 263 | if ( isset( $attr['page'] ) && $attr['page'] != "") { 264 | $src .= "/" . $attr['page']; # subpage specified 265 | } elseif ( isset( $attr['globe'] ) && $attr['globe'] != "") { 266 | $src .= "/" . $attr['globe']; # subpage specified 267 | } elseif ( isset( $attr['region'] ) && $attr['region'] != "") { 268 | $region = strtoupper(substr($attr['region'],0,2)); 269 | $region = "/" . $region; # subpage specified 270 | } 271 | 272 | $bstitle = 'Something' ; 273 | #$bstitle = Title::makeTitleSafe( NS_PROJECT, $src.$region ); 274 | #$bsarticle = new Article( $bstitle ); 275 | /* 276 | if (($region != "") 277 | and ($bsarticle->getID() == 0)) { 278 | // * Region article does not exist, and was a subpage 279 | // * Default to main page 280 | $bstitle = Title::makeTitleSafe( NS_PROJECT, $src ); 281 | $bsarticle = new Article( $bstitle ); 282 | } 283 | */ 284 | /* if ($bsarticle->getID() == 0) { 285 | $wgOut->addHTML( "

Please add this page: " . 286 | $sk->makeBrokenLinkObj( $bstitle ).".

"); 287 | $wgOut->output(); 288 | wfErrorExit(); 289 | return ""; 290 | }*/ 291 | #$bstext = $bsarticle->getContent( false ); # allow redir 292 | $bstext = $this->thetext ; 293 | 294 | /* 295 | * Replace in page 296 | */ 297 | $search = array( 298 | "{latdegdec}", "{londegdec}", 299 | "{latdegdecabs}", "{londegdecabs}", 300 | "{latdeground}", "{londeground}", 301 | "{latdegroundabs}", "{londegroundabs}", 302 | "{latdeg_outer_abs}", "{londeg_outer_abs}", 303 | "{latantipodes}", "{longantipodes}", 304 | "{londegneg}", "{latdegint}", 305 | "{londegint}", "{latdegabs}", 306 | "{londegabs}", "{latmindec}", 307 | "{lonmindec}", "{latminint}", 308 | "{lonminint}", "{latsecdec}", 309 | "{lonsecdec}", "{latsecint}", 310 | "{lonsecint}", "{latNS}", 311 | "{lonEW}", "{utmzone}", 312 | "{utmnorthing}", "{utmeasting}", 313 | "{utm33northing}", "{utm33easting}", 314 | "{osgb36ref}", "{osgb36northing}", 315 | "{osgb36easting}", "{ch1903northing}", 316 | "{ch1903easting}", "{scale}", 317 | "{mmscale}", "{altitude}", 318 | "{zoom}", "{osmzoom}", "{span}", 319 | "{type}", "{region}", 320 | "{globe}", "{page}", 321 | "{pagename}", "{title}", 322 | "{geocountry}", "{geoa1}", 323 | "{params}", "{language}", 324 | "{pagename_gmaps}" ) ; 325 | 326 | # grab global varibles from geohack.php 327 | global $r_title, $r_pagename;# FIXME operations back in here 328 | 329 | if ($lon['deg'] > 0 ) $longantipodes = $lon['deg']-180; 330 | else $longantipodes = $lon['deg']+180; 331 | 332 | #solve the Bracket google maps bug for ~para/cgi-bin/kmlexport 333 | $pagename_gmaps=str_replace(array("(",")"),array("%2528","%2529"),$r_pagename); 334 | 335 | $replace = array( 336 | $lat['deg'], 337 | $lon['deg'], 338 | abs($lat['deg']), 339 | abs($lon['deg']), 340 | $latdeground, 341 | $londeground, 342 | abs($latdeground), 343 | abs($londeground), 344 | $latdeg_outer_abs, 345 | $londeg_outer_abs, 346 | -$lat['deg'], 347 | $longantipodes, 348 | -$lon['deg'], 349 | $latdegint, 350 | $londegint, 351 | abs(intval($lat['deg'])), 352 | abs(intval($lon['deg'])), 353 | $lat['min'], 354 | $lon['min'], 355 | intval($lat['min']), 356 | intval($lon['min']), 357 | $lat['sec'], 358 | $lon['sec'], 359 | intval($lat['sec']), 360 | intval($lon['sec']), 361 | $lat['NS'], 362 | $lon['EW'], 363 | $utm->Zone, 364 | round($utm->Northing), 365 | round($utm->Easting), 366 | round($utm33->Northing), 367 | round($utm33->Easting), 368 | $osgb36ref, 369 | round($osgb36->Northing), 370 | round($osgb36->Easting), 371 | round($ch1903->Northing), 372 | round($ch1903->Easting), 373 | $attr['scale'], 374 | $mmscale, 375 | $altitude, 376 | $zoom, 377 | $osmzoom, 378 | $span, 379 | isset( $attr['type'] ) ? $attr['type'] : "", 380 | isset( $attr['region'] ) ? $attr['region'] : "", 381 | isset( $attr['globe'] ) ? $attr['globe'] : "", 382 | isset( $attr['page'] ) ? $attr['page'] : "", 383 | #get_request( 'title', '' ) 384 | $r_pagename, 385 | $r_title, 386 | $region, 387 | isset( $attr['region'] ) ? strtoupper(substr($attr['region'], 4, 8)) : "", 388 | htmlspecialchars ( get_request ( 'params' ) ), 389 | htmlspecialchars ( get_request ( 'language', 'en' ) ), 390 | $pagename_gmaps 391 | ); 392 | 393 | return str_replace( $search, $replace, $bstext ); 394 | } 395 | } 396 | 397 | ?> 398 | -------------------------------------------------------------------------------- /client/wiwosm-list.php: -------------------------------------------------------------------------------- 1 | 0 and article not like \'%/%\' 20 | LIMIT 2000'; 21 | 22 | //WHERE way && ST_Transform(ST_SetSRID(ST_MakeBox2D( 23 | // ST_Point('.floatval($bbox[0]).','.floatval($bbox[1]).'), 24 | // ST_Point('.floatval($bbox[2]).','.floatval($bbox[3]).')), 25 | // 4326),900913) 26 | 27 | // query the database 28 | $res = pg_query($sql); 29 | 30 | // check for query error 31 | if($e = pg_last_error()) die($e); 32 | 33 | // produce some output 34 | echo ""; 42 | 43 | ?> 44 | -------------------------------------------------------------------------------- /server/class.Wiwosm.php: -------------------------------------------------------------------------------- 1 | start = microtime(true); 43 | $this->pgconn = false; 44 | $this->mysqliconn = false; 45 | $this->loglevel = $loglevel; 46 | $this->json_path = self::PROJECT_PATH . 'output/geojsongz'; 47 | } 48 | 49 | /** 50 | * This is what to do before exiting this program 51 | * (output time and memory consumption, close all db connections … ) 52 | **/ 53 | function __destruct() { 54 | $this->logMessage('Execution time: '.((microtime(true)-$this->start)/60)."min\n", 2); 55 | $this->logMessage('Peak memory usage: '.(memory_get_peak_usage(true)/1024/1024)."MB\n", 2); 56 | if ($this->pgconn) { 57 | pg_close($this->pgconn); 58 | } 59 | if ($this->mysqliconn) { 60 | $this->mysqliconn->close(); 61 | } 62 | } 63 | 64 | /** 65 | * Log a message at a specified loglevel 66 | **/ 67 | function logMessage($message, $level) { 68 | if ($this->loglevel >= $level) { 69 | echo $message; 70 | } 71 | } 72 | 73 | /** 74 | * Open a postgresql db connection 75 | **/ 76 | function getPgConn() { 77 | if (!$this->pgconn) { 78 | // open psql connection 79 | $this->pgconn = pg_connect('user=osm host=osmdb.eqiad.wmnet dbname=gis'); 80 | // check for connection error 81 | if($e = pg_last_error()) trigger_error($e, E_USER_ERROR); 82 | //pg_set_client_encoding($this->pgconn, UNICODE); 83 | } 84 | return $this->pgconn; 85 | } 86 | 87 | /** 88 | * Open a mysql db connection to wikidata 89 | **/ 90 | function getMysqlConn() { 91 | if (!$this->mysqliconn) { 92 | $mycnf = parse_ini_file(self::PROJECT_PATH . "replica.my.cnf"); 93 | $this->mysqliconn = new mysqli('wikidatawiki.labsdb', $mycnf['user'], $mycnf['password'], 'wikidatawiki_p'); 94 | if (mysqli_connect_errno()) { 95 | $this->logMessage('Mysql connection failed: '.mysqli_connect_error()."\n", 1); 96 | exit(); 97 | } 98 | } 99 | return $this->mysqliconn; 100 | } 101 | 102 | /** 103 | * fnvhash funtion copied from http://code.google.com/p/boyanov/wiki/FNVHash 104 | * @param string $txt Input text to hash 105 | * @return string FNVHash of text 106 | **/ 107 | function fnvhash($txt) { 108 | $buf = str_split($txt); 109 | $hash = 16777619; 110 | foreach ($buf as $chr) 111 | { 112 | $hash += ($hash << 1) + ($hash << 4) + ($hash << 7) + ($hash << 8) + ($hash << 24); 113 | $hash = $hash ^ ord($chr); 114 | } 115 | $hash = $hash & 0x0ffffffff; 116 | return sprintf("%X", $hash); 117 | } 118 | 119 | /** 120 | * This function computes a filepath for a given lang/article combination 121 | * so that a good distributed tree will result in the filesystem. 122 | * @param string $lang the language of the given article 123 | * @param string $article the name of the article 124 | * @return string the absolute filepath for this lang and article 125 | **/ 126 | function getFilePath($lang, $article, $create_if_missing = true, $relativ = false) { 127 | //$hash = md5($lang.str_replace('_',' ',$article)); 128 | // use fnvhash because its much faster than md5 129 | $article = str_replace('_',' ',$article); 130 | $hash = $this->fnvhash($lang.$article); 131 | $relpath = substr($hash,0,2).'/'.substr($hash,0,4); 132 | $fullpath = $this->json_path.'/'.$relpath; 133 | $path = ($relativ) ? $relpath : $fullpath; 134 | if ($create_if_missing && !file_exists($fullpath)) @mkdir($fullpath, 0755, true); 135 | $path .= '/'.$hash.'_'.substr(str_replace(array("\0",'/'),array('','-'),$lang.'_'.$article),0,230).'.geojson.gz'; 136 | unset($hash); 137 | return $path; 138 | } 139 | 140 | /** 141 | * If we find a trash article while connecting to $lang.'wiki-p.db.toolserver.org' we can log it here to watch the problem later 142 | * @param string $lang the language of the given article 143 | * @param string $article the name of the article 144 | **/ 145 | function logUnknownLang($l,$a) { 146 | error_log($l."\t".$a."\n",3, self::PROJECT_PATH . 'unknown.csv'); 147 | } 148 | 149 | /** 150 | * Write all broken languages with their articles into a nice html logfile 151 | **/ 152 | function logUnknown() { 153 | $htmlrows = ''; 154 | // get all broken languages 155 | $query = 'SELECT osm_id,lang,article,array_agg(ST_GeometryType(way)) AS geomtype FROM wiwosm WHERE wikidata_ref = -1 GROUP BY osm_id,lang,article'; 156 | $result = pg_query($this->getPgConn(),$query); 157 | $count = pg_num_rows($result); 158 | while ($row = pg_fetch_assoc($result)) { 159 | $osm_id = $row['osm_id']; 160 | $type = 'way'; 161 | if ($row['geomtype']=='{ST_Point}') $type = 'node'; 162 | if ($row['osm_id'] < 0) { 163 | $type = 'relation'; 164 | // if relation remove leading minus 165 | $osm_id = substr($row['osm_id'],1); 166 | } 167 | 168 | $htmlrows .= ' '."\n"; 169 | $htmlrows .= ' '.$osm_id.' ('.$type.')'."\n"; 170 | $htmlrows .= ' Potlatch2, JOSM/Merkaator'."\n"; 171 | $htmlrows .= ' '.htmlspecialchars($row['lang']).''."\n"; 172 | $htmlrows .= ' '.htmlspecialchars($row['article']).''."\n"; 173 | $htmlrows .= ' '."\n"; 174 | } 175 | $now = date(DATE_RFC822); 176 | 177 | $sortscript = ''; 178 | $sortmessage = ''; 179 | if ($count < 1000) { 180 | $sortscript = ''; 181 | $sortmessage = '

Hint: Columns are now sortable by clicking if you have JS enabled! (thanks to User Jjaf.de for the idea)

'; 182 | } 183 | 184 | $html = << 186 | 187 | 188 | 189 | WIWOSM broken languages 190 | $sortscript 191 | 192 | 193 |

$count unknown wikipedia tags found while WIWOSM-processing

194 |

$now

195 | $sortmessage 196 |

12.01.2013: Now all wikipedia tags with undefined language like wikipedia=article are shown, too! Sorry for the big load!

197 |

14.01.2013: Edit links are now available for potlatch2 and JOSM or Merkaator with Remotecontrol plugin.

198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | $htmlrows 206 |
OSM-ObjectEdit linkslanguagearticle
207 | 208 | 209 | EOT; 210 | 211 | //write that stuff to a file 212 | $fh = fopen(self::PROJECT_PATH . 'public_html/wiwosmlog/broken.html','w'); 213 | fwrite($fh, $html); 214 | fclose($fh); 215 | } 216 | 217 | /** 218 | * Write all broken languages with their articles into a nice JSON logfile 219 | **/ 220 | function logUnknownJSON() { 221 | // get all broken languages 222 | $query = 'SELECT DISTINCT ON (osm_id) osm_id,lang,article,geomtype,iso2,name FROM ( SELECT osm_id,lang,article,array_agg(ST_GeometryType(way)) AS geomtype, ST_Transform(ST_SetSRID(ST_Extent(way),900913),4326) AS extent FROM wiwosm WHERE wikidata_ref = -1 GROUP BY osm_id,lang,article ) AS w LEFT JOIN wiwosm_tm_world_borders_simple ON ST_Intersects(extent, ST_SetSRID(geom,4326))'; 223 | $result = pg_query($this->getPgConn(),$query); 224 | $count = pg_num_rows($result); 225 | $json = '{"created":"'.date(DATE_RFC822).'","count":"'.$count.'","items":['; 226 | $r = array(); 227 | while ($row = pg_fetch_assoc($result)) { 228 | $r['i'] = $row['osm_id']; 229 | $r['t'] = 'w'; 230 | if ($row['geomtype']=='{ST_Point}') $r['t'] = 'n'; 231 | if ($row['osm_id'] < 0) { 232 | $r['t'] = 'r'; 233 | // if relation remove leading minus 234 | $r['i'] = substr($row['osm_id'],1); 235 | } 236 | $r['l'] = $row['lang']; 237 | $r['a'] = $row['article']; 238 | $r['c'] = ''.$row['name']; 239 | $r['s'] = ''.$row['iso2']; 240 | $json .= json_encode($r).','; 241 | 242 | } 243 | $json = rtrim($json,','); 244 | $json .= ']}'; 245 | 246 | //write that stuff to a gzipped json file 247 | $handle = gzopen(self::PROJECT_PATH . 'public_html/wiwosmlog/broken.json.gz','w'); 248 | gzwrite($handle,$json); 249 | gzclose($handle); 250 | } 251 | 252 | /** 253 | * We have to make sure that the full update process did work and so we simply test, if there are enough files in our update directory. 254 | * If this is the case we remove the _old dir, move the current dir to _old and the _update to current dir. 255 | **/ 256 | function testAndRename() { 257 | //$countFiles = system('ls -RU1 --color=never '.$json_path.' | wc -l'); 258 | $this->logMessage('Execution time: '.((microtime(true)-$this->start)/60)."min\n", 2); 259 | $this->logMessage('Counting generated files …'."\n", 2); 260 | $countFiles = system('find '.$this->json_path.' -type f | wc -l'); 261 | // if there are more than 100000 262 | if ( $countFiles > 100000 ) { 263 | //exec('mv -T ' . self::JSON_PATH . '_old ' . self::JSON_PATH . '_old_remove'); 264 | //exec('mv -T ' . self::JSON_PATH . ' ' . self::JSON_PATH . '_old'); 265 | //exec('mv -T ' . $this->json_path . ' ' . self::JSON_PATH ); 266 | //unlink(self::JSON_PATH); 267 | //symlink($this->json_path,'geojsongz'); 268 | exec('ln -snf '.basename($this->json_path).' '.dirname($this->json_path).'/geojsongz'); 269 | //rename(self::JSON_PATH . '_old',self::JSON_PATH . '_old_remove'); 270 | //rename(self::JSON_PATH , self::JSON_PATH . '_old'); 271 | //rename($this->json_path , self::JSON_PATH ); 272 | // let cronie remove the old directory 273 | //exec('rm -rf /mnt/user-store/wiwosm/geojsongz_old_remove &'); 274 | } 275 | 276 | } 277 | 278 | /** 279 | * Just create some indices on wiwosm table that may help to speed things up. 280 | **/ 281 | function createIndices() { 282 | $query = <<getPgConn(),$query); 287 | } 288 | 289 | /** 290 | * Throw away the wiwosm table and rebuild it from the mapnik db 291 | **/ 292 | function createWiwosmDB() { 293 | $query = <<0 THEN lower(split_part(wikipedia, ':', 1)) ELSE '' END ) AS lang, split_part(substring(wikipedia from position(':' in wikipedia)+1),'#', 1) AS article, split_part(wikipedia,'#', 2) AS anchor FROM ( 298 | SELECT osm_id, way, 299 | ( CASE WHEN strpos(keys_string, 'wikipedia')>0 THEN 300 | regexp_replace( 301 | substring( 302 | concat( 303 | substring(keys_string from 'wikipedia:?[^,]*'), -- this is the tagname for example "wikipedia" or "wikipedia:de" 304 | ':', 305 | regexp_replace( 306 | tags->substring(keys_string from 'wikipedia:?[^,]*'), -- get the first wikipedia tag from hstore 307 | '^(?:https?://)?(\\w*)\\.wikipedia\\.org/wiki/(.*)$', -- matches if the value is a wikipedia url (otherwise it is an article) 308 | '\\1:\\2' -- get the domain prefix and use it as language key followed by the article name 309 | ) 310 | ) -- resulting string is for example wikipedia:de:Dresden 311 | from 11 -- remove the "wikipedia:" prefix 312 | ), 313 | '^(\\w*:)\\1','\\1' -- it is possible that there is such a thing like "de:de:Artikel" left if there was a tag like "wikipedia:de=http://de.wikipedia.org/wiki/Artikel", so remove double language labels 314 | ) ELSE '' END) AS "wikipedia", 315 | ( CASE WHEN wikidata ~ '^Q\\d+$' THEN -- try to get the wikidata ref from osm if it is formed like wikidata=Q1234 316 | CAST(substring(wikidata from 2) AS INTEGER) -- we strip the Q and cast to Integer 317 | ELSE 0 END) AS "wikidata_ref" 318 | FROM ( 319 | ( SELECT osm_id, tags, array_to_string(akeys(tags),',') AS keys_string, tags->'wikidata' AS wikidata, way FROM planet_osm_point WHERE concat(',',array_to_string(akeys(tags),',')) ~ ',wiki(data|pedia)' ) 320 | UNION ( SELECT osm_id, tags, array_to_string(akeys(tags),',') AS keys_string, tags->'wikidata' AS wikidata, way FROM planet_osm_line WHERE concat(',',array_to_string(akeys(tags),',')) ~ ',wiki(data|pedia)' AND NOT EXISTS (SELECT 1 FROM planet_osm_polygon WHERE planet_osm_polygon.osm_id = planet_osm_line.osm_id) ) -- we don't want LineStrings that exist as polygon, yet 321 | UNION ( SELECT osm_id, tags, array_to_string(akeys(tags),',') AS keys_string, tags->'wikidata' AS wikidata, way FROM planet_osm_polygon WHERE concat(',',array_to_string(akeys(tags),',')) ~ ',wiki(data|pedia)' ) 322 | ) AS wikistaff 323 | ) AS wikiobjects 324 | ORDER BY article,lang ASC 325 | ) 326 | ; 327 | UPDATE wiwosm SET wikidata_ref=-1 WHERE wikidata_ref = 0 AND lang = ANY (ARRAY['','http','subject','name','operator','related','sculptor','architect','maker']); -- we know that there could not be a language reference in Wikipedia for some lang values. 328 | COMMIT; 329 | EOQ; 330 | 331 | pg_query($this->getPgConn(),$query); 332 | if($e = pg_last_error()) { 333 | trigger_error($e, E_USER_ERROR); 334 | exit(); 335 | } 336 | } 337 | 338 | function updateWiwosmDB() { 339 | $this->createWiwosmDB(); 340 | $this->logMessage('wiwosm DB basic table build in '.((microtime(true)-$this->start)/60)." min\nStarting additional relation adding …\n", 2); 341 | $this->addMissingRelationObjects(); 342 | $this->logMessage('Missing Relations added '.((microtime(true)-$this->start)/60)." min\nCreate Indices and link articleslanguages …\n", 2); 343 | $this->createIndices(); 344 | $this->map_wikidata_languages(); 345 | $this->logMessage('wiwosm DB upgraded in '.((microtime(true)-$this->start)/60)." min\n", 2); 346 | } 347 | 348 | /** 349 | * Get all members of a relation and if there are children that are relations too recursivly traverse them 350 | * @param string $memberscsv This is a comma separated string of relation children to process 351 | * @param array $nodelist This is the list of all nodes we have traversed until now. It is passed by reference so we can add the current node members there. 352 | * @param array $waylist Same as with nodes but for ways. 353 | * @param array $rellist Same as with nodes but for relations. This list is also used to check for loopings while recursivly traverse the relations. 354 | **/ 355 | function getAllMembers($memberscsv,&$nodelist,&$waylist,&$rellist) { 356 | $subrellist = array(); 357 | $members = str_getcsv($memberscsv,',','"'); 358 | for($i=0; $i0) { 376 | $newrelscomplement = array(); 377 | foreach ($newrels AS $rel) { 378 | $newrelscomplement[] = '-'.$rel; 379 | $rellist[] = $rel; 380 | } 381 | 382 | $newrelscsv = implode(',',$newrelscomplement); 383 | 384 | $result = pg_execute($this->getPgConn(),'get_existing_member_relations',array('{'.$newrelscsv.'}')); 385 | $existingrels = ($result) ? pg_fetch_all_columns($result, 0) : array(); 386 | // we can simply add the existing relations with there negative id as if they were nodes or ways 387 | $nodelist = array_merge($nodelist,$existingrels); 388 | $waylist = array_merge($waylist,$existingrels); 389 | 390 | // all other relations we have to pick from the planet_osm_rels table 391 | $othersubrels = array_diff($newrelscomplement,$existingrels); 392 | if (count($othersubrels)>0) { 393 | $othersubrelscsv = ''; 394 | // first strip of the "-" and build csv 395 | foreach($othersubrels AS $subrel) { 396 | $othersubrelscsv .= ','.substr($subrel,1); 397 | } 398 | $othersubrelscsv = substr($othersubrelscsv,1); 399 | 400 | $res = pg_execute($this->getPgConn(),'get_member_relations_planet_osm_rels',array('{'.$othersubrelscsv.'}')); 401 | if ($res) { 402 | // fetch all members of all subrelations and combine them to one csv string 403 | $allsubmembers = pg_fetch_all_columns($res, 0); 404 | $allsubmemberscsv = ''; 405 | foreach($allsubmembers AS $submem) { 406 | // if submembers exist add them to csv 407 | if ($submem) $allsubmemberscsv .= ','.substr($submem,1,-1); 408 | } 409 | // call this function again to process all subrelations and add them to the arrays 410 | $this->getAllMembers(substr($allsubmemberscsv,1),$nodelist,$waylist,$rellist); 411 | } 412 | } 413 | } 414 | } 415 | 416 | /** 417 | * Osm2pgsql doesn't get all relations by default in the standard mapnik database, because mapnik doesn't need them. 418 | * But we need them, because they can be tagged with wikipedia tags so we have to look in the planet_osm_rels table, that is a preprocessing table for osm2pgsql that holds all the information we need, but in an ugly format. 419 | * So we have to search in the tags and members arrays if we can find something usefull, get the objects from the mapnik tables and store it in wiwosm. 420 | **/ 421 | function addMissingRelationObjects() { 422 | // prepare some often used queries: 423 | $pgconn = $this->getPgConn(); 424 | 425 | // search for existing relations that are build in osm2pgsql default scheme ( executed in getAllMembers function!) 426 | $result = pg_prepare($pgconn,'get_existing_member_relations','SELECT DISTINCT osm_id FROM ( 427 | (SELECT osm_id FROM planet_osm_point WHERE osm_id = ANY ($1)) 428 | UNION (SELECT osm_id FROM planet_osm_line WHERE osm_id = ANY ($1)) 429 | UNION (SELECT osm_id FROM planet_osm_polygon WHERE osm_id = ANY ($1)) 430 | ) AS existing'); 431 | if ($result === false) exit(); 432 | 433 | // fetch all members of all subrelations and combine them to one csv string ( executed in getAllMembers function!) 434 | $result = pg_prepare($pgconn,'get_member_relations_planet_osm_rels','SELECT members FROM planet_osm_rels WHERE id = ANY ($1)'); 435 | if ($result === false) exit(); 436 | 437 | // insert ways and polygons in wiwosm 438 | $result = pg_prepare($pgconn,'insert_relways_wiwosm','INSERT INTO wiwosm SELECT $1 AS osm_id, $2 AS wikidata_ref, ST_Collect(way) AS way, $3 AS lang, $4 AS article, $5 AS anchor FROM ( 439 | (SELECT way FROM planet_osm_polygon WHERE osm_id = ANY ($6) ) 440 | UNION ( SELECT way FROM planet_osm_line WHERE osm_id = ANY ($6) AND NOT EXISTS (SELECT 1 FROM planet_osm_polygon WHERE planet_osm_polygon.osm_id = planet_osm_line.osm_id) ) 441 | ) AS members'); 442 | if ($result === false) exit(); 443 | 444 | // insert nodes in wiwosm 445 | $result = pg_prepare($pgconn,'insert_relnodes_wiwosm','INSERT INTO wiwosm SELECT $1 AS osm_id, $2 AS wikidata_ref, ST_Collect(way) AS way, $3 AS lang, $4 AS article, $5 AS anchor FROM ( 446 | (SELECT way FROM planet_osm_point WHERE osm_id = ANY ($6) ) 447 | ) AS members'); 448 | if ($result === false) exit(); 449 | 450 | $query = "SELECT id,members,tags FROM planet_osm_rels WHERE array_to_string(tags,',') ~ 'wiki(pedia|data)' AND -id NOT IN ( SELECT osm_id FROM wiwosm WHERE osm_id<0 )"; 451 | $result = pg_query($pgconn,$query); 452 | if ($result === false) exit(); 453 | while ($row = pg_fetch_assoc($result)) { 454 | // if the relation has no members ignore it and try the next one 455 | if (!$row['members']) continue; 456 | $wikidata_ref = 0; 457 | $lang = ''; 458 | $article = ''; 459 | $anchor = ''; 460 | 461 | $has_wikipedia_tag = false; 462 | $has_wikidata_tag = false; 463 | 464 | $tagscsv = str_getcsv(substr($row['tags'],1,-1),',','"'); 465 | for($i=0; $i stop looping the tags 491 | if ($has_wikipedia_tag && $has_wikidata_tag) break; 492 | } 493 | // if we found a wikipedia or wikidata tag we fetch all relation members 494 | if ($has_wikipedia_tag || $has_wikidata_tag) { 495 | $nodelist = array(); 496 | $waylist = array(); 497 | $rellist = array($row['id']); 498 | $this->getAllMembers(substr($row['members'],1,-1),$nodelist,$waylist,$rellist); 499 | $nodelist = array_unique($nodelist); 500 | $waylist = array_unique($waylist); 501 | $nodescsv = implode(',',$nodelist); 502 | $wayscsv = implode(',',$waylist); 503 | $hasNodes = (count($nodelist)>0); 504 | $hasWays = (count($waylist)>0); 505 | if ($hasWays) { 506 | pg_execute($pgconn,'insert_relways_wiwosm',array('-'.$row['id'],$wikidata_ref,$lang,$article,$anchor,'{'.$wayscsv.'}')); 507 | } 508 | if ($hasNodes) { 509 | pg_execute($pgconn,'insert_relnodes_wiwosm',array('-'.$row['id'],$wikidata_ref,$lang,$article,$anchor,'{'.$nodescsv.'}')); 510 | } 511 | } 512 | } 513 | } 514 | 515 | /** 516 | * We want to work with real php arrays, so we have to process the hstore string 517 | * @param string $hstore This is a string returned by a postgresql hstore column that looks like: '"foo"=>"bar", "baz"=>"blub", "lang"=>"article"' … 518 | * @return array return a php array with languages as keys and articles as values 519 | **/ 520 | public static function hstoreToArray($hstore) { 521 | $ret_array = array(); 522 | if (preg_match_all('/(?:^| )"((?:[^"]|(?<=\\\\)")*)"=>"((?:[^"]|(?<=\\\\)")*)"(?:$|,)/',$hstore,$matches)) { 523 | $count = count($matches[1]); 524 | if ($count == count($matches[2])) { 525 | for($i=0; $i<$count; $i++) { 526 | $lang = stripslashes($matches[1][$i]); 527 | $article = stripslashes($matches[2][$i]); 528 | $ret_array[$lang] = $article; 529 | } 530 | } 531 | } 532 | return $ret_array; 533 | } 534 | 535 | /** 536 | * Believe it or not - in the year 2012 string encoding still sucks! 537 | * @param string $str A string that is maybe not correct UTF-8 (reason is a bad urlencoding for example) 538 | * @return string return a string that is definitly a valid UTF-8 string even if some characters were dropped 539 | **/ 540 | public static function fixUTF8($str) { 541 | $curenc = mb_detect_encoding($str); 542 | if ($curenc != 'UTF-8') { 543 | if ($curenc === false) { 544 | // if mb_detect_encoding failed we have to enforce clean UTF8 somehow 545 | return mb_convert_encoding(utf8_encode($str), 'UTF-8', 'UTF-8'); 546 | } 547 | // if we can guess the encoding we can convert it 548 | return mb_convert_encoding($str,'UTF-8',$curenc); 549 | } elseif (!mb_check_encoding($str,'UTF-8')) { 550 | // if there are invalid bytes try to remove them 551 | return mb_convert_encoding($str, 'UTF-8', 'UTF-8'); 552 | } 553 | // if it is already clean UTF-8 there should be no problems 554 | return $str; 555 | } 556 | 557 | function queryWikidataLanguagesByLangArticle($lang, $article) { 558 | // if no lang or article is given, we can stop here 559 | if (!$lang || !$article) return false; 560 | 561 | // if the lang for example is fiu-vro the site is named fiu_vrowiki so we have to replace - by _ 562 | $lang = str_replace('-','_',$lang).'wiki'; 563 | 564 | if (!$this->prep_wikidata_by_lang_article->bind_param('ss', $lang, $article)) { 565 | $this->logMessage('bind_param failed with lang="'.$lang.'" and article="'.$article.'": '.$this->prep_wikidata_by_lang_article->error."\n", 1); 566 | return false; 567 | } 568 | 569 | if (!$this->prep_wikidata_by_lang_article->execute()) { 570 | $this->logMessage('wikidata query failed with lang="'.$lang.'" and article="'.$article.'": '.$this->prep_wikidata_by_lang_article->error."\n", 1); 571 | return false; 572 | } 573 | 574 | if (!$this->prep_wikidata_by_lang_article->store_result()) { 575 | $this->logMessage('wikidata query store result failed with lang="'.$lang.'" and article="'.$article."\"\n", 1); 576 | return false; 577 | } 578 | 579 | if ($this->prep_wikidata_by_lang_article->num_rows == 0) return false; 580 | 581 | if (!$this->prep_wikidata_by_lang_article->bind_result($wd_id, $ll_lang, $ll_title)) { 582 | $this->logMessage('bind_result failed with lastarticle='.$this->lastarticle.': '.$this->prep_wikidata_by_lang_article->error."\n", 1); 583 | return false; 584 | } 585 | 586 | $langarray = array(); 587 | while ($this->prep_wikidata_by_lang_article->fetch()) { 588 | $langarray[str_replace('wiki', '', $ll_lang)] = $ll_title; 589 | } 590 | return array($wd_id, $langarray); 591 | } 592 | 593 | function queryWikidataLanguagesByWikidataref($wikidata_ref) { 594 | // if no $wikidata_ref is given, we can stop here 595 | if (!$wikidata_ref) return false; 596 | 597 | if (!$this->prep_wikidata_by_wikidata_ref->bind_param('s', $wikidata_ref)) { 598 | $this->logMessage('bind_param failed with wikidata_ref="'.$wikidata_ref.'": '.$this->prep_wikidata_by_wikidata_ref->error."\n", 1); 599 | return false; 600 | } 601 | 602 | if (!$this->prep_wikidata_by_wikidata_ref->execute()) { 603 | $this->logMessage('wikidata query failed with wikidata_ref="'.$wikidata_ref.'": '.$this->prep_wikidata_by_wikidata_ref->error."\n", 1); 604 | return false; 605 | } 606 | 607 | if (!$this->prep_wikidata_by_wikidata_ref->store_result()) { 608 | $this->logMessage('wikidata query store result failed with wikidata_ref="'.$wikidata_ref."\"\n", 1); 609 | return false; 610 | } 611 | 612 | if ($this->prep_wikidata_by_wikidata_ref->num_rows == 0) return false; 613 | 614 | if (!$this->prep_wikidata_by_wikidata_ref->bind_result($wd_id, $ll_lang, $ll_title)) { 615 | $this->logMessage('bind_result failed with lastarticle='.$this->lastarticle.': '.$this->prep_wikidata_by_wikidata_ref->error."\n", 1); 616 | return false; 617 | } 618 | 619 | $langarray = array(); 620 | while ($this->prep_wikidata_by_wikidata_ref->fetch()) { 621 | $langarray[str_replace('wiki', '', $ll_lang)] = $ll_title; 622 | } 623 | return array($wd_id, $langarray); 624 | } 625 | 626 | function escape($str) { 627 | return str_replace(array('\\','"'),array('\\\\','\\"'),$str); 628 | } 629 | 630 | function insert_wiwosm_wikidata_languages($res) { 631 | if ($res) { 632 | $pgconn = $this->getPgConn(); 633 | $wikidata_id = $res[0]; 634 | foreach ($res[1] as $l => $a) { 635 | pg_execute($pgconn,'insert_wiwosm_wikidata_languages',array($wikidata_id, str_replace('_','-',$l), $a)); 636 | } 637 | pg_execute($pgconn,'insert_wiwosm_wikidata_languages',array($wikidata_id,'wikidata','Q'.$wikidata_id)); 638 | } 639 | } 640 | 641 | function map_wikidata_languages() { 642 | $mysqlconn = $this->getMysqlConn(); 643 | $this->prep_wikidata_by_wikidata_ref = $mysqlconn->prepare('SELECT `ips_item_id`,`ips_site_id`,`ips_site_page` FROM `wb_items_per_site` WHERE `ips_item_id` = ? '); 644 | 645 | $pgconn = $this->getPgConn(); 646 | 647 | // delete cached wikidata_id before refetching them 648 | $result = pg_prepare($pgconn,'delete_wikidata_refs','DELETE FROM wiwosm_wikidata_languages WHERE wikidata_id = ANY ($1)'); 649 | if ($result === false) exit(); 650 | 651 | $result = pg_prepare($pgconn,'insert_wiwosm_wikidata_languages','INSERT INTO wiwosm_wikidata_languages (wikidata_id,lang,article) VALUES ($1,$2,$3)'); 652 | if ($result === false) exit(); 653 | 654 | // every wikidata_ref that is not present in wiwosm_wikidata_languages should get fetched from wikidata 655 | $sql = 'SELECT DISTINCT wikidata_ref FROM wiwosm WHERE wikidata_ref > 0 AND NOT EXISTS (SELECT 1 FROM wiwosm_wikidata_languages WHERE wiwosm_wikidata_languages.wikidata_id = wiwosm.wikidata_ref LIMIT 1)'; 656 | 657 | if (!pg_query($pgconn,'BEGIN WORK') || !pg_query($pgconn,'DECLARE wikidatarefcur NO SCROLL CURSOR FOR '.$sql)) { 658 | $this->logMessage('Could not declare cursor wikidatarefcur'. "\n" . pg_last_error() . "\n", 1); 659 | exit(); 660 | } 661 | 662 | $count = 0; 663 | 664 | // fetch from wikidatarefcur in steps of 1000 elements 665 | $result = pg_prepare($pgconn,'fetch_wikidatarefcur','FETCH 1000 FROM wikidatarefcur'); 666 | if ($result === false) exit(); 667 | 668 | $result = pg_execute($pgconn,'fetch_wikidatarefcur',array()); 669 | 670 | $fetchcount = pg_num_rows($result); 671 | 672 | $this->logMessage('Get the first '.$fetchcount.' wikidatarefs:'.((microtime(true)-$this->start)/60)." min\n", 2); 673 | 674 | //we use a cursor loop just to be sure that memory consumption does not explode: 675 | while ($fetchcount > 0) { 676 | $wikidata_refs = pg_fetch_all_columns($result); 677 | 678 | pg_execute($pgconn,'delete_wikidata_refs',array('{'.implode(',',$wikidata_refs).'}')); 679 | foreach ($wikidata_refs as $wikidata_ref) { 680 | $this->insert_wiwosm_wikidata_languages($this->queryWikidataLanguagesByWikidataref($wikidata_ref)); 681 | } 682 | $count += $fetchcount; 683 | $this->logMessage($count.' wikidatarefs processed:'.((microtime(true)-$this->start)/60)." min\n", 2); 684 | $result = pg_execute($pgconn,'fetch_wikidatarefcur',array()); 685 | $fetchcount = pg_num_rows($result); 686 | } 687 | 688 | pg_query($pgconn,'CLOSE wikidatarefcur'); 689 | pg_query($pgconn,'COMMIT WORK'); 690 | 691 | // try to fastconnect the obvious rows 692 | $query = "UPDATE wiwosm SET wikidata_ref=wikidata_id FROM wiwosm_wikidata_languages WHERE wikidata_ref = 0 AND wiwosm.lang=wiwosm_wikidata_languages.lang AND wiwosm.article=wiwosm_wikidata_languages.article"; 693 | $result = pg_query($pgconn,$query); 694 | 695 | // try to fetch wikidata_ref by language and article 696 | $this->prep_wikidata_by_lang_article = $mysqlconn->prepare('SELECT `ips_item_id`,`ips_site_id`,`ips_site_page` FROM `wb_items_per_site` WHERE `ips_item_id` = (SELECT `ips_item_id` FROM `wb_items_per_site` WHERE `ips_site_id` = ? AND `ips_site_page` = ? LIMIT 1)'); 697 | 698 | // every row in wiwosm with wikidata_ref=0 is an error and should get -1 or has no entries in wiwosm_wikidata_languages, yet 699 | $query = "SELECT lang,article FROM wiwosm WHERE wikidata_ref=0 ORDER BY lang,article"; 700 | // lets update every row and use a cursor for that 701 | if (!pg_query($pgconn,'BEGIN WORK') || !pg_query($pgconn,'DECLARE updatelangcur NO SCROLL CURSOR FOR '.$query.' FOR UPDATE OF wiwosm')) { 702 | $this->logMessage('Could not declare cursor for updating language refs'. "\n" . pg_last_error() . "\n", 1); 703 | exit(); 704 | } 705 | 706 | $langbefore = ''; 707 | $articlebefore = ''; 708 | $wikidata_id = '-1'; 709 | 710 | $count = 0; 711 | 712 | // prepare some sql queries that are used very often: 713 | 714 | // this is to search for an entry in wiwosm_wikidata_languages table by given article and language 715 | $result = pg_prepare($pgconn,'get_wikidata_id','SELECT wikidata_id FROM wiwosm_wikidata_languages WHERE lang=$1 AND article=$2'); 716 | if ($result === false) exit(); 717 | 718 | // update the wikidata_ref column in wiwosm table by using the current row from updatelangcur cursor 719 | $result = pg_prepare($pgconn,'update_wiwosm_wikidata_ref','UPDATE wiwosm SET wikidata_ref=$1 WHERE CURRENT OF updatelangcur'); 720 | if ($result === false) exit(); 721 | 722 | $result = pg_prepare($pgconn,'fetch_next_updatelangcur','FETCH NEXT FROM updatelangcur'); 723 | if ($result === false) exit(); 724 | $result = pg_execute($pgconn,'fetch_next_updatelangcur',array()); 725 | $fetchcount = pg_num_rows($result); 726 | 727 | while ($fetchcount == 1) { 728 | $row = pg_fetch_assoc($result); 729 | $article = str_replace('_',' ',stripcslashes(self::fixUTF8(urldecode($row['article'])))); 730 | $lang = $row['lang']; 731 | if ($langbefore !== $lang || $articlebefore !== $article) { 732 | if ($langbefore !== $lang) { 733 | $this->logMessage('Lastlang was:'.$langbefore."\n".'Handled '.$count.' rows '.((microtime(true)-$this->start)/60)." min\n", 2); 734 | } 735 | $langbefore = $lang; 736 | $articlebefore = $article; 737 | $wikidata_id = '-1'; 738 | $result = pg_execute($pgconn,'get_wikidata_id',array($lang, $article)); 739 | if ($result && pg_num_rows($result) == 1) { 740 | // if we found an entry in our wiwosm_wikidata table we use that id to link 741 | $wikidata_id = pg_fetch_result($result,0,0); 742 | } else { 743 | // if there was no such entry we have to query the wikidata mysql db 744 | $this->insert_wiwosm_wikidata_languages($this->queryWikidataLanguagesByLangArticle($lang,$article)); 745 | } 746 | } 747 | pg_execute($pgconn,'update_wiwosm_wikidata_ref',array($wikidata_id)); 748 | if ($result === false) exit(); 749 | $count += $fetchcount; 750 | $result = pg_execute($pgconn,'fetch_next_updatelangcur',array()); 751 | $fetchcount = pg_num_rows($result); 752 | } 753 | pg_query($pgconn,'CLOSE updatelangcur'); 754 | pg_query($pgconn,'COMMIT WORK'); 755 | 756 | if ($this->prep_wikidata_by_lang_article) $this->prep_wikidata_by_lang_article->close(); 757 | if ($this->prep_wikidata_by_wikidata_ref) $this->prep_wikidata_by_wikidata_ref->close(); 758 | } 759 | 760 | function createWikidataLangTable() { 761 | $query = <<getPgConn(),$query); 774 | } 775 | 776 | 777 | function createlinks($lang, $article, $geojson, $lang_hstore = '', $forceIWLLupdate = false) { 778 | // for every osm object with a valid wikipedia-tag print the geojson to file 779 | $filepath = $this->getFilePath($lang,$article); 780 | 781 | // we need no update of the Interwiki language links if there are no other languages in hstore given or 782 | // the file exists already and there is no force parameter given that forces to overwrite the existing links. 783 | // So we should create the Links, if the file does not exist already (and hstore is given) because it is new then 784 | $neednoIWLLupdate = ($lang_hstore == '') || (file_exists($filepath) && !$forceIWLLupdate); 785 | 786 | $handle = gzopen($filepath,'w'); 787 | gzwrite($handle,$geojson); 788 | gzclose($handle); 789 | 790 | // check if we need an update of the Interwiki language links 791 | if ($neednoIWLLupdate) return true; 792 | 793 | // get the relativ filepath 794 | // $filepath = $this->getFilePath($lang,$article,true); 795 | 796 | $langarray = self::hstoreToArray($lang_hstore); 797 | // for every interwikilink do a hard link to the real file written above 798 | foreach ($langarray as $l => $a) { 799 | if ($l != $lang) { 800 | $linkpath = $this->getFilePath($l,$a); 801 | @unlink($linkpath); 802 | //symlink('../../'.$filepath,$linkpath); 803 | link($filepath,$linkpath); 804 | unset($linkpath); 805 | } 806 | } 807 | // free the memory 808 | unset($filepath,$handle,$geojson,$lang_hstore,$langarray); 809 | return true; 810 | } 811 | 812 | 813 | function updateOneObject($lang,$article) { 814 | $pgconn = $this->getPgConn(); 815 | $articlefilter = '( tags @> $1::hstore ) OR ( tags @> $2::hstore ) OR ( tags @> $3::hstore ) OR ( tags @> $4::hstore ) OR ( tags @> $5::hstore ) OR ( tags @> $6::hstore )'; 816 | $sql = 'SELECT '.self::simplifyGeoJSON.' FROM ( 817 | ( SELECT way FROM planet_osm_polygon WHERE '.$articlefilter.' ) 818 | UNION ( SELECT way FROM planet_osm_line WHERE ( '.$articlefilter.' ) AND NOT EXISTS (SELECT 1 FROM planet_osm_polygon WHERE planet_osm_polygon.osm_id = planet_osm_line.osm_id) ) 819 | UNION ( SELECT way FROM planet_osm_point WHERE '.$articlefilter.' ) 820 | ) AS wikistaff 821 | '; 822 | pg_prepare($pgconn,'select_wikipedia_object',$sql); 823 | 824 | $a = $this->escape(str_replace('_',' ',$article)); 825 | $aurl = urlencode(str_replace(' ','_',$a)); 826 | $l = $this->escape(str_replace('_','-',$lang)); 827 | $lurl = str_replace('-','_',$l); 828 | $params = array('"wikipedia:'.$l.'"=>"'.$a.'"', 829 | '"wikipedia"=>"'.$l.':'.$a.'"', 830 | '"wikipedia"=>"http://'.$lurl.'.wikipedia.org/wiki/'.$aurl.'"', 831 | '"wikipedia"=>"https://'.$lurl.'.wikipedia.org/wiki/'.$aurl.'"', 832 | '"wikipedia:'.$l.'"=>"http://'.$lurl.'.wikipedia.org/wiki/'.$aurl.'"', 833 | '"wikipedia:'.$l.'"=>"https://'.$lurl.'.wikipedia.org/wiki/'.$aurl.'"'); 834 | 835 | $result = pg_execute($pgconn,'select_wikipedia_object',$params); 836 | if($e = pg_last_error()) trigger_error($e, E_USER_ERROR); 837 | 838 | if ($result && pg_num_rows($result) == 1 ) { 839 | $row = pg_fetch_assoc($result); 840 | $this->createlinks($lang, $article, $row['geojson']); 841 | } 842 | } 843 | 844 | function processOsmItems() { 845 | $pgconn = $this->getPgConn(); 846 | // to avoid problems with geometrycollections first dump all geometries and collect them again 847 | $sql = 'SELECT wikidata_ref, languages, geojson FROM 848 | ( SELECT wikidata_ref, '.self::simplifyGeoJSON.' FROM ( 849 | SELECT wikidata_ref,(ST_Dump(way)).geom AS way FROM wiwosm WHERE wikidata_ref > 0 850 | ) AS geomdump GROUP BY wikidata_ref) AS wiwosm_geom, ( 851 | SELECT wikidata_id, hstore(array_agg(wiwosm_wikidata_languages.lang), array_agg(wiwosm_wikidata_languages.article)) AS languages FROM wiwosm_wikidata_languages GROUP BY wikidata_id 852 | ) AS wikidata_languages 853 | WHERE wikidata_ref=wikidata_id'; 854 | 855 | // this consumes just too mutch memory: 856 | /* 857 | $result = pg_query($conn, $sql); 858 | if (!$result) { 859 | $this->logMessage("Fail to fetch results from postgis \n", 1); 860 | exit; 861 | } 862 | */ 863 | 864 | // so we have to use a cursor because its too much data: 865 | if (!pg_query($pgconn,'BEGIN WORK') || !pg_query($pgconn,'DECLARE osmcur NO SCROLL CURSOR FOR '.$sql)) { 866 | $this->logMessage('Could not declare cursor'. "\n" . pg_last_error() . "\n", 1); 867 | exit(); 868 | } 869 | 870 | 871 | $count = 0; 872 | 873 | // fetch from osmcur in steps of 1000 elements 874 | $result = pg_prepare($pgconn,'fetch_osmcur','FETCH 1000 FROM osmcur'); 875 | if ($result === false) exit(); 876 | 877 | $result = pg_execute($pgconn,'fetch_osmcur',array()); 878 | 879 | $fetchcount = pg_num_rows($result); 880 | 881 | $this->logMessage('Get the first '.$fetchcount.' rows:'.((microtime(true)-$this->start)/60)." min\n", 2); 882 | 883 | //damn cursor loop: 884 | while ($fetchcount > 0) { 885 | while ($row = pg_fetch_assoc($result)) { 886 | 887 | $this->createlinks('wikidata', 'Q'.$row['wikidata_ref'], $row['geojson'], $row['languages']); 888 | // free the memory 889 | unset($row); 890 | } 891 | $count += $fetchcount; 892 | $this->logMessage($count.' results processed:'.((microtime(true)-$this->start)/60)." min\n", 2); 893 | $result = pg_execute($pgconn,'fetch_osmcur',array()); 894 | $fetchcount = pg_num_rows($result); 895 | } 896 | 897 | pg_query($pgconn,'CLOSE osmcur'); 898 | pg_query($pgconn,'COMMIT WORK'); 899 | } 900 | 901 | } 902 | -------------------------------------------------------------------------------- /server/cleanup.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | #$ -N wiwosmcleanup 3 | #$ -l h_rt=2:00:00 4 | #$ -l virtual_free=5M 5 | #$ -l arch=* 6 | #$ -m a 7 | #$ -o $HOME/log/cleanup.out 8 | #$ -e $HOME/log/cleanup.err 9 | 10 | /usr/bin/rm -rf /mnt/user-store/wiwosm/geojsongz_old_remove 11 | 12 | -------------------------------------------------------------------------------- /server/gen_json_files.php: -------------------------------------------------------------------------------- 1 | 1) && ($argv[1] == 'full'); 11 | $linkupdate = ($argc > 1) && ($argv[1] == 'link'); 12 | 13 | echo date(DATE_RFC822)."\n"; 14 | 15 | $wiwosm = new Wiwosm(2); 16 | 17 | $defaultpath = $wiwosm->json_path; 18 | 19 | if ($fullupdate) { 20 | $wiwosm->json_path = dirname($defaultpath).'/'.date('Y-m-d_H-i').'_geojsongz'; 21 | echo 'doing full update'."\n"; 22 | $wiwosm->createWikidataLangTable(); 23 | } 24 | 25 | if (!$linkupdate) { 26 | $wiwosm->updateWiwosmDB(); 27 | $wiwosm->logUnknownJSON(); 28 | } else { 29 | $wiwosm->json_path = dirname($defaultpath).'/'.date('Y-m-d_H-i').'_geojsongz'; 30 | echo 'skip DB Update - doing linkupdate only'."\n"; 31 | } 32 | $wiwosm->processOsmItems(); 33 | if ($fullupdate || $linkupdate) $wiwosm->testAndRename(); 34 | } 35 | -------------------------------------------------------------------------------- /server/public_html/osmjson/getGeoJSON.php: -------------------------------------------------------------------------------- 1 | getFilePath($lang, $article, false); 21 | print "$article\t" . (file_exists($file) ? 1 : 0) . "\n"; 22 | } 23 | exit(); 24 | } 25 | 26 | if ($_GET['action']=='purge' && $article && $lang) { 27 | if ($lang == 'wikidata') { 28 | echo 'update of wikidata objects in WIWOSM is not possible at the moment. Sorry!'; 29 | exit(); 30 | } 31 | echo 'Sorry, wiwosm is under development, so the purge feature is disabled for now!'; 32 | exit(); 33 | $wiwosm->updateOneObject($lang,$article); 34 | } 35 | 36 | $file = $wiwosm->getFilePath($lang,$article,false); 37 | if (file_exists($file)) { 38 | if ($_GET['action']=='check') { 39 | echo 1; 40 | } else { 41 | header('Content-Encoding: gzip'); 42 | readfile($file); 43 | } 44 | } else { 45 | if ($_GET['action']=='check') { 46 | echo 0; 47 | } else { 48 | header("HTTP/1.0 404 Not Found"); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /server/public_html/wiwosmlog/broken.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WIWOSM broken languages 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |

Unknown wikipedia tags found while WIWOSM-processing

18 |

19 |

Objects in this list:

20 |

Note: You can get the raw data as JSON, too!

21 |
    22 |
  • 12.01.2013: Now all wikipedia tags with undefined language like wikipedia=article are shown, too!
  • 23 |
  • 14.01.2013: Edit links are now available for potlatch2 and JOSM or Merkaartor with Remotecontrol plugin.
  • 24 |
  • 15.01.2013: Handled the big load with SlickGrid.
  • 25 |
  • 16.01.2013: Columns are sortable again.
  • 26 |
  • 18.01.2013: Now I try to guess the country with iso2 country code by geographic match with World Borders Dataset.For Performance reasons I use the simple boundaries, so there could be some mistakes near borders! This matching is just a hint. You should check that manually in every case!
  • 27 |
  • 23.01.2013: You can use Quickfilters now, yeah!
  • 28 |
  • 29.01.2013: Quickfilters are case insensitive now.
  • 29 |
  • 03.03.2014: Now we use wikidata to get all associated languages! You see all articles here that were not found in wikidata.
  • 30 |
31 |

Important: Most of the wikipedia=article tags point to the english wikipedia.
Please check it first to be sure to link to the correct article. It is not enough to add just a guessed language!
Please verify that this article is really present in the specified wikipedia!

32 |
33 | 34 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /server/public_html/wiwosmlog/broken.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /server/wiwosm.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | #$ -N wiwosm 3 | #$ -l h_rt=12:00:00 4 | #$ -l virtual_free=100M 5 | #$ -o /data/project/wiwosm/log/wiwosm.out 6 | #$ -e /data/project/wiwosm/log/wiwosm.err 7 | 8 | 9 | #if test `date +%u` -eq 3 10 | #then 11 | # php /data/project/wiwosm/WIWOSM/server/gen_json_files.php full 12 | #else 13 | # php /data/project/wiwosm/WIWOSM/server/gen_json_files.php 14 | #fi 15 | 16 | #php /data/project/wiwosm/test.php 17 | 18 | php /data/project/wiwosm/WIWOSM/server/gen_json_files.php 19 | --------------------------------------------------------------------------------