<commit_before><?php
/**
 * @filesource
 * @copyright (c) 2013 - 2017 Cross Solution (http://cross-solution.de)
 * @license MIT
 * @author <NAME> <<EMAIL>>
 * @since 0.30
 */
namespace SimpleImport\Job;

use Geo\Entity\Geometry\Point;
use Geocoder\Geocoder;
use Geocoder\Model\Address;
use Jobs\Entity\Location;
use Exception;

class GeocodeLocation
{
    
    /**
     * @var Geocoder
     */
    private $geocoder;
    
    /**
     * @param Geocoder $geocoder
     */
    public function __construct(Geocoder $geocoder)
    {
        $this->geocoder = $geocoder;
    }
    
    /**
     * @param string $address
     * @return Location[] Job locations
     */
    public function getLocations($address)
    {
        $locations = [];
        
        try {
            $addresses = $this->geocoder->geocode($address);
        } catch (Exception $e) {
            return $locations;
        }
        
        /** @var \Geocoder\Model\Address $address */
        foreach ($addresses as $address) {
            $locations[] = $this->createLocationFromAddress($address);
        }
        
        return $locations;
    }
    
    /**
     * @param Address $address
     * @return Location
     */
    private function createLocationFromAddress(Address $address)
    {
        $location = new Location();
        
        $country = $address->getCountry();
        
        if ($country) {
            $location->setCountry($country->getName());
        }
        
        $city = $address->getLocality();
        
        if ($city) {
            $location->setCity($city);
        }
        
        $postalCode = $address->getPostalCode();
        
        if ($postalCode) {
            $location->setPostalCode($postalCode);
        }
        
        $region = $address->getAdminLevels()->first();
        
        if ($region) {
            $location->setRegion($region->getName());
        }
        
        $coordinates = $address->getCoordinates();
        
        if ($coordinates) {
            $point = new Point([$coordinates->getLatitude(), $coordinates->getLongitude()]);
            $location->setCoordinates($point);
        }
        
        return $location;
    }<commit_msg>list the longitude first and then latitude<commit_after><?php
/**
 * @filesource
 * @copyright (c) 2013 - 2017 Cross Solution (http://cross-solution.de)
 * @license MIT
 * @author <NAME> <<EMAIL>>
 * @since 0.30
 */
namespace SimpleImport\Job;

use Geo\Entity\Geometry\Point;
use Geocoder\Geocoder;
use Geocoder\Model\Address;
use Jobs\Entity\Location;
use Exception;

class GeocodeLocation
{
    
    /**
     * @var Geocoder
     */
    private $geocoder;
    
    /**
     * @param Geocoder $geocoder
     */
    public function __construct(Geocoder $geocoder)
    {
        $this->geocoder = $geocoder;
    }
    
    /**
     * @param string $address
     * @return Location[] Job locations
     */
    public function getLocations($address)
    {
        $locations = [];
        
        try {
            $addresses = $this->geocoder->geocode($address);
        } catch (Exception $e) {
            return $locations;
        }
        
        /** @var \Geocoder\Model\Address $address */
        foreach ($addresses as $address) {
            $locations[] = $this->createLocationFromAddress($address);
        }
        
        return $locations;
    }
    
    /**
     * @param Address $address
     * @return Location
     */
    private function createLocationFromAddress(Address $address)
    {
        $location = new Location();
        
        $country = $address->getCountry();
        
        if ($country) {
            $location->setCountry($country->getName());
        }
        
        $city = $address->getLocality();
        
        if ($city) {
            $location->setCity($city);
        }
        
        $postalCode = $address->getPostalCode();
        
        if ($postalCode) {
            $location->setPostalCode($postalCode);
        }
        
        $region = $address->getAdminLevels()->first();
        
        if ($region) {
            $location->setRegion($region->getName());
        }
        
        $coordinates = $address->getCoordinates();
        
        if ($coordinates) {
            $point = new Point([$coordinates->getLongitude(), $coordinates->getLatitude()]);
            $location->setCoordinates($point);
        }
        
        return $location;
    }
{'fraction_non_alphanumeric': 0.13727703770602845, 'fraction_numerical': 0.004967261232783924, 'mean_word_length': 1.7601246105919004, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3487700', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1261, 'n_words': 238}