Пример #1
0
 public function run()
 {
     $FoursquareClient = new \Foursquare\Client();
     $file_content = File::read(DOCROOT . 'data/NY.csv', true);
     $data = Format::forge($file_content, 'csv')->to_array();
     $valid_counties = array();
     $valid_counties[] = 'BRONX';
     $valid_counties[] = 'QUEENS';
     $valid_counties[] = 'KINGS';
     $valid_counties[] = 'NEW YORK';
     $valid_counties[] = 'RICHMOND';
     $i = 0;
     $j = 0;
     foreach ($data as $key => $value) {
         if (!in_array($value['County'], $valid_counties)) {
             continue;
         }
         $i++;
         if ($i > 300) {
             break;
         }
         $match = $FoursquareClient->getVenueMapping($value['Latitude'], $value['Longitude'], $value['Store_Name']);
         if ($this->hasMatches($match, &$j)) {
             $this->logMatches($value, $match, $matches, $j, $i);
             continue;
         }
         $this->CliOutput('write', 'Stripping chars from Store_Name: ' . $value['Store_Name']);
         // remove numbers from store name
         $value['Store_Name'] = trim(preg_replace("/[0-9]/", "", $value['Store_Name']));
         $match = $FoursquareClient->getVenueMapping($value['Latitude'], $value['Longitude'], $value['Store_Name']);
         if ($this->hasMatches($match, &$j)) {
             $this->logMatches($value, $match, $matches, $j, $i);
             continue;
         }
         $this->CliOutput('error', 'No match for ' . $value['Store_Name'] . ' ' . $value['Address'] . ' ' . $value['City'] . ' ' . $value['Zip5']);
     }
     $this->CliOutput('write', 'Matches: ' . $j . '/' . $i);
 }