예제 #1
0
 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();
 }
예제 #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();
 }
예제 #3
0
 private function _recreateLocationIndex()
 {
     CM_Model_Location::createAggregation();
     $searchIndexCli = new CM_Elasticsearch_Index_Cli();
     $searchIndexCli->create((new CM_Elasticsearch_Type_Location($this->_elasticsearchClient))->getIndexName());
 }
예제 #4
0
파일: MaxMind.php 프로젝트: cargomedia/cm
 protected function _updateSearchIndex()
 {
     CM_Model_Location::createAggregation();
     while (CM_Model_Location::getCreateAggregationInProgress($this->getServiceManager()->getDatabases()->getReadMaintenance())) {
         sleep(1);
     }
     $client = $this->getServiceManager()->getElasticsearch()->getClient();
     $type = new CM_Elasticsearch_Type_Location($client);
     $searchIndexCli = new CM_Elasticsearch_Index_Cli(null, $this->_streamOutput, $this->_streamError);
     $searchIndexCli->create($type->getIndexName());
 }
예제 #5
0
파일: TH.php 프로젝트: aladin1394/CM
 /**
  * @param int|null $level
  * @return CM_Model_Location
  */
 public static function createLocation($level = null)
 {
     $country = CM_Db_Db::insert('cm_model_location_country', array('abbreviation' => 'FOO', 'name' => 'countryFoo'));
     $state = CM_Db_Db::insert('cm_model_location_state', array('countryId' => $country, 'name' => 'stateFoo'));
     $city = CM_Db_Db::insert('cm_model_location_city', array('stateId' => $state, 'countryId' => $country, 'name' => 'cityFoo', 'lat' => 10, 'lon' => 15));
     $zip = CM_Db_Db::insert('cm_model_location_zip', array('cityId' => $city, 'name' => '1000', 'lat' => 10, 'lon' => 15));
     CM_Model_Location::createAggregation();
     switch ($level) {
         case CM_Model_Location::LEVEL_COUNTRY:
             return new CM_Model_Location(CM_Model_Location::LEVEL_COUNTRY, $country);
         case CM_Model_Location::LEVEL_CITY:
             return new CM_Model_Location(CM_Model_Location::LEVEL_CITY, $city);
         case CM_Model_Location::LEVEL_STATE:
             return new CM_Model_Location(CM_Model_Location::LEVEL_STATE, $state);
         default:
             return new CM_Model_Location(CM_Model_Location::LEVEL_ZIP, $zip);
     }
 }
예제 #6
0
 public function testFindByCoordinates()
 {
     CM_Db_Db::insert('cm_model_location_city', array('stateId' => self::$_fields[CM_Model_Location::LEVEL_STATE]['id'], 'countryId' => self::$_fields[CM_Model_Location::LEVEL_COUNTRY]['id'], 'name' => 'test', 'lat' => 20, 'lon' => 20));
     $idExpected1 = CM_Db_Db::insert('cm_model_location_city', array('stateId' => self::$_fields[CM_Model_Location::LEVEL_STATE]['id'], 'countryId' => self::$_fields[CM_Model_Location::LEVEL_COUNTRY]['id'], 'name' => 'test', 'lat' => 20.1, 'lon' => 20.2));
     $idExpected2 = CM_Db_Db::insert('cm_model_location_city', array('stateId' => self::$_fields[CM_Model_Location::LEVEL_STATE]['id'], 'countryId' => self::$_fields[CM_Model_Location::LEVEL_COUNTRY]['id'], 'name' => 'Waite Park', 'lat' => 45.53, 'lon' => -94.233));
     $locationExpected1 = new CM_Model_Location(CM_Model_Location::LEVEL_CITY, $idExpected1);
     $locationExpected2 = new CM_Model_Location(CM_Model_Location::LEVEL_CITY, $idExpected2);
     CM_Model_Location::createAggregation();
     $this->assertNull(CM_Model_Location::findByCoordinates(100, 100));
     $this->assertEquals($locationExpected1, CM_Model_Location::findByCoordinates(20, 20.3));
     $this->assertEquals($locationExpected2, CM_Model_Location::findByCoordinates(45.552222998855, -94.21451630079601));
 }
예제 #7
0
파일: 32.php 프로젝트: cargomedia/cm
<?php

CM_Model_Location::createAggregation();
$searchCli = new CM_Elasticsearch_Index_Cli(null, new CM_OutputStream_Stream_Output());
$searchCli->create('location');
예제 #8
0
 protected function _updateSearchIndex()
 {
     CM_Model_Location::createAggregation();
     $type = new CM_Elasticsearch_Type_Location();
     $searchIndexCli = new CM_Elasticsearch_Index_Cli(null, $this->_streamOutput, $this->_streamError);
     $searchIndexCli->create($type->getIndex()->getName());
 }