lineArray[$i])) {
$this->lineArray[$i] = array();
}
array_push($this->lineArray[$i], array("x" => $x, "y" => $y));
}
public function toGml2 () {
$str = "";
foreach ($this->lineArray as $line) {
$str .= "";
$ptArray = array();
foreach ($line as $point) {
$ptArray[] = $point["x"] . "," . $point["y"];
}
$str .= implode(" ", $ptArray);
$str .= "";
}
$str .= "";
return $str;
}
public function toGml3 () {
$str = "";
foreach ($this->lineArray as $line) {
$str .= "";
$ptArray = array();
foreach ($line as $point) {
$ptArray[] = "" . $point["x"] . " " . $point["y"] . "";
}
$str .= implode("", $ptArray);
$str .= "";
}
$str .= "";
return $str;
}
public function isEmpty () {
return !(count($this->lineArray) > 0);
}
public function toGeoJSON () {
$numberlineArray = count($this->lineArray);
$str = "";
$isLatLonSrs = $this->isLatLonSrs($this->srs);
if ($numberlineArray > 0) {
$str .= "{\"type\": \"MultiLineString\", \"coordinates\":[";
for ($cnt =0; $cnt < $numberlineArray; $cnt++){
if ($cnt > 0) {
$str .= ",";
}
$str .="[";
for ($i=0; $i < count($this->lineArray[$cnt]); $i++) {
if ($i > 0) {
$str .= ",";
}
if ($isLatLonSrs) {
$str .= "[".$this->lineArray[$cnt][$i]["y"].",".$this->lineArray[$cnt][$i]["x"]."]";
}
else {
$str .= "[".$this->lineArray[$cnt][$i]["x"].",".$this->lineArray[$cnt][$i]["y"]."]";
}
}
$str .="]";
}
$str .= "]}";
}
else {
$e = new mb_exception("GMLMultiLine: toGeoJSON: this multiLine is null.");
}
return $str;
}
}
?>