@@ -97,34 +97,34 @@ discard block |
||
| 97 | 97 | $this->records[] = $record; |
| 98 | 98 | $this->records[count($this->records) - 1]->recordNumber = count($this->records); |
| 99 | 99 | |
| 100 | - if ($this->boundingBox["xmin"]==0.0 || ($this->boundingBox["xmin"]>$record->SHPData["xmin"])) { |
|
| 100 | + if ($this->boundingBox["xmin"] == 0.0 || ($this->boundingBox["xmin"] > $record->SHPData["xmin"])) { |
|
| 101 | 101 | $this->boundingBox["xmin"] = $record->SHPData["xmin"]; |
| 102 | 102 | } |
| 103 | - if ($this->boundingBox["xmax"]==0.0 || ($this->boundingBox["xmax"]<$record->SHPData["xmax"])) { |
|
| 103 | + if ($this->boundingBox["xmax"] == 0.0 || ($this->boundingBox["xmax"] < $record->SHPData["xmax"])) { |
|
| 104 | 104 | $this->boundingBox["xmax"] = $record->SHPData["xmax"]; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if ($this->boundingBox["ymin"]==0.0 || ($this->boundingBox["ymin"]>$record->SHPData["ymin"])) { |
|
| 107 | + if ($this->boundingBox["ymin"] == 0.0 || ($this->boundingBox["ymin"] > $record->SHPData["ymin"])) { |
|
| 108 | 108 | $this->boundingBox["ymin"] = $record->SHPData["ymin"]; |
| 109 | 109 | } |
| 110 | - if ($this->boundingBox["ymax"]==0.0 || ($this->boundingBox["ymax"]<$record->SHPData["ymax"])) { |
|
| 110 | + if ($this->boundingBox["ymax"] == 0.0 || ($this->boundingBox["ymax"] < $record->SHPData["ymax"])) { |
|
| 111 | 111 | $this->boundingBox["ymax"] = $record->SHPData["ymax"]; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if (in_array($this->shapeType,array(11,13,15,18,21,23,25,28))) { |
|
| 115 | - if (!isset($this->boundingBox["mmin"]) || $this->boundingBox["mmin"]==0.0 || ($this->boundingBox["mmin"]>$record->SHPData["mmin"])) { |
|
| 114 | + if (in_array($this->shapeType, array(11, 13, 15, 18, 21, 23, 25, 28))) { |
|
| 115 | + if (!isset($this->boundingBox["mmin"]) || $this->boundingBox["mmin"] == 0.0 || ($this->boundingBox["mmin"] > $record->SHPData["mmin"])) { |
|
| 116 | 116 | $this->boundingBox["mmin"] = $record->SHPData["mmin"]; |
| 117 | 117 | } |
| 118 | - if (!isset($this->boundingBox["mmax"]) || $this->boundingBox["mmax"]==0.0 || ($this->boundingBox["mmax"]<$record->SHPData["mmax"])) { |
|
| 118 | + if (!isset($this->boundingBox["mmax"]) || $this->boundingBox["mmax"] == 0.0 || ($this->boundingBox["mmax"] < $record->SHPData["mmax"])) { |
|
| 119 | 119 | $this->boundingBox["mmax"] = $record->SHPData["mmax"]; |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if (in_array($this->shapeType,array(11,13,15,18))) { |
|
| 124 | - if (!isset($this->boundingBox["zmin"]) || $this->boundingBox["zmin"]==0.0 || ($this->boundingBox["zmin"]>$record->SHPData["zmin"])) { |
|
| 123 | + if (in_array($this->shapeType, array(11, 13, 15, 18))) { |
|
| 124 | + if (!isset($this->boundingBox["zmin"]) || $this->boundingBox["zmin"] == 0.0 || ($this->boundingBox["zmin"] > $record->SHPData["zmin"])) { |
|
| 125 | 125 | $this->boundingBox["zmin"] = $record->SHPData["zmin"]; |
| 126 | 126 | } |
| 127 | - if (!isset($this->boundingBox["zmax"]) || $this->boundingBox["zmax"]==0.0 || ($this->boundingBox["zmax"]<$record->SHPData["zmax"])) { |
|
| 127 | + if (!isset($this->boundingBox["zmax"]) || $this->boundingBox["zmax"] == 0.0 || ($this->boundingBox["zmax"] < $record->SHPData["zmax"])) { |
|
| 128 | 128 | $this->boundingBox["zmax"] = $record->SHPData["zmax"]; |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -237,23 +237,23 @@ discard block |
||
| 237 | 237 | fwrite($this->SHPFile, Util::packDouble($this->boundingBox['ymin'])); |
| 238 | 238 | fwrite($this->SHPFile, Util::packDouble($this->boundingBox['xmax'])); |
| 239 | 239 | fwrite($this->SHPFile, Util::packDouble($this->boundingBox['ymax'])); |
| 240 | - fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['zmin'])?$this->boundingBox['zmin']:0)); |
|
| 241 | - fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['zmax'])?$this->boundingBox['zmax']:0)); |
|
| 242 | - fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['mmin'])?$this->boundingBox['mmin']:0)); |
|
| 243 | - fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['mmax'])?$this->boundingBox['mmax']:0)); |
|
| 240 | + fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['zmin']) ? $this->boundingBox['zmin'] : 0)); |
|
| 241 | + fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['zmax']) ? $this->boundingBox['zmax'] : 0)); |
|
| 242 | + fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['mmin']) ? $this->boundingBox['mmin'] : 0)); |
|
| 243 | + fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['mmax']) ? $this->boundingBox['mmax'] : 0)); |
|
| 244 | 244 | |
| 245 | 245 | fwrite($this->SHXFile, pack("NNNNNN", 9994, 0, 0, 0, 0, 0)); |
| 246 | - fwrite($this->SHXFile, pack("N", 50 + 4*count($this->records))); |
|
| 246 | + fwrite($this->SHXFile, pack("N", 50 + 4 * count($this->records))); |
|
| 247 | 247 | fwrite($this->SHXFile, pack("V", 1000)); |
| 248 | 248 | fwrite($this->SHXFile, pack("V", $this->shapeType)); |
| 249 | 249 | fwrite($this->SHXFile, Util::packDouble($this->boundingBox['xmin'])); |
| 250 | 250 | fwrite($this->SHXFile, Util::packDouble($this->boundingBox['ymin'])); |
| 251 | 251 | fwrite($this->SHXFile, Util::packDouble($this->boundingBox['xmax'])); |
| 252 | 252 | fwrite($this->SHXFile, Util::packDouble($this->boundingBox['ymax'])); |
| 253 | - fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['zmin'])?$this->boundingBox['zmin']:0)); |
|
| 254 | - fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['zmax'])?$this->boundingBox['zmax']:0)); |
|
| 255 | - fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['mmin'])?$this->boundingBox['mmin']:0)); |
|
| 256 | - fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['mmax'])?$this->boundingBox['mmax']:0)); |
|
| 253 | + fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['zmin']) ? $this->boundingBox['zmin'] : 0)); |
|
| 254 | + fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['zmax']) ? $this->boundingBox['zmax'] : 0)); |
|
| 255 | + fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['mmin']) ? $this->boundingBox['mmin'] : 0)); |
|
| 256 | + fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['mmax']) ? $this->boundingBox['mmax'] : 0)); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | private function _loadRecords() { |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - private function _loadMultiPointMZRecord( $type ) { |
|
| 278 | + private function _loadMultiPointMZRecord($type) { |
|
| 279 | 279 | |
| 280 | 280 | $this->SHPData[$type."min"] = Util::loadData("d", fread($this->SHPFile, 8)); |
| 281 | 281 | $this->SHPData[$type."max"] = Util::loadData("d", fread($this->SHPFile, 8)); |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - private function _saveMultiPointMZRecord( $type ) { |
|
| 311 | + private function _saveMultiPointMZRecord($type) { |
|
| 312 | 312 | |
| 313 | 313 | fwrite($this->SHPFile, pack("dd", $this->SHPData[$type."min"], $this->SHPData[$type."max"])); |
| 314 | 314 | |
@@ -358,10 +358,10 @@ discard block |
||
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - fseek($this->SHPFile, $firstIndex + ($readPoints*16)); |
|
| 361 | + fseek($this->SHPFile, $firstIndex + ($readPoints * 16)); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - private function _loadPolyLineMZRecord( $type ) { |
|
| 364 | + private function _loadPolyLineMZRecord($type) { |
|
| 365 | 365 | |
| 366 | 366 | $this->SHPData[$type."min"] = Util::loadData("d", fread($this->SHPFile, 8)); |
| 367 | 367 | $this->SHPData[$type."max"] = Util::loadData("d", fread($this->SHPFile, 8)); |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - fseek($this->SHPFile, $firstIndex + ($readPoints*24)); |
|
| 379 | + fseek($this->SHPFile, $firstIndex + ($readPoints * 24)); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | private function _loadPolyLineMRecord() { |
@@ -398,10 +398,10 @@ discard block |
||
| 398 | 398 | fwrite($this->SHPFile, pack("VV", $this->SHPData["numparts"], $this->SHPData["numpoints"])); |
| 399 | 399 | |
| 400 | 400 | for ($i = 0; $i < $this->SHPData["numparts"]; $i++) { |
| 401 | - fwrite($this->SHPFile, pack("V", count($this->SHPData["parts"][$i])-1)); |
|
| 401 | + fwrite($this->SHPFile, pack("V", count($this->SHPData["parts"][$i]) - 1)); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - foreach ($this->SHPData["parts"] as $partData){ |
|
| 404 | + foreach ($this->SHPData["parts"] as $partData) { |
|
| 405 | 405 | reset($partData["points"]); |
| 406 | 406 | while (list($pointIndex, $pointData) = each($partData["points"])) { |
| 407 | 407 | $this->_savePoint($pointData); |
@@ -409,10 +409,10 @@ discard block |
||
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - private function _savePolyLineMZRecord( $type ) { |
|
| 412 | + private function _savePolyLineMZRecord($type) { |
|
| 413 | 413 | fwrite($this->SHPFile, pack("dd", $this->SHPData[$type."min"], $this->SHPData[$type."max"])); |
| 414 | 414 | |
| 415 | - foreach ($this->SHPData["parts"] as $partData){ |
|
| 415 | + foreach ($this->SHPData["parts"] as $partData) { |
|
| 416 | 416 | reset($partData["points"]); |
| 417 | 417 | while (list($pointIndex, $pointData) = each($partData["points"])) { |
| 418 | 418 | fwrite($this->SHPFile, Util::packDouble($pointData[$type])); |
@@ -465,10 +465,10 @@ discard block |
||
| 465 | 465 | case 1: |
| 466 | 466 | case 11: |
| 467 | 467 | case 21: |
| 468 | - if (in_array($this->shapeType,array(11,21)) && !isset($point["m"])) { |
|
| 468 | + if (in_array($this->shapeType, array(11, 21)) && !isset($point["m"])) { |
|
| 469 | 469 | $point["m"] = 0.0; // no_value |
| 470 | 470 | } |
| 471 | - if (in_array($this->shapeType,array(11)) && !isset($point["z"])) { |
|
| 471 | + if (in_array($this->shapeType, array(11)) && !isset($point["z"])) { |
|
| 472 | 472 | $point["z"] = 0.0; // no_value |
| 473 | 473 | } |
| 474 | 474 | //Substitutes the value of the current point |
@@ -480,10 +480,10 @@ discard block |
||
| 480 | 480 | case 15: |
| 481 | 481 | case 23: |
| 482 | 482 | case 25: |
| 483 | - if (in_array($this->shapeType,array(13,15,23,25)) && !isset($point["m"])) { |
|
| 483 | + if (in_array($this->shapeType, array(13, 15, 23, 25)) && !isset($point["m"])) { |
|
| 484 | 484 | $point["m"] = 0.0; // no_value |
| 485 | 485 | } |
| 486 | - if (in_array($this->shapeType,array(13,15)) && !isset($point["z"])) { |
|
| 486 | + if (in_array($this->shapeType, array(13, 15)) && !isset($point["z"])) { |
|
| 487 | 487 | $point["z"] = 0.0; // no_value |
| 488 | 488 | } |
| 489 | 489 | |
@@ -516,15 +516,15 @@ discard block |
||
| 516 | 516 | $this->SHPData["parts"][$partIndex]["points"][] = $point; |
| 517 | 517 | |
| 518 | 518 | $this->SHPData["numparts"] = count($this->SHPData["parts"]); |
| 519 | - $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"])?$this->SHPData["numpoints"]:0); |
|
| 519 | + $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"]) ? $this->SHPData["numpoints"] : 0); |
|
| 520 | 520 | break; |
| 521 | 521 | case 8: |
| 522 | 522 | case 18: |
| 523 | 523 | case 28: |
| 524 | - if (in_array($this->shapeType,array(18,28)) && !isset($point["m"])) { |
|
| 524 | + if (in_array($this->shapeType, array(18, 28)) && !isset($point["m"])) { |
|
| 525 | 525 | $point["m"] = 0.0; // no_value |
| 526 | 526 | } |
| 527 | - if (in_array($this->shapeType,array(18)) && !isset($point["z"])) { |
|
| 527 | + if (in_array($this->shapeType, array(18)) && !isset($point["z"])) { |
|
| 528 | 528 | $point["z"] = 0.0; // no_value |
| 529 | 529 | } |
| 530 | 530 | |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | $this->SHPData["points"][] = $point; |
| 558 | - $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"])?$this->SHPData["numpoints"]:0); |
|
| 558 | + $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"]) ? $this->SHPData["numpoints"] : 0); |
|
| 559 | 559 | break; |
| 560 | 560 | default: |
| 561 | 561 | $this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType)); |
@@ -574,10 +574,10 @@ discard block |
||
| 574 | 574 | //Sets the value of the point to zero |
| 575 | 575 | $this->SHPData["x"] = 0.0; |
| 576 | 576 | $this->SHPData["y"] = 0.0; |
| 577 | - if (in_array($this->shapeType,array(11,21))) { |
|
| 577 | + if (in_array($this->shapeType, array(11, 21))) { |
|
| 578 | 578 | $this->SHPData["m"] = 0.0; |
| 579 | 579 | } |
| 580 | - if (in_array($this->shapeType,array(11))) { |
|
| 580 | + if (in_array($this->shapeType, array(11))) { |
|
| 581 | 581 | $this->SHPData["z"] = 0.0; |
| 582 | 582 | } |
| 583 | 583 | break; |
@@ -635,33 +635,33 @@ discard block |
||
| 635 | 635 | break; |
| 636 | 636 | case 3: |
| 637 | 637 | case 5: |
| 638 | - $result = 22 + 2*count($this->SHPData["parts"]); |
|
| 638 | + $result = 22 + 2 * count($this->SHPData["parts"]); |
|
| 639 | 639 | for ($i = 0; $i < count($this->SHPData["parts"]); $i++) { |
| 640 | - $result += 8*count($this->SHPData["parts"][$i]["points"]); |
|
| 640 | + $result += 8 * count($this->SHPData["parts"][$i]["points"]); |
|
| 641 | 641 | } |
| 642 | 642 | break; |
| 643 | 643 | case 23: |
| 644 | 644 | case 25: |
| 645 | - $result = 22 + (2*4) + 2*count($this->SHPData["parts"]); |
|
| 645 | + $result = 22 + (2 * 4) + 2 * count($this->SHPData["parts"]); |
|
| 646 | 646 | for ($i = 0; $i < count($this->SHPData["parts"]); $i++) { |
| 647 | - $result += (8+4)*count($this->SHPData["parts"][$i]["points"]); |
|
| 647 | + $result += (8 + 4) * count($this->SHPData["parts"][$i]["points"]); |
|
| 648 | 648 | } |
| 649 | 649 | break; |
| 650 | 650 | case 13: |
| 651 | 651 | case 15: |
| 652 | - $result = 22 + (4*4) + 2*count($this->SHPData["parts"]); |
|
| 652 | + $result = 22 + (4 * 4) + 2 * count($this->SHPData["parts"]); |
|
| 653 | 653 | for ($i = 0; $i < count($this->SHPData["parts"]); $i++) { |
| 654 | - $result += (8+8)*count($this->SHPData["parts"][$i]["points"]); |
|
| 654 | + $result += (8 + 8) * count($this->SHPData["parts"][$i]["points"]); |
|
| 655 | 655 | } |
| 656 | 656 | break; |
| 657 | 657 | case 8: |
| 658 | - $result = 20 + 8*count($this->SHPData["points"]); |
|
| 658 | + $result = 20 + 8 * count($this->SHPData["points"]); |
|
| 659 | 659 | break; |
| 660 | 660 | case 28: |
| 661 | - $result = 20 + (2*4) + (8+4)*count($this->SHPData["points"]); |
|
| 661 | + $result = 20 + (2 * 4) + (8 + 4) * count($this->SHPData["points"]); |
|
| 662 | 662 | break; |
| 663 | 663 | case 18: |
| 664 | - $result = 20 + (4*4) + (8+8)*count($this->SHPData["points"]); |
|
| 664 | + $result = 20 + (4 * 4) + (8 + 8) * count($this->SHPData["points"]); |
|
| 665 | 665 | break; |
| 666 | 666 | default: |
| 667 | 667 | $result = false; |