<commit_before><?php
/**
 * This file is part of the Juvem package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace AppBundle\Entity\Geo;

use AppBundle\Entity\Event;
use AppBundle\Manager\Geo\AddressAwareInterface;
use AppBundle\Manager\Geo\CoordinatesAwareInterface;
use AppBundle\Manager\Geo\OpenStreetMapElement;
use AppBundle\Manager\Geo\OpenStreetMapPlace;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity
 * @ORM\Table(name="location_description")
 * @ORM\Entity(repositoryClass="LocationDescriptionRepository")
 */
class LocationDescription implements AddressAwareInterface, CoordinatesAwareInterface
{
    
    /**
     * @ORM\Column(type="integer", name="element_id")
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Id
     * @var int
     */
    private $elementId;
    
    /**
     * OSM Id or null if not found
     *
     * @ORM\Column(type="integer", name="osm_id", nullable=true)
     *
     * @var int|null
     */
    private $osmId = null;
    
    /**
     * OSM type or null if not found
     *
     * @ORM\Column(type="string", name="osm_type", columnDefinition="ENUM('N', 'W', 'R')", nullable=true)
     *
     * @var string|null
     */
    private $osmType = null;
    
    /**
     * @ORM\Column(type="string", length=128, name="address_street_name", nullable=true)
     *
     * @var string|null
     */
    private $addressStreetName = null;
    
    /**
     * @ORM\Column(type="string", length=16, name="address_street_number", nullable=true)
     *
     * @var string|null
     */
    private $addressStreetNumber = null;
    
    /**
     * @ORM\Column(type="string", length=128, name="address_city", nullable=true)
     *
     * @var string|null
     */
    private $addressCity = null;
    
    /**
     * @ORM\Column(type="string", length=16, name="address_zip", nullable=true)
     *
     * @var string|null
     */
    private $addressZip = null;
    
    /**
     * Related country
     *
     * @ORM\Column(type="string", length=128, name="address_country", nullable=true)
     *
     * @var string|null
     */
    private $addressCountry = null;
    
    /**
     * Location latitude if already fetched
     *
     * @ORM\Column(name="latitude", type="decimal", precision=10, scale=8, nullable=true)
     *
     * @var null|float
     */
    private $locationLatitude = null;
    
    /**
     * Location longitude if already fetched
     *
     * @ORM\Column(name="longitude", type="decimal", precision=11, scale=8, nullable=true)
     *
     * @var null|float
     */
    private $locationLongitude = null;
    
    /**
     * Detailed fetched (if not null) OSM details about this place
     *
     * @ORM\Column(type="json_array", length=16777215, name="details", nullable=true)
     *
     * @var array|null
     */
    private $details = [];
    
    /**
     * Create by address
     *
     * @param AddressAwareInterface $address
     * @return LocationDescription
     */
    public static function createByAddress(AddressAwareInterface $address): LocationDescription
    {
        $item = new self();
        $item->setAddress(
            $address->getAddressStreetName(),
            (string)$address->getAddressStreetNumber(),
            $address->getAddressCity(),
            $address->getAddressZip(),
            $address->getAddressCountry()
        );
        return $item;
    }
    
    /**
     * Create object by address and coordinates
     *
     * @param AddressAwareInterface $address
     * @param CoordinatesAwareInterface $coordinates
     * @return LocationDescription
     */
    public static function createByAddressAndCoordinates(
        AddressAwareInterface $address,
        CoordinatesAwareInterface $coordinates
    ): LocationDescription
    {
        $item = self::createByAddress($address);
        $item->setLocation($coordinates->getLocationLatitude(), $coordinates->getLocationLongitude());
        return $item;
    }
    
    /**
     * Create object by address and OSM place<commit_msg>Preventing issue if no street name given<commit_after><?php
/**
 * This file is part of the Juvem package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace AppBundle\Entity\Geo;

use AppBundle\Entity\Event;
use AppBundle\Manager\Geo\AddressAwareInterface;
use AppBundle\Manager\Geo\CoordinatesAwareInterface;
use AppBundle\Manager\Geo\OpenStreetMapElement;
use AppBundle\Manager\Geo\OpenStreetMapPlace;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity
 * @ORM\Table(name="location_description")
 * @ORM\Entity(repositoryClass="LocationDescriptionRepository")
 */
class LocationDescription implements AddressAwareInterface, CoordinatesAwareInterface
{
    
    /**
     * @ORM\Column(type="integer", name="element_id")
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Id
     * @var int
     */
    private $elementId;
    
    /**
     * OSM Id or null if not found
     *
     * @ORM\Column(type="integer", name="osm_id", nullable=true)
     *
     * @var int|null
     */
    private $osmId = null;
    
    /**
     * OSM type or null if not found
     *
     * @ORM\Column(type="string", name="osm_type", columnDefinition="ENUM('N', 'W', 'R')", nullable=true)
     *
     * @var string|null
     */
    private $osmType = null;
    
    /**
     * @ORM\Column(type="string", length=128, name="address_street_name", nullable=true)
     *
     * @var string|null
     */
    private $addressStreetName = null;
    
    /**
     * @ORM\Column(type="string", length=16, name="address_street_number", nullable=true)
     *
     * @var string|null
     */
    private $addressStreetNumber = null;
    
    /**
     * @ORM\Column(type="string", length=128, name="address_city", nullable=true)
     *
     * @var string|null
     */
    private $addressCity = null;
    
    /**
     * @ORM\Column(type="string", length=16, name="address_zip", nullable=true)
     *
     * @var string|null
     */
    private $addressZip = null;
    
    /**
     * Related country
     *
     * @ORM\Column(type="string", length=128, name="address_country", nullable=true)
     *
     * @var string|null
     */
    private $addressCountry = null;
    
    /**
     * Location latitude if already fetched
     *
     * @ORM\Column(name="latitude", type="decimal", precision=10, scale=8, nullable=true)
     *
     * @var null|float
     */
    private $locationLatitude = null;
    
    /**
     * Location longitude if already fetched
     *
     * @ORM\Column(name="longitude", type="decimal", precision=11, scale=8, nullable=true)
     *
     * @var null|float
     */
    private $locationLongitude = null;
    
    /**
     * Detailed fetched (if not null) OSM details about this place
     *
     * @ORM\Column(type="json_array", length=16777215, name="details", nullable=true)
     *
     * @var array|null
     */
    private $details = [];
    
    /**
     * Create by address
     *
     * @param AddressAwareInterface $address
     * @return LocationDescription
     */
    public static function createByAddress(AddressAwareInterface $address): LocationDescription
    {
        $item = new self();
        $item->setAddress(
            (string)$address->getAddressStreetName(),
            (string)$address->getAddressStreetNumber(),
            $address->getAddressCity(),
            $address->getAddressZip(),
            $address->getAddressCountry()
        );
        return $item;
    }
    
    /**
     * Create object by address and coordinates
     *
     * @param AddressAwareInterface $address
     * @param CoordinatesAwareInterface $coordinates
     * @return LocationDescription
     */
    public static function createByAddressAndCoordinates(
        AddressAwareInterface $address,
        CoordinatesAwareInterface $coordinates
    ): LocationDescription
    {
        $item = self::createByAddress($address);
        $item->setLocation($coordinates->getLocationLatitude(), $coordinates->getLocationLongitude());
        return $item;
    }
    
    /**
     * Create object by address and OSM place
{'fraction_non_alphanumeric': 0.12922488952585692, 'fraction_numerical': 0.006449301325689717, 'mean_word_length': 2.6647702407002187, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '4434049', 'n_tokens_mistral': 2541, 'n_tokens_neox': 2480, 'n_words': 517}