@@ -27,6 +27,8 @@ discard block |
||
| 27 | 27 | * along with this program; if not, you can download one from |
| 28 | 28 | * http://www.gnu.org/copyleft/gpl.html. |
| 29 | 29 | * |
| 30 | + * @param string $type |
|
| 31 | + * @param string $data |
|
| 30 | 32 | */ |
| 31 | 33 | function loadData($type, $data) { |
| 32 | 34 | if (!$data) return $data; |
@@ -34,6 +36,9 @@ discard block |
||
| 34 | 36 | return current($tmp); |
| 35 | 37 | } |
| 36 | 38 | |
| 39 | + /** |
|
| 40 | + * @param string $binValue |
|
| 41 | + */ |
|
| 37 | 42 | function swap($binValue) { |
| 38 | 43 | $result = $binValue{strlen($binValue) - 1}; |
| 39 | 44 | for($i = strlen($binValue) - 2; $i >= 0 ; $i--) { |
@@ -43,6 +48,9 @@ discard block |
||
| 43 | 48 | return $result; |
| 44 | 49 | } |
| 45 | 50 | |
| 51 | + /** |
|
| 52 | + * @return string |
|
| 53 | + */ |
|
| 46 | 54 | function packDouble($value, $mode = 'LE') { |
| 47 | 55 | $value = (double)$value; |
| 48 | 56 | $bin = pack("d", $value); |
@@ -339,6 +347,9 @@ discard block |
||
| 339 | 347 | } |
| 340 | 348 | } |
| 341 | 349 | |
| 350 | + /** |
|
| 351 | + * @param string $error |
|
| 352 | + */ |
|
| 342 | 353 | function setError($error) { |
| 343 | 354 | $this->lastError = $error; |
| 344 | 355 | return false; |
@@ -357,6 +368,9 @@ discard block |
||
| 357 | 368 | var $SHPData = array(); |
| 358 | 369 | var $DBFData = array(); |
| 359 | 370 | |
| 371 | + /** |
|
| 372 | + * @param integer $shapeType |
|
| 373 | + */ |
|
| 360 | 374 | public function __construct($shapeType) { |
| 361 | 375 | $this->shapeType = $shapeType; |
| 362 | 376 | } |
@@ -672,6 +686,9 @@ discard block |
||
| 672 | 686 | } |
| 673 | 687 | } |
| 674 | 688 | |
| 689 | + /** |
|
| 690 | + * @param string $error |
|
| 691 | + */ |
|
| 675 | 692 | function setError($error) { |
| 676 | 693 | $this->lastError = $error; |
| 677 | 694 | return false; |
@@ -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 |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | fwrite($this->SHPFile, pack("dddd", 0, 0, 0, 0)); |
| 234 | 234 | |
| 235 | 235 | fwrite($this->SHXFile, pack("NNNNNN", 9994, 0, 0, 0, 0, 0)); |
| 236 | - fwrite($this->SHXFile, pack("N", 50 + 4*count($this->records))); |
|
| 236 | + fwrite($this->SHXFile, pack("N", 50 + 4 * count($this->records))); |
|
| 237 | 237 | fwrite($this->SHXFile, pack("V", 1000)); |
| 238 | 238 | fwrite($this->SHXFile, pack("V", $this->shapeType)); |
| 239 | 239 | fwrite($this->SHXFile, packDouble($this->boundingBox['xmin'])); |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | - fseek($this->SHPFile, $firstIndex + ($readPoints*16)); |
|
| 525 | + fseek($this->SHPFile, $firstIndex + ($readPoints * 16)); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | function _savePolyLineRecord() { |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | fwrite($this->SHPFile, pack("V", count($this->SHPData["parts"][$i]))); |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | - foreach ($this->SHPData["parts"] as $partData){ |
|
| 537 | + foreach ($this->SHPData["parts"] as $partData) { |
|
| 538 | 538 | reset($partData["points"]); |
| 539 | 539 | while (list($pointIndex, $pointData) = each($partData["points"])) { |
| 540 | 540 | $this->_savePoint($pointData); |
@@ -638,13 +638,13 @@ discard block |
||
| 638 | 638 | break; |
| 639 | 639 | case 3: |
| 640 | 640 | case 5: |
| 641 | - $result = 22 + 2*count($this->SHPData["parts"]); |
|
| 641 | + $result = 22 + 2 * count($this->SHPData["parts"]); |
|
| 642 | 642 | for ($i = 0; $i < count($this->SHPData["parts"]); $i++) { |
| 643 | - $result += 8*count($this->SHPData["parts"][$i]["points"]); |
|
| 643 | + $result += 8 * count($this->SHPData["parts"][$i]["points"]); |
|
| 644 | 644 | } |
| 645 | 645 | break; |
| 646 | 646 | case 8: |
| 647 | - $result = 20 + 8*count($this->SHPData["points"]); |
|
| 647 | + $result = 20 + 8 * count($this->SHPData["points"]); |
|
| 648 | 648 | break; |
| 649 | 649 | default: |
| 650 | 650 | $result = false; |
@@ -5,14 +5,14 @@ |
||
| 5 | 5 | $shp->loadFromFile('data/mexico.*'); |
| 6 | 6 | |
| 7 | 7 | $i = 1; |
| 8 | -foreach($shp->records as $record){ |
|
| 8 | +foreach ($shp->records as $record) { |
|
| 9 | 9 | echo "<pre>"; |
| 10 | 10 | echo "Record No. $i:\n\n\n"; |
| 11 | 11 | echo "SHP Data = "; |
| 12 | - print_r($record->SHPData); //All the data related to the poligon |
|
| 12 | + print_r($record->SHPData); //All the data related to the poligon |
|
| 13 | 13 | print_r("\n\n\n"); |
| 14 | 14 | echo "DBF Data = "; |
| 15 | - print_r($record->DBFData); //All the information related to each poligon |
|
| 15 | + print_r($record->DBFData); //All the information related to each poligon |
|
| 16 | 16 | print_r("\n\n\n"); |
| 17 | 17 | echo "</pre>"; |
| 18 | 18 | $i++; |
@@ -5,14 +5,14 @@ |
||
| 5 | 5 | $shp->loadFromFile('data/capitals.*'); |
| 6 | 6 | |
| 7 | 7 | $i = 1; |
| 8 | -foreach($shp->records as $record){ |
|
| 8 | +foreach ($shp->records as $record) { |
|
| 9 | 9 | echo "<pre>"; |
| 10 | 10 | echo "Record No. $i:\n\n\n"; |
| 11 | 11 | echo "SHP Data = "; |
| 12 | - print_r($record->SHPData); //All the data related to the point |
|
| 12 | + print_r($record->SHPData); //All the data related to the point |
|
| 13 | 13 | print_r("\n\n\n"); |
| 14 | 14 | echo "DBF Data = "; |
| 15 | - print_r($record->DBFData); //All the information related to each point |
|
| 15 | + print_r($record->DBFData); //All the information related to each point |
|
| 16 | 16 | print_r("\n\n\n"); |
| 17 | 17 | echo "</pre>"; |
| 18 | 18 | $i++; |