Giter Site home page Giter Site logo

nevadskiy / laravel-geonames Goto Github PK

View Code? Open in Web Editor NEW
16.0 2.0 5.0 978 KB

🌎 Populate your database using the GeoNames service.

License: MIT License

PHP 97.23% Dockerfile 1.68% Makefile 1.09%
geonames geo countries cities laravel address location

laravel-geonames's People

Contributors

dependabot[bot] avatar maicommr avatar nevadskiy avatar tinusg avatar xmk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

laravel-geonames's Issues

php artisan geonames:insert --reset с ошибкой из-за ключей

При запуске команды
php artisan geonames:insert --reset

  • ошибка, невозможно очистить таблицу из-за ограничения ключей

Решение временно отключаем проверку ключей
в файле InsertCommand добавить
public function handle() {
Schema::disableForeignKeyConstraints();
.....
Schema::enableForeignKeyConstraints();
}

при добавлении России в таблице countries поле area(double(10, 2)) не достаточно, не помещается значение
увеличить поле area(double(12, 2))

Adding more Geonames Feature codes

Hi there,

I'm using your fantastic package and would like to ask you for adding (or pointing out if there is already some possible solution without changing the package) more Geonames Feature codes. Currently the package supports codes like these:

  • PPL
  • PPL...
  • ADM1
  • ADM2

However, I need also support for other codes like:

  • PARK
  • MT
  • HLL

More listed here: http://www.geonames.org/export/codes.html ↗

I have tried to extend CitySeeder (adding new codes into array $featureCodes), but it does not seem work even with updated filter method.

My code from /database/seeders/Geo/CitySeeder.php:

<?php

namespace Database\Seeders\Geo;

use App\Models\Geo\City;
use Illuminate\Database\Eloquent\Model;
use Nevadskiy\Geonames\Seeders\CitySeeder as Seeder;

class CitySeeder extends Seeder
{
    protected static $model = City::class;

    protected $minPopulation = 5000;

    /**
     * The allowed feature codes.
     *
     * @var array
     */
    protected $featureCodes = [
        FeatureCode::PPL,
        FeatureCode::PPLC,
        FeatureCode::PPLA,
        FeatureCode::PPLA2,
        FeatureCode::PPLA3,
        FeatureCode::PPLS,
        FeatureCode::MT,
        FeatureCode::HLL,
    ];

    /**
     * Get a new country model instance.
     */
    protected function newCountryModel(): Model
    {
        return CountrySeeder::newModel();
    }

    /**
     * Get a new division model instance.
     */
    protected function newDivisionModel(): Model
    {
        return DivisionSeeder::newModel();
    }

    protected function filter(array $record): bool
    {
        // Change filter to accept also hills and mountains
        if (
            // cities above given minPopulation
            (
                in_array($record['feature code'], $this->featureCodes, true)
                &&
                strpos($record['feature code'], 'PPL') !== false
                &&
                $record['population'] >= $this->minPopulation
            )
            ||
            // or mountains and hills - minPopulation is irelevant
            in_array($record['feature code'], ['MT', 'HLL'])
        ) {
            return true;
        } else {
            return false;
        }
    }
}

Adding support for more Feature codes would make this package even more useful and flexible.

Thank you for creating and maintaining this great package.

Wishes,
Pavel

Country Capital

В странах столица хранится в бд в виде строки, может было бы правильнее и удобнее хранить ее в виде связи с объектом города?

Error with geonames:seed

Hi there, thank you for the work on this package first of all.

It was smooth sailing when I was developing with this package locally. Everything seems to work great there.
When I pushed my code to a testing environment however, I'm getting the following error after running geonames;seed:

In Container.php line 1126:

  Target [Symfony\Component\Console\Input\InputInterface] is not instantiable
   while building [Nevadskiy\Geonames\Console\GeonamesSeedCommand, Database\S
  eeders\Geo\ContinentSeeder, Nevadskiy\Geonames\GeonamesSource, Nevadskiy\Ge
  onames\GeonamesDownloader, Illuminate\Console\OutputStyle].

FYI: I have overrided the default seeders by publishing the package seeders, though I've only changed the $minPopulation variable.
Tried manually adding the InputInterface to my serviceprovider but that didn't help at all.

SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'elevation' at row 521

Tried seeding and keep getting error above. Changed the model etc to be bigint and still giving issues.

"SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'elevation' at row 521"

Seems this entry, 5 column is elevation is stopping the insert, which is confusing since 1868 isn't bug
(130, 2022-08-31 19:08:21, 1868, 1745, 1868, PPL, 1232783, 6.97078, 80.78286, Nuwara Eliya, 27500, Asia/Colombo, 2022-01-10 00:00:00)

and then row 521 is

(119, 2022-08-31 19:08:16, -9999, 1619, ?, PPL, 1091117, -12.15667, 44.40806, Mirontsi, 10168, Indian/Comoro, 2020-06-14 00:00:00),

Timezone ID

Сейчас на всех объектах timezone указан строковым идентификатором (Europe\Moscow).
Я считаю что правильнее было бы собрать все timezones в отдельную таблицу и создать связи со всеми объектами по внутреннему ID.
Как считаешь?

nevadskiy/downloader dependency problem

Hello, I hope u r doing well,

Trying to install on Laravel 9.1,

composer require nevadskiy/laravel-geonames

I am getting the following error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - nevadskiy/downloader 0.3.0 requires psr/log ^1.1 -> found psr/log[1.1.0, ..., 1.1.4] but the package is fixed to 3.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - nevadskiy/laravel-geonames 0.4.2 requires nevadskiy/downloader 0.3.0 -> satisfiable by nevadskiy/downloader[0.3.0].
    - Root composer.json requires nevadskiy/laravel-geonames ^0.4.2 -> satisfiable by nevadskiy/laravel-geonames[0.4.2].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require nevadskiy/laravel-geonames:*" to figure out if any version is installable, or "composer require nevadskiy/laravel-geonames:^2.1" if you know which you need.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.