pointArray, array("x" => $x, "y" => $y));
}
public function toGml2 () {
$str = "srs\">" .
"";
$ptArray = array();
foreach ($this->pointArray as $point) {
$ptArray[] = $point["x"] . "," . $point["y"];
}
$str .= implode(" ", $ptArray);
$str .= "";
$str .= "";
return $str;
}
public function toGml3 () {
$str = "srs\">" .
"";
$ptArray = array();
foreach ($this->pointArray as $point) {
$ptArray[] = "" . $point["x"] . " " . $point["y"] . "";
}
$str .= implode("", $ptArray);
$str .= "";
$str .= "";
return $str;
}
public function isEmpty () {
return !(count($this->pointArray) > 0);
}
public function toGeoJSON () {
$numberOfPoints = count($this->pointArray);
$str = "";
if ($numberOfPoints > 0) {
$str .= "{\"type\": \"LineString\", \"coordinates\":[";
for ($i=0; $i < $numberOfPoints; $i++) {
if ($i > 0) {
$str .= ",";
}
if (in_array($this->srs, $this->latLonSrs)) {
$str .= "[".$this->pointArray[$i]["y"].",".$this->pointArray[$i]["x"]."]";
}
else {
$str .= "[".$this->pointArray[$i]["x"].",".$this->pointArray[$i]["y"]."]";
}
}
$str .= "]}";
}
else {
$e = new mb_exception("GMLLine: toGeoJSON: this point is null.");
}
return $str;
}
}
?>