innerRingArray) <= $i) { array_push($this->innerRingArray, array()); } while (count($this->innerRingArray[$i]) <= $j) { array_push($this->innerRingArray[$i], array()); } array_push($this->innerRingArray[$i][$j], array("x" => $x, "y" => $y)); } public function addPoint ($x, $y, $i) { while (count($this->polygonArray) <= $i) { array_push($this->polygonArray, array()); } array_push($this->polygonArray[$i], array("x" => $x, "y" => $y)); } public function toGml2 () { $str = ""; for ($i = 0; $i < count($this->polygonArray); $i++) { $str .= "" . ""; $currentExteriorRing = $this->polygonArray[$i]; $ptArray = array(); for ($j = 0; $j < count($currentExteriorRing); $j++) { $point = $currentExteriorRing[$j]; $ptArray[] = $point["x"] . "," . $point["y"]; } $str .= implode(" ", $ptArray); $str .= ""; // interior rings exist if (count($this->innerRingArray) > $i && count($this->innerRingArray[$i]) > 0) { for ($j = 0; $j < count($this->innerRingArray[$i]); $j++) { $currentInteriorRing = $this->innerRingArray[$i][$j]; $str .= ""; $ptArray = array(); for ($k = 0; $k < count($currentInteriorRing); $k++) { $point = $currentInteriorRing[$k]; $ptArray[] = $point["x"] . "," . $point["y"]; } $str .= implode(" ", $ptArray); $str .= ""; } } $str .= ""; } $str .= ""; return $str; } public function toGml3 () { $str = ""; for ($i = 0; $i < count($this->polygonArray); $i++) { $str .= "" . ""; $currentExteriorRing = $this->polygonArray[$i]; $ptArray = array(); for ($j = 0; $j < count($currentExteriorRing); $j++) { $point = $currentExteriorRing[$j]; $ptArray[] = "" . $point["x"] . " " . $point["y"] . ""; } $str .= implode("", $ptArray); $str .= ""; // interior rings exist if (count($this->innerRingArray) > $i && count($this->innerRingArray[$i]) > 0) { for ($j = 0; $j < count($this->innerRingArray[$i]); $j++) { $currentInteriorRing = $this->innerRingArray[$i][$j]; $str .= ""; $ptArray = array(); for ($k = 0; $k < count($currentInteriorRing); $k++) { $point = $currentInteriorRing[$k]; $ptArray[] = "" . $point["x"] . " " . $point["y"] . ""; } $str .= implode("", $ptArray); $str .= ""; } } $str .= ""; } $str .= ""; return $str; } public function isEmpty () { return !(count($this->polygonArray) > 0); } public function toGeoJSON () { $numberPolygonArray = count($this->polygonArray); $str = ""; if ($numberPolygonArray > 0) { $str .= "{\"type\": \"MultiPolygon\", \"coordinates\":["; for ($cnt =0; $cnt < $numberPolygonArray; $cnt++){ if ($cnt > 0) { $str .= ","; } $str .= "["; $str .= "["; for ($i=0; $i < count($this->polygonArray[$cnt]); $i++) { if ($i > 0) { $str .= ","; } if (in_array($this->srs, $this->latLonSrs)) { $str .= "[".$this->polygonArray[$cnt][$i]["y"].",".$this->polygonArray[$cnt][$i]["x"]."]"; } else { $str .= "[".$this->polygonArray[$cnt][$i]["x"].",".$this->polygonArray[$cnt][$i]["y"]."]"; } } $str .= "]"; for ($i=0; $i < count($this->innerRingArray[$cnt]); $i++) { $str .= ",["; for ($j=0; $j < count($this->innerRingArray[$cnt][$i]); $j++) { if ($j > 0) { $str .= ","; } if (in_array($this->srs, $this->latLonSrs)) { $str .= "[".$this->innerRingArray[$cnt][$i][$j]["y"].",".$this->innerRingArray[$cnt][$i][$j]["x"]."]"; } else { $str .= "[".$this->innerRingArray[$cnt][$i][$j]["x"].",".$this->innerRingArray[$cnt][$i][$j]["y"]."]"; } } $str .= "]"; } $str .= "]"; } $str .= "]}"; } else { $e = new mb_exception("GMLMultiPolygon: toGeoJSON: this multiLine is null."); } return $str; } } ?>