Wkb.php 759 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the Geocoder package.
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. *
  8. * @license MIT License
  9. */
  10. namespace Geocoder\Dumper;
  11. use Geocoder\Location;
  12. /**
  13. * @author Jan Sorgalla <jsorgalla@googlemail.com>
  14. */
  15. final class Wkb implements Dumper
  16. {
  17. /**
  18. * {@inheritdoc}
  19. */
  20. public function dump(Location $location): string
  21. {
  22. $lat = null;
  23. $lon = null;
  24. if (null !== $coordinates = $location->getCoordinates()) {
  25. $lat = $coordinates->getLatitude();
  26. $lon = $coordinates->getLongitude();
  27. }
  28. return pack('cLdd', 1, 1, $lon, $lat);
  29. }
  30. }