Index: trunk/extensions/geo/geo.php |
— | — | @@ -112,7 +112,7 @@ |
113 | 113 | # *Much* slower than the function above |
114 | 114 | function read_from_url ( $id ) |
115 | 115 | { |
116 | | - $indedx = "http://127.0.0.1/phase3/index.php" ; |
| 116 | + $index = "http://127.0.0.1/phase3/index.php" ; |
117 | 117 | $filename = "{$index}?title=Geo:{$id}&action=raw" ; |
118 | 118 | $handle = fopen($filename, "r"); |
119 | 119 | $contents = ''; |
— | — | @@ -130,9 +130,9 @@ |
131 | 131 | if ( isset ( $geo_cache[$id] ) ) # Try the cache first... |
132 | 132 | return $geo_cache[$id] ; |
133 | 133 | |
134 | | - if ( MEDIAWIKI ) |
| 134 | + if ( MEDIAWIKI ) # Direct connection to mediawiki database via Article/Title class |
135 | 135 | $contents = $this->read_from_article ( $id ) ; |
136 | | - else |
| 136 | + else # Over-the-net connection via URL "&action=raw", much slower |
137 | 137 | $contents = $this->read_from_url ( $id ) ; |
138 | 138 | |
139 | 139 | # Return text |
— | — | @@ -212,16 +212,23 @@ |
213 | 213 | if ( $p['font-size'] == "" ) $p['font-size'] = "medium" ; |
214 | 214 | if ( $p['font-size'] == "medium" ) $p['font-size'] = $medium_font_size . "pt" ; |
215 | 215 | |
| 216 | + # Link? |
| 217 | + if ( isset ( $l['style']['href'] ) ) |
| 218 | + { |
| 219 | + $href = $l['style']['href'] ; |
| 220 | + unset ( $l['style']['href'] ) ; # Don't want this to show up in the style attribute |
| 221 | + } |
| 222 | + else $href = "" ; |
| 223 | + |
216 | 224 | # Make a style parameter string |
217 | 225 | foreach ( $p AS $pk => $pv ) |
218 | 226 | $s .= "{$pk}: {$pv}; " ; |
219 | 227 | |
220 | 228 | $s .= "' x='{$x}' y='{$y}'>{$text}</text>" ; |
221 | | - if ( isset ( $l['style']['href'] ) ) |
222 | | - { |
223 | | - $href = $l['style']['href'] ; |
| 229 | + |
| 230 | + if ( $href != "" ) |
224 | 231 | $s = "<a xlink:href=\"{$href}\">{$s}</a>" ; |
225 | | - } |
| 232 | + |
226 | 233 | $ret .= $s."\n" ; |
227 | 234 | } |
228 | 235 | return $ret ; |
— | — | @@ -461,9 +468,8 @@ |
462 | 469 | { |
463 | 470 | $b = $this->get_data ( $params ) ; |
464 | 471 | $b = $b[0] ; # Only one point for cities... |
465 | | - if ( isset ( $this->data['magnitude'] ) ) $r = $this->data['magnitude'] * 100 ; |
| 472 | + if ( isset ( $this->data['magnitude'][0] ) ) $r = floor ( trim ( $this->data['magnitude'][0] ) ) * 100 ; |
466 | 473 | else $r = 300 ; |
467 | | - $params->data_to_real ( $b[0] , $b[1] ) ; |
468 | 474 | $ret .= "<circle cx=\"{$b[0]}\" cy=\"{$b[1]}\" r=\"{$r}\" fill=\"red\" style=\"fill-opacity:0.5\"/>\n" ; |
469 | 475 | $this->add_label ( $b[0] , $b[1] , $params ) ; |
470 | 476 | } |
Index: trunk/extensions/geo/fix_coordinates.php |
— | — | @@ -0,0 +1,106 @@ |
| 2 | +<? |
| 3 | + |
| 4 | +# This file is only needed temporarily and will be deleted |
| 5 | +require_once ( "geo_functions.php" ) ; |
| 6 | + |
| 7 | +function read_from_url ( $id ) |
| 8 | + { |
| 9 | + $index = "http://127.0.0.1/phase3/index.php" ; |
| 10 | + $filename = "{$index}?title=Geo:{$id}&action=raw" ; |
| 11 | + $handle = fopen($filename, "r"); |
| 12 | + $contents = ''; |
| 13 | + while (!feof($handle)) |
| 14 | + $contents .= fread($handle, 8192); |
| 15 | + fclose($handle); |
| 16 | + return $contents ; |
| 17 | + } |
| 18 | + |
| 19 | +function add ( $v , $dv ) |
| 20 | + { |
| 21 | + if ( substr ( $v , 0 , 1 ) == "-" ) { $mv = -1 ; $v = substr ( $v , 1 ) ; } |
| 22 | + else $mv = 1 ; |
| 23 | + if ( substr ( $dv , 0 , 1 ) == "-" ) { $mdv = -1 ; $dv = substr ( $dv , 1 ) ; } |
| 24 | + else $mdv = 1 ; |
| 25 | + |
| 26 | + $av = array ( substr ( $v , 0 , 2 ) , substr ( $v , 2 , 2 ) , substr ( $v , 4 , 2 ) ) ; |
| 27 | + $adv = array ( substr ( $dv , 0 , 2 ) , substr ( $dv , 2 , 2 ) , substr ( $dv , 4 , 2 ) ) ; |
| 28 | + $av[2] += $adv[2] * $mdv ; |
| 29 | + if ( $av[2] >= 60 ) { $av[2] -= 60 ; $av[1]++ ; } |
| 30 | + if ( $av[2] < 0 ) { $av[2] += 60 ; $av[1]-- ; } |
| 31 | + $av[1] += $adv[1] * $mdv ; |
| 32 | + if ( $av[1] >= 60 ) { $av[1] -= 60 ; $av[0]++ ; } |
| 33 | + if ( $av[1] < 0 ) { $av[1] += 60 ; $av[0]-- ; } |
| 34 | + $av[0] += $adv[0] * $mdv ; |
| 35 | + $ret = "" ; |
| 36 | + $ret .= $av[0] < 10 ? "0" . $av[0] : $av[0] ; |
| 37 | + $ret .= $av[1] < 10 ? "0" . $av[1] : $av[1] ; |
| 38 | + $ret .= $av[2] < 10 ? "0" . $av[2] : $av[2] ; |
| 39 | + return $ret ; |
| 40 | + } |
| 41 | + |
| 42 | +function transform ( $a , $tx , $ty ) |
| 43 | + { |
| 44 | + $x = trim ( $a[0] ) ; |
| 45 | + $y = trim ( $a[1] ) ; |
| 46 | + $x = add ( $x , $tx ) ; |
| 47 | + $y = add ( $y , $ty ) ; |
| 48 | + return $x . "," . $y ; |
| 49 | + } |
| 50 | + |
| 51 | +function runit ( $title , $tx , $ty ) |
| 52 | + { |
| 53 | + $text = explode ( "\n" , read_from_url ( $title ) ) ; |
| 54 | + $ret = array() ; |
| 55 | + foreach ( $text AS $t ) |
| 56 | + { |
| 57 | + if ( trim ( strtolower ( substr ( $t , 0 , 6 ) ) ) == ";data:" ) |
| 58 | + { |
| 59 | + $r = array () ; |
| 60 | + $t = explode ( ";" , substr ( $t , 6 ) ) ; |
| 61 | + foreach ( $t AS $s ) |
| 62 | + { |
| 63 | + $set = array() ; |
| 64 | + $s = explode ( " " , trim ( $s ) ) ; |
| 65 | + foreach ( $s AS $part ) |
| 66 | + { |
| 67 | + $part = explode ( "," , $part ) ; |
| 68 | + $set[] = transform ( $part , $tx , $ty ) ; |
| 69 | + } |
| 70 | + $r[] = implode ( " " , $set ) ; |
| 71 | + } |
| 72 | + $ret[] = ";data:" . implode ( ";" , $r ) ; |
| 73 | + } |
| 74 | + else $ret[] = $t ; |
| 75 | + } |
| 76 | + return $ret ; |
| 77 | + } |
| 78 | + |
| 79 | +$tx = $ty = "000000" ; |
| 80 | +if ( isset ( $_POST['tx'] ) ) $tx = $_POST['tx'] ; |
| 81 | +if ( isset ( $_POST['ty'] ) ) $ty = $_POST['ty'] ; |
| 82 | +if ( isset ( $_POST['title'] ) ) $title = $_POST['title'] ; |
| 83 | +if ( $title != "" ) |
| 84 | + { |
| 85 | + $ret = runit ( $title , $tx , $ty ) ; |
| 86 | + #$ret = runit ( $title , "004500" , "-001200" ) ; |
| 87 | + } |
| 88 | +else $ret = array () ; |
| 89 | +print "<html><head></head><body>" ; |
| 90 | +print "<p>This form is to mass-move coordinates. Enter the page title and the coordinate difference.</p>" ; |
| 91 | +print "<form method=post>Title : <input type=text name='title' value='{$title}'/><br/>" ; |
| 92 | +print "X : <input type=text name='tx' value='{$tx}'/><br/>"; |
| 93 | +print "Y : <input type=text name='ty' value='{$ty}'/><br/>"; |
| 94 | +print "<input type=submit name='OK'/>" ; |
| 95 | +print "</body></html>" ; |
| 96 | + |
| 97 | +if ( count ( $ret ) > 0 ) |
| 98 | + print "<pre>" . implode ( "\n" , $ret ) . "</pre>" ; |
| 99 | + |
| 100 | +/* |
| 101 | +$title = "germany.bavaria" ; |
| 102 | +$ret = runit ( $title , "004500" , "-001200" ) ; |
| 103 | +print implode ( "\n" , $ret ) . "\n" ; |
| 104 | +*/ |
| 105 | + |
| 106 | + |
| 107 | +?> |
\ No newline at end of file |
Property changes on: trunk/extensions/geo/fix_coordinates.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 108 | + native |
Added: svn:keywords |
2 | 109 | + Author Date Id Revision |