@@ -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; |
@@ -29,7 +29,9 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | */ |
| 31 | 31 | function loadData($type, $data) { |
| 32 | - if (!$data) return $data; |
|
| 32 | + if (!$data) { |
|
| 33 | + return $data; |
|
| 34 | + } |
|
| 33 | 35 | $tmp = unpack($type, $data); |
| 34 | 36 | return current($tmp); |
| 35 | 37 | } |
@@ -105,7 +107,9 @@ discard block |
||
| 105 | 107 | } |
| 106 | 108 | |
| 107 | 109 | function saveToFile($FileName = NULL) { |
| 108 | - if ($FileName != NULL) $this->FileName = $FileName; |
|
| 110 | + if ($FileName != NULL) { |
|
| 111 | + $this->FileName = $FileName; |
|
| 112 | + } |
|
| 109 | 113 | |
| 110 | 114 | if (($this->_openSHPFile(TRUE)) && ($this->_openSHXFile(TRUE)) && ($this->_openDBFFile(TRUE))) { |
| 111 | 115 | $this->_saveHeaders(); |
@@ -127,20 +131,36 @@ discard block |
||
| 127 | 131 | $this->records[] = $record; |
| 128 | 132 | $this->records[count($this->records) - 1]->recordNumber = count($this->records); |
| 129 | 133 | |
| 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"]; |
|
| 134 | + if ($this->boundingBox["xmin"]==0.0 || ($this->boundingBox["xmin"]>$record->SHPData["xmin"])) { |
|
| 135 | + $this->boundingBox["xmin"] = $record->SHPData["xmin"]; |
|
| 136 | + } |
|
| 137 | + if ($this->boundingBox["xmax"]==0.0 || ($this->boundingBox["xmax"]<$record->SHPData["xmax"])) { |
|
| 138 | + $this->boundingBox["xmax"] = $record->SHPData["xmax"]; |
|
| 139 | + } |
|
| 132 | 140 | |
| 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"]; |
|
| 141 | + if ($this->boundingBox["ymin"]==0.0 || ($this->boundingBox["ymin"]>$record->SHPData["ymin"])) { |
|
| 142 | + $this->boundingBox["ymin"] = $record->SHPData["ymin"]; |
|
| 143 | + } |
|
| 144 | + if ($this->boundingBox["ymax"]==0.0 || ($this->boundingBox["ymax"]<$record->SHPData["ymax"])) { |
|
| 145 | + $this->boundingBox["ymax"] = $record->SHPData["ymax"]; |
|
| 146 | + } |
|
| 135 | 147 | |
| 136 | 148 | 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"]; |
|
| 149 | + if (!isset($this->boundingBox["mmin"]) || $this->boundingBox["mmin"]==0.0 || ($this->boundingBox["mmin"]>$record->SHPData["mmin"])) { |
|
| 150 | + $this->boundingBox["mmin"] = $record->SHPData["mmin"]; |
|
| 151 | + } |
|
| 152 | + if (!isset($this->boundingBox["mmax"]) || $this->boundingBox["mmax"]==0.0 || ($this->boundingBox["mmax"]<$record->SHPData["mmax"])) { |
|
| 153 | + $this->boundingBox["mmax"] = $record->SHPData["mmax"]; |
|
| 154 | + } |
|
| 139 | 155 | } |
| 140 | 156 | |
| 141 | 157 | 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"]; |
|
| 158 | + if (!isset($this->boundingBox["zmin"]) || $this->boundingBox["zmin"]==0.0 || ($this->boundingBox["zmin"]>$record->SHPData["zmin"])) { |
|
| 159 | + $this->boundingBox["zmin"] = $record->SHPData["zmin"]; |
|
| 160 | + } |
|
| 161 | + if (!isset($this->boundingBox["zmax"]) || $this->boundingBox["zmax"]==0.0 || ($this->boundingBox["zmax"]<$record->SHPData["zmax"])) { |
|
| 162 | + $this->boundingBox["zmax"] = $record->SHPData["zmax"]; |
|
| 163 | + } |
|
| 144 | 164 | } |
| 145 | 165 | |
| 146 | 166 | return (count($this->records) - 1); |
@@ -807,8 +827,14 @@ discard block |
||
| 807 | 827 | case 1: |
| 808 | 828 | case 11: |
| 809 | 829 | 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 |
|
| 830 | + if (in_array($this->shapeType,array(11,21)) && !isset($point["m"])) { |
|
| 831 | + $point["m"] = 0.0; |
|
| 832 | + } |
|
| 833 | + // no_value |
|
| 834 | + if (in_array($this->shapeType,array(11)) && !isset($point["z"])) { |
|
| 835 | + $point["z"] = 0.0; |
|
| 836 | + } |
|
| 837 | + // no_value |
|
| 812 | 838 | //Substitutes the value of the current point |
| 813 | 839 | $this->SHPData = $point; |
| 814 | 840 | break; |
@@ -818,18 +844,40 @@ discard block |
||
| 818 | 844 | case 15: |
| 819 | 845 | case 23: |
| 820 | 846 | 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 |
|
| 847 | + if (in_array($this->shapeType,array(13,15,23,25)) && !isset($point["m"])) { |
|
| 848 | + $point["m"] = 0.0; |
|
| 849 | + } |
|
| 850 | + // no_value |
|
| 851 | + if (in_array($this->shapeType,array(13,15)) && !isset($point["z"])) { |
|
| 852 | + $point["z"] = 0.0; |
|
| 853 | + } |
|
| 854 | + // no_value |
|
| 823 | 855 | |
| 824 | 856 | //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"]; |
|
| 857 | + if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) { |
|
| 858 | + $this->SHPData["xmin"] = $point["x"]; |
|
| 859 | + } |
|
| 860 | + if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) { |
|
| 861 | + $this->SHPData["ymin"] = $point["y"]; |
|
| 862 | + } |
|
| 863 | + if (isset($point["m"]) && (!isset($this->SHPData["mmin"]) || ($this->SHPData["mmin"] > $point["m"]))) { |
|
| 864 | + $this->SHPData["mmin"] = $point["m"]; |
|
| 865 | + } |
|
| 866 | + if (isset($point["z"]) && (!isset($this->SHPData["zmin"]) || ($this->SHPData["zmin"] > $point["z"]))) { |
|
| 867 | + $this->SHPData["zmin"] = $point["z"]; |
|
| 868 | + } |
|
| 869 | + if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) { |
|
| 870 | + $this->SHPData["xmax"] = $point["x"]; |
|
| 871 | + } |
|
| 872 | + if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) { |
|
| 873 | + $this->SHPData["ymax"] = $point["y"]; |
|
| 874 | + } |
|
| 875 | + if (isset($point["m"]) && (!isset($this->SHPData["mmax"]) || ($this->SHPData["mmax"] < $point["m"]))) { |
|
| 876 | + $this->SHPData["mmax"] = $point["m"]; |
|
| 877 | + } |
|
| 878 | + if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) { |
|
| 879 | + $this->SHPData["zmax"] = $point["z"]; |
|
| 880 | + } |
|
| 833 | 881 | |
| 834 | 882 | $this->SHPData["parts"][$partIndex]["points"][] = $point; |
| 835 | 883 | |
@@ -839,18 +887,40 @@ discard block |
||
| 839 | 887 | case 8: |
| 840 | 888 | case 18: |
| 841 | 889 | 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 |
|
| 890 | + if (in_array($this->shapeType,array(18,28)) && !isset($point["m"])) { |
|
| 891 | + $point["m"] = 0.0; |
|
| 892 | + } |
|
| 893 | + // no_value |
|
| 894 | + if (in_array($this->shapeType,array(18)) && !isset($point["z"])) { |
|
| 895 | + $point["z"] = 0.0; |
|
| 896 | + } |
|
| 897 | + // no_value |
|
| 844 | 898 | |
| 845 | 899 | //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"]; |
|
| 900 | + if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) { |
|
| 901 | + $this->SHPData["xmin"] = $point["x"]; |
|
| 902 | + } |
|
| 903 | + if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) { |
|
| 904 | + $this->SHPData["ymin"] = $point["y"]; |
|
| 905 | + } |
|
| 906 | + if (isset($point["m"]) && (!isset($this->SHPData["mmin"]) || ($this->SHPData["mmin"] > $point["m"]))) { |
|
| 907 | + $this->SHPData["mmin"] = $point["m"]; |
|
| 908 | + } |
|
| 909 | + if (isset($point["z"]) && (!isset($this->SHPData["zmin"]) || ($this->SHPData["zmin"] > $point["z"]))) { |
|
| 910 | + $this->SHPData["zmin"] = $point["z"]; |
|
| 911 | + } |
|
| 912 | + if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) { |
|
| 913 | + $this->SHPData["xmax"] = $point["x"]; |
|
| 914 | + } |
|
| 915 | + if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) { |
|
| 916 | + $this->SHPData["ymax"] = $point["y"]; |
|
| 917 | + } |
|
| 918 | + if (isset($point["m"]) && (!isset($this->SHPData["mmax"]) || ($this->SHPData["mmax"] < $point["m"]))) { |
|
| 919 | + $this->SHPData["mmax"] = $point["m"]; |
|
| 920 | + } |
|
| 921 | + if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) { |
|
| 922 | + $this->SHPData["zmax"] = $point["z"]; |
|
| 923 | + } |
|
| 854 | 924 | |
| 855 | 925 | $this->SHPData["points"][] = $point; |
| 856 | 926 | $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"])?$this->SHPData["numpoints"]:0); |
@@ -872,8 +942,12 @@ discard block |
||
| 872 | 942 | //Sets the value of the point to zero |
| 873 | 943 | $this->SHPData["x"] = 0.0; |
| 874 | 944 | $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; |
|
| 945 | + if (in_array($this->shapeType,array(11,21))) { |
|
| 946 | + $this->SHPData["m"] = 0.0; |
|
| 947 | + } |
|
| 948 | + if (in_array($this->shapeType,array(11))) { |
|
| 949 | + $this->SHPData["z"] = 0.0; |
|
| 950 | + } |
|
| 877 | 951 | break; |
| 878 | 952 | case 3: |
| 879 | 953 | case 5: |