@@ -19,173 +19,173 @@ |
||
| 19 | 19 | throw new Exception("Cannot construct a LineString with a single point"); |
| 20 | 20 | } |
| 21 | 21 | */ |
| 22 | - // Call the Collection constructor to build the LineString |
|
| 23 | - parent::__construct($points); |
|
| 22 | + // Call the Collection constructor to build the LineString |
|
| 23 | + parent::__construct($points); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | // The boundary of a linestring is itself |
| 27 | 27 | public function boundary() { |
| 28 | - return $this; |
|
| 28 | + return $this; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public function startPoint() { |
| 32 | - return $this->pointN(1); |
|
| 32 | + return $this->pointN(1); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function endPoint() { |
| 36 | - $last_n = $this->numPoints(); |
|
| 37 | - return $this->pointN($last_n); |
|
| 36 | + $last_n = $this->numPoints(); |
|
| 37 | + return $this->pointN($last_n); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function isClosed() { |
| 41 | - return ($this->startPoint()->equals($this->endPoint())); |
|
| 41 | + return ($this->startPoint()->equals($this->endPoint())); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function isRing() { |
| 45 | - return ($this->isClosed() && $this->isSimple()); |
|
| 45 | + return ($this->isClosed() && $this->isSimple()); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public function numPoints() { |
| 49 | - return $this->numGeometries(); |
|
| 49 | + return $this->numGeometries(); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function pointN($n) { |
| 53 | - return $this->geometryN($n); |
|
| 53 | + return $this->geometryN($n); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | public function dimension() { |
| 57 | - if ($this->isEmpty()) return 0; |
|
| 58 | - return 1; |
|
| 57 | + if ($this->isEmpty()) return 0; |
|
| 58 | + return 1; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | public function area() { |
| 62 | - return 0; |
|
| 62 | + return 0; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | public function length() { |
| 66 | - if ($this->geos()) { |
|
| 67 | - return $this->geos()->length(); |
|
| 68 | - } |
|
| 69 | - $length = 0; |
|
| 70 | - foreach ($this->getPoints() as $delta => $point) { |
|
| 71 | - $previous_point = $this->geometryN($delta); |
|
| 72 | - if ($previous_point) { |
|
| 73 | - $length += sqrt(pow(($previous_point->getX() - $point->getX()), 2) + pow(($previous_point->getY()- $point->getY()), 2)); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - return $length; |
|
| 66 | + if ($this->geos()) { |
|
| 67 | + return $this->geos()->length(); |
|
| 68 | + } |
|
| 69 | + $length = 0; |
|
| 70 | + foreach ($this->getPoints() as $delta => $point) { |
|
| 71 | + $previous_point = $this->geometryN($delta); |
|
| 72 | + if ($previous_point) { |
|
| 73 | + $length += sqrt(pow(($previous_point->getX() - $point->getX()), 2) + pow(($previous_point->getY()- $point->getY()), 2)); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + return $length; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | public function greatCircleLength($radius = 6378137) { |
| 80 | - $length = 0; |
|
| 81 | - $points = $this->getPoints(); |
|
| 82 | - for($i=0; $i<$this->numPoints()-1; $i++) { |
|
| 83 | - $point = $points[$i]; |
|
| 84 | - $next_point = $points[$i+1]; |
|
| 85 | - if (!is_object($next_point)) {continue;} |
|
| 86 | - // Great circle method |
|
| 87 | - $lat1 = deg2rad($point->getY()); |
|
| 88 | - $lat2 = deg2rad($next_point->getY()); |
|
| 89 | - $lon1 = deg2rad($point->getX()); |
|
| 90 | - $lon2 = deg2rad($next_point->getX()); |
|
| 91 | - $dlon = $lon2 - $lon1; |
|
| 92 | - $length += |
|
| 93 | - $radius * |
|
| 94 | - atan2( |
|
| 95 | - sqrt( |
|
| 96 | - pow(cos($lat2) * sin($dlon), 2) + |
|
| 97 | - pow(cos($lat1) * sin($lat2) - sin($lat1) * cos($lat2) * cos($dlon), 2) |
|
| 98 | - ) |
|
| 99 | - , |
|
| 100 | - sin($lat1) * sin($lat2) + |
|
| 101 | - cos($lat1) * cos($lat2) * cos($dlon) |
|
| 102 | - ); |
|
| 103 | - } |
|
| 104 | - // Returns length in meters. |
|
| 105 | - return $length; |
|
| 80 | + $length = 0; |
|
| 81 | + $points = $this->getPoints(); |
|
| 82 | + for($i=0; $i<$this->numPoints()-1; $i++) { |
|
| 83 | + $point = $points[$i]; |
|
| 84 | + $next_point = $points[$i+1]; |
|
| 85 | + if (!is_object($next_point)) {continue;} |
|
| 86 | + // Great circle method |
|
| 87 | + $lat1 = deg2rad($point->getY()); |
|
| 88 | + $lat2 = deg2rad($next_point->getY()); |
|
| 89 | + $lon1 = deg2rad($point->getX()); |
|
| 90 | + $lon2 = deg2rad($next_point->getX()); |
|
| 91 | + $dlon = $lon2 - $lon1; |
|
| 92 | + $length += |
|
| 93 | + $radius * |
|
| 94 | + atan2( |
|
| 95 | + sqrt( |
|
| 96 | + pow(cos($lat2) * sin($dlon), 2) + |
|
| 97 | + pow(cos($lat1) * sin($lat2) - sin($lat1) * cos($lat2) * cos($dlon), 2) |
|
| 98 | + ) |
|
| 99 | + , |
|
| 100 | + sin($lat1) * sin($lat2) + |
|
| 101 | + cos($lat1) * cos($lat2) * cos($dlon) |
|
| 102 | + ); |
|
| 103 | + } |
|
| 104 | + // Returns length in meters. |
|
| 105 | + return $length; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | public function haversineLength() { |
| 109 | - $degrees = 0; |
|
| 110 | - $points = $this->getPoints(); |
|
| 111 | - for($i=0; $i<$this->numPoints()-1; $i++) { |
|
| 112 | - $point = $points[$i]; |
|
| 113 | - $next_point = $points[$i+1]; |
|
| 114 | - if (!is_object($next_point)) {continue;} |
|
| 115 | - $degree = rad2deg( |
|
| 116 | - acos( |
|
| 117 | - sin(deg2rad($point->getY())) * sin(deg2rad($next_point->getY())) + |
|
| 118 | - cos(deg2rad($point->getY())) * cos(deg2rad($next_point->getY())) * |
|
| 119 | - cos(deg2rad(abs($point->getX() - $next_point->getX()))) |
|
| 120 | - ) |
|
| 121 | - ); |
|
| 122 | - $degrees += $degree; |
|
| 123 | - } |
|
| 124 | - // Returns degrees |
|
| 125 | - return $degrees; |
|
| 109 | + $degrees = 0; |
|
| 110 | + $points = $this->getPoints(); |
|
| 111 | + for($i=0; $i<$this->numPoints()-1; $i++) { |
|
| 112 | + $point = $points[$i]; |
|
| 113 | + $next_point = $points[$i+1]; |
|
| 114 | + if (!is_object($next_point)) {continue;} |
|
| 115 | + $degree = rad2deg( |
|
| 116 | + acos( |
|
| 117 | + sin(deg2rad($point->getY())) * sin(deg2rad($next_point->getY())) + |
|
| 118 | + cos(deg2rad($point->getY())) * cos(deg2rad($next_point->getY())) * |
|
| 119 | + cos(deg2rad(abs($point->getX() - $next_point->getX()))) |
|
| 120 | + ) |
|
| 121 | + ); |
|
| 122 | + $degrees += $degree; |
|
| 123 | + } |
|
| 124 | + // Returns degrees |
|
| 125 | + return $degrees; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | public function explode() { |
| 129 | - $parts = array(); |
|
| 130 | - $points = $this->getPoints(); |
|
| 129 | + $parts = array(); |
|
| 130 | + $points = $this->getPoints(); |
|
| 131 | 131 | |
| 132 | - foreach ($points as $i => $point) { |
|
| 133 | - if (isset($points[$i+1])) { |
|
| 134 | - $parts[] = new LineString(array($point, $points[$i+1])); |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - return $parts; |
|
| 132 | + foreach ($points as $i => $point) { |
|
| 133 | + if (isset($points[$i+1])) { |
|
| 134 | + $parts[] = new LineString(array($point, $points[$i+1])); |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + return $parts; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | public function isSimple() { |
| 141 | - if ($this->geos()) { |
|
| 142 | - return $this->geos()->isSimple(); |
|
| 143 | - } |
|
| 141 | + if ($this->geos()) { |
|
| 142 | + return $this->geos()->isSimple(); |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - $segments = $this->explode(); |
|
| 145 | + $segments = $this->explode(); |
|
| 146 | 146 | |
| 147 | - foreach ($segments as $i => $segment) { |
|
| 148 | - foreach ($segments as $j => $check_segment) { |
|
| 149 | - if ($i != $j) { |
|
| 150 | - if ($segment->lineSegmentIntersect($check_segment)) { |
|
| 151 | - return FALSE; |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - return TRUE; |
|
| 147 | + foreach ($segments as $i => $segment) { |
|
| 148 | + foreach ($segments as $j => $check_segment) { |
|
| 149 | + if ($i != $j) { |
|
| 150 | + if ($segment->lineSegmentIntersect($check_segment)) { |
|
| 151 | + return FALSE; |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + return TRUE; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // Utility function to check if any line sigments intersect |
| 160 | 160 | // Derived from http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect |
| 161 | 161 | public function lineSegmentIntersect($segment) { |
| 162 | - $p0_x = $this->startPoint()->x(); |
|
| 163 | - $p0_y = $this->startPoint()->y(); |
|
| 164 | - $p1_x = $this->endPoint()->x(); |
|
| 165 | - $p1_y = $this->endPoint()->y(); |
|
| 166 | - $p2_x = $segment->startPoint()->x(); |
|
| 167 | - $p2_y = $segment->startPoint()->y(); |
|
| 168 | - $p3_x = $segment->endPoint()->x(); |
|
| 169 | - $p3_y = $segment->endPoint()->y(); |
|
| 170 | - |
|
| 171 | - $s1_x = $p1_x - $p0_x; $s1_y = $p1_y - $p0_y; |
|
| 172 | - $s2_x = $p3_x - $p2_x; $s2_y = $p3_y - $p2_y; |
|
| 173 | - |
|
| 174 | - $fps = (-$s2_x * $s1_y) + ($s1_x * $s2_y); |
|
| 175 | - $fpt = (-$s2_x * $s1_y) + ($s1_x * $s2_y); |
|
| 176 | - |
|
| 177 | - if ($fps == 0 || $fpt == 0) { |
|
| 178 | - return FALSE; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - $s = (-$s1_y * ($p0_x - $p2_x) + $s1_x * ($p0_y - $p2_y)) / $fps; |
|
| 182 | - $t = ( $s2_x * ($p0_y - $p2_y) - $s2_y * ($p0_x - $p2_x)) / $fpt; |
|
| 183 | - |
|
| 184 | - if ($s > 0 && $s < 1 && $t > 0 && $t < 1) { |
|
| 185 | - // Collision detected |
|
| 186 | - return TRUE; |
|
| 187 | - } |
|
| 188 | - return FALSE; |
|
| 162 | + $p0_x = $this->startPoint()->x(); |
|
| 163 | + $p0_y = $this->startPoint()->y(); |
|
| 164 | + $p1_x = $this->endPoint()->x(); |
|
| 165 | + $p1_y = $this->endPoint()->y(); |
|
| 166 | + $p2_x = $segment->startPoint()->x(); |
|
| 167 | + $p2_y = $segment->startPoint()->y(); |
|
| 168 | + $p3_x = $segment->endPoint()->x(); |
|
| 169 | + $p3_y = $segment->endPoint()->y(); |
|
| 170 | + |
|
| 171 | + $s1_x = $p1_x - $p0_x; $s1_y = $p1_y - $p0_y; |
|
| 172 | + $s2_x = $p3_x - $p2_x; $s2_y = $p3_y - $p2_y; |
|
| 173 | + |
|
| 174 | + $fps = (-$s2_x * $s1_y) + ($s1_x * $s2_y); |
|
| 175 | + $fpt = (-$s2_x * $s1_y) + ($s1_x * $s2_y); |
|
| 176 | + |
|
| 177 | + if ($fps == 0 || $fpt == 0) { |
|
| 178 | + return FALSE; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + $s = (-$s1_y * ($p0_x - $p2_x) + $s1_x * ($p0_y - $p2_y)) / $fps; |
|
| 182 | + $t = ( $s2_x * ($p0_y - $p2_y) - $s2_y * ($p0_x - $p2_x)) / $fpt; |
|
| 183 | + |
|
| 184 | + if ($s > 0 && $s < 1 && $t > 0 && $t < 1) { |
|
| 185 | + // Collision detected |
|
| 186 | + return TRUE; |
|
| 187 | + } |
|
| 188 | + return FALSE; |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
@@ -46,38 +46,38 @@ discard block |
||
| 46 | 46 | // Public: Standard -- Common to all geometries |
| 47 | 47 | // -------------------------------------------- |
| 48 | 48 | public function SRID() { |
| 49 | - return $this->srid; |
|
| 49 | + return $this->srid; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function setSRID($srid) { |
| 53 | - if ($this->geos()) { |
|
| 54 | - $this->geos()->setSRID($srid); |
|
| 55 | - } |
|
| 56 | - $this->srid = $srid; |
|
| 53 | + if ($this->geos()) { |
|
| 54 | + $this->geos()->setSRID($srid); |
|
| 55 | + } |
|
| 56 | + $this->srid = $srid; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function envelope() { |
| 60 | - if ($this->isEmpty()) return new Polygon(); |
|
| 60 | + if ($this->isEmpty()) return new Polygon(); |
|
| 61 | 61 | |
| 62 | - if ($this->geos()) { |
|
| 63 | - return geoPHP::geosToGeometry($this->geos()->envelope()); |
|
| 64 | - } |
|
| 62 | + if ($this->geos()) { |
|
| 63 | + return geoPHP::geosToGeometry($this->geos()->envelope()); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - $bbox = $this->getBBox(); |
|
| 67 | - $points = array ( |
|
| 68 | - new Point($bbox['maxx'],$bbox['miny']), |
|
| 69 | - new Point($bbox['maxx'],$bbox['maxy']), |
|
| 70 | - new Point($bbox['minx'],$bbox['maxy']), |
|
| 71 | - new Point($bbox['minx'],$bbox['miny']), |
|
| 72 | - new Point($bbox['maxx'],$bbox['miny']), |
|
| 73 | - ); |
|
| 66 | + $bbox = $this->getBBox(); |
|
| 67 | + $points = array ( |
|
| 68 | + new Point($bbox['maxx'],$bbox['miny']), |
|
| 69 | + new Point($bbox['maxx'],$bbox['maxy']), |
|
| 70 | + new Point($bbox['minx'],$bbox['maxy']), |
|
| 71 | + new Point($bbox['minx'],$bbox['miny']), |
|
| 72 | + new Point($bbox['maxx'],$bbox['miny']), |
|
| 73 | + ); |
|
| 74 | 74 | |
| 75 | - $outer_boundary = new LineString($points); |
|
| 76 | - return new Polygon(array($outer_boundary)); |
|
| 75 | + $outer_boundary = new LineString($points); |
|
| 76 | + return new Polygon(array($outer_boundary)); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | public function geometryType() { |
| 80 | - return $this->geom_type; |
|
| 80 | + return $this->geom_type; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // Public: Non-Standard -- Common to all geometries |
@@ -85,263 +85,263 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | // $this->out($format, $other_args); |
| 87 | 87 | public function out() { |
| 88 | - $args = func_get_args(); |
|
| 88 | + $args = func_get_args(); |
|
| 89 | 89 | |
| 90 | - $format = array_shift($args); |
|
| 91 | - $type_map = geoPHP::getAdapterMap(); |
|
| 92 | - $processor_type = $type_map[$format]; |
|
| 93 | - $processor = new $processor_type(); |
|
| 90 | + $format = array_shift($args); |
|
| 91 | + $type_map = geoPHP::getAdapterMap(); |
|
| 92 | + $processor_type = $type_map[$format]; |
|
| 93 | + $processor = new $processor_type(); |
|
| 94 | 94 | |
| 95 | - array_unshift($args, $this); |
|
| 96 | - $result = call_user_func_array(array($processor, 'write'), $args); |
|
| 95 | + array_unshift($args, $this); |
|
| 96 | + $result = call_user_func_array(array($processor, 'write'), $args); |
|
| 97 | 97 | |
| 98 | - return $result; |
|
| 98 | + return $result; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | // Public: Aliases |
| 103 | 103 | // --------------- |
| 104 | 104 | public function getCentroid() { |
| 105 | - return $this->centroid(); |
|
| 105 | + return $this->centroid(); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | public function getArea() { |
| 109 | - return $this->area(); |
|
| 109 | + return $this->area(); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | public function getX() { |
| 113 | - return $this->x(); |
|
| 113 | + return $this->x(); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | public function getY() { |
| 117 | - return $this->y(); |
|
| 117 | + return $this->y(); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | public function getGeos() { |
| 121 | - return $this->geos(); |
|
| 121 | + return $this->geos(); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | public function getGeomType() { |
| 125 | - return $this->geometryType(); |
|
| 125 | + return $this->geometryType(); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | public function getSRID() { |
| 129 | - return $this->SRID(); |
|
| 129 | + return $this->SRID(); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | public function asText() { |
| 133 | - return $this->out('wkt'); |
|
| 133 | + return $this->out('wkt'); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | public function asBinary() { |
| 137 | - return $this->out('wkb'); |
|
| 137 | + return $this->out('wkb'); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // Public: GEOS Only Functions |
| 141 | 141 | // --------------------------- |
| 142 | 142 | public function geos() { |
| 143 | - // If it's already been set, just return it |
|
| 144 | - if ($this->geos && geoPHP::geosInstalled()) { |
|
| 145 | - return $this->geos; |
|
| 146 | - } |
|
| 147 | - // It hasn't been set yet, generate it |
|
| 148 | - if (geoPHP::geosInstalled()) { |
|
| 149 | - $reader = new GEOSWKBReader(); |
|
| 150 | - $this->geos = $reader->readHEX($this->out('wkb',TRUE)); |
|
| 151 | - } |
|
| 152 | - else { |
|
| 153 | - $this->geos = FALSE; |
|
| 154 | - } |
|
| 155 | - return $this->geos; |
|
| 143 | + // If it's already been set, just return it |
|
| 144 | + if ($this->geos && geoPHP::geosInstalled()) { |
|
| 145 | + return $this->geos; |
|
| 146 | + } |
|
| 147 | + // It hasn't been set yet, generate it |
|
| 148 | + if (geoPHP::geosInstalled()) { |
|
| 149 | + $reader = new GEOSWKBReader(); |
|
| 150 | + $this->geos = $reader->readHEX($this->out('wkb',TRUE)); |
|
| 151 | + } |
|
| 152 | + else { |
|
| 153 | + $this->geos = FALSE; |
|
| 154 | + } |
|
| 155 | + return $this->geos; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | public function setGeos($geos) { |
| 159 | - $this->geos = $geos; |
|
| 159 | + $this->geos = $geos; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | public function pointOnSurface() { |
| 163 | - if ($this->geos()) { |
|
| 164 | - return geoPHP::geosToGeometry($this->geos()->pointOnSurface()); |
|
| 165 | - } |
|
| 163 | + if ($this->geos()) { |
|
| 164 | + return geoPHP::geosToGeometry($this->geos()->pointOnSurface()); |
|
| 165 | + } |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | public function equalsExact(Geometry $geometry) { |
| 169 | - if ($this->geos()) { |
|
| 170 | - return $this->geos()->equalsExact($geometry->geos()); |
|
| 171 | - } |
|
| 169 | + if ($this->geos()) { |
|
| 170 | + return $this->geos()->equalsExact($geometry->geos()); |
|
| 171 | + } |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | public function relate(Geometry $geometry, $pattern = NULL) { |
| 175 | - if ($this->geos()) { |
|
| 176 | - if ($pattern) { |
|
| 177 | - return $this->geos()->relate($geometry->geos(), $pattern); |
|
| 178 | - } |
|
| 179 | - else { |
|
| 180 | - return $this->geos()->relate($geometry->geos()); |
|
| 181 | - } |
|
| 182 | - } |
|
| 175 | + if ($this->geos()) { |
|
| 176 | + if ($pattern) { |
|
| 177 | + return $this->geos()->relate($geometry->geos(), $pattern); |
|
| 178 | + } |
|
| 179 | + else { |
|
| 180 | + return $this->geos()->relate($geometry->geos()); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | public function checkValidity() { |
| 186 | - if ($this->geos()) { |
|
| 187 | - return $this->geos()->checkValidity(); |
|
| 188 | - } |
|
| 186 | + if ($this->geos()) { |
|
| 187 | + return $this->geos()->checkValidity(); |
|
| 188 | + } |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | public function buffer($distance) { |
| 192 | - if ($this->geos()) { |
|
| 193 | - return geoPHP::geosToGeometry($this->geos()->buffer($distance)); |
|
| 194 | - } |
|
| 192 | + if ($this->geos()) { |
|
| 193 | + return geoPHP::geosToGeometry($this->geos()->buffer($distance)); |
|
| 194 | + } |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | public function intersection(Geometry $geometry) { |
| 198 | - if ($this->geos()) { |
|
| 199 | - return geoPHP::geosToGeometry($this->geos()->intersection($geometry->geos())); |
|
| 200 | - } |
|
| 198 | + if ($this->geos()) { |
|
| 199 | + return geoPHP::geosToGeometry($this->geos()->intersection($geometry->geos())); |
|
| 200 | + } |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | public function convexHull() { |
| 204 | - if ($this->geos()) { |
|
| 205 | - return geoPHP::geosToGeometry($this->geos()->convexHull()); |
|
| 206 | - } |
|
| 204 | + if ($this->geos()) { |
|
| 205 | + return geoPHP::geosToGeometry($this->geos()->convexHull()); |
|
| 206 | + } |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | public function difference(Geometry $geometry) { |
| 210 | - if ($this->geos()) { |
|
| 211 | - return geoPHP::geosToGeometry($this->geos()->difference($geometry->geos())); |
|
| 212 | - } |
|
| 210 | + if ($this->geos()) { |
|
| 211 | + return geoPHP::geosToGeometry($this->geos()->difference($geometry->geos())); |
|
| 212 | + } |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | public function symDifference(Geometry $geometry) { |
| 216 | - if ($this->geos()) { |
|
| 217 | - return geoPHP::geosToGeometry($this->geos()->symDifference($geometry->geos())); |
|
| 218 | - } |
|
| 216 | + if ($this->geos()) { |
|
| 217 | + return geoPHP::geosToGeometry($this->geos()->symDifference($geometry->geos())); |
|
| 218 | + } |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | // Can pass in a geometry or an array of geometries |
| 222 | 222 | public function union(Geometry $geometry) { |
| 223 | - if ($this->geos()) { |
|
| 224 | - if (is_array($geometry)) { |
|
| 225 | - $geom = $this->geos(); |
|
| 226 | - foreach ($geometry as $item) { |
|
| 227 | - $geom = $geom->union($item->geos()); |
|
| 228 | - } |
|
| 229 | - return geoPHP::geosToGeometry($geom); |
|
| 230 | - } |
|
| 231 | - else { |
|
| 232 | - return geoPHP::geosToGeometry($this->geos()->union($geometry->geos())); |
|
| 233 | - } |
|
| 234 | - } |
|
| 223 | + if ($this->geos()) { |
|
| 224 | + if (is_array($geometry)) { |
|
| 225 | + $geom = $this->geos(); |
|
| 226 | + foreach ($geometry as $item) { |
|
| 227 | + $geom = $geom->union($item->geos()); |
|
| 228 | + } |
|
| 229 | + return geoPHP::geosToGeometry($geom); |
|
| 230 | + } |
|
| 231 | + else { |
|
| 232 | + return geoPHP::geosToGeometry($this->geos()->union($geometry->geos())); |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | public function simplify($tolerance, $preserveTopology = FALSE) { |
| 238 | - if ($this->geos()) { |
|
| 239 | - return geoPHP::geosToGeometry($this->geos()->simplify($tolerance, $preserveTopology)); |
|
| 240 | - } |
|
| 238 | + if ($this->geos()) { |
|
| 239 | + return geoPHP::geosToGeometry($this->geos()->simplify($tolerance, $preserveTopology)); |
|
| 240 | + } |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | public function disjoint(Geometry $geometry) { |
| 244 | - if ($this->geos()) { |
|
| 245 | - return $this->geos()->disjoint($geometry->geos()); |
|
| 246 | - } |
|
| 244 | + if ($this->geos()) { |
|
| 245 | + return $this->geos()->disjoint($geometry->geos()); |
|
| 246 | + } |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | public function touches(Geometry $geometry) { |
| 250 | - if ($this->geos()) { |
|
| 251 | - return $this->geos()->touches($geometry->geos()); |
|
| 252 | - } |
|
| 250 | + if ($this->geos()) { |
|
| 251 | + return $this->geos()->touches($geometry->geos()); |
|
| 252 | + } |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | public function intersects(Geometry $geometry) { |
| 256 | - if ($this->geos()) { |
|
| 257 | - return $this->geos()->intersects($geometry->geos()); |
|
| 258 | - } |
|
| 256 | + if ($this->geos()) { |
|
| 257 | + return $this->geos()->intersects($geometry->geos()); |
|
| 258 | + } |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | public function crosses(Geometry $geometry) { |
| 262 | - if ($this->geos()) { |
|
| 263 | - return $this->geos()->crosses($geometry->geos()); |
|
| 264 | - } |
|
| 262 | + if ($this->geos()) { |
|
| 263 | + return $this->geos()->crosses($geometry->geos()); |
|
| 264 | + } |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | public function within(Geometry $geometry) { |
| 268 | - if ($this->geos()) { |
|
| 269 | - return $this->geos()->within($geometry->geos()); |
|
| 270 | - } |
|
| 268 | + if ($this->geos()) { |
|
| 269 | + return $this->geos()->within($geometry->geos()); |
|
| 270 | + } |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | public function contains(Geometry $geometry) { |
| 274 | - if ($this->geos()) { |
|
| 275 | - return $this->geos()->contains($geometry->geos()); |
|
| 276 | - } |
|
| 274 | + if ($this->geos()) { |
|
| 275 | + return $this->geos()->contains($geometry->geos()); |
|
| 276 | + } |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | public function overlaps(Geometry $geometry) { |
| 280 | - if ($this->geos()) { |
|
| 281 | - return $this->geos()->overlaps($geometry->geos()); |
|
| 282 | - } |
|
| 280 | + if ($this->geos()) { |
|
| 281 | + return $this->geos()->overlaps($geometry->geos()); |
|
| 282 | + } |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | public function covers(Geometry $geometry) { |
| 286 | - if ($this->geos()) { |
|
| 287 | - return $this->geos()->covers($geometry->geos()); |
|
| 288 | - } |
|
| 286 | + if ($this->geos()) { |
|
| 287 | + return $this->geos()->covers($geometry->geos()); |
|
| 288 | + } |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | public function coveredBy(Geometry $geometry) { |
| 292 | - if ($this->geos()) { |
|
| 293 | - return $this->geos()->coveredBy($geometry->geos()); |
|
| 294 | - } |
|
| 292 | + if ($this->geos()) { |
|
| 293 | + return $this->geos()->coveredBy($geometry->geos()); |
|
| 294 | + } |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | public function distance(Geometry $geometry) { |
| 298 | - if ($this->geos()) { |
|
| 299 | - return $this->geos()->distance($geometry->geos()); |
|
| 300 | - } |
|
| 298 | + if ($this->geos()) { |
|
| 299 | + return $this->geos()->distance($geometry->geos()); |
|
| 300 | + } |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | public function hausdorffDistance(Geometry $geometry) { |
| 304 | - if ($this->geos()) { |
|
| 305 | - return $this->geos()->hausdorffDistance($geometry->geos()); |
|
| 306 | - } |
|
| 304 | + if ($this->geos()) { |
|
| 305 | + return $this->geos()->hausdorffDistance($geometry->geos()); |
|
| 306 | + } |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | public function project(Geometry $point, $normalized = NULL) { |
| 310 | - if ($this->geos()) { |
|
| 311 | - return $this->geos()->project($point->geos(), $normalized); |
|
| 312 | - } |
|
| 310 | + if ($this->geos()) { |
|
| 311 | + return $this->geos()->project($point->geos(), $normalized); |
|
| 312 | + } |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | // Public - Placeholders |
| 316 | 316 | // --------------------- |
| 317 | 317 | public function hasZ() { |
| 318 | - // geoPHP does not support Z values at the moment |
|
| 319 | - return FALSE; |
|
| 318 | + // geoPHP does not support Z values at the moment |
|
| 319 | + return FALSE; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | public function is3D() { |
| 323 | - // geoPHP does not support 3D geometries at the moment |
|
| 324 | - return FALSE; |
|
| 323 | + // geoPHP does not support 3D geometries at the moment |
|
| 324 | + return FALSE; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | public function isMeasured() { |
| 328 | - // geoPHP does not yet support M values |
|
| 329 | - return FALSE; |
|
| 328 | + // geoPHP does not yet support M values |
|
| 329 | + return FALSE; |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | public function coordinateDimension() { |
| 333 | - // geoPHP only supports 2-dimentional space |
|
| 334 | - return 2; |
|
| 333 | + // geoPHP only supports 2-dimentional space |
|
| 334 | + return 2; |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | public function z() { |
| 338 | - // geoPHP only supports 2-dimentional space |
|
| 339 | - return NULL; |
|
| 338 | + // geoPHP only supports 2-dimentional space |
|
| 339 | + return NULL; |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | public function m() { |
| 343 | - // geoPHP only supports 2-dimentional space |
|
| 344 | - return NULL; |
|
| 343 | + // geoPHP only supports 2-dimentional space |
|
| 344 | + return NULL; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | } |
@@ -35,110 +35,110 @@ discard block |
||
| 35 | 35 | {
|
| 36 | 36 | |
| 37 | 37 | static function version() {
|
| 38 | - return '1.1'; |
|
| 38 | + return '1.1'; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // geoPHP::load($data, $type, $other_args); |
| 42 | 42 | // if $data is an array, all passed in values will be combined into a single geometry |
| 43 | 43 | static function load() {
|
| 44 | - $args = func_get_args(); |
|
| 44 | + $args = func_get_args(); |
|
| 45 | 45 | |
| 46 | - $data = array_shift($args); |
|
| 47 | - $type = array_shift($args); |
|
| 46 | + $data = array_shift($args); |
|
| 47 | + $type = array_shift($args); |
|
| 48 | 48 | |
| 49 | - $type_map = geoPHP::getAdapterMap(); |
|
| 49 | + $type_map = geoPHP::getAdapterMap(); |
|
| 50 | 50 | |
| 51 | - // Auto-detect type if needed |
|
| 52 | - if (!$type) {
|
|
| 53 | - // If the user is trying to load a Geometry from a Geometry... Just pass it back |
|
| 54 | - if (is_object($data)) {
|
|
| 55 | - if ($data instanceOf Geometry) return $data; |
|
| 56 | - } |
|
| 51 | + // Auto-detect type if needed |
|
| 52 | + if (!$type) {
|
|
| 53 | + // If the user is trying to load a Geometry from a Geometry... Just pass it back |
|
| 54 | + if (is_object($data)) {
|
|
| 55 | + if ($data instanceOf Geometry) return $data; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - $detected = geoPHP::detectFormat($data); |
|
| 59 | - if (!$detected) {
|
|
| 60 | - return FALSE; |
|
| 61 | - } |
|
| 58 | + $detected = geoPHP::detectFormat($data); |
|
| 59 | + if (!$detected) {
|
|
| 60 | + return FALSE; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - $format = explode(':', $detected);
|
|
| 64 | - $type = array_shift($format); |
|
| 65 | - $args = $format; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - $processor_type = $type_map[$type]; |
|
| 69 | - |
|
| 70 | - if (!$processor_type) {
|
|
| 71 | - throw new exception('geoPHP could not find an adapter of type '.htmlentities($type));
|
|
| 72 | - exit; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - $processor = new $processor_type(); |
|
| 76 | - |
|
| 77 | - // Data is not an array, just pass it normally |
|
| 78 | - if (!is_array($data)) {
|
|
| 79 | - $result = call_user_func_array(array($processor, "read"), array_merge(array($data), $args)); |
|
| 80 | - } |
|
| 81 | - // Data is an array, combine all passed in items into a single geomtetry |
|
| 82 | - else {
|
|
| 83 | - $geoms = array(); |
|
| 84 | - foreach ($data as $item) {
|
|
| 85 | - $geoms[] = call_user_func_array(array($processor, "read"), array_merge(array($item), $args)); |
|
| 86 | - } |
|
| 87 | - $result = geoPHP::geometryReduce($geoms); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - return $result; |
|
| 63 | + $format = explode(':', $detected);
|
|
| 64 | + $type = array_shift($format); |
|
| 65 | + $args = $format; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + $processor_type = $type_map[$type]; |
|
| 69 | + |
|
| 70 | + if (!$processor_type) {
|
|
| 71 | + throw new exception('geoPHP could not find an adapter of type '.htmlentities($type));
|
|
| 72 | + exit; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + $processor = new $processor_type(); |
|
| 76 | + |
|
| 77 | + // Data is not an array, just pass it normally |
|
| 78 | + if (!is_array($data)) {
|
|
| 79 | + $result = call_user_func_array(array($processor, "read"), array_merge(array($data), $args)); |
|
| 80 | + } |
|
| 81 | + // Data is an array, combine all passed in items into a single geomtetry |
|
| 82 | + else {
|
|
| 83 | + $geoms = array(); |
|
| 84 | + foreach ($data as $item) {
|
|
| 85 | + $geoms[] = call_user_func_array(array($processor, "read"), array_merge(array($item), $args)); |
|
| 86 | + } |
|
| 87 | + $result = geoPHP::geometryReduce($geoms); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + return $result; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | static function getAdapterMap() {
|
| 94 | - return array ( |
|
| 95 | - 'wkt' => 'WKT', |
|
| 96 | - 'ewkt' => 'EWKT', |
|
| 97 | - 'wkb' => 'WKB', |
|
| 98 | - 'ewkb' => 'EWKB', |
|
| 99 | - 'json' => 'GeoJSON', |
|
| 100 | - 'geojson' => 'GeoJSON', |
|
| 101 | - 'kml' => 'KML', |
|
| 102 | - 'gpx' => 'GPX', |
|
| 103 | - 'georss' => 'GeoRSS', |
|
| 104 | - 'google_geocode' => 'GoogleGeocode', |
|
| 105 | - 'geohash' => 'GeoHash', |
|
| 106 | - ); |
|
| 94 | + return array ( |
|
| 95 | + 'wkt' => 'WKT', |
|
| 96 | + 'ewkt' => 'EWKT', |
|
| 97 | + 'wkb' => 'WKB', |
|
| 98 | + 'ewkb' => 'EWKB', |
|
| 99 | + 'json' => 'GeoJSON', |
|
| 100 | + 'geojson' => 'GeoJSON', |
|
| 101 | + 'kml' => 'KML', |
|
| 102 | + 'gpx' => 'GPX', |
|
| 103 | + 'georss' => 'GeoRSS', |
|
| 104 | + 'google_geocode' => 'GoogleGeocode', |
|
| 105 | + 'geohash' => 'GeoHash', |
|
| 106 | + ); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | static function geometryList() {
|
| 110 | - return array( |
|
| 111 | - 'point' => 'Point', |
|
| 112 | - 'linestring' => 'LineString', |
|
| 113 | - 'polygon' => 'Polygon', |
|
| 114 | - 'multipoint' => 'MultiPoint', |
|
| 115 | - 'multilinestring' => 'MultiLineString', |
|
| 116 | - 'multipolygon' => 'MultiPolygon', |
|
| 117 | - 'geometrycollection' => 'GeometryCollection', |
|
| 118 | - ); |
|
| 110 | + return array( |
|
| 111 | + 'point' => 'Point', |
|
| 112 | + 'linestring' => 'LineString', |
|
| 113 | + 'polygon' => 'Polygon', |
|
| 114 | + 'multipoint' => 'MultiPoint', |
|
| 115 | + 'multilinestring' => 'MultiLineString', |
|
| 116 | + 'multipolygon' => 'MultiPolygon', |
|
| 117 | + 'geometrycollection' => 'GeometryCollection', |
|
| 118 | + ); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | static function geosInstalled($force = NULL) {
|
| 122 | - static $geos_installed = NULL; |
|
| 123 | - if ($force !== NULL) $geos_installed = $force; |
|
| 124 | - if ($geos_installed !== NULL) {
|
|
| 125 | - return $geos_installed; |
|
| 126 | - } |
|
| 127 | - $geos_installed = class_exists('GEOSGeometry');
|
|
| 128 | - return $geos_installed; |
|
| 122 | + static $geos_installed = NULL; |
|
| 123 | + if ($force !== NULL) $geos_installed = $force; |
|
| 124 | + if ($geos_installed !== NULL) {
|
|
| 125 | + return $geos_installed; |
|
| 126 | + } |
|
| 127 | + $geos_installed = class_exists('GEOSGeometry');
|
|
| 128 | + return $geos_installed; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | static function geosToGeometry($geos) {
|
| 132 | - if (!geoPHP::geosInstalled()) {
|
|
| 133 | - return NULL; |
|
| 134 | - } |
|
| 135 | - $wkb_writer = new GEOSWKBWriter(); |
|
| 136 | - $wkb = $wkb_writer->writeHEX($geos); |
|
| 137 | - $geometry = geoPHP::load($wkb, 'wkb', TRUE); |
|
| 138 | - if ($geometry) {
|
|
| 139 | - $geometry->setGeos($geos); |
|
| 140 | - return $geometry; |
|
| 141 | - } |
|
| 132 | + if (!geoPHP::geosInstalled()) {
|
|
| 133 | + return NULL; |
|
| 134 | + } |
|
| 135 | + $wkb_writer = new GEOSWKBWriter(); |
|
| 136 | + $wkb = $wkb_writer->writeHEX($geos); |
|
| 137 | + $geometry = geoPHP::load($wkb, 'wkb', TRUE); |
|
| 138 | + if ($geometry) {
|
|
| 139 | + $geometry->setGeos($geos); |
|
| 140 | + return $geometry; |
|
| 141 | + } |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // Reduce a geometry, or an array of geometries, into their 'lowest' available common geometry. |
@@ -146,155 +146,155 @@ discard block |
||
| 146 | 146 | // A multi-point containing a single point will return a point. |
| 147 | 147 | // An array of geometries can be passed and they will be compiled into a single geometry |
| 148 | 148 | static function geometryReduce($geometry) {
|
| 149 | - // If it's an array of one, then just parse the one |
|
| 150 | - if (is_array($geometry)) {
|
|
| 151 | - if (empty($geometry)) return FALSE; |
|
| 152 | - if (count($geometry) == 1) return geoPHP::geometryReduce(array_shift($geometry)); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - // If the geometry cannot even theoretically be reduced more, then pass it back |
|
| 156 | - if (gettype($geometry) == 'object') {
|
|
| 157 | - $passbacks = array('Point','LineString','Polygon');
|
|
| 158 | - if (in_array($geometry->geometryType(),$passbacks)) {
|
|
| 159 | - return $geometry; |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - // If it is a mutlti-geometry, check to see if it just has one member |
|
| 164 | - // If it does, then pass the member, if not, then just pass back the geometry |
|
| 165 | - if (gettype($geometry) == 'object') {
|
|
| 166 | - $simple_collections = array('MultiPoint','MultiLineString','MultiPolygon');
|
|
| 167 | - if (in_array(get_class($geometry),$passbacks)) {
|
|
| 168 | - $components = $geometry->getComponents(); |
|
| 169 | - if (count($components) == 1) {
|
|
| 170 | - return $components[0]; |
|
| 171 | - } |
|
| 172 | - else {
|
|
| 173 | - return $geometry; |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - // So now we either have an array of geometries, a GeometryCollection, or an array of GeometryCollections |
|
| 179 | - if (!is_array($geometry)) {
|
|
| 180 | - $geometry = array($geometry); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - $geometries = array(); |
|
| 184 | - $geom_types = array(); |
|
| 185 | - |
|
| 186 | - $collections = array('MultiPoint','MultiLineString','MultiPolygon','GeometryCollection');
|
|
| 187 | - |
|
| 188 | - foreach ($geometry as $item) {
|
|
| 189 | - if ($item) {
|
|
| 190 | - if (in_array(get_class($item), $collections)) {
|
|
| 191 | - foreach ($item->getComponents() as $component) {
|
|
| 192 | - $geometries[] = $component; |
|
| 193 | - $geom_types[] = $component->geometryType(); |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - else {
|
|
| 197 | - $geometries[] = $item; |
|
| 198 | - $geom_types[] = $item->geometryType(); |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - $geom_types = array_unique($geom_types); |
|
| 149 | + // If it's an array of one, then just parse the one |
|
| 150 | + if (is_array($geometry)) {
|
|
| 151 | + if (empty($geometry)) return FALSE; |
|
| 152 | + if (count($geometry) == 1) return geoPHP::geometryReduce(array_shift($geometry)); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + // If the geometry cannot even theoretically be reduced more, then pass it back |
|
| 156 | + if (gettype($geometry) == 'object') {
|
|
| 157 | + $passbacks = array('Point','LineString','Polygon');
|
|
| 158 | + if (in_array($geometry->geometryType(),$passbacks)) {
|
|
| 159 | + return $geometry; |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + // If it is a mutlti-geometry, check to see if it just has one member |
|
| 164 | + // If it does, then pass the member, if not, then just pass back the geometry |
|
| 165 | + if (gettype($geometry) == 'object') {
|
|
| 166 | + $simple_collections = array('MultiPoint','MultiLineString','MultiPolygon');
|
|
| 167 | + if (in_array(get_class($geometry),$passbacks)) {
|
|
| 168 | + $components = $geometry->getComponents(); |
|
| 169 | + if (count($components) == 1) {
|
|
| 170 | + return $components[0]; |
|
| 171 | + } |
|
| 172 | + else {
|
|
| 173 | + return $geometry; |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + // So now we either have an array of geometries, a GeometryCollection, or an array of GeometryCollections |
|
| 179 | + if (!is_array($geometry)) {
|
|
| 180 | + $geometry = array($geometry); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + $geometries = array(); |
|
| 184 | + $geom_types = array(); |
|
| 185 | + |
|
| 186 | + $collections = array('MultiPoint','MultiLineString','MultiPolygon','GeometryCollection');
|
|
| 187 | + |
|
| 188 | + foreach ($geometry as $item) {
|
|
| 189 | + if ($item) {
|
|
| 190 | + if (in_array(get_class($item), $collections)) {
|
|
| 191 | + foreach ($item->getComponents() as $component) {
|
|
| 192 | + $geometries[] = $component; |
|
| 193 | + $geom_types[] = $component->geometryType(); |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + else {
|
|
| 197 | + $geometries[] = $item; |
|
| 198 | + $geom_types[] = $item->geometryType(); |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + $geom_types = array_unique($geom_types); |
|
| 204 | 204 | |
| 205 | - if (empty($geom_types)) {
|
|
| 206 | - return FALSE; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - if (count($geom_types) == 1) {
|
|
| 210 | - if (count($geometries) == 1) {
|
|
| 211 | - return $geometries[0]; |
|
| 212 | - } |
|
| 213 | - else {
|
|
| 214 | - $class = 'Multi'.$geom_types[0]; |
|
| 215 | - return new $class($geometries); |
|
| 216 | - } |
|
| 217 | - } |
|
| 218 | - else {
|
|
| 219 | - return new GeometryCollection($geometries); |
|
| 220 | - } |
|
| 205 | + if (empty($geom_types)) {
|
|
| 206 | + return FALSE; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + if (count($geom_types) == 1) {
|
|
| 210 | + if (count($geometries) == 1) {
|
|
| 211 | + return $geometries[0]; |
|
| 212 | + } |
|
| 213 | + else {
|
|
| 214 | + $class = 'Multi'.$geom_types[0]; |
|
| 215 | + return new $class($geometries); |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | + else {
|
|
| 219 | + return new GeometryCollection($geometries); |
|
| 220 | + } |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // Detect a format given a value. This function is meant to be SPEEDY. |
| 224 | 224 | // It could make a mistake in XML detection if you are mixing or using namespaces in weird ways (ie, KML inside an RSS feed) |
| 225 | 225 | static function detectFormat(&$input) {
|
| 226 | - $mem = fopen('php://memory', 'r+');
|
|
| 227 | - fwrite($mem, $input, 11); // Write 11 bytes - we can detect the vast majority of formats in the first 11 bytes |
|
| 228 | - fseek($mem, 0); |
|
| 229 | - |
|
| 230 | - $bytes = unpack("c*", fread($mem, 11));
|
|
| 231 | - |
|
| 232 | - // If bytes is empty, then we were passed empty input |
|
| 233 | - if (empty($bytes)) return FALSE; |
|
| 234 | - |
|
| 235 | - // First char is a tab, space or carriage-return. trim it and try again |
|
| 236 | - if ($bytes[1] == 9 || $bytes[1] == 10 || $bytes[1] == 32) {
|
|
| 237 | - return geoPHP::detectFormat(ltrim($input)); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - // Detect WKB or EWKB -- first byte is 1 (little endian indicator) |
|
| 241 | - if ($bytes[1] == 1) {
|
|
| 242 | - // If SRID byte is TRUE (1), it's EWKB |
|
| 243 | - if ($bytes[5]) return 'ewkb'; |
|
| 244 | - else return 'wkb'; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - // Detect HEX encoded WKB or EWKB (PostGIS format) -- first byte is 48, second byte is 49 (hex '01' => first-byte = 1) |
|
| 248 | - if ($bytes[1] == 48 && $bytes[2] == 49) {
|
|
| 249 | - // The shortest possible WKB string (LINESTRING EMPTY) is 18 hex-chars (9 encoded bytes) long |
|
| 250 | - // This differentiates it from a geohash, which is always shorter than 18 characters. |
|
| 251 | - if (strlen($input) >= 18) {
|
|
| 252 | - //@@TODO: Differentiate between EWKB and WKB -- check hex-char 10 or 11 (SRID bool indicator at encoded byte 5) |
|
| 253 | - return 'ewkb:1'; |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - // Detect GeoJSON - first char starts with {
|
|
| 258 | - if ($bytes[1] == 123) {
|
|
| 259 | - return 'json'; |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - // Detect EWKT - first char is S |
|
| 263 | - if ($bytes[1] == 83) {
|
|
| 264 | - return 'ewkt'; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - // Detect WKT - first char starts with P (80), L (76), M (77), or G (71) |
|
| 268 | - $wkt_chars = array(80, 76, 77, 71); |
|
| 269 | - if (in_array($bytes[1], $wkt_chars)) {
|
|
| 270 | - return 'wkt'; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - // Detect XML -- first char is < |
|
| 274 | - if ($bytes[1] == 60) {
|
|
| 275 | - // grab the first 256 characters |
|
| 276 | - $string = substr($input, 0, 256); |
|
| 277 | - if (strpos($string, '<kml') !== FALSE) return 'kml'; |
|
| 278 | - if (strpos($string, '<coordinate') !== FALSE) return 'kml'; |
|
| 279 | - if (strpos($string, '<gpx') !== FALSE) return 'gpx'; |
|
| 280 | - if (strpos($string, '<georss') !== FALSE) return 'georss'; |
|
| 281 | - if (strpos($string, '<rss') !== FALSE) return 'georss'; |
|
| 282 | - if (strpos($string, '<feed') !== FALSE) return 'georss'; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - // We need an 8 byte string for geohash and unpacked WKB / WKT |
|
| 286 | - fseek($mem, 0); |
|
| 287 | - $string = trim(fread($mem, 8)); |
|
| 288 | - |
|
| 289 | - // Detect geohash - geohash ONLY contains lowercase chars and numerics |
|
| 290 | - preg_match('/[a-z0-9]+/', $string, $matches);
|
|
| 291 | - if ($matches[0] == $string) {
|
|
| 292 | - return 'geohash'; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - // What do you get when you cross an elephant with a rhino? |
|
| 296 | - // http://youtu.be/RCBn5J83Poc |
|
| 297 | - return FALSE; |
|
| 226 | + $mem = fopen('php://memory', 'r+');
|
|
| 227 | + fwrite($mem, $input, 11); // Write 11 bytes - we can detect the vast majority of formats in the first 11 bytes |
|
| 228 | + fseek($mem, 0); |
|
| 229 | + |
|
| 230 | + $bytes = unpack("c*", fread($mem, 11));
|
|
| 231 | + |
|
| 232 | + // If bytes is empty, then we were passed empty input |
|
| 233 | + if (empty($bytes)) return FALSE; |
|
| 234 | + |
|
| 235 | + // First char is a tab, space or carriage-return. trim it and try again |
|
| 236 | + if ($bytes[1] == 9 || $bytes[1] == 10 || $bytes[1] == 32) {
|
|
| 237 | + return geoPHP::detectFormat(ltrim($input)); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + // Detect WKB or EWKB -- first byte is 1 (little endian indicator) |
|
| 241 | + if ($bytes[1] == 1) {
|
|
| 242 | + // If SRID byte is TRUE (1), it's EWKB |
|
| 243 | + if ($bytes[5]) return 'ewkb'; |
|
| 244 | + else return 'wkb'; |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + // Detect HEX encoded WKB or EWKB (PostGIS format) -- first byte is 48, second byte is 49 (hex '01' => first-byte = 1) |
|
| 248 | + if ($bytes[1] == 48 && $bytes[2] == 49) {
|
|
| 249 | + // The shortest possible WKB string (LINESTRING EMPTY) is 18 hex-chars (9 encoded bytes) long |
|
| 250 | + // This differentiates it from a geohash, which is always shorter than 18 characters. |
|
| 251 | + if (strlen($input) >= 18) {
|
|
| 252 | + //@@TODO: Differentiate between EWKB and WKB -- check hex-char 10 or 11 (SRID bool indicator at encoded byte 5) |
|
| 253 | + return 'ewkb:1'; |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + // Detect GeoJSON - first char starts with {
|
|
| 258 | + if ($bytes[1] == 123) {
|
|
| 259 | + return 'json'; |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + // Detect EWKT - first char is S |
|
| 263 | + if ($bytes[1] == 83) {
|
|
| 264 | + return 'ewkt'; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + // Detect WKT - first char starts with P (80), L (76), M (77), or G (71) |
|
| 268 | + $wkt_chars = array(80, 76, 77, 71); |
|
| 269 | + if (in_array($bytes[1], $wkt_chars)) {
|
|
| 270 | + return 'wkt'; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + // Detect XML -- first char is < |
|
| 274 | + if ($bytes[1] == 60) {
|
|
| 275 | + // grab the first 256 characters |
|
| 276 | + $string = substr($input, 0, 256); |
|
| 277 | + if (strpos($string, '<kml') !== FALSE) return 'kml'; |
|
| 278 | + if (strpos($string, '<coordinate') !== FALSE) return 'kml'; |
|
| 279 | + if (strpos($string, '<gpx') !== FALSE) return 'gpx'; |
|
| 280 | + if (strpos($string, '<georss') !== FALSE) return 'georss'; |
|
| 281 | + if (strpos($string, '<rss') !== FALSE) return 'georss'; |
|
| 282 | + if (strpos($string, '<feed') !== FALSE) return 'georss'; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + // We need an 8 byte string for geohash and unpacked WKB / WKT |
|
| 286 | + fseek($mem, 0); |
|
| 287 | + $string = trim(fread($mem, 8)); |
|
| 288 | + |
|
| 289 | + // Detect geohash - geohash ONLY contains lowercase chars and numerics |
|
| 290 | + preg_match('/[a-z0-9]+/', $string, $matches);
|
|
| 291 | + if ($matches[0] == $string) {
|
|
| 292 | + return 'geohash'; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + // What do you get when you cross an elephant with a rhino? |
|
| 296 | + // http://youtu.be/RCBn5J83Poc |
|
| 297 | + return FALSE; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | } |
@@ -7,121 +7,121 @@ |
||
| 7 | 7 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 8 | 8 | |
| 9 | 9 | class SpotterServer { |
| 10 | - public $dbs = null; |
|
| 10 | + public $dbs = null; |
|
| 11 | 11 | |
| 12 | - function __construct($dbs = null) { |
|
| 12 | + function __construct($dbs = null) { |
|
| 13 | 13 | if ($dbs === null) { |
| 14 | - $Connection = new Connection(null,'server'); |
|
| 15 | - $this->dbs = $Connection->dbs; |
|
| 16 | - $query = "CREATE TABLE IF NOT EXISTS `spotter_temp` ( `id_data` INT NOT NULL AUTO_INCREMENT , `id_user` INT NOT NULL , `datetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `hex` VARCHAR(20) NOT NULL , `ident` VARCHAR(20) NULL , `latitude` FLOAT NULL , `longitude` FLOAT NULL , `verticalrate` INT NULL , `speed` INT NULL , `squawk` INT NULL , `altitude` INT NULL , `heading` INT NULL , `registration` VARCHAR(10) NULL , `aircraft_icao` VARCHAR(10) NULL , `waypoints` VARCHAR(255) NULL , `noarchive` BOOLEAN NOT NULL DEFAULT FALSE, `id_source` INT NOT NULL DEFAULT '1', `format_source` VARCHAR(25) NULL, `source_name` VARCHAR(25) NULL, `over_country` VARCHAR(255) NULL, PRIMARY KEY (`id_data`) ) ENGINE = MEMORY;"; |
|
| 17 | - try { |
|
| 14 | + $Connection = new Connection(null,'server'); |
|
| 15 | + $this->dbs = $Connection->dbs; |
|
| 16 | + $query = "CREATE TABLE IF NOT EXISTS `spotter_temp` ( `id_data` INT NOT NULL AUTO_INCREMENT , `id_user` INT NOT NULL , `datetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `hex` VARCHAR(20) NOT NULL , `ident` VARCHAR(20) NULL , `latitude` FLOAT NULL , `longitude` FLOAT NULL , `verticalrate` INT NULL , `speed` INT NULL , `squawk` INT NULL , `altitude` INT NULL , `heading` INT NULL , `registration` VARCHAR(10) NULL , `aircraft_icao` VARCHAR(10) NULL , `waypoints` VARCHAR(255) NULL , `noarchive` BOOLEAN NOT NULL DEFAULT FALSE, `id_source` INT NOT NULL DEFAULT '1', `format_source` VARCHAR(25) NULL, `source_name` VARCHAR(25) NULL, `over_country` VARCHAR(255) NULL, PRIMARY KEY (`id_data`) ) ENGINE = MEMORY;"; |
|
| 17 | + try { |
|
| 18 | 18 | $sth = $this->dbs['server']->exec($query); |
| 19 | - } catch(PDOException $e) { |
|
| 19 | + } catch(PDOException $e) { |
|
| 20 | 20 | return "error : ".$e->getMessage(); |
| 21 | - } |
|
| 21 | + } |
|
| 22 | + } |
|
| 22 | 23 | } |
| 23 | - } |
|
| 24 | 24 | |
| 25 | - function checkAll() { |
|
| 26 | - return true; |
|
| 27 | - } |
|
| 25 | + function checkAll() { |
|
| 26 | + return true; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - function add($line) { |
|
| 29 | + function add($line) { |
|
| 30 | 30 | global $globalDebug, $globalServerUserID; |
| 31 | 31 | date_default_timezone_set('UTC'); |
| 32 | 32 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'aprs')) { |
| 33 | 33 | if (isset($line['format_source'])) { |
| 34 | - if(is_array($line) && isset($line['hex'])) { |
|
| 34 | + if(is_array($line) && isset($line['hex'])) { |
|
| 35 | 35 | if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) { |
| 36 | - $data['hex'] = trim($line['hex']); |
|
| 37 | - if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 38 | - $data['datetime'] = $line['datetime']; |
|
| 39 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 40 | - if (!isset($line['aircraft_icao'])) { |
|
| 41 | - $Spotter = new Spotter(); |
|
| 42 | - $aircraft_icao = $Spotter->getAllAircraftType($data['hex']); |
|
| 43 | - $Spotter->db = null; |
|
| 36 | + $data['hex'] = trim($line['hex']); |
|
| 37 | + if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 38 | + $data['datetime'] = $line['datetime']; |
|
| 39 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 40 | + if (!isset($line['aircraft_icao'])) { |
|
| 41 | + $Spotter = new Spotter(); |
|
| 42 | + $aircraft_icao = $Spotter->getAllAircraftType($data['hex']); |
|
| 43 | + $Spotter->db = null; |
|
| 44 | 44 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
| 45 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
| 46 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
| 47 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
| 48 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
| 45 | + if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
| 46 | + elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
| 47 | + elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
| 48 | + elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
| 49 | 49 | } |
| 50 | 50 | $data['aircraft_icao'] = $aircraft_icao; |
| 51 | - } else $data['aircraft_icao'] = $line['aircraft_icao']; |
|
| 52 | - //if ($globalDebug) echo "*********** New aircraft hex : ".$data['hex']." ***********\n"; |
|
| 51 | + } else $data['aircraft_icao'] = $line['aircraft_icao']; |
|
| 52 | + //if ($globalDebug) echo "*********** New aircraft hex : ".$data['hex']." ***********\n"; |
|
| 53 | 53 | } |
| 54 | 54 | if (isset($line['registration']) && $line['registration'] != '') { |
| 55 | - $data['registration'] = $line['registration']; |
|
| 55 | + $data['registration'] = $line['registration']; |
|
| 56 | 56 | } else $data['registration'] = null; |
| 57 | 57 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 58 | - $data['waypoints'] = $line['waypoints']; |
|
| 58 | + $data['waypoints'] = $line['waypoints']; |
|
| 59 | 59 | } else $data['waypoints'] = null; |
| 60 | 60 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
| 61 | - $data['ident'] = trim($line['ident']); |
|
| 61 | + $data['ident'] = trim($line['ident']); |
|
| 62 | 62 | } else $data['ident'] = null; |
| 63 | 63 | |
| 64 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') { |
|
| 65 | - if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
|
| 64 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') { |
|
| 65 | + if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
|
| 66 | 66 | $data['latitude'] = $line['latitude']; |
| 67 | - } else $data['latitude'] = null; |
|
| 68 | - if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
|
| 69 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 67 | + } else $data['latitude'] = null; |
|
| 68 | + if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
|
| 69 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 70 | 70 | $data['longitude'] = $line['longitude']; |
| 71 | - } else $data['longitude'] = null; |
|
| 71 | + } else $data['longitude'] = null; |
|
| 72 | 72 | } else { |
| 73 | - $data['latitude'] = null; |
|
| 74 | - $data['longitude'] = null; |
|
| 73 | + $data['latitude'] = null; |
|
| 74 | + $data['longitude'] = null; |
|
| 75 | 75 | } |
| 76 | 76 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 77 | - $data['verticalrate'] = $line['verticalrate']; |
|
| 77 | + $data['verticalrate'] = $line['verticalrate']; |
|
| 78 | 78 | } else $data['verticalrate'] = null; |
| 79 | 79 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 80 | - $data['emergency'] = $line['emergency']; |
|
| 80 | + $data['emergency'] = $line['emergency']; |
|
| 81 | 81 | } else $data['emergency'] = null; |
| 82 | 82 | if (isset($line['ground']) && $line['ground'] != '') { |
| 83 | - $data['ground'] = $line['ground']; |
|
| 83 | + $data['ground'] = $line['ground']; |
|
| 84 | 84 | } else $data['ground'] = null; |
| 85 | 85 | if (isset($line['speed']) && $line['speed'] != '') { |
| 86 | - $data['speed'] = round($line['speed']); |
|
| 86 | + $data['speed'] = round($line['speed']); |
|
| 87 | 87 | } else $data['speed'] = null; |
| 88 | 88 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 89 | - $data['squawk'] = $line['squawk']; |
|
| 89 | + $data['squawk'] = $line['squawk']; |
|
| 90 | 90 | } else $data['squawk'] = null; |
| 91 | 91 | |
| 92 | 92 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 93 | 93 | $data['altitude'] = round($line['altitude']); |
| 94 | 94 | } else $data['altitude'] = null; |
| 95 | 95 | if (isset($line['heading']) && $line['heading'] != '') { |
| 96 | - $data['heading'] = round($line['heading']); |
|
| 96 | + $data['heading'] = round($line['heading']); |
|
| 97 | 97 | } else $data['heading'] = null; |
| 98 | 98 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 99 | - $data['source_name'] = $line['source_name']; |
|
| 99 | + $data['source_name'] = $line['source_name']; |
|
| 100 | 100 | } else $data['source_name'] = null; |
| 101 | 101 | if (isset($line['over_country']) && $line['over_country'] != '') { |
| 102 | - $data['over_country'] = $line['over_country']; |
|
| 102 | + $data['over_country'] = $line['over_country']; |
|
| 103 | 103 | } else $data['over_country'] = null; |
| 104 | 104 | if (isset($line['noarchive']) && $line['noarchive']) { |
| 105 | - $data['noarchive'] = true; |
|
| 105 | + $data['noarchive'] = true; |
|
| 106 | 106 | } else $data['noarchive'] = false; |
| 107 | 107 | $data['format_source'] = $line['format_source']; |
| 108 | 108 | if (isset($line['id_source'])) $id_source = $line['id_source']; |
| 109 | 109 | if (isset($data['hex'])) { |
| 110 | - echo '.'; |
|
| 111 | - $id_user = $globalServerUserID; |
|
| 112 | - if ($id_user == NULL) $id_user = 1; |
|
| 113 | - if (!isset($id_source)) $id_source = 1; |
|
| 114 | - $query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive,format_source,source_name,over_country) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive, :format_source, :source_name, :over_country)'; |
|
| 115 | - $query_values = array(':id_user' => $id_user,':datetime' => $data['datetime'],':hex' => $data['hex'],':ident' => $data['ident'],':latitude' => $data['latitude'],':longitude' => $data['longitude'],':verticalrate' => $data['verticalrate'],':speed' => $data['speed'],':squawk' => $data['squawk'],':altitude' => $data['altitude'],':heading' => $data['heading'],':registration' => $data['registration'],':aircraft_icao' => $data['aircraft_icao'],':waypoints' => $data['waypoints'],':id_source' => $id_source,':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'],':over_country' => $data['over_country']); |
|
| 116 | - try { |
|
| 117 | - $sth = $this->dbs['server']->prepare($query); |
|
| 118 | - $sth->execute($query_values); |
|
| 119 | - } catch(PDOException $e) { |
|
| 120 | - return "error : ".$e->getMessage(); |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - } |
|
| 110 | + echo '.'; |
|
| 111 | + $id_user = $globalServerUserID; |
|
| 112 | + if ($id_user == NULL) $id_user = 1; |
|
| 113 | + if (!isset($id_source)) $id_source = 1; |
|
| 114 | + $query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive,format_source,source_name,over_country) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive, :format_source, :source_name, :over_country)'; |
|
| 115 | + $query_values = array(':id_user' => $id_user,':datetime' => $data['datetime'],':hex' => $data['hex'],':ident' => $data['ident'],':latitude' => $data['latitude'],':longitude' => $data['longitude'],':verticalrate' => $data['verticalrate'],':speed' => $data['speed'],':squawk' => $data['squawk'],':altitude' => $data['altitude'],':heading' => $data['heading'],':registration' => $data['registration'],':aircraft_icao' => $data['aircraft_icao'],':waypoints' => $data['waypoints'],':id_source' => $id_source,':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'],':over_country' => $data['over_country']); |
|
| 116 | + try { |
|
| 117 | + $sth = $this->dbs['server']->prepare($query); |
|
| 118 | + $sth->execute($query_values); |
|
| 119 | + } catch(PDOException $e) { |
|
| 120 | + return "error : ".$e->getMessage(); |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + } |
|
| 124 | 125 | } |
| 125 | - } |
|
| 126 | 126 | } |
| 127 | 127 | ?> |
@@ -4,55 +4,55 @@ discard block |
||
| 4 | 4 | require_once('require/class.Language.php'); |
| 5 | 5 | $Spotter = new Spotter(); |
| 6 | 6 | if (isset($_GET['start_date'])) { |
| 7 | - //for the date manipulation into the query |
|
| 8 | - if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
| 9 | - $start_date = $_GET['start_date'].":00"; |
|
| 10 | - $end_date = $_GET['end_date'].":00"; |
|
| 11 | - $sql_date = $start_date.",".$end_date; |
|
| 12 | - } else if($_GET['start_date'] != ""){ |
|
| 13 | - $start_date = $_GET['start_date'].":00"; |
|
| 14 | - $sql_date = $start_date; |
|
| 15 | - } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
| 16 | - $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
|
| 17 | - $sql_date = $end_date; |
|
| 18 | - } else $sql_date = ''; |
|
| 7 | + //for the date manipulation into the query |
|
| 8 | + if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
| 9 | + $start_date = $_GET['start_date'].":00"; |
|
| 10 | + $end_date = $_GET['end_date'].":00"; |
|
| 11 | + $sql_date = $start_date.",".$end_date; |
|
| 12 | + } else if($_GET['start_date'] != ""){ |
|
| 13 | + $start_date = $_GET['start_date'].":00"; |
|
| 14 | + $sql_date = $start_date; |
|
| 15 | + } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
| 16 | + $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
|
| 17 | + $sql_date = $end_date; |
|
| 18 | + } else $sql_date = ''; |
|
| 19 | 19 | } else $sql_date = ''; |
| 20 | 20 | |
| 21 | 21 | if (isset($_GET['highest_altitude'])) { |
| 22 | - //for altitude manipulation |
|
| 23 | - if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
| 24 | - $end_altitude = $_GET['highest_altitude']; |
|
| 25 | - $start_altitude = $_GET['lowest_altitude']; |
|
| 26 | - $sql_altitude = $start_altitude.",".$end_altitude; |
|
| 27 | - } else if($_GET['highest_altitude'] != ""){ |
|
| 28 | - $end_altitude = $_GET['highest_altitude']; |
|
| 29 | - $sql_altitude = $end_altitude; |
|
| 30 | - } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
| 31 | - $start_altitude = $_GET['lowest_altitude'].",60000"; |
|
| 32 | - $sql_altitude = $start_altitude; |
|
| 33 | - } else $sql_altitude = ''; |
|
| 22 | + //for altitude manipulation |
|
| 23 | + if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
| 24 | + $end_altitude = $_GET['highest_altitude']; |
|
| 25 | + $start_altitude = $_GET['lowest_altitude']; |
|
| 26 | + $sql_altitude = $start_altitude.",".$end_altitude; |
|
| 27 | + } else if($_GET['highest_altitude'] != ""){ |
|
| 28 | + $end_altitude = $_GET['highest_altitude']; |
|
| 29 | + $sql_altitude = $end_altitude; |
|
| 30 | + } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
| 31 | + $start_altitude = $_GET['lowest_altitude'].",60000"; |
|
| 32 | + $sql_altitude = $start_altitude; |
|
| 33 | + } else $sql_altitude = ''; |
|
| 34 | 34 | } else $sql_altitude = ''; |
| 35 | 35 | |
| 36 | 36 | //calculuation for the pagination |
| 37 | 37 | if(!isset($_GET['limit'])) |
| 38 | 38 | { |
| 39 | - if (!isset($_GET['number_results'])) |
|
| 40 | - { |
|
| 41 | - $limit_start = 0; |
|
| 42 | - $limit_end = 25; |
|
| 43 | - $absolute_difference = 25; |
|
| 44 | - } else { |
|
| 45 | - if ($_GET['number_results'] > 1000){ |
|
| 46 | - $_GET['number_results'] = 1000; |
|
| 47 | - } |
|
| 48 | - $limit_start = 0; |
|
| 49 | - $limit_end = $_GET['number_results']; |
|
| 50 | - $absolute_difference = $_GET['number_results']; |
|
| 51 | - } |
|
| 39 | + if (!isset($_GET['number_results'])) |
|
| 40 | + { |
|
| 41 | + $limit_start = 0; |
|
| 42 | + $limit_end = 25; |
|
| 43 | + $absolute_difference = 25; |
|
| 44 | + } else { |
|
| 45 | + if ($_GET['number_results'] > 1000){ |
|
| 46 | + $_GET['number_results'] = 1000; |
|
| 47 | + } |
|
| 48 | + $limit_start = 0; |
|
| 49 | + $limit_end = $_GET['number_results']; |
|
| 50 | + $absolute_difference = $_GET['number_results']; |
|
| 51 | + } |
|
| 52 | 52 | } else { |
| 53 | - $limit_explode = explode(",", $_GET['limit']); |
|
| 54 | - $limit_start = $limit_explode[0]; |
|
| 55 | - $limit_end = $limit_explode[1]; |
|
| 53 | + $limit_explode = explode(",", $_GET['limit']); |
|
| 54 | + $limit_start = $limit_explode[0]; |
|
| 55 | + $limit_end = $limit_explode[1]; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $absolute_difference = abs($limit_start - $limit_end); |
@@ -89,52 +89,52 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $output = '{'; |
| 91 | 91 | $output .= '"flightairmap": {'; |
| 92 | - $output .= '"title": "FlightAirMap JSON Feed",'; |
|
| 93 | - $output .= '"link": "http://www.flightairmap.fr",'; |
|
| 94 | - $output .= '"aircraft": ['; |
|
| 92 | + $output .= '"title": "FlightAirMap JSON Feed",'; |
|
| 93 | + $output .= '"link": "http://www.flightairmap.fr",'; |
|
| 94 | + $output .= '"aircraft": ['; |
|
| 95 | 95 | |
| 96 | - if (!empty($spotter_array)) |
|
| 96 | + if (!empty($spotter_array)) |
|
| 97 | 97 | { |
| 98 | - foreach($spotter_array as $spotter_item) |
|
| 99 | - { |
|
| 98 | + foreach($spotter_array as $spotter_item) |
|
| 99 | + { |
|
| 100 | 100 | |
| 101 | 101 | $output .= '{'; |
| 102 | - $output .= '"id": "'.$spotter_item['spotter_id'].'",'; |
|
| 103 | - $output .= '"ident": "'.$spotter_item['ident'].'",'; |
|
| 104 | - $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 105 | - $output .= '"aircraft_icao": "'.$spotter_item['aircraft_type'].'",'; |
|
| 106 | - $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].'",'; |
|
| 107 | - $output .= '"aircraft_manufacturer": "'.$spotter_item['aircraft_manufacturer'].'",'; |
|
| 108 | - $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
|
| 109 | - $output .= '"airline_icao": "'.$spotter_item['airline_icao'].'",'; |
|
| 110 | - $output .= '"airline_iata": "'.$spotter_item['airline_iata'].'",'; |
|
| 111 | - $output .= '"airline_country": "'.$spotter_item['airline_country'].'",'; |
|
| 112 | - $output .= '"airline_callsign": "'.$spotter_item['airline_callsign'].'",'; |
|
| 113 | - $output .= '"airline_type": "'.$spotter_item['airline_type'].'",'; |
|
| 114 | - $output .= '"departure_airport_city": "'.$spotter_item['departure_airport_city'].'",'; |
|
| 115 | - $output .= '"departure_airport_country": "'.$spotter_item['departure_airport_country'].'",'; |
|
| 116 | - $output .= '"departure_airport_iata": "'.$spotter_item['departure_airport_iata'].'",'; |
|
| 117 | - $output .= '"departure_airport_icao": "'.$spotter_item['departure_airport_icao'].'",'; |
|
| 118 | - $output .= '"departure_airport_latitude": "'.$spotter_item['departure_airport_latitude'].'",'; |
|
| 119 | - $output .= '"departure_airport_longitude": "'.$spotter_item['departure_airport_longitude'].'",'; |
|
| 120 | - $output .= '"departure_airport_altitude": "'.$spotter_item['departure_airport_altitude'].'",'; |
|
| 121 | - $output .= '"arrival_airport_city": "'.$spotter_item['arrival_airport_city'].'",'; |
|
| 122 | - $output .= '"arrival_airport_country": "'.$spotter_item['arrival_airport_country'].'",'; |
|
| 123 | - $output .= '"arrival_airport_iata": "'.$spotter_item['arrival_airport_iata'].'",'; |
|
| 124 | - $output .= '"departure_airport_icao": "'.$spotter_item['arrival_airport_icao'].'",'; |
|
| 125 | - $output .= '"arrival_airport_latitude": "'.$spotter_item['arrival_airport_latitude'].'",'; |
|
| 126 | - $output .= '"arrival_airport_longitude": "'.$spotter_item['arrival_airport_longitude'].'",'; |
|
| 127 | - $output .= '"arrival_airport_altitude": "'.$spotter_item['arrival_airport_altitude'].'",'; |
|
| 128 | - $output .= '"latitude": "'.$spotter_item['latitude'].'",'; |
|
| 129 | - $output .= '"longitude": "'.$spotter_item['longitude'].'",'; |
|
| 130 | - $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 131 | - $output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",'; |
|
| 132 | - $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 133 | - $output .= '"heading_name": "'.$spotter_item['heading_name'].'",'; |
|
| 134 | - $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
|
| 135 | - $output .= '"date": "'.date("c", strtotime($spotter_item['date_iso_8601'])).'"'; |
|
| 102 | + $output .= '"id": "'.$spotter_item['spotter_id'].'",'; |
|
| 103 | + $output .= '"ident": "'.$spotter_item['ident'].'",'; |
|
| 104 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 105 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_type'].'",'; |
|
| 106 | + $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].'",'; |
|
| 107 | + $output .= '"aircraft_manufacturer": "'.$spotter_item['aircraft_manufacturer'].'",'; |
|
| 108 | + $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
|
| 109 | + $output .= '"airline_icao": "'.$spotter_item['airline_icao'].'",'; |
|
| 110 | + $output .= '"airline_iata": "'.$spotter_item['airline_iata'].'",'; |
|
| 111 | + $output .= '"airline_country": "'.$spotter_item['airline_country'].'",'; |
|
| 112 | + $output .= '"airline_callsign": "'.$spotter_item['airline_callsign'].'",'; |
|
| 113 | + $output .= '"airline_type": "'.$spotter_item['airline_type'].'",'; |
|
| 114 | + $output .= '"departure_airport_city": "'.$spotter_item['departure_airport_city'].'",'; |
|
| 115 | + $output .= '"departure_airport_country": "'.$spotter_item['departure_airport_country'].'",'; |
|
| 116 | + $output .= '"departure_airport_iata": "'.$spotter_item['departure_airport_iata'].'",'; |
|
| 117 | + $output .= '"departure_airport_icao": "'.$spotter_item['departure_airport_icao'].'",'; |
|
| 118 | + $output .= '"departure_airport_latitude": "'.$spotter_item['departure_airport_latitude'].'",'; |
|
| 119 | + $output .= '"departure_airport_longitude": "'.$spotter_item['departure_airport_longitude'].'",'; |
|
| 120 | + $output .= '"departure_airport_altitude": "'.$spotter_item['departure_airport_altitude'].'",'; |
|
| 121 | + $output .= '"arrival_airport_city": "'.$spotter_item['arrival_airport_city'].'",'; |
|
| 122 | + $output .= '"arrival_airport_country": "'.$spotter_item['arrival_airport_country'].'",'; |
|
| 123 | + $output .= '"arrival_airport_iata": "'.$spotter_item['arrival_airport_iata'].'",'; |
|
| 124 | + $output .= '"departure_airport_icao": "'.$spotter_item['arrival_airport_icao'].'",'; |
|
| 125 | + $output .= '"arrival_airport_latitude": "'.$spotter_item['arrival_airport_latitude'].'",'; |
|
| 126 | + $output .= '"arrival_airport_longitude": "'.$spotter_item['arrival_airport_longitude'].'",'; |
|
| 127 | + $output .= '"arrival_airport_altitude": "'.$spotter_item['arrival_airport_altitude'].'",'; |
|
| 128 | + $output .= '"latitude": "'.$spotter_item['latitude'].'",'; |
|
| 129 | + $output .= '"longitude": "'.$spotter_item['longitude'].'",'; |
|
| 130 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 131 | + $output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",'; |
|
| 132 | + $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 133 | + $output .= '"heading_name": "'.$spotter_item['heading_name'].'",'; |
|
| 134 | + $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
|
| 135 | + $output .= '"date": "'.date("c", strtotime($spotter_item['date_iso_8601'])).'"'; |
|
| 136 | 136 | $output .= '},'; |
| 137 | - } |
|
| 137 | + } |
|
| 138 | 138 | } |
| 139 | 139 | $output = substr($output, 0, -1); |
| 140 | 140 | $output .= ']'; |
@@ -11,12 +11,12 @@ |
||
| 11 | 11 | //checks to see if FlightAware import is set |
| 12 | 12 | if ($globalFlightAware == TRUE) |
| 13 | 13 | { |
| 14 | - $SpotterLive = new SpotterLive(); |
|
| 15 | - $Spotter = new Spotter(); |
|
| 16 | - //deletes the spotter LIVE data |
|
| 17 | - $SpotterLive->deleteLiveSpotterData(); |
|
| 14 | + $SpotterLive = new SpotterLive(); |
|
| 15 | + $Spotter = new Spotter(); |
|
| 16 | + //deletes the spotter LIVE data |
|
| 17 | + $SpotterLive->deleteLiveSpotterData(); |
|
| 18 | 18 | |
| 19 | - //imports the new data from FlightAware |
|
| 20 | - $Spotter->importFromFlightAware(); |
|
| 19 | + //imports the new data from FlightAware |
|
| 20 | + $Spotter->importFromFlightAware(); |
|
| 21 | 21 | } |
| 22 | 22 | ?> |
| 23 | 23 | \ No newline at end of file |
@@ -5,8 +5,8 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | require_once(dirname(__FILE__).'/../require/settings.php'); |
| 7 | 7 | if ($globalInstalled) { |
| 8 | - echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
| 9 | - exit; |
|
| 8 | + echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
| 9 | + exit; |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | require_once('../require/class.Connection.php'); |
@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 12 | 12 | $schema = new Connection(); |
| 13 | 13 | if ($schema->latest() === false) { |
| 14 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
| 15 | - exit(); |
|
| 14 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
| 15 | + exit(); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | $debug = true; |
@@ -21,11 +21,11 @@ discard block |
||
| 21 | 21 | date_default_timezone_set('UTC'); |
| 22 | 22 | // signal handler - playing nice with sockets and dump1090 |
| 23 | 23 | pcntl_signal(SIGINT, function($signo) { |
| 24 | - global $sock; |
|
| 25 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 26 | - socket_shutdown($sock, 0); |
|
| 27 | - socket_close($sock); |
|
| 28 | - die("Bye!\n"); |
|
| 24 | + global $sock; |
|
| 25 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 26 | + socket_shutdown($sock, 0); |
|
| 27 | + socket_close($sock); |
|
| 28 | + die("Bye!\n"); |
|
| 29 | 29 | }); |
| 30 | 30 | pcntl_signal_dispatch(); |
| 31 | 31 | |
@@ -38,24 +38,24 @@ discard block |
||
| 38 | 38 | // Bind the source address |
| 39 | 39 | if( !socket_bind($sock, $globalACARSHost , $globalACARSPort) ) |
| 40 | 40 | { |
| 41 | - $errorcode = socket_last_error(); |
|
| 42 | - $errormsg = socket_strerror($errorcode); |
|
| 41 | + $errorcode = socket_last_error(); |
|
| 42 | + $errormsg = socket_strerror($errorcode); |
|
| 43 | 43 | |
| 44 | - die("Could not bind socket : [$errorcode] $errormsg \n"); |
|
| 44 | + die("Could not bind socket : [$errorcode] $errormsg \n"); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | echo "LISTEN UDP MODE \n\n"; |
| 48 | 48 | while(1) { |
| 49 | - $r = socket_recvfrom($sock, $buffer, 512, 0, $remote_ip, $remote_port); |
|
| 50 | - |
|
| 51 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 52 | - pcntl_signal_dispatch(); |
|
| 53 | - $dataFound = false; |
|
| 54 | - // (null) 2 23/02/2015 14:46:06 0 -16 X .D-AIPW ! 1L 7 M82A LH077P 010952342854:VP-MIBI+W+0)-V+(),GB1 |
|
| 55 | - echo $buffer."\n"; |
|
| 56 | - $ACARS->add(trim($buffer)); |
|
| 57 | - socket_sendto($sock, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 58 | - $ACARS->deleteLiveAcarsData(); |
|
| 49 | + $r = socket_recvfrom($sock, $buffer, 512, 0, $remote_ip, $remote_port); |
|
| 50 | + |
|
| 51 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 52 | + pcntl_signal_dispatch(); |
|
| 53 | + $dataFound = false; |
|
| 54 | + // (null) 2 23/02/2015 14:46:06 0 -16 X .D-AIPW ! 1L 7 M82A LH077P 010952342854:VP-MIBI+W+0)-V+(),GB1 |
|
| 55 | + echo $buffer."\n"; |
|
| 56 | + $ACARS->add(trim($buffer)); |
|
| 57 | + socket_sendto($sock, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 58 | + $ACARS->deleteLiveAcarsData(); |
|
| 59 | 59 | } |
| 60 | 60 | pcntl_exec($_,$argv); |
| 61 | 61 | ?> |
@@ -4,55 +4,55 @@ discard block |
||
| 4 | 4 | require_once('require/class.Language.php'); |
| 5 | 5 | $Spotter=new Spotter(); |
| 6 | 6 | if (isset($_GET['start_date'])) { |
| 7 | - //for the date manipulation into the query |
|
| 8 | - if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
| 9 | - $start_date = $_GET['start_date'].":00"; |
|
| 10 | - $end_date = $_GET['end_date'].":00"; |
|
| 11 | - $sql_date = $start_date.",".$end_date; |
|
| 12 | - } else if($_GET['start_date'] != ""){ |
|
| 13 | - $start_date = $_GET['start_date'].":00"; |
|
| 14 | - $sql_date = $start_date; |
|
| 15 | - } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
| 16 | - $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
|
| 17 | - $sql_date = $end_date; |
|
| 18 | - } else $sql_date = ''; |
|
| 7 | + //for the date manipulation into the query |
|
| 8 | + if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
| 9 | + $start_date = $_GET['start_date'].":00"; |
|
| 10 | + $end_date = $_GET['end_date'].":00"; |
|
| 11 | + $sql_date = $start_date.",".$end_date; |
|
| 12 | + } else if($_GET['start_date'] != ""){ |
|
| 13 | + $start_date = $_GET['start_date'].":00"; |
|
| 14 | + $sql_date = $start_date; |
|
| 15 | + } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
| 16 | + $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
|
| 17 | + $sql_date = $end_date; |
|
| 18 | + } else $sql_date = ''; |
|
| 19 | 19 | } else $sql_date = ''; |
| 20 | 20 | |
| 21 | 21 | if (isset($_GET['highest_altitude'])) { |
| 22 | - //for altitude manipulation |
|
| 23 | - if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
| 24 | - $end_altitude = $_GET['highest_altitude']; |
|
| 25 | - $start_altitude = $_GET['lowest_altitude']; |
|
| 26 | - $sql_altitude = $start_altitude.",".$end_altitude; |
|
| 27 | - } else if($_GET['highest_altitude'] != ""){ |
|
| 28 | - $end_altitude = $_GET['highest_altitude']; |
|
| 29 | - $sql_altitude = $end_altitude; |
|
| 30 | - } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
| 31 | - $start_altitude = $_GET['lowest_altitude'].",60000"; |
|
| 32 | - $sql_altitude = $start_altitude; |
|
| 33 | - } else $sql_altitude = ''; |
|
| 22 | + //for altitude manipulation |
|
| 23 | + if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
| 24 | + $end_altitude = $_GET['highest_altitude']; |
|
| 25 | + $start_altitude = $_GET['lowest_altitude']; |
|
| 26 | + $sql_altitude = $start_altitude.",".$end_altitude; |
|
| 27 | + } else if($_GET['highest_altitude'] != ""){ |
|
| 28 | + $end_altitude = $_GET['highest_altitude']; |
|
| 29 | + $sql_altitude = $end_altitude; |
|
| 30 | + } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
| 31 | + $start_altitude = $_GET['lowest_altitude'].",60000"; |
|
| 32 | + $sql_altitude = $start_altitude; |
|
| 33 | + } else $sql_altitude = ''; |
|
| 34 | 34 | } else $sql_altitude = ''; |
| 35 | 35 | |
| 36 | 36 | //calculuation for the pagination |
| 37 | 37 | if(!isset($_GET['limit'])) |
| 38 | 38 | { |
| 39 | - if (!isset($_GET['number_results'])) |
|
| 40 | - { |
|
| 41 | - $limit_start = 0; |
|
| 42 | - $limit_end = 25; |
|
| 43 | - $absolute_difference = 25; |
|
| 44 | - } else { |
|
| 45 | - if ($_GET['number_results'] > 1000){ |
|
| 46 | - $_GET['number_results'] = 1000; |
|
| 47 | - } |
|
| 48 | - $limit_start = 0; |
|
| 49 | - $limit_end = $_GET['number_results']; |
|
| 50 | - $absolute_difference = $_GET['number_results']; |
|
| 51 | - } |
|
| 39 | + if (!isset($_GET['number_results'])) |
|
| 40 | + { |
|
| 41 | + $limit_start = 0; |
|
| 42 | + $limit_end = 25; |
|
| 43 | + $absolute_difference = 25; |
|
| 44 | + } else { |
|
| 45 | + if ($_GET['number_results'] > 1000){ |
|
| 46 | + $_GET['number_results'] = 1000; |
|
| 47 | + } |
|
| 48 | + $limit_start = 0; |
|
| 49 | + $limit_end = $_GET['number_results']; |
|
| 50 | + $absolute_difference = $_GET['number_results']; |
|
| 51 | + } |
|
| 52 | 52 | } else { |
| 53 | - $limit_explode = explode(",", $_GET['limit']); |
|
| 54 | - $limit_start = $limit_explode[0]; |
|
| 55 | - $limit_end = $limit_explode[1]; |
|
| 53 | + $limit_explode = explode(",", $_GET['limit']); |
|
| 54 | + $limit_start = $limit_explode[0]; |
|
| 55 | + $limit_end = $limit_explode[1]; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $absolute_difference = abs($limit_start - $limit_end); |
@@ -90,69 +90,69 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $output = '{'; |
| 92 | 92 | $output .= '"type": "FeatureCollection",'; |
| 93 | - $output .= '"features": ['; |
|
| 93 | + $output .= '"features": ['; |
|
| 94 | 94 | |
| 95 | 95 | |
| 96 | - if (!empty($spotter_array)) |
|
| 96 | + if (!empty($spotter_array)) |
|
| 97 | 97 | { |
| 98 | - foreach($spotter_array as $spotter_item) |
|
| 99 | - { |
|
| 98 | + foreach($spotter_array as $spotter_item) |
|
| 99 | + { |
|
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | //waypoint plotting |
| 103 | 103 | $output .= '{'; |
| 104 | 104 | $output .= '"type": "Feature",'; |
| 105 | - $output .= '"properties": {'; |
|
| 106 | - $output .= '"id": "'.$spotter_item['spotter_id'].'",'; |
|
| 107 | - $output .= '"ident": "'.$spotter_item['ident'].'",'; |
|
| 108 | - $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 109 | - $output .= '"aircraft_icao": "'.$spotter_item['aircraft_type'].'",'; |
|
| 110 | - $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].'",'; |
|
| 111 | - $output .= '"aircraft_manufacturer": "'.$spotter_item['aircraft_manufacturer'].'",'; |
|
| 112 | - $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
|
| 113 | - $output .= '"airline_icao": "'.$spotter_item['airline_icao'].'",'; |
|
| 114 | - $output .= '"airline_iata": "'.$spotter_item['airline_iata'].'",'; |
|
| 115 | - $output .= '"airline_country": "'.$spotter_item['airline_country'].'",'; |
|
| 116 | - $output .= '"airline_callsign": "'.$spotter_item['airline_callsign'].'",'; |
|
| 117 | - $output .= '"airline_type": "'.$spotter_item['airline_type'].'",'; |
|
| 118 | - $output .= '"departure_airport_city": "'.$spotter_item['departure_airport_city'].'",'; |
|
| 119 | - $output .= '"departure_airport_country": "'.$spotter_item['departure_airport_country'].'",'; |
|
| 120 | - $output .= '"departure_airport_iata": "'.$spotter_item['departure_airport_iata'].'",'; |
|
| 121 | - $output .= '"departure_airport_icao": "'.$spotter_item['departure_airport_icao'].'",'; |
|
| 122 | - $output .= '"departure_airport_latitude": "'.$spotter_item['departure_airport_latitude'].'",'; |
|
| 123 | - $output .= '"departure_airport_longitude": "'.$spotter_item['departure_airport_longitude'].'",'; |
|
| 124 | - $output .= '"departure_airport_altitude": "'.$spotter_item['departure_airport_altitude'].'",'; |
|
| 125 | - $output .= '"arrival_airport_city": "'.$spotter_item['arrival_airport_city'].'",'; |
|
| 126 | - $output .= '"arrival_airport_country": "'.$spotter_item['arrival_airport_country'].'",'; |
|
| 127 | - $output .= '"arrival_airport_iata": "'.$spotter_item['arrival_airport_iata'].'",'; |
|
| 128 | - $output .= '"departure_airport_icao": "'.$spotter_item['arrival_airport_icao'].'",'; |
|
| 129 | - $output .= '"arrival_airport_latitude": "'.$spotter_item['arrival_airport_latitude'].'",'; |
|
| 130 | - $output .= '"arrival_airport_longitude": "'.$spotter_item['arrival_airport_longitude'].'",'; |
|
| 131 | - $output .= '"arrival_airport_altitude": "'.$spotter_item['arrival_airport_altitude'].'",'; |
|
| 132 | - $output .= '"latitude": "'.$spotter_item['latitude'].'",'; |
|
| 133 | - $output .= '"longitude": "'.$spotter_item['longitude'].'",'; |
|
| 134 | - $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 135 | - $output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",'; |
|
| 136 | - $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 137 | - $output .= '"heading_name": "'.$spotter_item['heading_name'].'",'; |
|
| 138 | - $output .= '"date": "'.date("c", strtotime($spotter_item['date_iso_8601'])).'"'; |
|
| 139 | - $output .= '}'; |
|
| 140 | - if ($spotter_item['waypoints'] != '') { |
|
| 141 | - $output .= ',"geometry": {'; |
|
| 142 | - $output .= '"type": "LineString",'; |
|
| 143 | - $output .= '"coordinates": ['; |
|
| 144 | - $waypoint_pieces = explode(' ', $spotter_item['waypoints']); |
|
| 105 | + $output .= '"properties": {'; |
|
| 106 | + $output .= '"id": "'.$spotter_item['spotter_id'].'",'; |
|
| 107 | + $output .= '"ident": "'.$spotter_item['ident'].'",'; |
|
| 108 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 109 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_type'].'",'; |
|
| 110 | + $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].'",'; |
|
| 111 | + $output .= '"aircraft_manufacturer": "'.$spotter_item['aircraft_manufacturer'].'",'; |
|
| 112 | + $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
|
| 113 | + $output .= '"airline_icao": "'.$spotter_item['airline_icao'].'",'; |
|
| 114 | + $output .= '"airline_iata": "'.$spotter_item['airline_iata'].'",'; |
|
| 115 | + $output .= '"airline_country": "'.$spotter_item['airline_country'].'",'; |
|
| 116 | + $output .= '"airline_callsign": "'.$spotter_item['airline_callsign'].'",'; |
|
| 117 | + $output .= '"airline_type": "'.$spotter_item['airline_type'].'",'; |
|
| 118 | + $output .= '"departure_airport_city": "'.$spotter_item['departure_airport_city'].'",'; |
|
| 119 | + $output .= '"departure_airport_country": "'.$spotter_item['departure_airport_country'].'",'; |
|
| 120 | + $output .= '"departure_airport_iata": "'.$spotter_item['departure_airport_iata'].'",'; |
|
| 121 | + $output .= '"departure_airport_icao": "'.$spotter_item['departure_airport_icao'].'",'; |
|
| 122 | + $output .= '"departure_airport_latitude": "'.$spotter_item['departure_airport_latitude'].'",'; |
|
| 123 | + $output .= '"departure_airport_longitude": "'.$spotter_item['departure_airport_longitude'].'",'; |
|
| 124 | + $output .= '"departure_airport_altitude": "'.$spotter_item['departure_airport_altitude'].'",'; |
|
| 125 | + $output .= '"arrival_airport_city": "'.$spotter_item['arrival_airport_city'].'",'; |
|
| 126 | + $output .= '"arrival_airport_country": "'.$spotter_item['arrival_airport_country'].'",'; |
|
| 127 | + $output .= '"arrival_airport_iata": "'.$spotter_item['arrival_airport_iata'].'",'; |
|
| 128 | + $output .= '"departure_airport_icao": "'.$spotter_item['arrival_airport_icao'].'",'; |
|
| 129 | + $output .= '"arrival_airport_latitude": "'.$spotter_item['arrival_airport_latitude'].'",'; |
|
| 130 | + $output .= '"arrival_airport_longitude": "'.$spotter_item['arrival_airport_longitude'].'",'; |
|
| 131 | + $output .= '"arrival_airport_altitude": "'.$spotter_item['arrival_airport_altitude'].'",'; |
|
| 132 | + $output .= '"latitude": "'.$spotter_item['latitude'].'",'; |
|
| 133 | + $output .= '"longitude": "'.$spotter_item['longitude'].'",'; |
|
| 134 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 135 | + $output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",'; |
|
| 136 | + $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 137 | + $output .= '"heading_name": "'.$spotter_item['heading_name'].'",'; |
|
| 138 | + $output .= '"date": "'.date("c", strtotime($spotter_item['date_iso_8601'])).'"'; |
|
| 139 | + $output .= '}'; |
|
| 140 | + if ($spotter_item['waypoints'] != '') { |
|
| 141 | + $output .= ',"geometry": {'; |
|
| 142 | + $output .= '"type": "LineString",'; |
|
| 143 | + $output .= '"coordinates": ['; |
|
| 144 | + $waypoint_pieces = explode(' ', $spotter_item['waypoints']); |
|
| 145 | 145 | $waypoint_pieces = array_chunk($waypoint_pieces, 2); |
| 146 | 146 | |
| 147 | 147 | foreach ($waypoint_pieces as $waypoint_coordinate) |
| 148 | 148 | { |
| 149 | 149 | $output .= '['; |
| 150 | - $output .= $waypoint_coordinate[1].', '; |
|
| 151 | - $output .= $waypoint_coordinate[0]; |
|
| 150 | + $output .= $waypoint_coordinate[1].', '; |
|
| 151 | + $output .= $waypoint_coordinate[0]; |
|
| 152 | 152 | $output .= '],'; |
| 153 | 153 | |
| 154 | 154 | } |
| 155 | - $output = substr($output, 0, -1); |
|
| 155 | + $output = substr($output, 0, -1); |
|
| 156 | 156 | $output .= ']'; |
| 157 | 157 | $output .= '}'; |
| 158 | 158 | } |
@@ -161,50 +161,50 @@ discard block |
||
| 161 | 161 | //location of aircraft |
| 162 | 162 | $output .= '{'; |
| 163 | 163 | $output .= '"type": "Feature",'; |
| 164 | - $output .= '"properties": {'; |
|
| 165 | - $output .= '"id": "'.$spotter_item['spotter_id'].'",'; |
|
| 166 | - $output .= '"ident": "'.$spotter_item['ident'].'",'; |
|
| 167 | - $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 168 | - $output .= '"aircraft_icao": "'.$spotter_item['aircraft_type'].'",'; |
|
| 169 | - $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].'",'; |
|
| 170 | - $output .= '"aircraft_manufacturer": "'.$spotter_item['aircraft_manufacturer'].'",'; |
|
| 171 | - $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
|
| 172 | - $output .= '"airline_icao": "'.$spotter_item['airline_icao'].'",'; |
|
| 173 | - $output .= '"airline_iata": "'.$spotter_item['airline_iata'].'",'; |
|
| 174 | - $output .= '"airline_country": "'.$spotter_item['airline_country'].'",'; |
|
| 175 | - $output .= '"airline_callsign": "'.$spotter_item['airline_callsign'].'",'; |
|
| 176 | - $output .= '"airline_type": "'.$spotter_item['airline_type'].'",'; |
|
| 177 | - $output .= '"departure_airport_city": "'.$spotter_item['departure_airport_city'].'",'; |
|
| 178 | - $output .= '"departure_airport_country": "'.$spotter_item['departure_airport_country'].'",'; |
|
| 179 | - $output .= '"departure_airport_iata": "'.$spotter_item['departure_airport_iata'].'",'; |
|
| 180 | - $output .= '"departure_airport_icao": "'.$spotter_item['departure_airport_icao'].'",'; |
|
| 181 | - $output .= '"departure_airport_latitude": "'.$spotter_item['departure_airport_latitude'].'",'; |
|
| 182 | - $output .= '"departure_airport_longitude": "'.$spotter_item['departure_airport_longitude'].'",'; |
|
| 183 | - $output .= '"departure_airport_altitude": "'.$spotter_item['departure_airport_altitude'].'",'; |
|
| 184 | - $output .= '"arrival_airport_city": "'.$spotter_item['arrival_airport_city'].'",'; |
|
| 185 | - $output .= '"arrival_airport_country": "'.$spotter_item['arrival_airport_country'].'",'; |
|
| 186 | - $output .= '"arrival_airport_iata": "'.$spotter_item['arrival_airport_iata'].'",'; |
|
| 187 | - $output .= '"departure_airport_icao": "'.$spotter_item['arrival_airport_icao'].'",'; |
|
| 188 | - $output .= '"arrival_airport_latitude": "'.$spotter_item['arrival_airport_latitude'].'",'; |
|
| 189 | - $output .= '"arrival_airport_longitude": "'.$spotter_item['arrival_airport_longitude'].'",'; |
|
| 190 | - $output .= '"arrival_airport_altitude": "'.$spotter_item['arrival_airport_altitude'].'",'; |
|
| 191 | - $output .= '"latitude": "'.$spotter_item['latitude'].'",'; |
|
| 192 | - $output .= '"longitude": "'.$spotter_item['longitude'].'",'; |
|
| 193 | - $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 194 | - $output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",'; |
|
| 195 | - $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 196 | - $output .= '"heading_name": "'.$spotter_item['heading_name'].'",'; |
|
| 197 | - $output .= '"date": "'.date("c", strtotime($spotter_item['date_iso_8601'])).'"'; |
|
| 198 | - $output .= '},'; |
|
| 199 | - $output .= '"geometry": {'; |
|
| 200 | - $output .= '"type": "Point",'; |
|
| 201 | - $output .= '"coordinates": ['; |
|
| 164 | + $output .= '"properties": {'; |
|
| 165 | + $output .= '"id": "'.$spotter_item['spotter_id'].'",'; |
|
| 166 | + $output .= '"ident": "'.$spotter_item['ident'].'",'; |
|
| 167 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 168 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_type'].'",'; |
|
| 169 | + $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].'",'; |
|
| 170 | + $output .= '"aircraft_manufacturer": "'.$spotter_item['aircraft_manufacturer'].'",'; |
|
| 171 | + $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
|
| 172 | + $output .= '"airline_icao": "'.$spotter_item['airline_icao'].'",'; |
|
| 173 | + $output .= '"airline_iata": "'.$spotter_item['airline_iata'].'",'; |
|
| 174 | + $output .= '"airline_country": "'.$spotter_item['airline_country'].'",'; |
|
| 175 | + $output .= '"airline_callsign": "'.$spotter_item['airline_callsign'].'",'; |
|
| 176 | + $output .= '"airline_type": "'.$spotter_item['airline_type'].'",'; |
|
| 177 | + $output .= '"departure_airport_city": "'.$spotter_item['departure_airport_city'].'",'; |
|
| 178 | + $output .= '"departure_airport_country": "'.$spotter_item['departure_airport_country'].'",'; |
|
| 179 | + $output .= '"departure_airport_iata": "'.$spotter_item['departure_airport_iata'].'",'; |
|
| 180 | + $output .= '"departure_airport_icao": "'.$spotter_item['departure_airport_icao'].'",'; |
|
| 181 | + $output .= '"departure_airport_latitude": "'.$spotter_item['departure_airport_latitude'].'",'; |
|
| 182 | + $output .= '"departure_airport_longitude": "'.$spotter_item['departure_airport_longitude'].'",'; |
|
| 183 | + $output .= '"departure_airport_altitude": "'.$spotter_item['departure_airport_altitude'].'",'; |
|
| 184 | + $output .= '"arrival_airport_city": "'.$spotter_item['arrival_airport_city'].'",'; |
|
| 185 | + $output .= '"arrival_airport_country": "'.$spotter_item['arrival_airport_country'].'",'; |
|
| 186 | + $output .= '"arrival_airport_iata": "'.$spotter_item['arrival_airport_iata'].'",'; |
|
| 187 | + $output .= '"departure_airport_icao": "'.$spotter_item['arrival_airport_icao'].'",'; |
|
| 188 | + $output .= '"arrival_airport_latitude": "'.$spotter_item['arrival_airport_latitude'].'",'; |
|
| 189 | + $output .= '"arrival_airport_longitude": "'.$spotter_item['arrival_airport_longitude'].'",'; |
|
| 190 | + $output .= '"arrival_airport_altitude": "'.$spotter_item['arrival_airport_altitude'].'",'; |
|
| 191 | + $output .= '"latitude": "'.$spotter_item['latitude'].'",'; |
|
| 192 | + $output .= '"longitude": "'.$spotter_item['longitude'].'",'; |
|
| 193 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 194 | + $output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",'; |
|
| 195 | + $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 196 | + $output .= '"heading_name": "'.$spotter_item['heading_name'].'",'; |
|
| 197 | + $output .= '"date": "'.date("c", strtotime($spotter_item['date_iso_8601'])).'"'; |
|
| 198 | + $output .= '},'; |
|
| 199 | + $output .= '"geometry": {'; |
|
| 200 | + $output .= '"type": "Point",'; |
|
| 201 | + $output .= '"coordinates": ['; |
|
| 202 | 202 | $output .= $spotter_item['longitude'].', '; |
| 203 | 203 | $output .= $spotter_item['latitude']; |
| 204 | 204 | $output .= ']'; |
| 205 | 205 | $output .= '}'; |
| 206 | 206 | $output .= '},'; |
| 207 | - } |
|
| 207 | + } |
|
| 208 | 208 | } |
| 209 | 209 | $output = substr($output, 0, -1); |
| 210 | 210 | |