mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-05 04:49:44 +00:00
add type hinting in Point and PointException
This commit is contained in:
@@ -13,7 +13,7 @@ class Point implements JsonSerializable {
|
|||||||
private float $lon;
|
private float $lon;
|
||||||
public static string $SRID = '4326';
|
public static string $SRID = '4326';
|
||||||
|
|
||||||
private function __construct($lon, $lat)
|
private function __construct(float $lon, float $lat)
|
||||||
{
|
{
|
||||||
$this->lat = $lat;
|
$this->lat = $lat;
|
||||||
$this->lon = $lon;
|
$this->lon = $lon;
|
||||||
@@ -52,7 +52,7 @@ class Point implements JsonSerializable {
|
|||||||
* @param type $geojson
|
* @param type $geojson
|
||||||
* @return Point
|
* @return Point
|
||||||
*/
|
*/
|
||||||
public static function fromGeoJson($geojson): Point
|
public static function fromGeoJson(string $geojson): Point
|
||||||
{
|
{
|
||||||
$a = json_decode($geojson);
|
$a = json_decode($geojson);
|
||||||
//check if the geojson string is correct
|
//check if the geojson string is correct
|
||||||
@@ -70,7 +70,7 @@ class Point implements JsonSerializable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fromLonLat($lon, $lat): Point
|
public static function fromLonLat(float $lon, float $lat): Point
|
||||||
{
|
{
|
||||||
if (($lon > -180 && $lon < 180) && ($lat > -90 && $lat < 90))
|
if (($lon > -180 && $lon < 180) && ($lat > -90 && $lat < 90))
|
||||||
{
|
{
|
||||||
@@ -80,7 +80,7 @@ class Point implements JsonSerializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fromArrayGeoJson($array): Point
|
public static function fromArrayGeoJson(array $array): Point
|
||||||
{
|
{
|
||||||
if ($array['type'] == 'Point' &&
|
if ($array['type'] == 'Point' &&
|
||||||
isset($array['coordinates']))
|
isset($array['coordinates']))
|
||||||
|
Reference in New Issue
Block a user