public static function setUpBeforeClass()
 {
     $country1 = CM_Model_Location_Country::create('Andorra', 'AD');
     $state1 = CM_Model_Location_State::create($country1, 'Canillo', null, 'AD02');
     $state2 = CM_Model_Location_State::create($country1, 'Encamp', null, 'AD03');
     $state3 = CM_Model_Location_State::create($country1, 'La Massana', null, 'AD04');
     $city = CM_Model_Location_City::create($country1, $state1, 'Canillo', '42.567', '1.6', '146765');
     $cityNext = CM_Model_Location_City::create($country1, $state1, 'El Tarter', '42.583', '1.65', '211022');
     CM_Model_Location_City::create($country1, $state1, 'Meritxell', '42.55', '1.6', '230839');
     CM_Model_Location_City::create($country1, $state1, 'Pas De La Casa', '42.55', '1.733', '177897');
     CM_Model_Location_City::create($country1, $state1, 'Soldeu', '42.583', '1.667', '177181');
     CM_Model_Location_City::create($country1, $state2, 'Encamp', '42.533', '1.583', '58282');
     CM_Model_Location_City::create($country1, $state3, 'Arinsal', '42.567', '1.483', '209956');
     CM_Model_Location_City::create($country1, $state3, 'El Serrat', '42.617', '1.55', '209961');
     $country2 = CM_Model_Location_Country::create('Australia', 'AU');
     $state4 = CM_Model_Location_State::create($country2, 'Queensland', null, 'AU04');
     $state5 = CM_Model_Location_State::create($country2, 'Victoria', null, 'AU07');
     $state6 = CM_Model_Location_State::create($country2, 'Tasmania', null, 'AU06');
     CM_Model_Location_City::create($country2, $state4, 'Abermain', '-27.567', '152.783', '33924');
     CM_Model_Location_City::create($country2, $state5, 'Acheron', '-37.25', '145.7', '195676');
     CM_Model_Location_City::create($country2, $state6, 'Baden', '-42.433', '147.467', '242082');
     CM_Model_Location::createAggregation();
     CMTest_TH::getServiceManager()->getElasticsearch()->setEnabled(true);
     self::$_type = new CM_Elasticsearch_Type_Location();
     self::$_searchIndexCli = new CM_Elasticsearch_Index_Cli();
     self::$_searchIndexCli->create(self::$_type->getIndex()->getName());
     self::$_countryId1 = $country1->getId();
     self::$_countryId2 = $country2->getId();
     self::$_stateId1 = $state1->getId();
     self::$_stateId4 = $state4->getId();
     self::$_cityId = $city->getId();
     self::$_cityIdNext = $cityNext->getId();
 }
Exemple #2
0
 public static function setUpBeforeClass()
 {
     $country = CM_Model_Location_Country::create('Andorra', 'AD');
     $state1 = CM_Model_Location_State::create($country, 'Canillo', null, 'AD02');
     $state2 = CM_Model_Location_State::create($country, 'Encamp', null, 'AD03');
     $state3 = CM_Model_Location_State::create($country, 'La Massana', null, 'AD04');
     $city = CM_Model_Location_City::create($country, $state1, 'Canillo', '42.567', '1.6', '146765');
     CM_Model_Location_City::create($country, $state1, 'El Tarter', '42.583', '1.65', '211022');
     CM_Model_Location_City::create($country, $state1, 'Meritxell', '42.55', '1.6', '230839');
     CM_Model_Location_City::create($country, $state1, 'Pas De La Casa', '42.55', '1.733', '177897');
     CM_Model_Location_City::create($country, $state1, 'Soldeu', '42.583', '1.667', '177181');
     CM_Model_Location_City::create($country, $state2, 'Encamp', '42.533', '1.583', '58282');
     CM_Model_Location_City::create($country, $state3, 'Arinsal', '42.567', '1.483', '209956');
     CM_Model_Location_City::create($country, $state3, 'El Serrat', '42.617', '1.55', '209961');
     CM_Model_Location::createAggregation();
     CMTest_TH::getServiceManager()->getElasticsearch()->setEnabled(true);
     self::$_type = new CM_Elasticsearch_Type_Location();
     self::$_searchIndexCli = new CM_Elasticsearch_Index_Cli();
     self::$_searchIndexCli->create(self::$_type->getIndex()->getName());
     self::$_cityId = $city->getId();
 }
Exemple #3
0
 /**
  * @param CM_Model_Location $parentLocation
  * @param string            $name
  * @param float             $latitude
  * @param float             $longitude
  * @param string|null       $_maxmind
  * @throws CM_Exception_Invalid
  * @return CM_Model_Location
  */
 public static function createCity(CM_Model_Location $parentLocation, $name, $latitude, $longitude, $_maxmind = null)
 {
     if (CM_Model_Location::LEVEL_STATE !== $parentLocation->getLevel() && CM_Model_Location::LEVEL_COUNTRY !== $parentLocation->getLevel()) {
         throw new CM_Exception_Invalid('The parent location should be a state or a country');
     }
     $state = $parentLocation->_getLocation(self::LEVEL_STATE);
     $country = $parentLocation->_getLocation(self::LEVEL_COUNTRY);
     $city = CM_Model_Location_City::create($country, $state, $name, $latitude, $longitude, $_maxmind);
     return self::fromLocation($city);
 }