| @@ 21-86 (lines=66) @@ | ||
| 18 | * |
|
| 19 | * @see http://wiki.openstreetmap.org/wiki/Nominatim |
|
| 20 | */ |
|
| 21 | class Details extends Query |
|
| 22 | { |
|
| 23 | /** |
|
| 24 | * OSM Type accepted (Node/Way/Relation). |
|
| 25 | * |
|
| 26 | * @var array |
|
| 27 | */ |
|
| 28 | private $osmType = ['N', 'W', 'R']; |
|
| 29 | ||
| 30 | /** |
|
| 31 | * Constructor. |
|
| 32 | * |
|
| 33 | * @param array $query Default value for this query |
|
| 34 | */ |
|
| 35 | public function __construct(array &$query = []) |
|
| 36 | { |
|
| 37 | parent::__construct($query); |
|
| 38 | ||
| 39 | $this->setPath('details'); |
|
| 40 | ||
| 41 | $this->acceptedFormat[] = 'html'; |
|
| 42 | $this->acceptedFormat[] = 'jsonv2'; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Place information by placeId. |
|
| 47 | * |
|
| 48 | * @return Details |
|
| 49 | */ |
|
| 50 | public function placeId(int $placeId): self |
|
| 51 | { |
|
| 52 | $this->query['place_id'] = $placeId; |
|
| 53 | ||
| 54 | return $this; |
|
| 55 | } |
|
| 56 | ||
| 57 | /** |
|
| 58 | * [osmType description]. |
|
| 59 | * |
|
| 60 | * @throws \maxh\Nominatim\Exceptions\InvalidParameterException if osm type is not supported |
|
| 61 | * |
|
| 62 | * @return \maxh\Nominatim\Reverse |
|
| 63 | */ |
|
| 64 | public function osmType(string $type): self |
|
| 65 | { |
|
| 66 | if (\in_array($type, $this->osmType, true)) { |
|
| 67 | $this->query['osmtype'] = $type; |
|
| 68 | ||
| 69 | return $this; |
|
| 70 | } |
|
| 71 | ||
| 72 | throw new InvalidParameterException('OSM Type is not supported'); |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * Place information by osmtype and osmid. |
|
| 77 | * |
|
| 78 | * @return Details |
|
| 79 | */ |
|
| 80 | public function osmId(int $osmId): self |
|
| 81 | { |
|
| 82 | $this->query['osmid'] = $osmId; |
|
| 83 | ||
| 84 | return $this; |
|
| 85 | } |
|
| 86 | } |
|
| 87 | ||
| @@ 21-102 (lines=82) @@ | ||
| 18 | * |
|
| 19 | * @see http://wiki.openstreetmap.org/wiki/Nominatim |
|
| 20 | */ |
|
| 21 | class Reverse extends Query |
|
| 22 | { |
|
| 23 | /** |
|
| 24 | * OSM Type accepted (Node/Way/Relation). |
|
| 25 | * |
|
| 26 | * @var array |
|
| 27 | */ |
|
| 28 | public $osmType = ['N', 'W', 'R']; |
|
| 29 | ||
| 30 | /** |
|
| 31 | * Constructor. |
|
| 32 | * |
|
| 33 | * @param array $query Default value for this query |
|
| 34 | */ |
|
| 35 | public function __construct(array &$query = []) |
|
| 36 | { |
|
| 37 | parent::__construct($query); |
|
| 38 | ||
| 39 | $this->setPath('reverse'); |
|
| 40 | } |
|
| 41 | ||
| 42 | // -- Builder methods ------------------------------------------------------ |
|
| 43 | ||
| 44 | /** |
|
| 45 | * [osmType description]. |
|
| 46 | * |
|
| 47 | * @throws \maxh\Nominatim\Exceptions\InvalidParameterException if osm type is not supported |
|
| 48 | * |
|
| 49 | * @return \maxh\Nominatim\Reverse |
|
| 50 | */ |
|
| 51 | public function osmType(string $type): self |
|
| 52 | { |
|
| 53 | if (\in_array($type, $this->osmType, true)) { |
|
| 54 | $this->query['osm_type'] = $type; |
|
| 55 | ||
| 56 | return $this; |
|
| 57 | } |
|
| 58 | ||
| 59 | throw new InvalidParameterException('OSM Type is not supported'); |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * A specific osm node / way / relation to return an address for. |
|
| 64 | * |
|
| 65 | * @return \maxh\Nominatim\Reverse |
|
| 66 | */ |
|
| 67 | public function osmId(int $id): self |
|
| 68 | { |
|
| 69 | $this->query['osm_id'] = $id; |
|
| 70 | ||
| 71 | return $this; |
|
| 72 | } |
|
| 73 | ||
| 74 | /** |
|
| 75 | * The location to generate an address for. |
|
| 76 | * |
|
| 77 | * @param float $lat The latitude |
|
| 78 | * @param float $lon The longitude |
|
| 79 | * |
|
| 80 | * @return \maxh\Nominatim\Reverse |
|
| 81 | */ |
|
| 82 | public function latlon(float $lat, float $lon): self |
|
| 83 | { |
|
| 84 | $this->query['lat'] = $lat; |
|
| 85 | ||
| 86 | $this->query['lon'] = $lon; |
|
| 87 | ||
| 88 | return $this; |
|
| 89 | } |
|
| 90 | ||
| 91 | /** |
|
| 92 | * Level of detail required where 0 is country and 18 is house/building. |
|
| 93 | * |
|
| 94 | * @return \maxh\Nominatim\Reverse |
|
| 95 | */ |
|
| 96 | public function zoom(int $zoom): self |
|
| 97 | { |
|
| 98 | $this->query['zoom'] = (string) $zoom; |
|
| 99 | ||
| 100 | return $this; |
|
| 101 | } |
|
| 102 | } |
|
| 103 | ||