EWKT.class.php 534 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * EWKT (Extended Well Known Text) Adapter
  4. */
  5. class EWKT extends WKT
  6. {
  7. /**
  8. * Serialize geometries into an EWKT string.
  9. *
  10. * @param Geometry $geometry
  11. *
  12. * @return string The Extended-WKT string representation of the input geometries
  13. */
  14. public function write(Geometry $geometry) {
  15. $srid = $geometry->SRID();
  16. $wkt = '';
  17. if ($srid) {
  18. $wkt = 'SRID=' . $srid . ';';
  19. $wkt .= $geometry->out('wkt');
  20. return $wkt;
  21. }
  22. else {
  23. return $geometry->out('wkt');
  24. }
  25. }
  26. }