@@ -28,27 +28,27 @@ discard block |
||
| 28 | 28 | * http://www.gnu.org/copyleft/gpl.html. |
| 29 | 29 | * |
| 30 | 30 | */ |
| 31 | - function loadData($type, $data) { |
|
| 32 | - if (!$data) return $data; |
|
| 33 | - $tmp = unpack($type, $data); |
|
| 34 | - return current($tmp); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - function swap($binValue) { |
|
| 38 | - $result = $binValue{strlen($binValue) - 1}; |
|
| 39 | - for($i = strlen($binValue) - 2; $i >= 0 ; $i--) { |
|
| 31 | + function loadData($type, $data) { |
|
| 32 | + if (!$data) return $data; |
|
| 33 | + $tmp = unpack($type, $data); |
|
| 34 | + return current($tmp); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + function swap($binValue) { |
|
| 38 | + $result = $binValue{strlen($binValue) - 1}; |
|
| 39 | + for($i = strlen($binValue) - 2; $i >= 0 ; $i--) { |
|
| 40 | 40 | $result .= $binValue{$i}; |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - return $result; |
|
| 44 | - } |
|
| 43 | + return $result; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - function packDouble($value, $mode = 'LE') { |
|
| 47 | - $value = (double)$value; |
|
| 48 | - $bin = pack("d", $value); |
|
| 46 | + function packDouble($value, $mode = 'LE') { |
|
| 47 | + $value = (double)$value; |
|
| 48 | + $bin = pack("d", $value); |
|
| 49 | 49 | |
| 50 | - //We test if the conversion of an integer (1) is done as LE or BE by default |
|
| 51 | - switch (pack ('L', 1)) { |
|
| 50 | + //We test if the conversion of an integer (1) is done as LE or BE by default |
|
| 51 | + switch (pack ('L', 1)) { |
|
| 52 | 52 | case pack ('V', 1): //Little Endian |
| 53 | 53 | $result = ($mode == 'LE') ? $bin : swap($bin); |
| 54 | 54 | break; |
@@ -57,70 +57,70 @@ discard block |
||
| 57 | 57 | break; |
| 58 | 58 | default: //Some other thing, we just return false |
| 59 | 59 | $result = FALSE; |
| 60 | - } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return $result; |
|
| 63 | - } |
|
| 62 | + return $result; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * ShapeFile class |
| 67 | 67 | * |
| 68 | 68 | * @package bfShapeFiles |
| 69 | 69 | */ |
| 70 | - class ShapeFile { |
|
| 71 | - var $FileName; |
|
| 70 | + class ShapeFile { |
|
| 71 | + var $FileName; |
|
| 72 | 72 | |
| 73 | - var $SHPFile; |
|
| 74 | - var $SHXFile; |
|
| 75 | - var $DBFFile; |
|
| 73 | + var $SHPFile; |
|
| 74 | + var $SHXFile; |
|
| 75 | + var $DBFFile; |
|
| 76 | 76 | |
| 77 | - var $DBFHeader; |
|
| 77 | + var $DBFHeader; |
|
| 78 | 78 | |
| 79 | - var $lastError = ""; |
|
| 79 | + var $lastError = ""; |
|
| 80 | 80 | |
| 81 | - var $boundingBox = array("xmin" => 0.0, "ymin" => 0.0, "xmax" => 0.0, "ymax" => 0.0); |
|
| 82 | - var $fileLength = 0; |
|
| 83 | - var $shapeType = 0; |
|
| 81 | + var $boundingBox = array("xmin" => 0.0, "ymin" => 0.0, "xmax" => 0.0, "ymax" => 0.0); |
|
| 82 | + var $fileLength = 0; |
|
| 83 | + var $shapeType = 0; |
|
| 84 | 84 | |
| 85 | - var $records; |
|
| 85 | + var $records; |
|
| 86 | 86 | |
| 87 | - public function __construct($shapeType, $boundingBox = array("xmin" => 0.0, "ymin" => 0.0, "xmax" => 0.0, "ymax" => 0.0), $FileName = NULL) { |
|
| 87 | + public function __construct($shapeType, $boundingBox = array("xmin" => 0.0, "ymin" => 0.0, "xmax" => 0.0, "ymax" => 0.0), $FileName = NULL) { |
|
| 88 | 88 | $this->shapeType = $shapeType; |
| 89 | 89 | $this->boundingBox = $boundingBox; |
| 90 | 90 | $this->FileName = $FileName; |
| 91 | 91 | $this->fileLength = 50; // The value for file length is the total length of the file in 16-bit words (including the fifty 16-bit words that make up the header). |
| 92 | - } |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - function loadFromFile($FileName) { |
|
| 94 | + function loadFromFile($FileName) { |
|
| 95 | 95 | $this->FileName = $FileName; |
| 96 | 96 | |
| 97 | 97 | if (($this->_openSHPFile()) && ($this->_openDBFFile())) { |
| 98 | - $this->_loadHeaders(); |
|
| 99 | - $this->_loadRecords(); |
|
| 100 | - $this->_closeSHPFile(); |
|
| 101 | - $this->_closeDBFFile(); |
|
| 98 | + $this->_loadHeaders(); |
|
| 99 | + $this->_loadRecords(); |
|
| 100 | + $this->_closeSHPFile(); |
|
| 101 | + $this->_closeDBFFile(); |
|
| 102 | 102 | } else { |
| 103 | - return false; |
|
| 103 | + return false; |
|
| 104 | + } |
|
| 104 | 105 | } |
| 105 | - } |
|
| 106 | 106 | |
| 107 | - function saveToFile($FileName = NULL) { |
|
| 107 | + function saveToFile($FileName = NULL) { |
|
| 108 | 108 | if ($FileName != NULL) $this->FileName = $FileName; |
| 109 | 109 | |
| 110 | 110 | if (($this->_openSHPFile(TRUE)) && ($this->_openSHXFile(TRUE)) && ($this->_openDBFFile(TRUE))) { |
| 111 | - $this->_saveHeaders(); |
|
| 112 | - $this->_saveRecords(); |
|
| 113 | - $this->_closeSHPFile(); |
|
| 114 | - $this->_closeSHXFile(); |
|
| 115 | - $this->_closeDBFFile(); |
|
| 111 | + $this->_saveHeaders(); |
|
| 112 | + $this->_saveRecords(); |
|
| 113 | + $this->_closeSHPFile(); |
|
| 114 | + $this->_closeSHXFile(); |
|
| 115 | + $this->_closeDBFFile(); |
|
| 116 | 116 | } else { |
| 117 | - return false; |
|
| 117 | + return false; |
|
| 118 | + } |
|
| 118 | 119 | } |
| 119 | - } |
|
| 120 | 120 | |
| 121 | - function addRecord($record) { |
|
| 121 | + function addRecord($record) { |
|
| 122 | 122 | if ((isset($this->DBFHeader)) && (is_array($this->DBFHeader))) { |
| 123 | - $record->updateDBFInfo($this->DBFHeader); |
|
| 123 | + $record->updateDBFInfo($this->DBFHeader); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $this->fileLength += ($record->getContentLength() + 4); |
@@ -134,53 +134,53 @@ discard block |
||
| 134 | 134 | if ($this->boundingBox["ymax"]==0.0 || ($this->boundingBox["ymax"]<$record->SHPData["ymax"])) $this->boundingBox["ymax"] = $record->SHPData["ymax"]; |
| 135 | 135 | |
| 136 | 136 | if (in_array($this->shapeType,array(11,13,15,18,21,23,25,28))) { |
| 137 | - if (!isset($this->boundingBox["mmin"]) || $this->boundingBox["mmin"]==0.0 || ($this->boundingBox["mmin"]>$record->SHPData["mmin"])) $this->boundingBox["mmin"] = $record->SHPData["mmin"]; |
|
| 138 | - if (!isset($this->boundingBox["mmax"]) || $this->boundingBox["mmax"]==0.0 || ($this->boundingBox["mmax"]<$record->SHPData["mmax"])) $this->boundingBox["mmax"] = $record->SHPData["mmax"]; |
|
| 137 | + if (!isset($this->boundingBox["mmin"]) || $this->boundingBox["mmin"]==0.0 || ($this->boundingBox["mmin"]>$record->SHPData["mmin"])) $this->boundingBox["mmin"] = $record->SHPData["mmin"]; |
|
| 138 | + if (!isset($this->boundingBox["mmax"]) || $this->boundingBox["mmax"]==0.0 || ($this->boundingBox["mmax"]<$record->SHPData["mmax"])) $this->boundingBox["mmax"] = $record->SHPData["mmax"]; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | if (in_array($this->shapeType,array(11,13,15,18))) { |
| 142 | - if (!isset($this->boundingBox["zmin"]) || $this->boundingBox["zmin"]==0.0 || ($this->boundingBox["zmin"]>$record->SHPData["zmin"])) $this->boundingBox["zmin"] = $record->SHPData["zmin"]; |
|
| 143 | - if (!isset($this->boundingBox["zmax"]) || $this->boundingBox["zmax"]==0.0 || ($this->boundingBox["zmax"]<$record->SHPData["zmax"])) $this->boundingBox["zmax"] = $record->SHPData["zmax"]; |
|
| 142 | + if (!isset($this->boundingBox["zmin"]) || $this->boundingBox["zmin"]==0.0 || ($this->boundingBox["zmin"]>$record->SHPData["zmin"])) $this->boundingBox["zmin"] = $record->SHPData["zmin"]; |
|
| 143 | + if (!isset($this->boundingBox["zmax"]) || $this->boundingBox["zmax"]==0.0 || ($this->boundingBox["zmax"]<$record->SHPData["zmax"])) $this->boundingBox["zmax"] = $record->SHPData["zmax"]; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | return (count($this->records) - 1); |
| 147 | - } |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - function deleteRecord($index) { |
|
| 149 | + function deleteRecord($index) { |
|
| 150 | 150 | if (isset($this->records[$index])) { |
| 151 | - $this->fileLength -= ($this->records[$index]->getContentLength() + 4); |
|
| 152 | - for ($i = $index; $i < (count($this->records) - 1); $i++) { |
|
| 153 | - $this->records[$i] = $this->records[$i + 1]; |
|
| 154 | - } |
|
| 155 | - unset($this->records[count($this->records) - 1]); |
|
| 156 | - $this->_deleteRecordFromDBF($index); |
|
| 151 | + $this->fileLength -= ($this->records[$index]->getContentLength() + 4); |
|
| 152 | + for ($i = $index; $i < (count($this->records) - 1); $i++) { |
|
| 153 | + $this->records[$i] = $this->records[$i + 1]; |
|
| 154 | + } |
|
| 155 | + unset($this->records[count($this->records) - 1]); |
|
| 156 | + $this->_deleteRecordFromDBF($index); |
|
| 157 | + } |
|
| 157 | 158 | } |
| 158 | - } |
|
| 159 | 159 | |
| 160 | - function getDBFHeader() { |
|
| 160 | + function getDBFHeader() { |
|
| 161 | 161 | return $this->DBFHeader; |
| 162 | - } |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - function setDBFHeader($header) { |
|
| 164 | + function setDBFHeader($header) { |
|
| 165 | 165 | $this->DBFHeader = $header; |
| 166 | 166 | |
| 167 | 167 | for ($i = 0; $i < count($this->records); $i++) { |
| 168 | - $this->records[$i]->updateDBFInfo($header); |
|
| 168 | + $this->records[$i]->updateDBFInfo($header); |
|
| 169 | + } |
|
| 169 | 170 | } |
| 170 | - } |
|
| 171 | 171 | |
| 172 | - function getIndexFromDBFData($field, $value) { |
|
| 172 | + function getIndexFromDBFData($field, $value) { |
|
| 173 | 173 | $result = -1; |
| 174 | 174 | for ($i = 0; $i < (count($this->records) - 1); $i++) { |
| 175 | - if (isset($this->records[$i]->DBFData[$field]) && (strtoupper($this->records[$i]->DBFData[$field]) == strtoupper($value))) { |
|
| 176 | - $result = $i; |
|
| 177 | - } |
|
| 175 | + if (isset($this->records[$i]->DBFData[$field]) && (strtoupper($this->records[$i]->DBFData[$field]) == strtoupper($value))) { |
|
| 176 | + $result = $i; |
|
| 177 | + } |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | return $result; |
| 181 | - } |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - function _loadDBFHeader() { |
|
| 183 | + function _loadDBFHeader() { |
|
| 184 | 184 | $DBFFile = fopen(str_replace('.*', '.dbf', $this->FileName), 'r'); |
| 185 | 185 | |
| 186 | 186 | $result = array(); |
@@ -189,40 +189,40 @@ discard block |
||
| 189 | 189 | $inHeader = true; |
| 190 | 190 | |
| 191 | 191 | while ($inHeader) { |
| 192 | - if (!feof($DBFFile)) { |
|
| 193 | - $buff32 = fread($DBFFile, 32); |
|
| 194 | - if ($i > 1) { |
|
| 192 | + if (!feof($DBFFile)) { |
|
| 193 | + $buff32 = fread($DBFFile, 32); |
|
| 194 | + if ($i > 1) { |
|
| 195 | 195 | if (substr($buff32, 0, 1) == chr(13)) { |
| 196 | - $inHeader = false; |
|
| 196 | + $inHeader = false; |
|
| 197 | 197 | } else { |
| 198 | - $pos = strpos(substr($buff32, 0, 10), chr(0)); |
|
| 199 | - $pos = ($pos == 0 ? 10 : $pos); |
|
| 198 | + $pos = strpos(substr($buff32, 0, 10), chr(0)); |
|
| 199 | + $pos = ($pos == 0 ? 10 : $pos); |
|
| 200 | 200 | |
| 201 | - $fieldName = substr($buff32, 0, $pos); |
|
| 202 | - $fieldType = substr($buff32, 11, 1); |
|
| 203 | - $fieldLen = ord(substr($buff32, 16, 1)); |
|
| 204 | - $fieldDec = ord(substr($buff32, 17, 1)); |
|
| 201 | + $fieldName = substr($buff32, 0, $pos); |
|
| 202 | + $fieldType = substr($buff32, 11, 1); |
|
| 203 | + $fieldLen = ord(substr($buff32, 16, 1)); |
|
| 204 | + $fieldDec = ord(substr($buff32, 17, 1)); |
|
| 205 | 205 | |
| 206 | - array_push($result, array($fieldName, $fieldType, $fieldLen, $fieldDec)); |
|
| 206 | + array_push($result, array($fieldName, $fieldType, $fieldLen, $fieldDec)); |
|
| 207 | + } |
|
| 207 | 208 | } |
| 208 | - } |
|
| 209 | - $i++; |
|
| 210 | - } else { |
|
| 211 | - $inHeader = false; |
|
| 212 | - } |
|
| 209 | + $i++; |
|
| 210 | + } else { |
|
| 211 | + $inHeader = false; |
|
| 212 | + } |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | fclose($DBFFile); |
| 216 | 216 | return($result); |
| 217 | - } |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - function _deleteRecordFromDBF($index) { |
|
| 219 | + function _deleteRecordFromDBF($index) { |
|
| 220 | 220 | if (@dbase_delete_record($this->DBFFile, $index)) { |
| 221 | - @dbase_pack($this->DBFFile); |
|
| 221 | + @dbase_pack($this->DBFFile); |
|
| 222 | + } |
|
| 222 | 223 | } |
| 223 | - } |
|
| 224 | 224 | |
| 225 | - function _loadHeaders() { |
|
| 225 | + function _loadHeaders() { |
|
| 226 | 226 | fseek($this->SHPFile, 24, SEEK_SET); |
| 227 | 227 | $this->fileLength = loadData("N", fread($this->SHPFile, 4)); |
| 228 | 228 | |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | $this->boundingBox["mmax"] = loadData("d", fread($this->SHPFile, 8)); |
| 241 | 241 | |
| 242 | 242 | $this->DBFHeader = $this->_loadDBFHeader(); |
| 243 | - } |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - function _saveHeaders() { |
|
| 245 | + function _saveHeaders() { |
|
| 246 | 246 | fwrite($this->SHPFile, pack("NNNNNN", 9994, 0, 0, 0, 0, 0)); |
| 247 | 247 | fwrite($this->SHPFile, pack("N", $this->fileLength)); |
| 248 | 248 | fwrite($this->SHPFile, pack("V", 1000)); |
@@ -268,263 +268,263 @@ discard block |
||
| 268 | 268 | fwrite($this->SHXFile, packDouble(isset($this->boundingBox['zmax'])?$this->boundingBox['zmax']:0)); |
| 269 | 269 | fwrite($this->SHXFile, packDouble(isset($this->boundingBox['mmin'])?$this->boundingBox['mmin']:0)); |
| 270 | 270 | fwrite($this->SHXFile, packDouble(isset($this->boundingBox['mmax'])?$this->boundingBox['mmax']:0)); |
| 271 | - } |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - function _loadRecords() { |
|
| 273 | + function _loadRecords() { |
|
| 274 | 274 | fseek($this->SHPFile, 100); |
| 275 | 275 | while (!feof($this->SHPFile)) { |
| 276 | - $bByte = ftell($this->SHPFile); |
|
| 277 | - $record = new ShapeRecord(-1); |
|
| 278 | - $record->loadFromFile($this->SHPFile, $this->DBFFile); |
|
| 279 | - $eByte = ftell($this->SHPFile); |
|
| 280 | - if (($eByte <= $bByte) || ($record->lastError != "")) { |
|
| 281 | - return false; |
|
| 282 | - } |
|
| 276 | + $bByte = ftell($this->SHPFile); |
|
| 277 | + $record = new ShapeRecord(-1); |
|
| 278 | + $record->loadFromFile($this->SHPFile, $this->DBFFile); |
|
| 279 | + $eByte = ftell($this->SHPFile); |
|
| 280 | + if (($eByte <= $bByte) || ($record->lastError != "")) { |
|
| 281 | + return false; |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | - $this->records[] = $record; |
|
| 284 | + $this->records[] = $record; |
|
| 285 | + } |
|
| 285 | 286 | } |
| 286 | - } |
|
| 287 | 287 | |
| 288 | - function _saveRecords() { |
|
| 288 | + function _saveRecords() { |
|
| 289 | 289 | if (file_exists(str_replace('.*', '.dbf', $this->FileName))) { |
| 290 | - @unlink(str_replace('.*', '.dbf', $this->FileName)); |
|
| 290 | + @unlink(str_replace('.*', '.dbf', $this->FileName)); |
|
| 291 | 291 | } |
| 292 | 292 | if (!($this->DBFFile = @dbase_create(str_replace('.*', '.dbf', $this->FileName), $this->DBFHeader))) { |
| 293 | - return $this->setError(sprintf("It wasn't possible to create the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName))); |
|
| 293 | + return $this->setError(sprintf("It wasn't possible to create the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName))); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | $offset = 50; |
| 297 | 297 | if (is_array($this->records) && (count($this->records) > 0)) { |
| 298 | - reset($this->records); |
|
| 299 | - while (list($index, $record) = each($this->records)) { |
|
| 300 | - //Save the record to the .shp file |
|
| 301 | - $record->saveToFile($this->SHPFile, $this->DBFFile, $index + 1); |
|
| 298 | + reset($this->records); |
|
| 299 | + while (list($index, $record) = each($this->records)) { |
|
| 300 | + //Save the record to the .shp file |
|
| 301 | + $record->saveToFile($this->SHPFile, $this->DBFFile, $index + 1); |
|
| 302 | 302 | |
| 303 | - //Save the record to the .shx file |
|
| 304 | - fwrite($this->SHXFile, pack("N", $offset)); |
|
| 305 | - fwrite($this->SHXFile, pack("N", $record->getContentLength())); |
|
| 306 | - $offset += (4 + $record->getContentLength()); |
|
| 307 | - } |
|
| 303 | + //Save the record to the .shx file |
|
| 304 | + fwrite($this->SHXFile, pack("N", $offset)); |
|
| 305 | + fwrite($this->SHXFile, pack("N", $record->getContentLength())); |
|
| 306 | + $offset += (4 + $record->getContentLength()); |
|
| 307 | + } |
|
| 308 | 308 | } |
| 309 | 309 | @dbase_pack($this->DBFFile); |
| 310 | - } |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - function _openSHPFile($toWrite = false) { |
|
| 312 | + function _openSHPFile($toWrite = false) { |
|
| 313 | 313 | $this->SHPFile = @fopen(str_replace('.*', '.shp', $this->FileName), ($toWrite ? "wb+" : "rb")); |
| 314 | 314 | if (!$this->SHPFile) { |
| 315 | - return $this->setError(sprintf("It wasn't possible to open the Shape file '%s'", str_replace('.*', '.shp', $this->FileName))); |
|
| 315 | + return $this->setError(sprintf("It wasn't possible to open the Shape file '%s'", str_replace('.*', '.shp', $this->FileName))); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | return TRUE; |
| 319 | - } |
|
| 319 | + } |
|
| 320 | 320 | |
| 321 | - function _closeSHPFile() { |
|
| 321 | + function _closeSHPFile() { |
|
| 322 | 322 | if ($this->SHPFile) { |
| 323 | - fclose($this->SHPFile); |
|
| 324 | - $this->SHPFile = NULL; |
|
| 323 | + fclose($this->SHPFile); |
|
| 324 | + $this->SHPFile = NULL; |
|
| 325 | + } |
|
| 325 | 326 | } |
| 326 | - } |
|
| 327 | 327 | |
| 328 | - function _openSHXFile($toWrite = false) { |
|
| 328 | + function _openSHXFile($toWrite = false) { |
|
| 329 | 329 | $this->SHXFile = @fopen(str_replace('.*', '.shx', $this->FileName), ($toWrite ? "wb+" : "rb")); |
| 330 | 330 | if (!$this->SHXFile) { |
| 331 | - return $this->setError(sprintf("It wasn't possible to open the Index file '%s'", str_replace('.*', '.shx', $this->FileName))); |
|
| 331 | + return $this->setError(sprintf("It wasn't possible to open the Index file '%s'", str_replace('.*', '.shx', $this->FileName))); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | return TRUE; |
| 335 | - } |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | - function _closeSHXFile() { |
|
| 337 | + function _closeSHXFile() { |
|
| 338 | 338 | if ($this->SHXFile) { |
| 339 | - fclose($this->SHXFile); |
|
| 340 | - $this->SHXFile = NULL; |
|
| 339 | + fclose($this->SHXFile); |
|
| 340 | + $this->SHXFile = NULL; |
|
| 341 | + } |
|
| 341 | 342 | } |
| 342 | - } |
|
| 343 | 343 | |
| 344 | - function _openDBFFile($toWrite = false) { |
|
| 344 | + function _openDBFFile($toWrite = false) { |
|
| 345 | 345 | $checkFunction = $toWrite ? "is_writable" : "is_readable"; |
| 346 | 346 | if (($toWrite) && (!file_exists(str_replace('.*', '.dbf', $this->FileName)))) { |
| 347 | - if (!@dbase_create(str_replace('.*', '.dbf', $this->FileName), $this->DBFHeader)) { |
|
| 348 | - return $this->setError(sprintf("It wasn't possible to create the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName))); |
|
| 349 | - } |
|
| 347 | + if (!@dbase_create(str_replace('.*', '.dbf', $this->FileName), $this->DBFHeader)) { |
|
| 348 | + return $this->setError(sprintf("It wasn't possible to create the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName))); |
|
| 349 | + } |
|
| 350 | 350 | } |
| 351 | 351 | if ($checkFunction(str_replace('.*', '.dbf', $this->FileName))) { |
| 352 | - $this->DBFFile = dbase_open(str_replace('.*', '.dbf', $this->FileName), ($toWrite ? 2 : 0)); |
|
| 353 | - if (!$this->DBFFile) { |
|
| 354 | - return $this->setError(sprintf("It wasn't possible to open the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName))); |
|
| 355 | - } |
|
| 352 | + $this->DBFFile = dbase_open(str_replace('.*', '.dbf', $this->FileName), ($toWrite ? 2 : 0)); |
|
| 353 | + if (!$this->DBFFile) { |
|
| 354 | + return $this->setError(sprintf("It wasn't possible to open the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName))); |
|
| 355 | + } |
|
| 356 | 356 | } else { |
| 357 | - return $this->setError(sprintf("It wasn't possible to find the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName))); |
|
| 357 | + return $this->setError(sprintf("It wasn't possible to find the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName))); |
|
| 358 | 358 | } |
| 359 | 359 | return TRUE; |
| 360 | - } |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | - function _closeDBFFile() { |
|
| 362 | + function _closeDBFFile() { |
|
| 363 | 363 | if ($this->DBFFile) { |
| 364 | - dbase_close($this->DBFFile); |
|
| 365 | - $this->DBFFile = NULL; |
|
| 364 | + dbase_close($this->DBFFile); |
|
| 365 | + $this->DBFFile = NULL; |
|
| 366 | + } |
|
| 366 | 367 | } |
| 367 | - } |
|
| 368 | 368 | |
| 369 | - function setError($error) { |
|
| 369 | + function setError($error) { |
|
| 370 | 370 | $this->lastError = $error; |
| 371 | 371 | return false; |
| 372 | - } |
|
| 373 | - } |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | - class ShapeRecord { |
|
| 376 | - var $SHPFile = NULL; |
|
| 377 | - var $DBFFile = NULL; |
|
| 375 | + class ShapeRecord { |
|
| 376 | + var $SHPFile = NULL; |
|
| 377 | + var $DBFFile = NULL; |
|
| 378 | 378 | |
| 379 | - var $recordNumber = NULL; |
|
| 380 | - var $shapeType = NULL; |
|
| 379 | + var $recordNumber = NULL; |
|
| 380 | + var $shapeType = NULL; |
|
| 381 | 381 | |
| 382 | - var $lastError = ""; |
|
| 382 | + var $lastError = ""; |
|
| 383 | 383 | |
| 384 | - var $SHPData = array(); |
|
| 385 | - var $DBFData = array(); |
|
| 384 | + var $SHPData = array(); |
|
| 385 | + var $DBFData = array(); |
|
| 386 | 386 | |
| 387 | - public function __construct($shapeType) { |
|
| 387 | + public function __construct($shapeType) { |
|
| 388 | 388 | $this->shapeType = $shapeType; |
| 389 | - } |
|
| 389 | + } |
|
| 390 | 390 | |
| 391 | - function loadFromFile(&$SHPFile, &$DBFFile) { |
|
| 391 | + function loadFromFile(&$SHPFile, &$DBFFile) { |
|
| 392 | 392 | $this->SHPFile = $SHPFile; |
| 393 | 393 | $this->DBFFile = $DBFFile; |
| 394 | 394 | $this->_loadHeaders(); |
| 395 | 395 | |
| 396 | 396 | switch ($this->shapeType) { |
| 397 | - case 0: |
|
| 397 | + case 0: |
|
| 398 | 398 | $this->_loadNullRecord(); |
| 399 | - break; |
|
| 400 | - case 1: |
|
| 399 | + break; |
|
| 400 | + case 1: |
|
| 401 | 401 | $this->_loadPointRecord(); |
| 402 | - break; |
|
| 403 | - case 21: |
|
| 402 | + break; |
|
| 403 | + case 21: |
|
| 404 | 404 | $this->_loadPointMRecord(); |
| 405 | - break; |
|
| 406 | - case 11: |
|
| 405 | + break; |
|
| 406 | + case 11: |
|
| 407 | 407 | $this->_loadPointZRecord(); |
| 408 | - break; |
|
| 409 | - case 3: |
|
| 408 | + break; |
|
| 409 | + case 3: |
|
| 410 | 410 | $this->_loadPolyLineRecord(); |
| 411 | - break; |
|
| 412 | - case 23: |
|
| 411 | + break; |
|
| 412 | + case 23: |
|
| 413 | 413 | $this->_loadPolyLineMRecord(); |
| 414 | - break; |
|
| 415 | - case 13: |
|
| 414 | + break; |
|
| 415 | + case 13: |
|
| 416 | 416 | $this->_loadPolyLineZRecord(); |
| 417 | - break; |
|
| 418 | - case 5: |
|
| 417 | + break; |
|
| 418 | + case 5: |
|
| 419 | 419 | $this->_loadPolygonRecord(); |
| 420 | - break; |
|
| 421 | - case 25: |
|
| 420 | + break; |
|
| 421 | + case 25: |
|
| 422 | 422 | $this->_loadPolygonMRecord(); |
| 423 | - break; |
|
| 424 | - case 15: |
|
| 423 | + break; |
|
| 424 | + case 15: |
|
| 425 | 425 | $this->_loadPolygonZRecord(); |
| 426 | - break; |
|
| 427 | - case 8: |
|
| 426 | + break; |
|
| 427 | + case 8: |
|
| 428 | 428 | $this->_loadMultiPointRecord(); |
| 429 | - break; |
|
| 430 | - case 28: |
|
| 429 | + break; |
|
| 430 | + case 28: |
|
| 431 | 431 | $this->_loadMultiPointMRecord(); |
| 432 | - break; |
|
| 433 | - case 18: |
|
| 432 | + break; |
|
| 433 | + case 18: |
|
| 434 | 434 | $this->_loadMultiPointZRecord(); |
| 435 | - break; |
|
| 436 | - default: |
|
| 435 | + break; |
|
| 436 | + default: |
|
| 437 | 437 | $this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType)); |
| 438 | - break; |
|
| 438 | + break; |
|
| 439 | 439 | } |
| 440 | 440 | $this->_loadDBFData(); |
| 441 | - } |
|
| 441 | + } |
|
| 442 | 442 | |
| 443 | - function saveToFile(&$SHPFile, &$DBFFile, $recordNumber) { |
|
| 443 | + function saveToFile(&$SHPFile, &$DBFFile, $recordNumber) { |
|
| 444 | 444 | $this->SHPFile = $SHPFile; |
| 445 | 445 | $this->DBFFile = $DBFFile; |
| 446 | 446 | $this->recordNumber = $recordNumber; |
| 447 | 447 | $this->_saveHeaders(); |
| 448 | 448 | |
| 449 | 449 | switch ($this->shapeType) { |
| 450 | - case 0: |
|
| 450 | + case 0: |
|
| 451 | 451 | $this->_saveNullRecord(); |
| 452 | - break; |
|
| 453 | - case 1: |
|
| 452 | + break; |
|
| 453 | + case 1: |
|
| 454 | 454 | $this->_savePointRecord(); |
| 455 | - break; |
|
| 456 | - case 21: |
|
| 455 | + break; |
|
| 456 | + case 21: |
|
| 457 | 457 | $this->_savePointMRecord(); |
| 458 | - break; |
|
| 459 | - case 11: |
|
| 458 | + break; |
|
| 459 | + case 11: |
|
| 460 | 460 | $this->_savePointZRecord(); |
| 461 | - break; |
|
| 462 | - case 3: |
|
| 461 | + break; |
|
| 462 | + case 3: |
|
| 463 | 463 | $this->_savePolyLineRecord(); |
| 464 | - break; |
|
| 465 | - case 23: |
|
| 464 | + break; |
|
| 465 | + case 23: |
|
| 466 | 466 | $this->_savePolyLineMRecord(); |
| 467 | - break; |
|
| 468 | - case 13: |
|
| 467 | + break; |
|
| 468 | + case 13: |
|
| 469 | 469 | $this->_savePolyLineZRecord(); |
| 470 | - break; |
|
| 471 | - case 5: |
|
| 470 | + break; |
|
| 471 | + case 5: |
|
| 472 | 472 | $this->_savePolygonRecord(); |
| 473 | - break; |
|
| 474 | - case 25: |
|
| 473 | + break; |
|
| 474 | + case 25: |
|
| 475 | 475 | $this->_savePolygonMRecord(); |
| 476 | - break; |
|
| 477 | - case 15: |
|
| 476 | + break; |
|
| 477 | + case 15: |
|
| 478 | 478 | $this->_savePolygonZRecord(); |
| 479 | - break; |
|
| 480 | - case 8: |
|
| 479 | + break; |
|
| 480 | + case 8: |
|
| 481 | 481 | $this->_saveMultiPointRecord(); |
| 482 | - break; |
|
| 483 | - case 28: |
|
| 482 | + break; |
|
| 483 | + case 28: |
|
| 484 | 484 | $this->_saveMultiPointMRecord(); |
| 485 | - break; |
|
| 486 | - case 18: |
|
| 485 | + break; |
|
| 486 | + case 18: |
|
| 487 | 487 | $this->_saveMultiPointZRecord(); |
| 488 | - break; |
|
| 489 | - default: |
|
| 488 | + break; |
|
| 489 | + default: |
|
| 490 | 490 | $this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType)); |
| 491 | - break; |
|
| 491 | + break; |
|
| 492 | 492 | } |
| 493 | 493 | $this->_saveDBFData(); |
| 494 | - } |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | - function updateDBFInfo($header) { |
|
| 496 | + function updateDBFInfo($header) { |
|
| 497 | 497 | $tmp = $this->DBFData; |
| 498 | 498 | unset($this->DBFData); |
| 499 | 499 | $this->DBFData = array(); |
| 500 | 500 | reset($header); |
| 501 | 501 | while (list($key, $value) = each($header)) { |
| 502 | - $this->DBFData[$value[0]] = (isset($tmp[$value[0]])) ? $tmp[$value[0]] : ""; |
|
| 502 | + $this->DBFData[$value[0]] = (isset($tmp[$value[0]])) ? $tmp[$value[0]] : ""; |
|
| 503 | + } |
|
| 503 | 504 | } |
| 504 | - } |
|
| 505 | 505 | |
| 506 | - function _loadHeaders() { |
|
| 506 | + function _loadHeaders() { |
|
| 507 | 507 | $this->recordNumber = loadData("N", fread($this->SHPFile, 4)); |
| 508 | 508 | $tmp = loadData("N", fread($this->SHPFile, 4)); //We read the length of the record |
| 509 | 509 | $this->shapeType = loadData("V", fread($this->SHPFile, 4)); |
| 510 | - } |
|
| 510 | + } |
|
| 511 | 511 | |
| 512 | - function _saveHeaders() { |
|
| 512 | + function _saveHeaders() { |
|
| 513 | 513 | fwrite($this->SHPFile, pack("N", $this->recordNumber)); |
| 514 | 514 | fwrite($this->SHPFile, pack("N", $this->getContentLength())); |
| 515 | 515 | fwrite($this->SHPFile, pack("V", $this->shapeType)); |
| 516 | - } |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | - function _loadPoint() { |
|
| 518 | + function _loadPoint() { |
|
| 519 | 519 | $data = array(); |
| 520 | 520 | |
| 521 | 521 | $data["x"] = loadData("d", fread($this->SHPFile, 8)); |
| 522 | 522 | $data["y"] = loadData("d", fread($this->SHPFile, 8)); |
| 523 | 523 | |
| 524 | 524 | return $data; |
| 525 | - } |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | - function _loadPointM() { |
|
| 527 | + function _loadPointM() { |
|
| 528 | 528 | $data = array(); |
| 529 | 529 | |
| 530 | 530 | $data["x"] = loadData("d", fread($this->SHPFile, 8)); |
@@ -532,9 +532,9 @@ discard block |
||
| 532 | 532 | $data["m"] = loadData("d", fread($this->SHPFile, 8)); |
| 533 | 533 | |
| 534 | 534 | return $data; |
| 535 | - } |
|
| 535 | + } |
|
| 536 | 536 | |
| 537 | - function _loadPointZ() { |
|
| 537 | + function _loadPointZ() { |
|
| 538 | 538 | $data = array(); |
| 539 | 539 | |
| 540 | 540 | $data["x"] = loadData("d", fread($this->SHPFile, 8)); |
@@ -543,67 +543,67 @@ discard block |
||
| 543 | 543 | $data["m"] = loadData("d", fread($this->SHPFile, 8)); |
| 544 | 544 | |
| 545 | 545 | return $data; |
| 546 | - } |
|
| 546 | + } |
|
| 547 | 547 | |
| 548 | - function _savePoint($data) { |
|
| 548 | + function _savePoint($data) { |
|
| 549 | 549 | fwrite($this->SHPFile, packDouble($data["x"])); |
| 550 | 550 | fwrite($this->SHPFile, packDouble($data["y"])); |
| 551 | - } |
|
| 551 | + } |
|
| 552 | 552 | |
| 553 | - function _savePointM($data) { |
|
| 553 | + function _savePointM($data) { |
|
| 554 | 554 | fwrite($this->SHPFile, packDouble($data["x"])); |
| 555 | 555 | fwrite($this->SHPFile, packDouble($data["y"])); |
| 556 | 556 | fwrite($this->SHPFile, packDouble($data["m"])); |
| 557 | - } |
|
| 557 | + } |
|
| 558 | 558 | |
| 559 | - function _savePointZ($data) { |
|
| 559 | + function _savePointZ($data) { |
|
| 560 | 560 | fwrite($this->SHPFile, packDouble($data["x"])); |
| 561 | 561 | fwrite($this->SHPFile, packDouble($data["y"])); |
| 562 | 562 | fwrite($this->SHPFile, packDouble($data["z"])); |
| 563 | 563 | fwrite($this->SHPFile, packDouble($data["m"])); |
| 564 | - } |
|
| 564 | + } |
|
| 565 | 565 | |
| 566 | - function _saveMeasure($data) { |
|
| 566 | + function _saveMeasure($data) { |
|
| 567 | 567 | fwrite($this->SHPFile, packDouble($data["m"])); |
| 568 | - } |
|
| 568 | + } |
|
| 569 | 569 | |
| 570 | - function _saveZCoordinate($data) { |
|
| 570 | + function _saveZCoordinate($data) { |
|
| 571 | 571 | fwrite($this->SHPFile, packDouble($data["z"])); |
| 572 | - } |
|
| 572 | + } |
|
| 573 | 573 | |
| 574 | - function _loadNullRecord() { |
|
| 574 | + function _loadNullRecord() { |
|
| 575 | 575 | $this->SHPData = array(); |
| 576 | - } |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | - function _saveNullRecord() { |
|
| 578 | + function _saveNullRecord() { |
|
| 579 | 579 | //Don't save anything |
| 580 | - } |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | - function _loadPointRecord() { |
|
| 582 | + function _loadPointRecord() { |
|
| 583 | 583 | $this->SHPData = $this->_loadPoint(); |
| 584 | - } |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | - function _loadPointMRecord() { |
|
| 586 | + function _loadPointMRecord() { |
|
| 587 | 587 | $this->SHPData = $this->_loadPointM(); |
| 588 | - } |
|
| 588 | + } |
|
| 589 | 589 | |
| 590 | - function _loadPointZRecord() { |
|
| 590 | + function _loadPointZRecord() { |
|
| 591 | 591 | $this->SHPData = $this->_loadPointZ(); |
| 592 | - } |
|
| 592 | + } |
|
| 593 | 593 | |
| 594 | - function _savePointRecord() { |
|
| 594 | + function _savePointRecord() { |
|
| 595 | 595 | $this->_savePoint($this->SHPData); |
| 596 | - } |
|
| 596 | + } |
|
| 597 | 597 | |
| 598 | - function _savePointMRecord() { |
|
| 598 | + function _savePointMRecord() { |
|
| 599 | 599 | $this->_savePointM($this->SHPData); |
| 600 | - } |
|
| 600 | + } |
|
| 601 | 601 | |
| 602 | - function _savePointZRecord() { |
|
| 602 | + function _savePointZRecord() { |
|
| 603 | 603 | $this->_savePointZ($this->SHPData); |
| 604 | - } |
|
| 604 | + } |
|
| 605 | 605 | |
| 606 | - function _loadMultiPointRecord() { |
|
| 606 | + function _loadMultiPointRecord() { |
|
| 607 | 607 | $this->SHPData = array(); |
| 608 | 608 | $this->SHPData["xmin"] = loadData("d", fread($this->SHPFile, 8)); |
| 609 | 609 | $this->SHPData["ymin"] = loadData("d", fread($this->SHPFile, 8)); |
@@ -613,66 +613,66 @@ discard block |
||
| 613 | 613 | $this->SHPData["numpoints"] = loadData("V", fread($this->SHPFile, 4)); |
| 614 | 614 | |
| 615 | 615 | for ($i = 0; $i <= $this->SHPData["numpoints"]; $i++) { |
| 616 | - $this->SHPData["points"][] = $this->_loadPoint(); |
|
| 616 | + $this->SHPData["points"][] = $this->_loadPoint(); |
|
| 617 | + } |
|
| 617 | 618 | } |
| 618 | - } |
|
| 619 | 619 | |
| 620 | - function _loadMultiPointMZRecord( $type ) { |
|
| 620 | + function _loadMultiPointMZRecord( $type ) { |
|
| 621 | 621 | |
| 622 | 622 | $this->SHPData[$type."min"] = loadData("d", fread($this->SHPFile, 8)); |
| 623 | 623 | $this->SHPData[$type."max"] = loadData("d", fread($this->SHPFile, 8)); |
| 624 | 624 | |
| 625 | 625 | for ($i = 0; $i <= $this->SHPData["numpoints"]; $i++) { |
| 626 | - $this->SHPData["points"][$i][$type] = loadData("d", fread($this->SHPFile, 8)); |
|
| 626 | + $this->SHPData["points"][$i][$type] = loadData("d", fread($this->SHPFile, 8)); |
|
| 627 | + } |
|
| 627 | 628 | } |
| 628 | - } |
|
| 629 | 629 | |
| 630 | - function _loadMultiPointMRecord() { |
|
| 630 | + function _loadMultiPointMRecord() { |
|
| 631 | 631 | $this->_loadMultiPointRecord(); |
| 632 | 632 | |
| 633 | 633 | $this->_loadMultiPointMZRecord("m"); |
| 634 | - } |
|
| 634 | + } |
|
| 635 | 635 | |
| 636 | - function _loadMultiPointZRecord() { |
|
| 636 | + function _loadMultiPointZRecord() { |
|
| 637 | 637 | $this->_loadMultiPointRecord(); |
| 638 | 638 | |
| 639 | 639 | $this->_loadMultiPointMZRecord("z"); |
| 640 | 640 | $this->_loadMultiPointMZRecord("m"); |
| 641 | - } |
|
| 641 | + } |
|
| 642 | 642 | |
| 643 | - function _saveMultiPointRecord() { |
|
| 643 | + function _saveMultiPointRecord() { |
|
| 644 | 644 | fwrite($this->SHPFile, pack("dddd", $this->SHPData["xmin"], $this->SHPData["ymin"], $this->SHPData["xmax"], $this->SHPData["ymax"])); |
| 645 | 645 | |
| 646 | 646 | fwrite($this->SHPFile, pack("V", $this->SHPData["numpoints"])); |
| 647 | 647 | |
| 648 | 648 | for ($i = 0; $i <= $this->SHPData["numpoints"]; $i++) { |
| 649 | - $this->_savePoint($this->SHPData["points"][$i]); |
|
| 649 | + $this->_savePoint($this->SHPData["points"][$i]); |
|
| 650 | + } |
|
| 650 | 651 | } |
| 651 | - } |
|
| 652 | 652 | |
| 653 | - function _saveMultiPointMZRecord( $type ) { |
|
| 653 | + function _saveMultiPointMZRecord( $type ) { |
|
| 654 | 654 | |
| 655 | 655 | fwrite($this->SHPFile, pack("dd", $this->SHPData[$type."min"], $this->SHPData[$type."max"])); |
| 656 | 656 | |
| 657 | 657 | for ($i = 0; $i <= $this->SHPData["numpoints"]; $i++) { |
| 658 | - fwrite($this->SHPFile, packDouble($this->SHPData["points"][$type])); |
|
| 658 | + fwrite($this->SHPFile, packDouble($this->SHPData["points"][$type])); |
|
| 659 | + } |
|
| 659 | 660 | } |
| 660 | - } |
|
| 661 | 661 | |
| 662 | - function _saveMultiPointMRecord() { |
|
| 662 | + function _saveMultiPointMRecord() { |
|
| 663 | 663 | $this->_saveMultiPointRecord(); |
| 664 | 664 | |
| 665 | 665 | $this->_saveMultiPointMZRecord("m"); |
| 666 | - } |
|
| 666 | + } |
|
| 667 | 667 | |
| 668 | - function _saveMultiPointZRecord() { |
|
| 668 | + function _saveMultiPointZRecord() { |
|
| 669 | 669 | $this->_saveMultiPointRecord(); |
| 670 | 670 | |
| 671 | 671 | $this->_saveMultiPointMZRecord("z"); |
| 672 | 672 | $this->_saveMultiPointMZRecord("m"); |
| 673 | - } |
|
| 673 | + } |
|
| 674 | 674 | |
| 675 | - function _loadPolyLineRecord() { |
|
| 675 | + function _loadPolyLineRecord() { |
|
| 676 | 676 | $this->SHPData = array(); |
| 677 | 677 | $this->SHPData["xmin"] = loadData("d", fread($this->SHPFile, 8)); |
| 678 | 678 | $this->SHPData["ymin"] = loadData("d", fread($this->SHPFile, 8)); |
@@ -683,27 +683,27 @@ discard block |
||
| 683 | 683 | $this->SHPData["numpoints"] = loadData("V", fread($this->SHPFile, 4)); |
| 684 | 684 | |
| 685 | 685 | for ($i = 0; $i < $this->SHPData["numparts"]; $i++) { |
| 686 | - $this->SHPData["parts"][$i] = loadData("V", fread($this->SHPFile, 4)); |
|
| 686 | + $this->SHPData["parts"][$i] = loadData("V", fread($this->SHPFile, 4)); |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | $firstIndex = ftell($this->SHPFile); |
| 690 | 690 | $readPoints = 0; |
| 691 | 691 | reset($this->SHPData["parts"]); |
| 692 | 692 | while (list($partIndex, $partData) = each($this->SHPData["parts"])) { |
| 693 | - if (!isset($this->SHPData["parts"][$partIndex]["points"]) || !is_array($this->SHPData["parts"][$partIndex]["points"])) { |
|
| 694 | - $this->SHPData["parts"][$partIndex] = array(); |
|
| 695 | - $this->SHPData["parts"][$partIndex]["points"] = array(); |
|
| 696 | - } |
|
| 697 | - while (!in_array($readPoints, $this->SHPData["parts"]) && ($readPoints < ($this->SHPData["numpoints"])) && !feof($this->SHPFile)) { |
|
| 698 | - $this->SHPData["parts"][$partIndex]["points"][] = $this->_loadPoint(); |
|
| 699 | - $readPoints++; |
|
| 700 | - } |
|
| 693 | + if (!isset($this->SHPData["parts"][$partIndex]["points"]) || !is_array($this->SHPData["parts"][$partIndex]["points"])) { |
|
| 694 | + $this->SHPData["parts"][$partIndex] = array(); |
|
| 695 | + $this->SHPData["parts"][$partIndex]["points"] = array(); |
|
| 696 | + } |
|
| 697 | + while (!in_array($readPoints, $this->SHPData["parts"]) && ($readPoints < ($this->SHPData["numpoints"])) && !feof($this->SHPFile)) { |
|
| 698 | + $this->SHPData["parts"][$partIndex]["points"][] = $this->_loadPoint(); |
|
| 699 | + $readPoints++; |
|
| 700 | + } |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | fseek($this->SHPFile, $firstIndex + ($readPoints*16)); |
| 704 | - } |
|
| 704 | + } |
|
| 705 | 705 | |
| 706 | - function _loadPolyLineMZRecord( $type ) { |
|
| 706 | + function _loadPolyLineMZRecord( $type ) { |
|
| 707 | 707 | |
| 708 | 708 | $this->SHPData[$type."min"] = loadData("d", fread($this->SHPFile, 8)); |
| 709 | 709 | $this->SHPData[$type."max"] = loadData("d", fread($this->SHPFile, 8)); |
@@ -712,170 +712,170 @@ discard block |
||
| 712 | 712 | $readPoints = 0; |
| 713 | 713 | reset($this->SHPData["parts"]); |
| 714 | 714 | while (list($partIndex, $partData) = each($this->SHPData["parts"])) { |
| 715 | - while (!in_array($readPoints, $this->SHPData["parts"]) && ($readPoints < ($this->SHPData["numpoints"])) && !feof($this->SHPFile)) { |
|
| 716 | - $this->SHPData["parts"][$partIndex]["points"][$readPoints][$type] = loadData("d", fread($this->SHPFile, 8)); |
|
| 717 | - $readPoints++; |
|
| 718 | - } |
|
| 715 | + while (!in_array($readPoints, $this->SHPData["parts"]) && ($readPoints < ($this->SHPData["numpoints"])) && !feof($this->SHPFile)) { |
|
| 716 | + $this->SHPData["parts"][$partIndex]["points"][$readPoints][$type] = loadData("d", fread($this->SHPFile, 8)); |
|
| 717 | + $readPoints++; |
|
| 718 | + } |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | fseek($this->SHPFile, $firstIndex + ($readPoints*24)); |
| 722 | - } |
|
| 722 | + } |
|
| 723 | 723 | |
| 724 | - function _loadPolyLineMRecord() { |
|
| 724 | + function _loadPolyLineMRecord() { |
|
| 725 | 725 | $this->_loadPolyLineRecord(); |
| 726 | 726 | |
| 727 | 727 | $this->_loadPolyLineMZRecord("m"); |
| 728 | - } |
|
| 728 | + } |
|
| 729 | 729 | |
| 730 | - function _loadPolyLineZRecord() { |
|
| 730 | + function _loadPolyLineZRecord() { |
|
| 731 | 731 | $this->_loadPolyLineRecord(); |
| 732 | 732 | |
| 733 | 733 | $this->_loadPolyLineMZRecord("z"); |
| 734 | 734 | $this->_loadPolyLineMZRecord("m"); |
| 735 | - } |
|
| 735 | + } |
|
| 736 | 736 | |
| 737 | - function _savePolyLineRecord() { |
|
| 737 | + function _savePolyLineRecord() { |
|
| 738 | 738 | fwrite($this->SHPFile, pack("dddd", $this->SHPData["xmin"], $this->SHPData["ymin"], $this->SHPData["xmax"], $this->SHPData["ymax"])); |
| 739 | 739 | |
| 740 | 740 | fwrite($this->SHPFile, pack("VV", $this->SHPData["numparts"], $this->SHPData["numpoints"])); |
| 741 | 741 | |
| 742 | 742 | for ($i = 0; $i < $this->SHPData["numparts"]; $i++) { |
| 743 | - fwrite($this->SHPFile, pack("V", count($this->SHPData["parts"][$i])-1)); |
|
| 743 | + fwrite($this->SHPFile, pack("V", count($this->SHPData["parts"][$i])-1)); |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | foreach ($this->SHPData["parts"] as $partData){ |
| 747 | - reset($partData["points"]); |
|
| 748 | - while (list($pointIndex, $pointData) = each($partData["points"])) { |
|
| 749 | - $this->_savePoint($pointData); |
|
| 750 | - } |
|
| 747 | + reset($partData["points"]); |
|
| 748 | + while (list($pointIndex, $pointData) = each($partData["points"])) { |
|
| 749 | + $this->_savePoint($pointData); |
|
| 750 | + } |
|
| 751 | + } |
|
| 751 | 752 | } |
| 752 | - } |
|
| 753 | 753 | |
| 754 | - function _savePolyLineMZRecord( $type ) { |
|
| 754 | + function _savePolyLineMZRecord( $type ) { |
|
| 755 | 755 | fwrite($this->SHPFile, pack("dd", $this->SHPData[$type."min"], $this->SHPData[$type."max"])); |
| 756 | 756 | |
| 757 | 757 | foreach ($this->SHPData["parts"] as $partData){ |
| 758 | - reset($partData["points"]); |
|
| 759 | - while (list($pointIndex, $pointData) = each($partData["points"])) { |
|
| 760 | - fwrite($this->SHPFile, packDouble($pointData[$type])); |
|
| 761 | - } |
|
| 758 | + reset($partData["points"]); |
|
| 759 | + while (list($pointIndex, $pointData) = each($partData["points"])) { |
|
| 760 | + fwrite($this->SHPFile, packDouble($pointData[$type])); |
|
| 761 | + } |
|
| 762 | + } |
|
| 762 | 763 | } |
| 763 | - } |
|
| 764 | 764 | |
| 765 | - function _savePolyLineMRecord() { |
|
| 765 | + function _savePolyLineMRecord() { |
|
| 766 | 766 | $this->_savePolyLineRecord(); |
| 767 | 767 | |
| 768 | 768 | $this->_savePolyLineMZRecord("m"); |
| 769 | - } |
|
| 769 | + } |
|
| 770 | 770 | |
| 771 | - function _savePolyLineZRecord() { |
|
| 771 | + function _savePolyLineZRecord() { |
|
| 772 | 772 | $this->_savePolyLineRecord(); |
| 773 | 773 | |
| 774 | 774 | $this->_savePolyLineMZRecord("z"); |
| 775 | 775 | $this->_savePolyLineMZRecord("m"); |
| 776 | - } |
|
| 776 | + } |
|
| 777 | 777 | |
| 778 | - function _loadPolygonRecord() { |
|
| 778 | + function _loadPolygonRecord() { |
|
| 779 | 779 | $this->_loadPolyLineRecord(); |
| 780 | - } |
|
| 780 | + } |
|
| 781 | 781 | |
| 782 | - function _loadPolygonMRecord() { |
|
| 782 | + function _loadPolygonMRecord() { |
|
| 783 | 783 | $this->_loadPolyLineMRecord(); |
| 784 | - } |
|
| 784 | + } |
|
| 785 | 785 | |
| 786 | - function _loadPolygonZRecord() { |
|
| 786 | + function _loadPolygonZRecord() { |
|
| 787 | 787 | $this->_loadPolyLineZRecord(); |
| 788 | - } |
|
| 788 | + } |
|
| 789 | 789 | |
| 790 | - function _savePolygonRecord() { |
|
| 790 | + function _savePolygonRecord() { |
|
| 791 | 791 | $this->_savePolyLineRecord(); |
| 792 | - } |
|
| 792 | + } |
|
| 793 | 793 | |
| 794 | - function _savePolygonMRecord() { |
|
| 794 | + function _savePolygonMRecord() { |
|
| 795 | 795 | $this->_savePolyLineMRecord(); |
| 796 | - } |
|
| 796 | + } |
|
| 797 | 797 | |
| 798 | - function _savePolygonZRecord() { |
|
| 798 | + function _savePolygonZRecord() { |
|
| 799 | 799 | $this->_savePolyLineZRecord(); |
| 800 | - } |
|
| 800 | + } |
|
| 801 | 801 | |
| 802 | - function addPoint($point, $partIndex = 0) { |
|
| 802 | + function addPoint($point, $partIndex = 0) { |
|
| 803 | 803 | switch ($this->shapeType) { |
| 804 | - case 0: |
|
| 804 | + case 0: |
|
| 805 | 805 | //Don't add anything |
| 806 | 806 | break; |
| 807 | - case 1: |
|
| 807 | + case 1: |
|
| 808 | 808 | case 11: |
| 809 | 809 | case 21: |
| 810 | 810 | if (in_array($this->shapeType,array(11,21)) && !isset($point["m"])) $point["m"] = 0.0; // no_value |
| 811 | - if (in_array($this->shapeType,array(11)) && !isset($point["z"])) $point["z"] = 0.0; // no_value |
|
| 812 | - //Substitutes the value of the current point |
|
| 813 | - $this->SHPData = $point; |
|
| 814 | - break; |
|
| 815 | - case 3: |
|
| 811 | + if (in_array($this->shapeType,array(11)) && !isset($point["z"])) $point["z"] = 0.0; // no_value |
|
| 812 | + //Substitutes the value of the current point |
|
| 813 | + $this->SHPData = $point; |
|
| 814 | + break; |
|
| 815 | + case 3: |
|
| 816 | 816 | case 5: |
| 817 | 817 | case 13: |
| 818 | 818 | case 15: |
| 819 | 819 | case 23: |
| 820 | 820 | case 25: |
| 821 | 821 | if (in_array($this->shapeType,array(13,15,23,25)) && !isset($point["m"])) $point["m"] = 0.0; // no_value |
| 822 | - if (in_array($this->shapeType,array(13,15)) && !isset($point["z"])) $point["z"] = 0.0; // no_value |
|
| 823 | - |
|
| 824 | - //Adds a new point to the selected part |
|
| 825 | - if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) $this->SHPData["xmin"] = $point["x"]; |
|
| 826 | - if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) $this->SHPData["ymin"] = $point["y"]; |
|
| 827 | - if (isset($point["m"]) && (!isset($this->SHPData["mmin"]) || ($this->SHPData["mmin"] > $point["m"]))) $this->SHPData["mmin"] = $point["m"]; |
|
| 828 | - if (isset($point["z"]) && (!isset($this->SHPData["zmin"]) || ($this->SHPData["zmin"] > $point["z"]))) $this->SHPData["zmin"] = $point["z"]; |
|
| 829 | - if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) $this->SHPData["xmax"] = $point["x"]; |
|
| 830 | - if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) $this->SHPData["ymax"] = $point["y"]; |
|
| 831 | - if (isset($point["m"]) && (!isset($this->SHPData["mmax"]) || ($this->SHPData["mmax"] < $point["m"]))) $this->SHPData["mmax"] = $point["m"]; |
|
| 832 | - if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) $this->SHPData["zmax"] = $point["z"]; |
|
| 833 | - |
|
| 834 | - $this->SHPData["parts"][$partIndex]["points"][] = $point; |
|
| 835 | - |
|
| 836 | - $this->SHPData["numparts"] = count($this->SHPData["parts"]); |
|
| 837 | - $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"])?$this->SHPData["numpoints"]:0); |
|
| 838 | - break; |
|
| 839 | - case 8: |
|
| 822 | + if (in_array($this->shapeType,array(13,15)) && !isset($point["z"])) $point["z"] = 0.0; // no_value |
|
| 823 | + |
|
| 824 | + //Adds a new point to the selected part |
|
| 825 | + if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) $this->SHPData["xmin"] = $point["x"]; |
|
| 826 | + if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) $this->SHPData["ymin"] = $point["y"]; |
|
| 827 | + if (isset($point["m"]) && (!isset($this->SHPData["mmin"]) || ($this->SHPData["mmin"] > $point["m"]))) $this->SHPData["mmin"] = $point["m"]; |
|
| 828 | + if (isset($point["z"]) && (!isset($this->SHPData["zmin"]) || ($this->SHPData["zmin"] > $point["z"]))) $this->SHPData["zmin"] = $point["z"]; |
|
| 829 | + if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) $this->SHPData["xmax"] = $point["x"]; |
|
| 830 | + if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) $this->SHPData["ymax"] = $point["y"]; |
|
| 831 | + if (isset($point["m"]) && (!isset($this->SHPData["mmax"]) || ($this->SHPData["mmax"] < $point["m"]))) $this->SHPData["mmax"] = $point["m"]; |
|
| 832 | + if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) $this->SHPData["zmax"] = $point["z"]; |
|
| 833 | + |
|
| 834 | + $this->SHPData["parts"][$partIndex]["points"][] = $point; |
|
| 835 | + |
|
| 836 | + $this->SHPData["numparts"] = count($this->SHPData["parts"]); |
|
| 837 | + $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"])?$this->SHPData["numpoints"]:0); |
|
| 838 | + break; |
|
| 839 | + case 8: |
|
| 840 | 840 | case 18: |
| 841 | 841 | case 28: |
| 842 | 842 | if (in_array($this->shapeType,array(18,28)) && !isset($point["m"])) $point["m"] = 0.0; // no_value |
| 843 | - if (in_array($this->shapeType,array(18)) && !isset($point["z"])) $point["z"] = 0.0; // no_value |
|
| 844 | - |
|
| 845 | - //Adds a new point |
|
| 846 | - if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) $this->SHPData["xmin"] = $point["x"]; |
|
| 847 | - if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) $this->SHPData["ymin"] = $point["y"]; |
|
| 848 | - if (isset($point["m"]) && (!isset($this->SHPData["mmin"]) || ($this->SHPData["mmin"] > $point["m"]))) $this->SHPData["mmin"] = $point["m"]; |
|
| 849 | - if (isset($point["z"]) && (!isset($this->SHPData["zmin"]) || ($this->SHPData["zmin"] > $point["z"]))) $this->SHPData["zmin"] = $point["z"]; |
|
| 850 | - if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) $this->SHPData["xmax"] = $point["x"]; |
|
| 851 | - if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) $this->SHPData["ymax"] = $point["y"]; |
|
| 852 | - if (isset($point["m"]) && (!isset($this->SHPData["mmax"]) || ($this->SHPData["mmax"] < $point["m"]))) $this->SHPData["mmax"] = $point["m"]; |
|
| 853 | - if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) $this->SHPData["zmax"] = $point["z"]; |
|
| 854 | - |
|
| 855 | - $this->SHPData["points"][] = $point; |
|
| 856 | - $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"])?$this->SHPData["numpoints"]:0); |
|
| 857 | - break; |
|
| 858 | - default: |
|
| 843 | + if (in_array($this->shapeType,array(18)) && !isset($point["z"])) $point["z"] = 0.0; // no_value |
|
| 844 | + |
|
| 845 | + //Adds a new point |
|
| 846 | + if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) $this->SHPData["xmin"] = $point["x"]; |
|
| 847 | + if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) $this->SHPData["ymin"] = $point["y"]; |
|
| 848 | + if (isset($point["m"]) && (!isset($this->SHPData["mmin"]) || ($this->SHPData["mmin"] > $point["m"]))) $this->SHPData["mmin"] = $point["m"]; |
|
| 849 | + if (isset($point["z"]) && (!isset($this->SHPData["zmin"]) || ($this->SHPData["zmin"] > $point["z"]))) $this->SHPData["zmin"] = $point["z"]; |
|
| 850 | + if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) $this->SHPData["xmax"] = $point["x"]; |
|
| 851 | + if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) $this->SHPData["ymax"] = $point["y"]; |
|
| 852 | + if (isset($point["m"]) && (!isset($this->SHPData["mmax"]) || ($this->SHPData["mmax"] < $point["m"]))) $this->SHPData["mmax"] = $point["m"]; |
|
| 853 | + if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) $this->SHPData["zmax"] = $point["z"]; |
|
| 854 | + |
|
| 855 | + $this->SHPData["points"][] = $point; |
|
| 856 | + $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"])?$this->SHPData["numpoints"]:0); |
|
| 857 | + break; |
|
| 858 | + default: |
|
| 859 | 859 | $this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType)); |
| 860 | - break; |
|
| 860 | + break; |
|
| 861 | + } |
|
| 861 | 862 | } |
| 862 | - } |
|
| 863 | 863 | |
| 864 | - function deletePoint($pointIndex = 0, $partIndex = 0) { |
|
| 864 | + function deletePoint($pointIndex = 0, $partIndex = 0) { |
|
| 865 | 865 | switch ($this->shapeType) { |
| 866 | - case 0: |
|
| 866 | + case 0: |
|
| 867 | 867 | //Don't delete anything |
| 868 | 868 | break; |
| 869 | - case 1: |
|
| 869 | + case 1: |
|
| 870 | 870 | case 11: |
| 871 | 871 | case 21: |
| 872 | 872 | //Sets the value of the point to zero |
| 873 | 873 | $this->SHPData["x"] = 0.0; |
| 874 | - $this->SHPData["y"] = 0.0; |
|
| 875 | - if (in_array($this->shapeType,array(11,21))) $this->SHPData["m"] = 0.0; |
|
| 876 | - if (in_array($this->shapeType,array(11))) $this->SHPData["z"] = 0.0; |
|
| 877 | - break; |
|
| 878 | - case 3: |
|
| 874 | + $this->SHPData["y"] = 0.0; |
|
| 875 | + if (in_array($this->shapeType,array(11,21))) $this->SHPData["m"] = 0.0; |
|
| 876 | + if (in_array($this->shapeType,array(11))) $this->SHPData["z"] = 0.0; |
|
| 877 | + break; |
|
| 878 | + case 3: |
|
| 879 | 879 | case 5: |
| 880 | 880 | case 13: |
| 881 | 881 | case 15: |
@@ -884,107 +884,107 @@ discard block |
||
| 884 | 884 | //Deletes the point from the selected part, if exists |
| 885 | 885 | if (isset($this->SHPData["parts"][$partIndex]) && isset($this->SHPData["parts"][$partIndex]["points"][$pointIndex])) { |
| 886 | 886 | for ($i = $pointIndex; $i < (count($this->SHPData["parts"][$partIndex]["points"]) - 1); $i++) { |
| 887 | - $this->SHPData["parts"][$partIndex]["points"][$i] = $this->SHPData["parts"][$partIndex]["points"][$i + 1]; |
|
| 887 | + $this->SHPData["parts"][$partIndex]["points"][$i] = $this->SHPData["parts"][$partIndex]["points"][$i + 1]; |
|
| 888 | 888 | } |
| 889 | 889 | unset($this->SHPData["parts"][$partIndex]["points"][count($this->SHPData["parts"][$partIndex]["points"]) - 1]); |
| 890 | 890 | |
| 891 | 891 | $this->SHPData["numparts"] = count($this->SHPData["parts"]); |
| 892 | 892 | $this->SHPData["numpoints"]--; |
| 893 | - } |
|
| 894 | - break; |
|
| 895 | - case 8: |
|
| 893 | + } |
|
| 894 | + break; |
|
| 895 | + case 8: |
|
| 896 | 896 | case 18: |
| 897 | 897 | case 28: |
| 898 | 898 | //Deletes the point, if exists |
| 899 | 899 | if (isset($this->SHPData["points"][$pointIndex])) { |
| 900 | 900 | for ($i = $pointIndex; $i < (count($this->SHPData["points"]) - 1); $i++) { |
| 901 | - $this->SHPData["points"][$i] = $this->SHPData["points"][$i + 1]; |
|
| 901 | + $this->SHPData["points"][$i] = $this->SHPData["points"][$i + 1]; |
|
| 902 | 902 | } |
| 903 | 903 | unset($this->SHPData["points"][count($this->SHPData["points"]) - 1]); |
| 904 | 904 | |
| 905 | 905 | $this->SHPData["numpoints"]--; |
| 906 | - } |
|
| 907 | - break; |
|
| 908 | - default: |
|
| 906 | + } |
|
| 907 | + break; |
|
| 908 | + default: |
|
| 909 | 909 | $this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType)); |
| 910 | - break; |
|
| 910 | + break; |
|
| 911 | + } |
|
| 911 | 912 | } |
| 912 | - } |
|
| 913 | 913 | |
| 914 | - function getContentLength() { |
|
| 914 | + function getContentLength() { |
|
| 915 | 915 | // The content length for a record is the length of the record contents section measured in 16-bit words. |
| 916 | 916 | // one coordinate makes 4 16-bit words (64 bit double) |
| 917 | 917 | switch ($this->shapeType) { |
| 918 | - case 0: |
|
| 918 | + case 0: |
|
| 919 | 919 | $result = 0; |
| 920 | - break; |
|
| 921 | - case 1: |
|
| 920 | + break; |
|
| 921 | + case 1: |
|
| 922 | 922 | $result = 10; |
| 923 | - break; |
|
| 924 | - case 21: |
|
| 923 | + break; |
|
| 924 | + case 21: |
|
| 925 | 925 | $result = 10 + 4; |
| 926 | - break; |
|
| 927 | - case 11: |
|
| 926 | + break; |
|
| 927 | + case 11: |
|
| 928 | 928 | $result = 10 + 8; |
| 929 | - break; |
|
| 930 | - case 3: |
|
| 929 | + break; |
|
| 930 | + case 3: |
|
| 931 | 931 | case 5: |
| 932 | 932 | $result = 22 + 2*count($this->SHPData["parts"]); |
| 933 | - for ($i = 0; $i < count($this->SHPData["parts"]); $i++) { |
|
| 933 | + for ($i = 0; $i < count($this->SHPData["parts"]); $i++) { |
|
| 934 | 934 | $result += 8*count($this->SHPData["parts"][$i]["points"]); |
| 935 | - } |
|
| 936 | - break; |
|
| 937 | - case 23: |
|
| 935 | + } |
|
| 936 | + break; |
|
| 937 | + case 23: |
|
| 938 | 938 | case 25: |
| 939 | 939 | $result = 22 + (2*4) + 2*count($this->SHPData["parts"]); |
| 940 | - for ($i = 0; $i < count($this->SHPData["parts"]); $i++) { |
|
| 940 | + for ($i = 0; $i < count($this->SHPData["parts"]); $i++) { |
|
| 941 | 941 | $result += (8+4)*count($this->SHPData["parts"][$i]["points"]); |
| 942 | - } |
|
| 943 | - break; |
|
| 944 | - case 13: |
|
| 942 | + } |
|
| 943 | + break; |
|
| 944 | + case 13: |
|
| 945 | 945 | case 15: |
| 946 | 946 | $result = 22 + (4*4) + 2*count($this->SHPData["parts"]); |
| 947 | - for ($i = 0; $i < count($this->SHPData["parts"]); $i++) { |
|
| 947 | + for ($i = 0; $i < count($this->SHPData["parts"]); $i++) { |
|
| 948 | 948 | $result += (8+8)*count($this->SHPData["parts"][$i]["points"]); |
| 949 | - } |
|
| 950 | - break; |
|
| 951 | - case 8: |
|
| 949 | + } |
|
| 950 | + break; |
|
| 951 | + case 8: |
|
| 952 | 952 | $result = 20 + 8*count($this->SHPData["points"]); |
| 953 | - break; |
|
| 954 | - case 28: |
|
| 953 | + break; |
|
| 954 | + case 28: |
|
| 955 | 955 | $result = 20 + (2*4) + (8+4)*count($this->SHPData["points"]); |
| 956 | - break; |
|
| 957 | - case 18: |
|
| 956 | + break; |
|
| 957 | + case 18: |
|
| 958 | 958 | $result = 20 + (4*4) + (8+8)*count($this->SHPData["points"]); |
| 959 | - break; |
|
| 960 | - default: |
|
| 959 | + break; |
|
| 960 | + default: |
|
| 961 | 961 | $result = false; |
| 962 | - $this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType)); |
|
| 963 | - break; |
|
| 962 | + $this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType)); |
|
| 963 | + break; |
|
| 964 | 964 | } |
| 965 | 965 | return $result; |
| 966 | - } |
|
| 966 | + } |
|
| 967 | 967 | |
| 968 | - function _loadDBFData() { |
|
| 968 | + function _loadDBFData() { |
|
| 969 | 969 | $this->DBFData = @dbase_get_record_with_names($this->DBFFile, $this->recordNumber); |
| 970 | 970 | unset($this->DBFData["deleted"]); |
| 971 | - } |
|
| 971 | + } |
|
| 972 | 972 | |
| 973 | - function _saveDBFData() { |
|
| 973 | + function _saveDBFData() { |
|
| 974 | 974 | unset($this->DBFData["deleted"]); |
| 975 | 975 | if ($this->recordNumber <= dbase_numrecords($this->DBFFile)) { |
| 976 | - if (!dbase_replace_record($this->DBFFile, array_values($this->DBFData), $this->recordNumber)) { |
|
| 977 | - $this->setError("I wasn't possible to update the information in the DBF file."); |
|
| 978 | - } |
|
| 976 | + if (!dbase_replace_record($this->DBFFile, array_values($this->DBFData), $this->recordNumber)) { |
|
| 977 | + $this->setError("I wasn't possible to update the information in the DBF file."); |
|
| 978 | + } |
|
| 979 | 979 | } else { |
| 980 | - if (!dbase_add_record($this->DBFFile, array_values($this->DBFData))) { |
|
| 981 | - $this->setError("I wasn't possible to add the information to the DBF file."); |
|
| 982 | - } |
|
| 980 | + if (!dbase_add_record($this->DBFFile, array_values($this->DBFData))) { |
|
| 981 | + $this->setError("I wasn't possible to add the information to the DBF file."); |
|
| 982 | + } |
|
| 983 | + } |
|
| 983 | 984 | } |
| 984 | - } |
|
| 985 | 985 | |
| 986 | - function setError($error) { |
|
| 986 | + function setError($error) { |
|
| 987 | 987 | $this->lastError = $error; |
| 988 | 988 | return false; |
| 989 | - } |
|
| 990 | - } |
|
| 989 | + } |
|
| 990 | + } |
|
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | function swap($binValue) { |
| 38 | 38 | $result = $binValue{strlen($binValue) - 1}; |
| 39 | - for($i = strlen($binValue) - 2; $i >= 0 ; $i--) { |
|
| 39 | + for ($i = strlen($binValue) - 2; $i >= 0; $i--) { |
|
| 40 | 40 | $result .= $binValue{$i}; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -44,15 +44,15 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | function packDouble($value, $mode = 'LE') { |
| 47 | - $value = (double)$value; |
|
| 47 | + $value = (double) $value; |
|
| 48 | 48 | $bin = pack("d", $value); |
| 49 | 49 | |
| 50 | 50 | //We test if the conversion of an integer (1) is done as LE or BE by default |
| 51 | - switch (pack ('L', 1)) { |
|
| 52 | - case pack ('V', 1): //Little Endian |
|
| 51 | + switch (pack('L', 1)) { |
|
| 52 | + case pack('V', 1): //Little Endian |
|
| 53 | 53 | $result = ($mode == 'LE') ? $bin : swap($bin); |
| 54 | 54 | break; |
| 55 | - case pack ('N', 1): //Big Endian |
|
| 55 | + case pack('N', 1): //Big Endian |
|
| 56 | 56 | $result = ($mode == 'BE') ? $bin : swap($bin); |
| 57 | 57 | break; |
| 58 | 58 | default: //Some other thing, we just return false |
@@ -127,20 +127,20 @@ discard block |
||
| 127 | 127 | $this->records[] = $record; |
| 128 | 128 | $this->records[count($this->records) - 1]->recordNumber = count($this->records); |
| 129 | 129 | |
| 130 | - if ($this->boundingBox["xmin"]==0.0 || ($this->boundingBox["xmin"]>$record->SHPData["xmin"])) $this->boundingBox["xmin"] = $record->SHPData["xmin"]; |
|
| 131 | - if ($this->boundingBox["xmax"]==0.0 || ($this->boundingBox["xmax"]<$record->SHPData["xmax"])) $this->boundingBox["xmax"] = $record->SHPData["xmax"]; |
|
| 130 | + if ($this->boundingBox["xmin"] == 0.0 || ($this->boundingBox["xmin"] > $record->SHPData["xmin"])) $this->boundingBox["xmin"] = $record->SHPData["xmin"]; |
|
| 131 | + if ($this->boundingBox["xmax"] == 0.0 || ($this->boundingBox["xmax"] < $record->SHPData["xmax"])) $this->boundingBox["xmax"] = $record->SHPData["xmax"]; |
|
| 132 | 132 | |
| 133 | - if ($this->boundingBox["ymin"]==0.0 || ($this->boundingBox["ymin"]>$record->SHPData["ymin"])) $this->boundingBox["ymin"] = $record->SHPData["ymin"]; |
|
| 134 | - if ($this->boundingBox["ymax"]==0.0 || ($this->boundingBox["ymax"]<$record->SHPData["ymax"])) $this->boundingBox["ymax"] = $record->SHPData["ymax"]; |
|
| 133 | + if ($this->boundingBox["ymin"] == 0.0 || ($this->boundingBox["ymin"] > $record->SHPData["ymin"])) $this->boundingBox["ymin"] = $record->SHPData["ymin"]; |
|
| 134 | + if ($this->boundingBox["ymax"] == 0.0 || ($this->boundingBox["ymax"] < $record->SHPData["ymax"])) $this->boundingBox["ymax"] = $record->SHPData["ymax"]; |
|
| 135 | 135 | |
| 136 | - if (in_array($this->shapeType,array(11,13,15,18,21,23,25,28))) { |
|
| 137 | - if (!isset($this->boundingBox["mmin"]) || $this->boundingBox["mmin"]==0.0 || ($this->boundingBox["mmin"]>$record->SHPData["mmin"])) $this->boundingBox["mmin"] = $record->SHPData["mmin"]; |
|
| 138 | - if (!isset($this->boundingBox["mmax"]) || $this->boundingBox["mmax"]==0.0 || ($this->boundingBox["mmax"]<$record->SHPData["mmax"])) $this->boundingBox["mmax"] = $record->SHPData["mmax"]; |
|
| 136 | + if (in_array($this->shapeType, array(11, 13, 15, 18, 21, 23, 25, 28))) { |
|
| 137 | + if (!isset($this->boundingBox["mmin"]) || $this->boundingBox["mmin"] == 0.0 || ($this->boundingBox["mmin"] > $record->SHPData["mmin"])) $this->boundingBox["mmin"] = $record->SHPData["mmin"]; |
|
| 138 | + if (!isset($this->boundingBox["mmax"]) || $this->boundingBox["mmax"] == 0.0 || ($this->boundingBox["mmax"] < $record->SHPData["mmax"])) $this->boundingBox["mmax"] = $record->SHPData["mmax"]; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if (in_array($this->shapeType,array(11,13,15,18))) { |
|
| 142 | - if (!isset($this->boundingBox["zmin"]) || $this->boundingBox["zmin"]==0.0 || ($this->boundingBox["zmin"]>$record->SHPData["zmin"])) $this->boundingBox["zmin"] = $record->SHPData["zmin"]; |
|
| 143 | - if (!isset($this->boundingBox["zmax"]) || $this->boundingBox["zmax"]==0.0 || ($this->boundingBox["zmax"]<$record->SHPData["zmax"])) $this->boundingBox["zmax"] = $record->SHPData["zmax"]; |
|
| 141 | + if (in_array($this->shapeType, array(11, 13, 15, 18))) { |
|
| 142 | + if (!isset($this->boundingBox["zmin"]) || $this->boundingBox["zmin"] == 0.0 || ($this->boundingBox["zmin"] > $record->SHPData["zmin"])) $this->boundingBox["zmin"] = $record->SHPData["zmin"]; |
|
| 143 | + if (!isset($this->boundingBox["zmax"]) || $this->boundingBox["zmax"] == 0.0 || ($this->boundingBox["zmax"] < $record->SHPData["zmax"])) $this->boundingBox["zmax"] = $record->SHPData["zmax"]; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | return (count($this->records) - 1); |
@@ -251,23 +251,23 @@ discard block |
||
| 251 | 251 | fwrite($this->SHPFile, packDouble($this->boundingBox['ymin'])); |
| 252 | 252 | fwrite($this->SHPFile, packDouble($this->boundingBox['xmax'])); |
| 253 | 253 | fwrite($this->SHPFile, packDouble($this->boundingBox['ymax'])); |
| 254 | - fwrite($this->SHPFile, packDouble(isset($this->boundingBox['zmin'])?$this->boundingBox['zmin']:0)); |
|
| 255 | - fwrite($this->SHPFile, packDouble(isset($this->boundingBox['zmax'])?$this->boundingBox['zmax']:0)); |
|
| 256 | - fwrite($this->SHPFile, packDouble(isset($this->boundingBox['mmin'])?$this->boundingBox['mmin']:0)); |
|
| 257 | - fwrite($this->SHPFile, packDouble(isset($this->boundingBox['mmax'])?$this->boundingBox['mmax']:0)); |
|
| 254 | + fwrite($this->SHPFile, packDouble(isset($this->boundingBox['zmin']) ? $this->boundingBox['zmin'] : 0)); |
|
| 255 | + fwrite($this->SHPFile, packDouble(isset($this->boundingBox['zmax']) ? $this->boundingBox['zmax'] : 0)); |
|
| 256 | + fwrite($this->SHPFile, packDouble(isset($this->boundingBox['mmin']) ? $this->boundingBox['mmin'] : 0)); |
|
| 257 | + fwrite($this->SHPFile, packDouble(isset($this->boundingBox['mmax']) ? $this->boundingBox['mmax'] : 0)); |
|
| 258 | 258 | |
| 259 | 259 | fwrite($this->SHXFile, pack("NNNNNN", 9994, 0, 0, 0, 0, 0)); |
| 260 | - fwrite($this->SHXFile, pack("N", 50 + 4*count($this->records))); |
|
| 260 | + fwrite($this->SHXFile, pack("N", 50 + 4 * count($this->records))); |
|
| 261 | 261 | fwrite($this->SHXFile, pack("V", 1000)); |
| 262 | 262 | fwrite($this->SHXFile, pack("V", $this->shapeType)); |
| 263 | 263 | fwrite($this->SHXFile, packDouble($this->boundingBox['xmin'])); |
| 264 | 264 | fwrite($this->SHXFile, packDouble($this->boundingBox['ymin'])); |
| 265 | 265 | fwrite($this->SHXFile, packDouble($this->boundingBox['xmax'])); |
| 266 | 266 | fwrite($this->SHXFile, packDouble($this->boundingBox['ymax'])); |
| 267 | - fwrite($this->SHXFile, packDouble(isset($this->boundingBox['zmin'])?$this->boundingBox['zmin']:0)); |
|
| 268 | - fwrite($this->SHXFile, packDouble(isset($this->boundingBox['zmax'])?$this->boundingBox['zmax']:0)); |
|
| 269 | - fwrite($this->SHXFile, packDouble(isset($this->boundingBox['mmin'])?$this->boundingBox['mmin']:0)); |
|
| 270 | - fwrite($this->SHXFile, packDouble(isset($this->boundingBox['mmax'])?$this->boundingBox['mmax']:0)); |
|
| 267 | + fwrite($this->SHXFile, packDouble(isset($this->boundingBox['zmin']) ? $this->boundingBox['zmin'] : 0)); |
|
| 268 | + fwrite($this->SHXFile, packDouble(isset($this->boundingBox['zmax']) ? $this->boundingBox['zmax'] : 0)); |
|
| 269 | + fwrite($this->SHXFile, packDouble(isset($this->boundingBox['mmin']) ? $this->boundingBox['mmin'] : 0)); |
|
| 270 | + fwrite($this->SHXFile, packDouble(isset($this->boundingBox['mmax']) ? $this->boundingBox['mmax'] : 0)); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | function _loadRecords() { |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | } |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | - function _loadMultiPointMZRecord( $type ) { |
|
| 620 | + function _loadMultiPointMZRecord($type) { |
|
| 621 | 621 | |
| 622 | 622 | $this->SHPData[$type."min"] = loadData("d", fread($this->SHPFile, 8)); |
| 623 | 623 | $this->SHPData[$type."max"] = loadData("d", fread($this->SHPFile, 8)); |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | } |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - function _saveMultiPointMZRecord( $type ) { |
|
| 653 | + function _saveMultiPointMZRecord($type) { |
|
| 654 | 654 | |
| 655 | 655 | fwrite($this->SHPFile, pack("dd", $this->SHPData[$type."min"], $this->SHPData[$type."max"])); |
| 656 | 656 | |
@@ -700,10 +700,10 @@ discard block |
||
| 700 | 700 | } |
| 701 | 701 | } |
| 702 | 702 | |
| 703 | - fseek($this->SHPFile, $firstIndex + ($readPoints*16)); |
|
| 703 | + fseek($this->SHPFile, $firstIndex + ($readPoints * 16)); |
|
| 704 | 704 | } |
| 705 | 705 | |
| 706 | - function _loadPolyLineMZRecord( $type ) { |
|
| 706 | + function _loadPolyLineMZRecord($type) { |
|
| 707 | 707 | |
| 708 | 708 | $this->SHPData[$type."min"] = loadData("d", fread($this->SHPFile, 8)); |
| 709 | 709 | $this->SHPData[$type."max"] = loadData("d", fread($this->SHPFile, 8)); |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | 720 | |
| 721 | - fseek($this->SHPFile, $firstIndex + ($readPoints*24)); |
|
| 721 | + fseek($this->SHPFile, $firstIndex + ($readPoints * 24)); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | function _loadPolyLineMRecord() { |
@@ -740,10 +740,10 @@ discard block |
||
| 740 | 740 | fwrite($this->SHPFile, pack("VV", $this->SHPData["numparts"], $this->SHPData["numpoints"])); |
| 741 | 741 | |
| 742 | 742 | for ($i = 0; $i < $this->SHPData["numparts"]; $i++) { |
| 743 | - fwrite($this->SHPFile, pack("V", count($this->SHPData["parts"][$i])-1)); |
|
| 743 | + fwrite($this->SHPFile, pack("V", count($this->SHPData["parts"][$i]) - 1)); |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - foreach ($this->SHPData["parts"] as $partData){ |
|
| 746 | + foreach ($this->SHPData["parts"] as $partData) { |
|
| 747 | 747 | reset($partData["points"]); |
| 748 | 748 | while (list($pointIndex, $pointData) = each($partData["points"])) { |
| 749 | 749 | $this->_savePoint($pointData); |
@@ -751,10 +751,10 @@ discard block |
||
| 751 | 751 | } |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | - function _savePolyLineMZRecord( $type ) { |
|
| 754 | + function _savePolyLineMZRecord($type) { |
|
| 755 | 755 | fwrite($this->SHPFile, pack("dd", $this->SHPData[$type."min"], $this->SHPData[$type."max"])); |
| 756 | 756 | |
| 757 | - foreach ($this->SHPData["parts"] as $partData){ |
|
| 757 | + foreach ($this->SHPData["parts"] as $partData) { |
|
| 758 | 758 | reset($partData["points"]); |
| 759 | 759 | while (list($pointIndex, $pointData) = each($partData["points"])) { |
| 760 | 760 | fwrite($this->SHPFile, packDouble($pointData[$type])); |
@@ -807,8 +807,8 @@ discard block |
||
| 807 | 807 | case 1: |
| 808 | 808 | case 11: |
| 809 | 809 | case 21: |
| 810 | - if (in_array($this->shapeType,array(11,21)) && !isset($point["m"])) $point["m"] = 0.0; // no_value |
|
| 811 | - if (in_array($this->shapeType,array(11)) && !isset($point["z"])) $point["z"] = 0.0; // no_value |
|
| 810 | + if (in_array($this->shapeType, array(11, 21)) && !isset($point["m"])) $point["m"] = 0.0; // no_value |
|
| 811 | + if (in_array($this->shapeType, array(11)) && !isset($point["z"])) $point["z"] = 0.0; // no_value |
|
| 812 | 812 | //Substitutes the value of the current point |
| 813 | 813 | $this->SHPData = $point; |
| 814 | 814 | break; |
@@ -818,8 +818,8 @@ discard block |
||
| 818 | 818 | case 15: |
| 819 | 819 | case 23: |
| 820 | 820 | case 25: |
| 821 | - if (in_array($this->shapeType,array(13,15,23,25)) && !isset($point["m"])) $point["m"] = 0.0; // no_value |
|
| 822 | - if (in_array($this->shapeType,array(13,15)) && !isset($point["z"])) $point["z"] = 0.0; // no_value |
|
| 821 | + if (in_array($this->shapeType, array(13, 15, 23, 25)) && !isset($point["m"])) $point["m"] = 0.0; // no_value |
|
| 822 | + if (in_array($this->shapeType, array(13, 15)) && !isset($point["z"])) $point["z"] = 0.0; // no_value |
|
| 823 | 823 | |
| 824 | 824 | //Adds a new point to the selected part |
| 825 | 825 | if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) $this->SHPData["xmin"] = $point["x"]; |
@@ -834,13 +834,13 @@ discard block |
||
| 834 | 834 | $this->SHPData["parts"][$partIndex]["points"][] = $point; |
| 835 | 835 | |
| 836 | 836 | $this->SHPData["numparts"] = count($this->SHPData["parts"]); |
| 837 | - $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"])?$this->SHPData["numpoints"]:0); |
|
| 837 | + $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"]) ? $this->SHPData["numpoints"] : 0); |
|
| 838 | 838 | break; |
| 839 | 839 | case 8: |
| 840 | 840 | case 18: |
| 841 | 841 | case 28: |
| 842 | - if (in_array($this->shapeType,array(18,28)) && !isset($point["m"])) $point["m"] = 0.0; // no_value |
|
| 843 | - if (in_array($this->shapeType,array(18)) && !isset($point["z"])) $point["z"] = 0.0; // no_value |
|
| 842 | + if (in_array($this->shapeType, array(18, 28)) && !isset($point["m"])) $point["m"] = 0.0; // no_value |
|
| 843 | + if (in_array($this->shapeType, array(18)) && !isset($point["z"])) $point["z"] = 0.0; // no_value |
|
| 844 | 844 | |
| 845 | 845 | //Adds a new point |
| 846 | 846 | if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) $this->SHPData["xmin"] = $point["x"]; |
@@ -853,7 +853,7 @@ discard block |
||
| 853 | 853 | if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) $this->SHPData["zmax"] = $point["z"]; |
| 854 | 854 | |
| 855 | 855 | $this->SHPData["points"][] = $point; |
| 856 | - $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"])?$this->SHPData["numpoints"]:0); |
|
| 856 | + $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"]) ? $this->SHPData["numpoints"] : 0); |
|
| 857 | 857 | break; |
| 858 | 858 | default: |
| 859 | 859 | $this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType)); |
@@ -872,8 +872,8 @@ discard block |
||
| 872 | 872 | //Sets the value of the point to zero |
| 873 | 873 | $this->SHPData["x"] = 0.0; |
| 874 | 874 | $this->SHPData["y"] = 0.0; |
| 875 | - if (in_array($this->shapeType,array(11,21))) $this->SHPData["m"] = 0.0; |
|
| 876 | - if (in_array($this->shapeType,array(11))) $this->SHPData["z"] = 0.0; |
|
| 875 | + if (in_array($this->shapeType, array(11, 21))) $this->SHPData["m"] = 0.0; |
|
| 876 | + if (in_array($this->shapeType, array(11))) $this->SHPData["z"] = 0.0; |
|
| 877 | 877 | break; |
| 878 | 878 | case 3: |
| 879 | 879 | case 5: |
@@ -929,33 +929,33 @@ discard block |
||
| 929 | 929 | break; |
| 930 | 930 | case 3: |
| 931 | 931 | case 5: |
| 932 | - $result = 22 + 2*count($this->SHPData["parts"]); |
|
| 932 | + $result = 22 + 2 * count($this->SHPData["parts"]); |
|
| 933 | 933 | for ($i = 0; $i < count($this->SHPData["parts"]); $i++) { |
| 934 | - $result += 8*count($this->SHPData["parts"][$i]["points"]); |
|
| 934 | + $result += 8 * count($this->SHPData["parts"][$i]["points"]); |
|
| 935 | 935 | } |
| 936 | 936 | break; |
| 937 | 937 | case 23: |
| 938 | 938 | case 25: |
| 939 | - $result = 22 + (2*4) + 2*count($this->SHPData["parts"]); |
|
| 939 | + $result = 22 + (2 * 4) + 2 * count($this->SHPData["parts"]); |
|
| 940 | 940 | for ($i = 0; $i < count($this->SHPData["parts"]); $i++) { |
| 941 | - $result += (8+4)*count($this->SHPData["parts"][$i]["points"]); |
|
| 941 | + $result += (8 + 4) * count($this->SHPData["parts"][$i]["points"]); |
|
| 942 | 942 | } |
| 943 | 943 | break; |
| 944 | 944 | case 13: |
| 945 | 945 | case 15: |
| 946 | - $result = 22 + (4*4) + 2*count($this->SHPData["parts"]); |
|
| 946 | + $result = 22 + (4 * 4) + 2 * count($this->SHPData["parts"]); |
|
| 947 | 947 | for ($i = 0; $i < count($this->SHPData["parts"]); $i++) { |
| 948 | - $result += (8+8)*count($this->SHPData["parts"][$i]["points"]); |
|
| 948 | + $result += (8 + 8) * count($this->SHPData["parts"][$i]["points"]); |
|
| 949 | 949 | } |
| 950 | 950 | break; |
| 951 | 951 | case 8: |
| 952 | - $result = 20 + 8*count($this->SHPData["points"]); |
|
| 952 | + $result = 20 + 8 * count($this->SHPData["points"]); |
|
| 953 | 953 | break; |
| 954 | 954 | case 28: |
| 955 | - $result = 20 + (2*4) + (8+4)*count($this->SHPData["points"]); |
|
| 955 | + $result = 20 + (2 * 4) + (8 + 4) * count($this->SHPData["points"]); |
|
| 956 | 956 | break; |
| 957 | 957 | case 18: |
| 958 | - $result = 20 + (4*4) + (8+8)*count($this->SHPData["points"]); |
|
| 958 | + $result = 20 + (4 * 4) + (8 + 8) * count($this->SHPData["points"]); |
|
| 959 | 959 | break; |
| 960 | 960 | default: |
| 961 | 961 | $result = false; |