default services conflit ?
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Geocoder package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
namespace Geocoder\Dumper;
|
||||
|
||||
use Geocoder\Location;
|
||||
|
||||
/**
|
||||
* @author Tomas Norkūnas <norkunas.tom@gmail.com>
|
||||
*/
|
||||
abstract class AbstractArrayDumper
|
||||
{
|
||||
/**
|
||||
* @param Location $location
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArray(Location $location): array
|
||||
{
|
||||
$properties = array_filter($location->toArray(), function ($value) {
|
||||
return !empty($value);
|
||||
});
|
||||
|
||||
unset(
|
||||
$properties['latitude'],
|
||||
$properties['longitude'],
|
||||
$properties['bounds']
|
||||
);
|
||||
|
||||
if ([] === $properties) {
|
||||
$properties = null;
|
||||
}
|
||||
|
||||
$lat = 0;
|
||||
$lon = 0;
|
||||
if (null !== $coordinates = $location->getCoordinates()) {
|
||||
$lat = $coordinates->getLatitude();
|
||||
$lon = $coordinates->getLongitude();
|
||||
}
|
||||
|
||||
$array = [
|
||||
'type' => 'Feature',
|
||||
'geometry' => [
|
||||
'type' => 'Point',
|
||||
'coordinates' => [$lon, $lat],
|
||||
],
|
||||
'properties' => $properties,
|
||||
];
|
||||
|
||||
if (null !== $bounds = $location->getBounds()) {
|
||||
$array['bounds'] = $bounds->toArray();
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
45
old.vendor/willdurand/geocoder/Dumper/AbstractDumper.php
Normal file
45
old.vendor/willdurand/geocoder/Dumper/AbstractDumper.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Geocoder package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
namespace Geocoder\Dumper;
|
||||
|
||||
use Geocoder\Location;
|
||||
|
||||
abstract class AbstractDumper
|
||||
{
|
||||
/**
|
||||
* @param Location $address
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function formatName(Location $address): string
|
||||
{
|
||||
$name = [];
|
||||
$array = $address->toArray();
|
||||
|
||||
foreach (['streetNumber', 'streetName', 'postalCode', 'locality'] as $attr) {
|
||||
$name[] = $array[$attr];
|
||||
}
|
||||
|
||||
if (isset($array['adminLevels'][2])) {
|
||||
$name[] = $array['adminLevels'][2]['name'];
|
||||
}
|
||||
|
||||
if (isset($array['adminLevels'][1])) {
|
||||
$name[] = $array['adminLevels'][1]['name'];
|
||||
}
|
||||
|
||||
$name[] = $array['country'];
|
||||
|
||||
return implode(', ', array_filter($name));
|
||||
}
|
||||
}
|
||||
31
old.vendor/willdurand/geocoder/Dumper/Dumper.php
Normal file
31
old.vendor/willdurand/geocoder/Dumper/Dumper.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Geocoder package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
namespace Geocoder\Dumper;
|
||||
|
||||
use Geocoder\Location;
|
||||
|
||||
/**
|
||||
* @author William Durand <william.durand1@gmail.com>
|
||||
*/
|
||||
interface Dumper
|
||||
{
|
||||
/**
|
||||
* Dumps an `Location` object as a string representation of
|
||||
* the implemented format.
|
||||
*
|
||||
* @param Location $location
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function dump(Location $location);
|
||||
}
|
||||
29
old.vendor/willdurand/geocoder/Dumper/GeoArray.php
Normal file
29
old.vendor/willdurand/geocoder/Dumper/GeoArray.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Geocoder package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
namespace Geocoder\Dumper;
|
||||
|
||||
use Geocoder\Location;
|
||||
|
||||
/**
|
||||
* @author Tomas Norkūnas <norkunas.tom@gmail.com>
|
||||
*/
|
||||
final class GeoArray extends AbstractArrayDumper implements Dumper
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dump(Location $location): array
|
||||
{
|
||||
return $this->getArray($location);
|
||||
}
|
||||
}
|
||||
29
old.vendor/willdurand/geocoder/Dumper/GeoJson.php
Normal file
29
old.vendor/willdurand/geocoder/Dumper/GeoJson.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Geocoder package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
namespace Geocoder\Dumper;
|
||||
|
||||
use Geocoder\Location;
|
||||
|
||||
/**
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
final class GeoJson extends AbstractArrayDumper implements Dumper
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dump(Location $location): string
|
||||
{
|
||||
return json_encode($this->getArray($location));
|
||||
}
|
||||
}
|
||||
72
old.vendor/willdurand/geocoder/Dumper/Gpx.php
Normal file
72
old.vendor/willdurand/geocoder/Dumper/Gpx.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Geocoder package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
namespace Geocoder\Dumper;
|
||||
|
||||
use Geocoder\Geocoder;
|
||||
use Geocoder\Location;
|
||||
|
||||
/**
|
||||
* @author William Durand <william.durand1@gmail.com>
|
||||
*/
|
||||
final class Gpx extends AbstractDumper implements Dumper
|
||||
{
|
||||
/**
|
||||
* @param Location $location
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function dump(Location $location): string
|
||||
{
|
||||
$gpx = sprintf(<<<'GPX'
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<gpx
|
||||
version="1.0"
|
||||
creator="Geocoder" version="%s"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.topografix.com/GPX/1/0"
|
||||
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
|
||||
|
||||
GPX
|
||||
, Geocoder::VERSION);
|
||||
|
||||
if (null !== $bounds = $location->getBounds()) {
|
||||
$gpx .= sprintf(<<<'GPX'
|
||||
<bounds minlat="%f" minlon="%f" maxlat="%f" maxlon="%f"/>
|
||||
|
||||
GPX
|
||||
, $bounds->getWest(), $bounds->getSouth(), $bounds->getEast(), $bounds->getNorth());
|
||||
}
|
||||
|
||||
$lat = null;
|
||||
$lon = null;
|
||||
if (null !== $coordinates = $location->getCoordinates()) {
|
||||
$lat = $coordinates->getLatitude();
|
||||
$lon = $coordinates->getLongitude();
|
||||
}
|
||||
|
||||
$gpx .= sprintf(<<<'GPX'
|
||||
<wpt lat="%.7f" lon="%.7f">
|
||||
<name><![CDATA[%s]]></name>
|
||||
<type><![CDATA[Address]]></type>
|
||||
</wpt>
|
||||
|
||||
GPX
|
||||
, $lat, $lon, $this->formatName($location));
|
||||
|
||||
$gpx .= <<<'GPX'
|
||||
</gpx>
|
||||
GPX;
|
||||
|
||||
return $gpx;
|
||||
}
|
||||
}
|
||||
52
old.vendor/willdurand/geocoder/Dumper/Kml.php
Normal file
52
old.vendor/willdurand/geocoder/Dumper/Kml.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Geocoder package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
namespace Geocoder\Dumper;
|
||||
|
||||
use Geocoder\Location;
|
||||
|
||||
/**
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
final class Kml extends AbstractDumper implements Dumper
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dump(Location $location): string
|
||||
{
|
||||
$name = $this->formatName($location);
|
||||
$kml = <<<'KML'
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kml xmlns="http://www.opengis.net/kml/2.2">
|
||||
<Document>
|
||||
<Placemark>
|
||||
<name><![CDATA[%s]]></name>
|
||||
<description><![CDATA[%s]]></description>
|
||||
<Point>
|
||||
<coordinates>%.7F,%.7F,0</coordinates>
|
||||
</Point>
|
||||
</Placemark>
|
||||
</Document>
|
||||
</kml>
|
||||
KML;
|
||||
|
||||
$lat = null;
|
||||
$lon = null;
|
||||
if (null !== $coordinates = $location->getCoordinates()) {
|
||||
$lat = $coordinates->getLatitude();
|
||||
$lon = $coordinates->getLongitude();
|
||||
}
|
||||
|
||||
return sprintf($kml, $name, $name, $lon, $lat);
|
||||
}
|
||||
}
|
||||
36
old.vendor/willdurand/geocoder/Dumper/Wkb.php
Normal file
36
old.vendor/willdurand/geocoder/Dumper/Wkb.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Geocoder package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
namespace Geocoder\Dumper;
|
||||
|
||||
use Geocoder\Location;
|
||||
|
||||
/**
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
final class Wkb implements Dumper
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dump(Location $location): string
|
||||
{
|
||||
$lat = null;
|
||||
$lon = null;
|
||||
if (null !== $coordinates = $location->getCoordinates()) {
|
||||
$lat = $coordinates->getLatitude();
|
||||
$lon = $coordinates->getLongitude();
|
||||
}
|
||||
|
||||
return pack('cLdd', 1, 1, $lon, $lat);
|
||||
}
|
||||
}
|
||||
36
old.vendor/willdurand/geocoder/Dumper/Wkt.php
Normal file
36
old.vendor/willdurand/geocoder/Dumper/Wkt.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Geocoder package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
namespace Geocoder\Dumper;
|
||||
|
||||
use Geocoder\Location;
|
||||
|
||||
/**
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
final class Wkt implements Dumper
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dump(Location $location): string
|
||||
{
|
||||
$lat = null;
|
||||
$lon = null;
|
||||
if (null !== $coordinates = $location->getCoordinates()) {
|
||||
$lat = $coordinates->getLatitude();
|
||||
$lon = $coordinates->getLongitude();
|
||||
}
|
||||
|
||||
return sprintf('POINT(%F %F)', $lon, $lat);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user