@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | if (empty($wkb)) { |
| 38 | - throw new Exception('Cannot read empty WKB geometry. Found ' . gettype($wkb)); |
|
| 38 | + throw new Exception('Cannot read empty WKB geometry. Found '.gettype($wkb)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $mem = fopen('php://memory', 'r+'); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | function getPoint(&$mem) |
| 90 | 90 | { |
| 91 | - $point_coords = unpack("d*", fread($mem, $this->dimension*8)); |
|
| 91 | + $point_coords = unpack("d*", fread($mem, $this->dimension * 8)); |
|
| 92 | 92 | if (!empty($point_coords)) { |
| 93 | 93 | return new Point($point_coords[1], $point_coords[2]); |
| 94 | 94 | } else { |
@@ -105,14 +105,14 @@ discard block |
||
| 105 | 105 | if (!$line_length[1]) return new LineString(); |
| 106 | 106 | |
| 107 | 107 | // Read the nubmer of points x2 (each point is two coords) into decimal-floats |
| 108 | - $line_coords = unpack('d*', fread($mem, $line_length[1]*$this->dimension*8)); |
|
| 108 | + $line_coords = unpack('d*', fread($mem, $line_length[1] * $this->dimension * 8)); |
|
| 109 | 109 | |
| 110 | 110 | // We have our coords, build up the linestring |
| 111 | 111 | $components = array(); |
| 112 | 112 | $i = 1; |
| 113 | 113 | $num_coords = count($line_coords); |
| 114 | 114 | while ($i <= $num_coords) { |
| 115 | - $components[] = new Point($line_coords[$i], $line_coords[$i+1]); |
|
| 115 | + $components[] = new Point($line_coords[$i], $line_coords[$i + 1]); |
|
| 116 | 116 | $i += 2; |
| 117 | 117 | } |
| 118 | 118 | return new LineString($components); |
@@ -102,7 +102,9 @@ |
||
| 102 | 102 | $line_length = unpack('L', fread($mem, 4)); |
| 103 | 103 | |
| 104 | 104 | // Return an empty linestring if there is no line-length |
| 105 | - if (!$line_length[1]) return new LineString(); |
|
| 105 | + if (!$line_length[1]) { |
|
| 106 | + return new LineString(); |
|
| 107 | + } |
|
| 106 | 108 | |
| 107 | 109 | // Read the nubmer of points x2 (each point is two coords) into decimal-floats |
| 108 | 110 | $line_coords = unpack('d*', fread($mem, $line_length[1]*$this->dimension*8)); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | $url = "http://maps.googleapis.com/maps/api/geocode/json"; |
| 46 | - $url .= '?address='. urlencode($address); |
|
| 46 | + $url .= '?address='.urlencode($address); |
|
| 47 | 47 | $url .= $bounds_string; |
| 48 | 48 | $url .= '&sensor=false'; |
| 49 | 49 | $this->result = json_decode(@file_get_contents($url)); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | private function getPolygon($delta = 0) |
| 131 | 131 | { |
| 132 | - $points = array ( |
|
| 132 | + $points = array( |
|
| 133 | 133 | $this->getTopLeft($delta), |
| 134 | 134 | $this->getTopRight($delta), |
| 135 | 135 | $this->getBottomRight($delta), |
@@ -31,7 +31,9 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function read($address, $return_type = 'point', $bounds = false, $return_multiple = false) |
| 33 | 33 | { |
| 34 | - if (is_array($address)) $address = join(',', $address); |
|
| 34 | + if (is_array($address)) { |
|
| 35 | + $address = join(',', $address); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | if (gettype($bounds) == 'object') { |
| 37 | 39 | $bounds = $bounds->getBBox(); |
@@ -74,8 +76,11 @@ discard block |
||
| 74 | 76 | } |
| 75 | 77 | } |
| 76 | 78 | } else { |
| 77 | - if ($this->result->status) throw new Exception('Error in Google Geocoder: '.$this->result->status); |
|
| 78 | - else throw new Exception('Unknown error in Google Geocoder'); |
|
| 79 | + if ($this->result->status) { |
|
| 80 | + throw new Exception('Error in Google Geocoder: '.$this->result->status); |
|
| 81 | + } else { |
|
| 82 | + throw new Exception('Unknown error in Google Geocoder'); |
|
| 83 | + } |
|
| 79 | 84 | return false; |
| 80 | 85 | } |
| 81 | 86 | } |
@@ -114,8 +119,11 @@ discard block |
||
| 114 | 119 | return $this->result->results; |
| 115 | 120 | } |
| 116 | 121 | } else { |
| 117 | - if ($this->result->status) throw new Exception('Error in Google Reverse Geocoder: '.$this->result->status); |
|
| 118 | - else throw new Exception('Unknown error in Google Reverse Geocoder'); |
|
| 122 | + if ($this->result->status) { |
|
| 123 | + throw new Exception('Error in Google Reverse Geocoder: '.$this->result->status); |
|
| 124 | + } else { |
|
| 125 | + throw new Exception('Unknown error in Google Reverse Geocoder'); |
|
| 126 | + } |
|
| 119 | 127 | return false; |
| 120 | 128 | } |
| 121 | 129 | } |
@@ -61,14 +61,14 @@ discard block |
||
| 61 | 61 | $xmlobj = new DOMDocument(); |
| 62 | 62 | @$xmlobj->loadXML($text); |
| 63 | 63 | if ($xmlobj === false) { |
| 64 | - throw new Exception("Invalid KML: ". $text); |
|
| 64 | + throw new Exception("Invalid KML: ".$text); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $this->xmlobj = $xmlobj; |
| 68 | 68 | try { |
| 69 | 69 | $geom = $this->geomFromXML(); |
| 70 | 70 | } catch (InvalidText $e) { |
| 71 | - throw new Exception("Cannot Read Geometry From KML: ". $text); |
|
| 71 | + throw new Exception("Cannot Read Geometry From KML: ".$text); |
|
| 72 | 72 | } catch (Exception $e) { |
| 73 | 73 | throw $e; |
| 74 | 74 | } |
@@ -237,21 +237,21 @@ discard block |
||
| 237 | 237 | $type = $geom->getGeomType(); |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - $str = '<'.$this->nss . $type .'>'; |
|
| 240 | + $str = '<'.$this->nss.$type.'>'; |
|
| 241 | 241 | |
| 242 | 242 | if (!$geom->isEmpty()) { |
| 243 | 243 | $str .= '<'.$this->nss.'coordinates>'; |
| 244 | - $i=0; |
|
| 244 | + $i = 0; |
|
| 245 | 245 | foreach ($geom->getComponents() as $comp) { |
| 246 | 246 | if ($i != 0) $str .= ' '; |
| 247 | - $str .= $comp->getX() .','. $comp->getY(); |
|
| 247 | + $str .= $comp->getX().','.$comp->getY(); |
|
| 248 | 248 | $i++; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | $str .= '</'.$this->nss.'coordinates>'; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - $str .= '</'. $this->nss . $type .'>'; |
|
| 254 | + $str .= '</'.$this->nss.$type.'>'; |
|
| 255 | 255 | |
| 256 | 256 | return $str; |
| 257 | 257 | } |
@@ -261,13 +261,13 @@ discard block |
||
| 261 | 261 | $components = $geom->getComponents(); |
| 262 | 262 | $str = ''; |
| 263 | 263 | if (!empty($components)) { |
| 264 | - $str = '<'.$this->nss.'outerBoundaryIs>' . $this->linestringToKML($components[0], 'LinearRing') . '</'.$this->nss.'outerBoundaryIs>'; |
|
| 264 | + $str = '<'.$this->nss.'outerBoundaryIs>'.$this->linestringToKML($components[0], 'LinearRing').'</'.$this->nss.'outerBoundaryIs>'; |
|
| 265 | 265 | foreach (array_slice($components, 1) as $comp) { |
| 266 | - $str .= '<'.$this->nss.'innerBoundaryIs>' . $this->linestringToKML($comp) . '</'.$this->nss.'innerBoundaryIs>'; |
|
| 266 | + $str .= '<'.$this->nss.'innerBoundaryIs>'.$this->linestringToKML($comp).'</'.$this->nss.'innerBoundaryIs>'; |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - return '<'.$this->nss.'Polygon>'. $str .'</'.$this->nss.'Polygon>'; |
|
| 270 | + return '<'.$this->nss.'Polygon>'.$str.'</'.$this->nss.'Polygon>'; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | public function collectionToKML($geom) |
@@ -279,6 +279,6 @@ discard block |
||
| 279 | 279 | $str .= $sub_adapter->write($comp); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - return $str .'</'.$this->nss.'MultiGeometry>'; |
|
| 282 | + return $str.'</'.$this->nss.'MultiGeometry>'; |
|
| 283 | 283 | } |
| 284 | 284 | } |
@@ -243,7 +243,9 @@ |
||
| 243 | 243 | $str .= '<'.$this->nss.'coordinates>'; |
| 244 | 244 | $i=0; |
| 245 | 245 | foreach ($geom->getComponents() as $comp) { |
| 246 | - if ($i != 0) $str .= ' '; |
|
| 246 | + if ($i != 0) { |
|
| 247 | + $str .= ' '; |
|
| 248 | + } |
|
| 247 | 249 | $str .= $comp->getX() .','. $comp->getY(); |
| 248 | 250 | $i++; |
| 249 | 251 | } |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | $xmlobj = new DOMDocument(); |
| 54 | 54 | @$xmlobj->loadXML($text); |
| 55 | 55 | if ($xmlobj === false) { |
| 56 | - throw new Exception("Invalid GeoRSS: ". $text); |
|
| 56 | + throw new Exception("Invalid GeoRSS: ".$text); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $this->xmlobj = $xmlobj; |
| 60 | 60 | try { |
| 61 | 61 | $geom = $this->geomFromXML(); |
| 62 | 62 | } catch (InvalidText $e) { |
| 63 | - throw new Exception("Cannot Read Geometry From GeoRSS: ". $text); |
|
| 63 | + throw new Exception("Cannot Read Geometry From GeoRSS: ".$text); |
|
| 64 | 64 | } catch (Exception $e) { |
| 65 | 65 | throw $e; |
| 66 | 66 | } |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | $output = '<'.$this->nss.'line>'; |
| 223 | 223 | foreach ($geom->getComponents() as $k => $point) { |
| 224 | 224 | $output .= $point->getY().' '.$point->getX(); |
| 225 | - if ($k < ($geom->numGeometries() -1)) $output .= ' '; |
|
| 225 | + if ($k < ($geom->numGeometries() - 1)) $output .= ' '; |
|
| 226 | 226 | } |
| 227 | 227 | $output .= '</'.$this->nss.'line>'; |
| 228 | 228 | return $output; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | $exterior_ring = $geom->exteriorRing(); |
| 235 | 235 | foreach ($exterior_ring->getComponents() as $k => $point) { |
| 236 | 236 | $output .= $point->getY().' '.$point->getX(); |
| 237 | - if ($k < ($exterior_ring->numGeometries() -1)) $output .= ' '; |
|
| 237 | + if ($k < ($exterior_ring->numGeometries() - 1)) $output .= ' '; |
|
| 238 | 238 | } |
| 239 | 239 | $output .= '</'.$this->nss.'polygon>'; |
| 240 | 240 | return $output; |
@@ -222,7 +222,9 @@ discard block |
||
| 222 | 222 | $output = '<'.$this->nss.'line>'; |
| 223 | 223 | foreach ($geom->getComponents() as $k => $point) { |
| 224 | 224 | $output .= $point->getY().' '.$point->getX(); |
| 225 | - if ($k < ($geom->numGeometries() -1)) $output .= ' '; |
|
| 225 | + if ($k < ($geom->numGeometries() -1)) { |
|
| 226 | + $output .= ' '; |
|
| 227 | + } |
|
| 226 | 228 | } |
| 227 | 229 | $output .= '</'.$this->nss.'line>'; |
| 228 | 230 | return $output; |
@@ -234,7 +236,9 @@ discard block |
||
| 234 | 236 | $exterior_ring = $geom->exteriorRing(); |
| 235 | 237 | foreach ($exterior_ring->getComponents() as $k => $point) { |
| 236 | 238 | $output .= $point->getY().' '.$point->getX(); |
| 237 | - if ($k < ($exterior_ring->numGeometries() -1)) $output .= ' '; |
|
| 239 | + if ($k < ($exterior_ring->numGeometries() -1)) { |
|
| 240 | + $output .= ' '; |
|
| 241 | + } |
|
| 238 | 242 | } |
| 239 | 243 | $output .= '</'.$this->nss.'polygon>'; |
| 240 | 244 | return $output; |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | if ($type == 'GeometryCollection') { |
| 53 | 53 | return $this->objToGeometryCollection($obj); |
| 54 | 54 | } |
| 55 | - $method = 'arrayTo' . $type; |
|
| 55 | + $method = 'arrayTo'.$type; |
|
| 56 | 56 | return $this->$method($obj->coordinates); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -153,9 +153,11 @@ |
||
| 153 | 153 | 'type'=> 'GeometryCollection', |
| 154 | 154 | 'geometries'=> $component_array, |
| 155 | 155 | ); |
| 156 | - } else return array( |
|
| 156 | + } else { |
|
| 157 | + return array( |
|
| 157 | 158 | 'type'=> $geometry->getGeomType(), |
| 158 | 159 | 'coordinates'=> $geometry->asArray(), |
| 159 | 160 | ); |
| 161 | + } |
|
| 160 | 162 | } |
| 161 | 163 | } |
@@ -17,24 +17,24 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * array of neighbouring hash character maps. |
| 19 | 19 | */ |
| 20 | - private $neighbours = array ( |
|
| 20 | + private $neighbours = array( |
|
| 21 | 21 | // north |
| 22 | - 'top' => array ( |
|
| 22 | + 'top' => array( |
|
| 23 | 23 | 'even' => 'p0r21436x8zb9dcf5h7kjnmqesgutwvy', |
| 24 | 24 | 'odd' => 'bc01fg45238967deuvhjyznpkmstqrwx' |
| 25 | 25 | ), |
| 26 | 26 | // east |
| 27 | - 'right' => array ( |
|
| 27 | + 'right' => array( |
|
| 28 | 28 | 'even' => 'bc01fg45238967deuvhjyznpkmstqrwx', |
| 29 | 29 | 'odd' => 'p0r21436x8zb9dcf5h7kjnmqesgutwvy' |
| 30 | 30 | ), |
| 31 | 31 | // west |
| 32 | - 'left' => array ( |
|
| 32 | + 'left' => array( |
|
| 33 | 33 | 'even' => '238967debc01fg45kmstqrwxuvhjyznp', |
| 34 | 34 | 'odd' => '14365h7k9dcfesgujnmqp0r2twvyx8zb' |
| 35 | 35 | ), |
| 36 | 36 | // south |
| 37 | - 'bottom' => array ( |
|
| 37 | + 'bottom' => array( |
|
| 38 | 38 | 'even' => '14365h7k9dcfesgujnmqp0r2twvyx8zb', |
| 39 | 39 | 'odd' => '238967debc01fg45kmstqrwxuvhjyznp' |
| 40 | 40 | ) |
@@ -43,24 +43,24 @@ discard block |
||
| 43 | 43 | /** |
| 44 | 44 | * array of bordering hash character maps. |
| 45 | 45 | */ |
| 46 | - private $borders = array ( |
|
| 46 | + private $borders = array( |
|
| 47 | 47 | // north |
| 48 | - 'top' => array ( |
|
| 48 | + 'top' => array( |
|
| 49 | 49 | 'even' => 'prxz', |
| 50 | 50 | 'odd' => 'bcfguvyz' |
| 51 | 51 | ), |
| 52 | 52 | // east |
| 53 | - 'right' => array ( |
|
| 53 | + 'right' => array( |
|
| 54 | 54 | 'even' => 'bcfguvyz', |
| 55 | 55 | 'odd' => 'prxz' |
| 56 | 56 | ), |
| 57 | 57 | // west |
| 58 | - 'left' => array ( |
|
| 58 | + 'left' => array( |
|
| 59 | 59 | 'even' => '0145hjnp', |
| 60 | 60 | 'odd' => '028b' |
| 61 | 61 | ), |
| 62 | 62 | // south |
| 63 | - 'bottom' => array ( |
|
| 63 | + 'bottom' => array( |
|
| 64 | 64 | 'even' => '028b', |
| 65 | 65 | 'odd' => '0145hjnp' |
| 66 | 66 | ) |
@@ -134,27 +134,27 @@ discard block |
||
| 134 | 134 | private function encodePoint($point, $precision = null) |
| 135 | 135 | { |
| 136 | 136 | if ($precision === null) { |
| 137 | - $lap = strlen($point->y())-strpos($point->y(), "."); |
|
| 138 | - $lop = strlen($point->x())-strpos($point->x(), "."); |
|
| 139 | - $precision = pow(10, -max($lap-1, $lop-1, 0))/2; |
|
| 137 | + $lap = strlen($point->y()) - strpos($point->y(), "."); |
|
| 138 | + $lop = strlen($point->x()) - strpos($point->x(), "."); |
|
| 139 | + $precision = pow(10, -max($lap - 1, $lop - 1, 0)) / 2; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - $minlat = -90; |
|
| 143 | - $maxlat = 90; |
|
| 142 | + $minlat = -90; |
|
| 143 | + $maxlat = 90; |
|
| 144 | 144 | $minlon = -180; |
| 145 | - $maxlon = 180; |
|
| 146 | - $latE = 90; |
|
| 147 | - $lonE = 180; |
|
| 145 | + $maxlon = 180; |
|
| 146 | + $latE = 90; |
|
| 147 | + $lonE = 180; |
|
| 148 | 148 | $i = 0; |
| 149 | 149 | $error = 180; |
| 150 | - $hash=''; |
|
| 151 | - while ($error>=$precision) { |
|
| 150 | + $hash = ''; |
|
| 151 | + while ($error >= $precision) { |
|
| 152 | 152 | $chr = 0; |
| 153 | - for ($b=4;$b>=0;--$b) { |
|
| 154 | - if ((1&$b) == (1&$i)) { |
|
| 153 | + for ($b = 4; $b >= 0; --$b) { |
|
| 154 | + if ((1 & $b) == (1 & $i)) { |
|
| 155 | 155 | // even char, even bit OR odd char, odd bit...a lon |
| 156 | - $next = ($minlon+$maxlon)/2; |
|
| 157 | - if ($point->x()>$next) { |
|
| 156 | + $next = ($minlon + $maxlon) / 2; |
|
| 157 | + if ($point->x() > $next) { |
|
| 158 | 158 | $chr |= pow(2, $b); |
| 159 | 159 | $minlon = $next; |
| 160 | 160 | } else { |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | $lonE /= 2; |
| 164 | 164 | } else { |
| 165 | 165 | // odd char, even bit OR even char, odd bit...a lat |
| 166 | - $next = ($minlat+$maxlat)/2; |
|
| 167 | - if ($point->y()>$next) { |
|
| 166 | + $next = ($minlat + $maxlat) / 2; |
|
| 167 | + if ($point->y() > $next) { |
|
| 168 | 168 | $chr |= pow(2, $b); |
| 169 | 169 | $minlat = $next; |
| 170 | 170 | } else { |
@@ -188,28 +188,28 @@ discard block |
||
| 188 | 188 | private function decode($hash) |
| 189 | 189 | { |
| 190 | 190 | $ll = array(); |
| 191 | - $minlat = -90; |
|
| 192 | - $maxlat = 90; |
|
| 191 | + $minlat = -90; |
|
| 192 | + $maxlat = 90; |
|
| 193 | 193 | $minlon = -180; |
| 194 | - $maxlon = 180; |
|
| 195 | - $latE = 90; |
|
| 196 | - $lonE = 180; |
|
| 197 | - for ($i=0,$c=strlen($hash);$i<$c;$i++) { |
|
| 194 | + $maxlon = 180; |
|
| 195 | + $latE = 90; |
|
| 196 | + $lonE = 180; |
|
| 197 | + for ($i = 0, $c = strlen($hash); $i < $c; $i++) { |
|
| 198 | 198 | $v = strpos($this->table, $hash[$i]); |
| 199 | - if (1&$i) { |
|
| 200 | - if (16&$v)$minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 201 | - if (8&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 202 | - if (4&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 203 | - if (2&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 204 | - if (1&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 199 | + if (1 & $i) { |
|
| 200 | + if (16 & $v)$minlat = ($minlat + $maxlat) / 2; else $maxlat = ($minlat + $maxlat) / 2; |
|
| 201 | + if (8 & $v) $minlon = ($minlon + $maxlon) / 2; else $maxlon = ($minlon + $maxlon) / 2; |
|
| 202 | + if (4 & $v) $minlat = ($minlat + $maxlat) / 2; else $maxlat = ($minlat + $maxlat) / 2; |
|
| 203 | + if (2 & $v) $minlon = ($minlon + $maxlon) / 2; else $maxlon = ($minlon + $maxlon) / 2; |
|
| 204 | + if (1 & $v) $minlat = ($minlat + $maxlat) / 2; else $maxlat = ($minlat + $maxlat) / 2; |
|
| 205 | 205 | $latE /= 8; |
| 206 | 206 | $lonE /= 4; |
| 207 | 207 | } else { |
| 208 | - if (16&$v)$minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 209 | - if (8&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 210 | - if (4&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 211 | - if (2&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 212 | - if (1&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 208 | + if (16 & $v)$minlon = ($minlon + $maxlon) / 2; else $maxlon = ($minlon + $maxlon) / 2; |
|
| 209 | + if (8 & $v) $minlat = ($minlat + $maxlat) / 2; else $maxlat = ($minlat + $maxlat) / 2; |
|
| 210 | + if (4 & $v) $minlon = ($minlon + $maxlon) / 2; else $maxlon = ($minlon + $maxlon) / 2; |
|
| 211 | + if (2 & $v) $minlat = ($minlat + $maxlat) / 2; else $maxlat = ($minlat + $maxlat) / 2; |
|
| 212 | + if (1 & $v) $minlon = ($minlon + $maxlon) / 2; else $maxlon = ($minlon + $maxlon) / 2; |
|
| 213 | 213 | $latE /= 4; |
| 214 | 214 | $lonE /= 8; |
| 215 | 215 | } |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | $ll['minlon'] = $minlon; |
| 219 | 219 | $ll['maxlat'] = $maxlat; |
| 220 | 220 | $ll['maxlon'] = $maxlon; |
| 221 | - $ll['medlat'] = round(($minlat+$maxlat)/2, max(1, -round(log10($latE)))-1); |
|
| 222 | - $ll['medlon'] = round(($minlon+$maxlon)/2, max(1, -round(log10($lonE)))-1); |
|
| 221 | + $ll['medlat'] = round(($minlat + $maxlat) / 2, max(1, -round(log10($latE))) - 1); |
|
| 222 | + $ll['medlon'] = round(($minlon + $maxlon) / 2, max(1, -round(log10($lonE))) - 1); |
|
| 223 | 223 | return $ll; |
| 224 | 224 | } |
| 225 | 225 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | public function adjacent($hash, $direction) |
| 244 | 244 | { |
| 245 | 245 | $last = substr($hash, -1); |
| 246 | - $type = (strlen($hash) % 2)? 'odd': 'even'; |
|
| 246 | + $type = (strlen($hash) % 2) ? 'odd' : 'even'; |
|
| 247 | 247 | $base = substr($hash, 0, strlen($hash) - 1); |
| 248 | 248 | if (strpos(($this->borders[$direction][$type]), $last) !== false) { |
| 249 | 249 | $base = $this->adjacent($base, $direction); |
@@ -98,7 +98,9 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function write(Geometry $geometry, $precision = null) |
| 100 | 100 | { |
| 101 | - if ($geometry->isEmpty()) return ''; |
|
| 101 | + if ($geometry->isEmpty()) { |
|
| 102 | + return ''; |
|
| 103 | + } |
|
| 102 | 104 | |
| 103 | 105 | if ($geometry->geometryType() === 'Point') { |
| 104 | 106 | return $this->encodePoint($geometry, $precision); |
@@ -197,19 +199,59 @@ discard block |
||
| 197 | 199 | for ($i=0,$c=strlen($hash);$i<$c;$i++) { |
| 198 | 200 | $v = strpos($this->table, $hash[$i]); |
| 199 | 201 | if (1&$i) { |
| 200 | - if (16&$v)$minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 201 | - if (8&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 202 | - if (4&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 203 | - if (2&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 204 | - if (1&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 202 | + if (16&$v) { |
|
| 203 | + $minlat = ($minlat+$maxlat)/2; |
|
| 204 | + } else { |
|
| 205 | + $maxlat = ($minlat+$maxlat)/2; |
|
| 206 | + } |
|
| 207 | + if (8&$v) { |
|
| 208 | + $minlon = ($minlon+$maxlon)/2; |
|
| 209 | + } else { |
|
| 210 | + $maxlon = ($minlon+$maxlon)/2; |
|
| 211 | + } |
|
| 212 | + if (4&$v) { |
|
| 213 | + $minlat = ($minlat+$maxlat)/2; |
|
| 214 | + } else { |
|
| 215 | + $maxlat = ($minlat+$maxlat)/2; |
|
| 216 | + } |
|
| 217 | + if (2&$v) { |
|
| 218 | + $minlon = ($minlon+$maxlon)/2; |
|
| 219 | + } else { |
|
| 220 | + $maxlon = ($minlon+$maxlon)/2; |
|
| 221 | + } |
|
| 222 | + if (1&$v) { |
|
| 223 | + $minlat = ($minlat+$maxlat)/2; |
|
| 224 | + } else { |
|
| 225 | + $maxlat = ($minlat+$maxlat)/2; |
|
| 226 | + } |
|
| 205 | 227 | $latE /= 8; |
| 206 | 228 | $lonE /= 4; |
| 207 | 229 | } else { |
| 208 | - if (16&$v)$minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 209 | - if (8&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 210 | - if (4&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 211 | - if (2&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 212 | - if (1&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 230 | + if (16&$v) { |
|
| 231 | + $minlon = ($minlon+$maxlon)/2; |
|
| 232 | + } else { |
|
| 233 | + $maxlon = ($minlon+$maxlon)/2; |
|
| 234 | + } |
|
| 235 | + if (8&$v) { |
|
| 236 | + $minlat = ($minlat+$maxlat)/2; |
|
| 237 | + } else { |
|
| 238 | + $maxlat = ($minlat+$maxlat)/2; |
|
| 239 | + } |
|
| 240 | + if (4&$v) { |
|
| 241 | + $minlon = ($minlon+$maxlon)/2; |
|
| 242 | + } else { |
|
| 243 | + $maxlon = ($minlon+$maxlon)/2; |
|
| 244 | + } |
|
| 245 | + if (2&$v) { |
|
| 246 | + $minlat = ($minlat+$maxlat)/2; |
|
| 247 | + } else { |
|
| 248 | + $maxlat = ($minlat+$maxlat)/2; |
|
| 249 | + } |
|
| 250 | + if (1&$v) { |
|
| 251 | + $minlon = ($minlon+$maxlon)/2; |
|
| 252 | + } else { |
|
| 253 | + $maxlon = ($minlon+$maxlon)/2; |
|
| 254 | + } |
|
| 213 | 255 | $latE /= 4; |
| 214 | 256 | $lonE /= 8; |
| 215 | 257 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | static function getAdapterMap() |
| 95 | 95 | { |
| 96 | - return array ( |
|
| 96 | + return array( |
|
| 97 | 97 | 'wkt' => 'WKT', |
| 98 | 98 | 'ewkt' => 'EWKT', |
| 99 | 99 | 'wkb' => 'WKB', |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | // If the geometry cannot even theoretically be reduced more, then pass it back |
| 162 | 162 | if (gettype($geometry) == 'object') { |
| 163 | - $passbacks = array('Point','LineString','Polygon'); |
|
| 163 | + $passbacks = array('Point', 'LineString', 'Polygon'); |
|
| 164 | 164 | if (in_array($geometry->geometryType(), $passbacks)) { |
| 165 | 165 | return $geometry; |
| 166 | 166 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | // If it is a mutlti-geometry, check to see if it just has one member |
| 170 | 170 | // If it does, then pass the member, if not, then just pass back the geometry |
| 171 | 171 | if (gettype($geometry) == 'object') { |
| 172 | - $simple_collections = array('MultiPoint','MultiLineString','MultiPolygon'); |
|
| 172 | + $simple_collections = array('MultiPoint', 'MultiLineString', 'MultiPolygon'); |
|
| 173 | 173 | if (in_array(get_class($geometry), $passbacks)) { |
| 174 | 174 | $components = $geometry->getComponents(); |
| 175 | 175 | if (count($components) == 1) { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $geometries = array(); |
| 189 | 189 | $geom_types = array(); |
| 190 | 190 | |
| 191 | - $collections = array('MultiPoint','MultiLineString','MultiPolygon','GeometryCollection'); |
|
| 191 | + $collections = array('MultiPoint', 'MultiLineString', 'MultiPolygon', 'GeometryCollection'); |
|
| 192 | 192 | |
| 193 | 193 | foreach ($geometry as $item) { |
| 194 | 194 | if ($item) { |
@@ -54,7 +54,9 @@ discard block |
||
| 54 | 54 | if (!$type) { |
| 55 | 55 | // If the user is trying to load a Geometry from a Geometry... Just pass it back |
| 56 | 56 | if (is_object($data)) { |
| 57 | - if ($data instanceOf Geometry) return $data; |
|
| 57 | + if ($data instanceOf Geometry) { |
|
| 58 | + return $data; |
|
| 59 | + } |
|
| 58 | 60 | } |
| 59 | 61 | |
| 60 | 62 | $detected = geoPHP::detectFormat($data); |
@@ -124,7 +126,9 @@ discard block |
||
| 124 | 126 | static function geosInstalled($force = null) |
| 125 | 127 | { |
| 126 | 128 | static $geos_installed = null; |
| 127 | - if ($force !== null) $geos_installed = $force; |
|
| 129 | + if ($force !== null) { |
|
| 130 | + $geos_installed = $force; |
|
| 131 | + } |
|
| 128 | 132 | if ($geos_installed !== null) { |
| 129 | 133 | return $geos_installed; |
| 130 | 134 | } |
@@ -154,8 +158,12 @@ discard block |
||
| 154 | 158 | { |
| 155 | 159 | // If it's an array of one, then just parse the one |
| 156 | 160 | if (is_array($geometry)) { |
| 157 | - if (empty($geometry)) return false; |
|
| 158 | - if (count($geometry) == 1) return geoPHP::geometryReduce(array_shift($geometry)); |
|
| 161 | + if (empty($geometry)) { |
|
| 162 | + return false; |
|
| 163 | + } |
|
| 164 | + if (count($geometry) == 1) { |
|
| 165 | + return geoPHP::geometryReduce(array_shift($geometry)); |
|
| 166 | + } |
|
| 159 | 167 | } |
| 160 | 168 | |
| 161 | 169 | // If the geometry cannot even theoretically be reduced more, then pass it back |
@@ -233,7 +241,9 @@ discard block |
||
| 233 | 241 | $bytes = unpack("c*", fread($mem, 11)); |
| 234 | 242 | |
| 235 | 243 | // If bytes is empty, then we were passed empty input |
| 236 | - if (empty($bytes)) return false; |
|
| 244 | + if (empty($bytes)) { |
|
| 245 | + return false; |
|
| 246 | + } |
|
| 237 | 247 | |
| 238 | 248 | // First char is a tab, space or carriage-return. trim it and try again |
| 239 | 249 | if ($bytes[1] == 9 || $bytes[1] == 10 || $bytes[1] == 32) { |
@@ -244,8 +254,11 @@ discard block |
||
| 244 | 254 | // Detect WKB or EWKB -- first byte is 1 (little endian indicator) |
| 245 | 255 | if ($bytes[1] == 1) { |
| 246 | 256 | // If SRID byte is TRUE (1), it's EWKB |
| 247 | - if ($bytes[5]) return 'ewkb'; |
|
| 248 | - else return 'wkb'; |
|
| 257 | + if ($bytes[5]) { |
|
| 258 | + return 'ewkb'; |
|
| 259 | + } else { |
|
| 260 | + return 'wkb'; |
|
| 261 | + } |
|
| 249 | 262 | } |
| 250 | 263 | |
| 251 | 264 | // Detect HEX encoded WKB or EWKB (PostGIS format) -- first byte is 48, second byte is 49 (hex '01' => first-byte = 1) |
@@ -278,12 +291,24 @@ discard block |
||
| 278 | 291 | if ($bytes[1] == 60) { |
| 279 | 292 | // grab the first 256 characters |
| 280 | 293 | $string = substr($input, 0, 256); |
| 281 | - if (strpos($string, '<kml') !== false) return 'kml'; |
|
| 282 | - if (strpos($string, '<coordinate') !== false) return 'kml'; |
|
| 283 | - if (strpos($string, '<gpx') !== false) return 'gpx'; |
|
| 284 | - if (strpos($string, '<georss') !== false) return 'georss'; |
|
| 285 | - if (strpos($string, '<rss') !== false) return 'georss'; |
|
| 286 | - if (strpos($string, '<feed') !== false) return 'georss'; |
|
| 294 | + if (strpos($string, '<kml') !== false) { |
|
| 295 | + return 'kml'; |
|
| 296 | + } |
|
| 297 | + if (strpos($string, '<coordinate') !== false) { |
|
| 298 | + return 'kml'; |
|
| 299 | + } |
|
| 300 | + if (strpos($string, '<gpx') !== false) { |
|
| 301 | + return 'gpx'; |
|
| 302 | + } |
|
| 303 | + if (strpos($string, '<georss') !== false) { |
|
| 304 | + return 'georss'; |
|
| 305 | + } |
|
| 306 | + if (strpos($string, '<rss') !== false) { |
|
| 307 | + return 'georss'; |
|
| 308 | + } |
|
| 309 | + if (strpos($string, '<feed') !== false) { |
|
| 310 | + return 'georss'; |
|
| 311 | + } |
|
| 287 | 312 | } |
| 288 | 313 | |
| 289 | 314 | // We need an 8 byte string for geohash and unpacked WKB / WKT |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | if (!$type) { |
| 55 | 55 | // If the user is trying to load a Geometry from a Geometry... Just pass it back |
| 56 | 56 | if (is_object($data)) { |
| 57 | - if ($data instanceOf Geometry) return $data; |
|
| 57 | + if ($data instanceof Geometry) return $data; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $detected = geoPHP::detectFormat($data); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | // Parameters |
| 35 | 35 | $action = GETPOST('action', 'aZ09'); |
| 36 | 36 | $backtopage = GETPOST('backtopage', 'alpha'); |
| 37 | -$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php |
|
| 37 | +$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php |
|
| 38 | 38 | |
| 39 | 39 | if (empty($action)) { |
| 40 | 40 | $action = 'edit'; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | //'gemini' => 'Gemini' |
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | -$item = $formSetup->newItem('AI_API_SERVICE'); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
| 73 | +$item = $formSetup->newItem('AI_API_SERVICE'); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
| 74 | 74 | $item->setAsSelect($arrayofia); |
| 75 | 75 | |
| 76 | 76 | foreach ($arrayofia as $ia => $ialabel) { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $item->defaultFieldValue = ''; |
| 80 | 80 | $item->cssClass = 'minwidth500';*/ |
| 81 | 81 | |
| 82 | - $item = $formSetup->newItem('AI_API_'.strtoupper($ia).'_KEY'); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
| 82 | + $item = $formSetup->newItem('AI_API_'.strtoupper($ia).'_KEY'); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
| 83 | 83 | $item->nameText = $langs->trans("AI_API_KEY").' ('.$ialabel.')'; |
| 84 | 84 | $item->defaultFieldValue = ''; |
| 85 | 85 | $item->cssClass = 'minwidth500'; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $ai = new Ai($db); |
| 63 | 63 | |
| 64 | 64 | // Get parameters |
| 65 | -$function = empty($jsonData['function']) ? 'textgeneration' : $jsonData['function']; // Default value. Can also be 'textgenerationemail', 'textgenerationwebpage', ... |
|
| 65 | +$function = empty($jsonData['function']) ? 'textgeneration' : $jsonData['function']; // Default value. Can also be 'textgenerationemail', 'textgenerationwebpage', ... |
|
| 66 | 66 | $instructions = dol_string_nohtmltag($jsonData['instructions'], 1, 'UTF-8'); |
| 67 | 67 | $format = empty($jsonData['format']) ? '' : $jsonData['format']; |
| 68 | 68 | |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | if (!empty($generatedContent['code']) && $generatedContent['code'] == 429) { |
| 74 | 74 | print "Quota or allowed period exceeded. Retry Later !"; |
| 75 | 75 | } elseif ($generatedContent['code'] >= 400) { |
| 76 | - print "Error : " . $generatedContent['message']; |
|
| 76 | + print "Error : ".$generatedContent['message']; |
|
| 77 | 77 | print '<br><a href="'.DOL_MAIN_URL_ROOT.'/ai/admin/setup.php">'.$langs->trans('ErrorGoToModuleSetup').'</a>'; |
| 78 | 78 | } else { |
| 79 | - print "Error returned by API call: " . $generatedContent['message']; |
|
| 79 | + print "Error returned by API call: ".$generatedContent['message']; |
|
| 80 | 80 | } |
| 81 | 81 | } else { |
| 82 | 82 | print $generatedContent; |