diff --git a/core/component_geolocation/class.component_geolocation.php b/core/component_geolocation/class.component_geolocation.php index 7c79e0ef6..e25a4f977 100644 --- a/core/component_geolocation/class.component_geolocation.php +++ b/core/component_geolocation/class.component_geolocation.php @@ -302,6 +302,60 @@ public function regenerate_component() : bool { + /** + * GET_LATITUDE + * Get the latitude of the component, if the data has the default data, return null + * @return float $latitude + */ + public function get_latitude() : ?float { + + $dato = $this->get_dato(); + if (empty($dato) || empty($dato[0]) ) { + return null; + } + + $dato = $dato[0]; + $data_latitude = $dato->lat ?? null; + + if(empty($data_latitude)){ + return null; + } + $latitude = strval($data_latitude)==='39.462571' + ? null + : floatval($data_latitude); + + return $latitude; + }//end get_latitude + + + + /** + * GET_LONGITUDE + * Get the longitude of the component, if the data has the default data, return null + * @return float $longitude + */ + public function get_longitude() : ?float { + + $dato = $this->get_dato(); + if (empty($dato) || empty($dato[0]) ) { + return null; + } + + $dato = $dato[0]; + $data_longitude = $dato->long ?? null; + + if(empty($data_longitude)){ + return null; + } + $longitude = strval($data_longitude)==='-0.376295' + ? null + : floatval($data_longitude); + + return $longitude; + }//end get_longitude + + + /** * GET_DIFFUSION_VALUE_SOCRATA * Calculate current component diffusion value for target field in socrata