/**
  *
  * @param string $latLong
  * @param bool $forceReload
  * @return \models\entities\GeocodeCached Description
  *
  */
 public function lookUp($latLong, $forceReload = false)
 {
     list($lat, $long) = explode(',', $latLong);
     $preciseLat = round(doubleval($lat), self::GEOCODE_PRECISION);
     $preciseLong = round(doubleval($long), self::GEOCODE_PRECISION);
     if (!$forceReload) {
         $lookUpWhere = (new \DbTableWhere())->where('longitude', $preciseLong)->where('latitude', $preciseLat)->setLimitAndOffset(1);
         $cachedList = \models\entities\GeocodeCached::manager()->getEntitiesWhere($lookUpWhere);
         if (count($cachedList)) {
             return $cachedList[0];
         }
     }
     foreach ($this->serviceProviderList as $serviceProvier) {
         $lookUpResult = $serviceProvier->lookUp($preciseLong, $preciseLat);
         \SystemLogger::debug("Making call with: ", $serviceProvier->getClassBasic());
         if ($lookUpResult && ($lookUpResult->getCity() || $lookUpResult->getPostalCode())) {
             //var_dump($lookUpResult);exit;
             return $this->cacheLookup($lookUpResult, $preciseLong, $preciseLat);
         } else {
             if ($lastError = $serviceProvier->getLastError(true)) {
                 \SystemLogger::warn("Error: {$lastError->getMessage()} TYPE: {$lastError->getType()}");
             }
             if ($lastError && !$lastError->isRateLimit()) {
                 break;
             }
         }
     }
     return null;
 }
 /**
  *
  * @param TheatreNearby $tnb
  * @return GeocodeCached
  *
  */
 public static function getGeocodeCached(TheatreNearby $tnb)
 {
     $queryWhere = new \DbTableWhere();
     $queryWhere->where('country_iso', $tnb->country_iso);
     if ($tnb->postal_code) {
         $queryWhere->where(new \DbTableFunction("REPLACE(postal_code, ' ', '')"), str_replace(' ', '', $tnb->postal_code));
     } else {
         $queryWhere->where('city', $tnb->city);
     }
     $key = $queryWhere->getWhereString();
     if (array_key_exists($key, self::$cachedGeocodes)) {
         return self::$cachedGeocodes[$key];
     } else {
         return self::$cachedGeocodes[$key] = GeocodeCached::manager()->getEntityWhere($queryWhere);
     }
 }