Version 5.0.13

This commit is contained in:
Neo committed 2025-12-19 19:04:57 -08:00
1 parent b89858b2ff
commit 5efe744c5f
1407 files changed
+69690 -30177

No files matched your search

+83 -115
View File
@@ -52,62 +52,50 @@ class Mapbox extends GeoCoder
$obj = new GeoLocation;
$_address = '';
/* Make sure the response from Mapbox is valid */
if( isset( $data['results'] ) AND is_array( $data['results'] ) AND count( $data['results'] ) )
if( !empty( $data['features'] ) )
{
if( isset( $data['results'][0]['geometry'] ) AND isset( $data['results'][0]['geometry']['coordinates'] ) )
if( !empty( $data['features'][0]['geometry'] ) )
{
$obj->long = $data['results'][0]['geometry']['coordinates'][0];
$obj->lat = $data['results'][0]['geometry']['coordinates'][1];
$obj->long = $data['features'][0]['geometry']['coordinates'][0];
$obj->lat = $data['features'][0]['geometry']['coordinates'][1];
}
$obj->placeName = $data['results'][0]['place_name'];
$obj->placeName = $data['features'][0]['place_name'];
foreach( $data['results'][0]['address_components'] as $component )
/* If we are at address level, the address will not be in a property */
if( $data['features'][0]['place_type'][0] == 'address' )
{
if( $component['types'][0] == 'street_number' )
{
$_address = $component['long_name'];
}
elseif( $component['types'][0] == 'route' )
{
$_address .= " " . $component['long_name'];
}
$obj->addressLines = [ $data['features'][0]['address'] . ' ' . $data['features'][0]['text'] ];
}
if( $component['types'][0] == 'postal_code' )
foreach( $data['features'][0]['context'] as $property )
{
$propertyType = mb_substr( $property['id'], 0, mb_strpos( $property['id'], '.' ) );
switch( $propertyType )
{
$obj->postalCode = $component['long_name'];
}
case 'locality':
$obj->city = $property['text'];
break;
if( $component['types'][0] == 'country' )
{
$obj->country = $component['short_name'];
}
case 'postcode':
$obj->postalCode = $property['text'];
break;
if( $component['types'][0] == 'administrative_area_level_1' )
{
$obj->region = $component['long_name'];
}
case 'country':
$obj->country = $property['text'];
break;
if( $component['types'][0] == 'administrative_area_level_2' )
{
$obj->county = $component['long_name'];
}
case 'region':
$obj->region = $property['text'];
break;
if( $component['types'][0] == 'locality' )
{
$obj->city = $component['long_name'];
case 'district':
$obj->county = $property['text'];
break;
}
}
}
if( $_address )
{
$obj->addressLines = array( $_address );
}
return $obj;
}
else
@@ -138,54 +126,44 @@ class Mapbox extends GeoCoder
$obj->lat = $lat;
$obj->long = $long;
$_address = '';
/* Make sure the response from Mapbox is valid */
if( isset( $data['results'] ) AND is_array( $data['results'] ) AND count( $data['results'] ) )
if( !empty( $data['features'] ) )
{
foreach( $data['results'][0]['address_components'] as $component )
$obj->placeName = $data['features'][0]['place_name'];
/* If we are at address level, the address will not be in a property */
if( $data['features'][0]['place_type'][0] == 'address' )
{
if( $component['types'][0] == 'street_number' )
{
$_address = $component['long_name'];
}
elseif( $component['types'][0] == 'route' )
{
$_address .= " " . $component['long_name'];
}
$obj->addressLines = [ $data['features'][0]['address'] . ' ' . $data['features'][0]['text'] ];
}
if( $component['types'][0] == 'postal_code' )
foreach( $data['features'][0]['context'] as $property )
{
$propertyType = mb_substr( $property['id'], 0, mb_strpos( $property['id'], '.' ) );
switch( $propertyType )
{
$obj->postalCode = $component['long_name'];
}
case 'locality':
$obj->city = $property['text'];
break;
if( $component['types'][0] == 'country' )
{
$obj->country = $component['short_name'];
}
case 'postcode':
$obj->postalCode = $property['text'];
break;
if( $component['types'][0] == 'administrative_area_level_1' )
{
$obj->region = $component['long_name'];
}
case 'country':
$obj->country = $property['text'];
break;
if( $component['types'][0] == 'administrative_area_level_2' )
{
$obj->county = $component['long_name'];
}
case 'region':
$obj->region = $property['text'];
break;
if( $component['types'][0] == 'locality' )
{
$obj->city = $component['long_name'];
case 'district':
$obj->county = $property['text'];
break;
}
}
}
if( $_address )
{
$obj->addressLines = array( $_address );
}
return $obj;
}
else
@@ -229,49 +207,39 @@ class Mapbox extends GeoCoder
if( $setAddress === TRUE )
{
if( isset( $data['results'] ) AND is_array( $data['results'] ) AND count( $data['results'] ) )
$geoLocation->placeName = $data['features'][0]['place_name'];
/* If we are at address level, the address will not be in a property */
if( $data['features'][0]['place_type'][0] == 'address' )
{
foreach( $data['results'][0]['address_components'] as $component )
{
if( $component['types'][0] == 'street_number' )
{
$_address = $component['long_name'];
}
elseif( $component['types'][0] == 'route' )
{
$_address .= " " . $component['long_name'];
}
if( $component['types'][0] == 'postal_code' )
{
$geoLocation->postalCode = $component['long_name'];
}
if( $component['types'][0] == 'country' )
{
$geoLocation->country = $component['short_name'];
}
if( $component['types'][0] == 'administrative_area_level_1' )
{
$geoLocation->region = $component['long_name'];
}
if( $component['types'][0] == 'administrative_area_level_2' )
{
$geoLocation->county = $component['long_name'];
}
if( $component['types'][0] == 'locality' )
{
$geoLocation->city = $component['long_name'];
}
}
$geoLocation->addressLines = [ $data['features'][0]['address'] . ' ' . $data['features'][0]['text'] ];
}
if( $_address )
foreach( $data['features'][0]['context'] as $property )
{
$geoLocation->addressLines = array( $_address );
$propertyType = mb_substr( $property['id'], 0, mb_strpos( $property['id'], '.' ) );
switch( $propertyType )
{
case 'locality':
$geoLocation->city = $property['text'];
break;
case 'postcode':
$geoLocation->postalCode = $property['text'];
break;
case 'country':
$geoLocation->country = $property['text'];
break;
case 'region':
$geoLocation->region = $property['text'];
break;
case 'district':
$geoLocation->county = $property['text'];
break;
}
}
}
}