public function WKT::write in geoPHP 8
Same name and namespace in other branches
- 7 geoPHP/lib/adapters/WKT.class.php \WKT::write()
Serialize geometries into a WKT string.
Parameters
Geometry $geometry:
Return value
string The WKT string representation of the input geometries
Overrides GeoAdapter::write
1 method overrides WKT::write()
- EWKT::write in geoPHP/
lib/ adapters/ EWKT.class.php - Serialize geometries into an EWKT string.
File
- geoPHP/
lib/ adapters/ WKT.class.php, line 199
Class
- WKT
- WKT (Well Known Text) Adapter
Code
public function write(Geometry $geometry) {
// If geos is installed, then we take a shortcut and let it write the WKT
if (geoPHP::geosInstalled()) {
$writer = new GEOSWKTWriter();
$writer
->setTrim(TRUE);
return $writer
->write($geometry
->geos());
}
if ($geometry
->isEmpty()) {
return strtoupper($geometry
->geometryType()) . ' EMPTY';
}
else {
if ($data = $this
->extractData($geometry)) {
return strtoupper($geometry
->geometryType()) . ' (' . $data . ')';
}
}
}