26 defined(
'LGV_DBF_CATCHER' ) or die ( 'Cannot Execute Directly' );
28 require_once(CO_Config::db_classes_class_dir().'/co_ll_location.class.php');
30 if ( !defined('LGV_CHAMELEON_UTILS_CATCHER') ) {
31 define(
'LGV_CHAMELEON_UTILS_CATCHER', 1);
34 $utils_file = CO_Config::chameleon_main_class_dir().
'/co_chameleon_utils.class.php';
38 if (array() === $arr)
return false;
39 return array_keys($arr) !== range(0, count($arr) - 1);
80 $in_tags_array = NULL,
96 parent::__construct($in_db_object, $in_db_result, $in_owner_id, $in_tags_array, $in_longitude, $in_latitude);
98 $this->class_description =
"This is a 'Place' Class for General Addresses.";
99 $this->instance_description = isset($this->name) && $this->name ?
"$this->name ($this->_longitude, $this->_latitude)" :
"($this->_longitude, $this->_latitude)";
105 $this->google_geocode_uri_prefix =
'https://maps.googleapis.com/maps/api/geocode/json?'.$bias.
'key='.CO_Config::$google_api_key.
'&address=';
106 $this->google_lookup_uri_prefix =
'https://maps.googleapis.com/maps/api/geocode/json?'.$bias.
'key='.CO_Config::$google_api_key.
'&latlng=';
131 $this->address_elements = Array();
134 for ($i = 0; $i < count($labels); $i++) {
138 $tag_value = isset($in_tags[$labels[$i]]) ? $in_tags[$labels[$i]] :
'';
140 $tag_value = isset($in_tags[$i]) ? $in_tags[$i] :
'';
165 $in_index = intval($in_index);
168 if ((0 <= $in_index) && ($in_index < count($labels))) {
169 $key = $labels[$in_index];
171 $in_value = strval($in_value);
173 $this->address_elements[$key] = $in_value;
174 $this->_tags[$in_index] = $in_value;
196 $in_index = intval($in_index);
199 for ($i = 0; $i < count($labels); $i++) {
200 if ($labels[$i] == $in_key) {
219 if ((0 <= $in_index) && ($in_index < count($labels))) {
220 $key = $labels[$in_index];
221 $ret = $this->address_elements[$key];
240 if (isset($resulting_json) && $resulting_json &&isset($resulting_json->results) && is_array($resulting_json->results) && count($resulting_json->results)) {
241 if (isset($resulting_json->results[0]->geometry) && isset($resulting_json->results[0]->geometry->location) && isset($resulting_json->results[0]->geometry->location->lng) && isset($resulting_json->results[0]->geometry->location->lat)) {
242 return Array(
'longitude' => floatval($resulting_json->results[0]->geometry->location->lng),
'latitude' => floatval($resulting_json->results[0]->geometry->location->lat));
266 if (isset($resulting_json) && $resulting_json &&isset($resulting_json->results) && is_array($resulting_json->results) && count($resulting_json->results)) {
267 if (isset($resulting_json->results[0]->address_components) && is_array($resulting_json->results[0]->address_components) && count($resulting_json->results[0]->address_components)) {
268 $address_components = $resulting_json->results[0]->address_components;
271 $ret = Array($labels[0] =>
'', $labels[1] =>
'', $labels[3] =>
'', $labels[4] =>
'', $labels[5] =>
'', $labels[6] =>
'');
273 if (isset($labels[7])) {
274 $ret[$labels[7]] =
'';
277 foreach ($address_components as $component) {
278 $int_key = $component->types[0];
282 if ($ret[$labels[0]]) {
283 $ret[$labels[0]] =
' '.$ret[$labels[0]];
285 $ret[$labels[0]] = strval($component->long_name).$ret[$labels[0]];
287 case 'street_number':
288 if ($ret[$labels[1]]) {
289 $ret[$labels[1]] =
' '.$ret[$labels[1]];
291 $ret[$labels[1]] = strval($component->short_name).$ret[$labels[1]];
294 if ($ret[$labels[1]]) {
295 $ret[$labels[1]] .=
' ';
297 $ret[$labels[1]] .= strval($component->long_name);
300 $ret[$labels[3]] = strval($component->long_name);
302 case 'administrative_area_level_1':
303 $ret[$labels[5]] = strval($component->short_name);
305 case 'administrative_area_level_2':
306 $ret[$labels[4]] = strval($component->short_name);
309 if ($ret[$labels[6]]) {
310 $ret[$labels[6]] =
'-'.$ret[$labels[6]];
312 $ret[$labels[6]] = strval($component->short_name).$ret[$labels[6]];
314 case 'postal_code_suffix':
315 if ($ret[$labels[6]]) {
316 $ret[$labels[6]] .=
'-';
318 $ret[$labels[6]] .= strval($component->short_name);
321 if (isset($labels[7])) {
322 $ret[$labels[7]] = strval($component->short_name);
349 if (isset($tag_key_array) && is_array($tag_key_array) && count($tag_key_array)) {
350 if ($with_venue && isset($tag_key_array[0]) && isset($this->address_elements[$tag_key_array[0]])) {
351 $ret = $this->address_elements[$tag_key_array[0]];
354 if ($with_venue && isset($tag_key_array[2]) && isset($this->address_elements[$tag_key_array[2]]) && $this->address_elements[$tag_key_array[2]]) {
362 $ret .= $this->address_elements[$tag_key_array[2]];
369 if (isset($tag_key_array[1]) && isset($this->address_elements[$tag_key_array[1]]) && $this->address_elements[$tag_key_array[1]]) {
374 $ret .= $this->address_elements[$tag_key_array[1]];
377 if (isset($tag_key_array[3]) && isset($this->address_elements[$tag_key_array[3]]) && $this->address_elements[$tag_key_array[3]]) {
382 $ret .= $this->address_elements[$tag_key_array[3]];
385 if (isset($tag_key_array[5]) && isset($this->address_elements[$tag_key_array[5]]) && $this->address_elements[$tag_key_array[5]]) {
390 $ret .= $this->address_elements[$tag_key_array[5]];
393 if (isset($tag_key_array[6]) && isset($this->address_elements[$tag_key_array[6]]) && $this->address_elements[$tag_key_array[6]]) {
398 $ret .= $this->address_elements[$tag_key_array[6]];
401 if (isset($tag_key_array[7]) && isset($this->address_elements[$tag_key_array[7]]) && $this->address_elements[$tag_key_array[7]]) {
406 $ret .= $this->address_elements[$tag_key_array[7]];
420 $new_tags = $this->tags;
423 for ($i = 0; $i < count($labels); $i++) {
425 $new_tags[$key] = $this->address_elements[$key];
439 for ($i = 0; $i < count($labels); $i++) {
441 if (isset($this->address_elements[$key]) && trim($this->address_elements[$key])) {
442 $ret[$key] = trim($this->address_elements[$key]);
if(!defined('LGV_ACCESS_CATCHER')) if(!defined( 'LGV_ANDISOL_CATCHER'))
test_is_assoc(array $arr)
if(!defined('LGV_CHAMELEON_UTILS_CATCHER')) $utils_file
get_address_element_by_index( $in_index)
__construct( $in_db_object=NULL, $in_db_result=NULL, $in_owner_id=NULL, $in_tags_array=NULL, $in_longitude=NULL, $in_latitude=NULL)
$region_bias
This can be set by subclasses in order to set a region bias.
$google_lookup_uri_prefix
This is the lookup URI for the Google reverse Geocode.
_get_address_element_labels()
$google_geocode_uri_prefix
This is the Geocode URI for the Google Geocode.
set_address_element_by_key( $in_key, $in_value, $dont_save=false)
set_address_element( $in_index, $in_value, $dont_save=false)
set_tags_from_address_elements()
set_address_elements( $in_tags, $dont_save=false)
get_readable_address( $with_venue=true)
$address_elements
These are the address elements we use for creating lookup addresses.
static $chameleon_co_place_tag_2
static $chameleon_co_place_tag_7
static $chameleon_co_place_tag_4
static $chameleon_co_place_tag_1
static $chameleon_co_place_tag_6
static $chameleon_co_place_tag_5
static $chameleon_co_place_tag_3
static $chameleon_co_place_tag_0
These apply to the CO_Place class. Only the first seven tags are used for US location information.
static $co_place_error_code_failed_to_geocode
static $co_place_error_code_failed_to_lookup
static $co_place_error_name_failed_to_geocode
static $co_place_error_name_failed_to_lookup
static $co_place_error_desc_failed_to_lookup
static $co_place_error_desc_failed_to_geocode
static call_curl( $in_uri, $in_post=false, &$http_status=NULL, &$content_failure_note=NULL)
This is a function that returns the results of an HTTP call to a URI. It is a lot more secure than fi...
set_tags( $in_tags_array)
This class provides a general error report, with file, method and error information.