Giter Club home page Giter Club logo

geonames's People

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

geonames's Issues

laravel geonames:install

When i try and install i get

The database connection name was set to: mysql
Testing database connection...
Undefined offset: 1001

"violation: 1071 Specified key was too long"

Hi!
I'm trying to install your package and I am getting stuck on the migration.
I have tried the appservice provider fix

use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;


class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Schema::defaultStringLength(191);
    }
}

Ive even tried changing the database engine to innodb

'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => 'InnoDB',
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

I was hoping maybe you might have an idea?

vue-element-example not in Views

The file vue-element-example referenced at

Route::get( '/geonames/examples/vue/element/autocomplete', function () {
return view( 'geonames::vue-element-example' );
} );

not exists

Laravel version 10

Hi
I've tried to install the package on a Larvel 10 project but it fails

Could you please consider making it compatible with Larvel 10?

Thanks!

Inserting language codes issue

Seems like a path issue. Any workarounds?

I'm doing
php artisan geonames:install

Same if it try only for 1 country.

Downloading iso-languagecodes.txt 131720/131720 [============================] 100% Inserting via LOAD DATA INFILE: C:\xampp\htdocs\xxx\storage\geonames\iso-languagecodes.txt SQLSTATE[HY000]: General error: 7890 Can't find file 'C:xampphtdocsxxxstoragegeonamesiso-languagecodes.txt'.
PS: the file exists in the given directory

Add an index

alternate_name should have its index. Maybe with isPreferredName ?
Usefull if we want to propose cities from a postcode. (Postcodes are stored in alternate_name of table geonames_alternate_names)

Invalid utf8 character string

I'm getting error as following when I execute php artisan geonames:install --country=TR --country=US

File: /home/forge/app/storage/geonames/TR.txt

Combining TR.txt 10669811/10669811 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
File: /home/forge/app/storage/geonames/US.txt

Combining US.txt 302388147/302388147 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Num Lines: 2323203

Starting to insert the records found in /home/forge/app/storage/geonames/master.txt
We are going to try to insert 2323202 geoname records.
Dropping the temp table named geonames_working (if it exists).
Creating the temp table named geonames_working
Running the LOAD DATA INFILE query...
SQLSTATE[HY000]: General error: 1300 Invalid utf8 character string: ''Iowa,Aioua,Aiova,Ajov,Ajova,Ajovae,Ajovo,Ayova,Ayowa,Hawkeye St'

backslash problem

Hi,
Great plugin....

I found a problem after running this command:

php artisan geonames:install --country=CR --language=en

It fails at some point with this:

Inserting via LOAD DATA INFILE: D:\Web Development\laravel\timezonedb\storage\geonames\iso-languagecodes.txt
SQLSTATE[HY000]: General error: 7890 Can't find file 'D:Web Developmentlaravel  imezonedbstoragegeonamesiso-languagecod'.

I am developing on my Windows computer, so path file has backslash, these causes problems while running the following query:

$query = "LOAD DATA LOCAL INFILE '" . $localFilePath . "'
    INTO TABLE " . self::TABLE_WORKING . " IGNORE 1 LINES
        (   iso_639_3, 
            iso_639_2,
            iso_639_1, 
            language_name,          
            @created_at, 
            @updated_at)
    SET created_at=NOW(),updated_at=null";

I fixed it by adding the following line

$localFilePath = str_replace("\\", "\/", $localFilePath); <<<!! 
        $query = "LOAD DATA LOCAL INFILE '" . $localFilePath . "'......

Will not install on laravel 6.4

`Problem 1
- Conclusion: remove laravel/framework v6.4.0
- Conclusion: don't install laravel/framework v6.4.0
- michaeldrennen/geonames v2.0.0 requires illuminate/routing ^5.8 -> satisfiable by laravel/framework[5.8.x-dev], illuminate/routing[5.8.x-dev, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5
.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.4, v5.8.8, v5.8.9].
- michaeldrennen/geonames v2.0.1 requires illuminate/routing ^5.8 -> satisfiable by laravel/framework[5.8.x-dev], illuminate/routing[5.8.x-dev, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5
.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.4, v5.8.8, v5.8.9].
- michaeldrennen/geonames v2.0.2 requires laravel/framework ^5.8 -> satisfiable by laravel/framework[5.8.x-dev].
- michaeldrennen/geonames v2.x-dev requires illuminate/routing ^5.8 -> satisfiable by laravel/framework[5.8.x-dev], illuminate/routing[5.8.x-dev, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27,
v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.4, v5.8.8, v5.8.9].
- Can only install one of: laravel/framework[5.8.x-dev, v6.4.0].
- don't install illuminate/routing 5.8.x-dev|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.0|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.11|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.12|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.14|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.15|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.17|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.18|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.19|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.2|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.20|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.22|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.24|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.27|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.28|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.29|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.3|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.30|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.31|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.32|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.33|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.34|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.35|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.4|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.8|don't install laravel/framework v6.4.0
- don't install illuminate/routing v5.8.9|don't install laravel/framework v6.4.0
- Installation request for laravel/framework (locked at v6.4.0, required as ^6.2) -> satisfiable by laravel/framework[v6.4.0].
- Installation request for michaeldrennen/geonames ^2.0 -> satisfiable by michaeldrennen/geonames[v2.0.0, v2.0.1, v2.0.2, v2.x-dev].

Installation failed, reverting ./composer.json to its original content.
`

checkDatabase() failed

I had a strange error:

First I installed the package, then i had run migrations, so migration succeeded, a have all tables in my DB, but when i run php artisan geonames:install this error occurs:

checkDatabase() failed: Make sure you have this line added to your database connection config in the /config/database.php in your project: 'options' => [\PDO::MYSQL_ATTR_LOCAL_INFILE => true,]

Thnx for any idea!

laravel 9

Hi, will this work with L9? If so, could you bump the composer? Many thanks!

geonames:install doesn't pass through database connection to all subsequent calls

Command: php artisan geonames:install --connection=geonames --country=US --language=en

Output:

The database connection name was set to: geonames
Testing database connection...
Confirmed database connection set up correctly.
GeoSetting::install() called on connection: geonames
...
alternate_names data was downloaded and inserted in 1393.3221490383 seconds.
Running the geonames:geoname artisan command in live mode.
Running geonames:download-geonames on database connection: mysql
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.geonames_settings' doesn't exist (SQL: select * from `geonames_settings` limit 1)

However, running php artisan geonames:install --connection=geonames --test does work.

Nothing to migrate?

Hi,
I have followed all the steps to install the package in laravel. But on migration step it is saying "Nothing to migrate.". Please help.

geonames:update-geonames

When i run this command i received this error:
Undefined property: MichaelDrennen\Geonames\Console\UpdateGeonames::$storageDir (UpdateGeonames.php:255)

Not working on latest Laravel 5.6 version

Problem 1
    - The requested package phpunit/phpunit (locked at 6.5.6, required as ~7.0) is satisfiable by phpunit/phpunit[6.5.6] but these conflict with your requirements or minimum-stability.
  Problem 2
    - Installation request for michaeldrennen/geonames ^1.0 -> satisfiable by michaeldrennen/geonames[v1.0.0].
    - michaeldrennen/geonames v1.0.0 requires ext-intl * -> the requested PHP extension intl is missing from your system.
  Problem 3
    - Installation request for sebastian/diff (locked at 2.0.1) -> satisfiable by sebastian/diff[2.0.1].
    - phpunit/phpunit 7.0.0 requires sebastian/diff ^3.0 -> satisfiable by sebastian/diff[3.0.0].
    - phpunit/phpunit 7.0.1 requires sebastian/diff ^3.0 -> satisfiable by sebastian/diff[3.0.0].
    - phpunit/phpunit 7.0.2 requires sebastian/diff ^3.0 -> satisfiable by sebastian/diff[3.0.0].
    - Conclusion: don't install sebastian/diff 3.0.0
    - Installation request for phpunit/phpunit ~7.0 -> satisfiable by phpunit/phpunit[7.0.0, 7.0.1, 7.0.2].

PostgreSQL support

Current DB queries

DB::statement('CREATE TABLE ' . self::TABLE_WORKING . ' LIKE ' . self::TABLE . ';');

are not supported by PostgreSQL.
Throws error.

primaryKey issue

$primaryKey parameter should be set to geonameid on Admin1Code and Admin2Code models

Postcode issue

Firstly, thank you for this package. It's very good.

I need to use the geoname API to do searches by postcode and suburb, for now, just for Australia. It's possible doit with the current version of this package?

I ask because I don't see the postcode/placeName in the database. When I found them?

Thanks

Error when running route:cache

./artisan route:cache
gives that result :

Route cache cleared!

In Route.php line 917:
Unable to prepare route [geonames/examples/vue/element/autocomplete] for serialization. Uses Closure```

Misuse of env

When config cache is enabled calling env('DB_GEONAMES_CONNECTION') returns null.

We better use config('geonames.connection')

Problems with backslash (Windows, DIRECTORY_SEPARATOR)

It seems like this problem is still here: #18
PHP constant DIRECTORY_SEPARATOR on Windows system is backslash: "\"
On MySQL query running it make a troubles:

# php.exe artisan geonames:install --country=EN --language=en
.............................................................
Inserting via LOAD DATA INFILE: D:\OpenServer\domains\project\storage\geonames\iso-languagecodes.txt
SQLSTATE[HY000]: General error: 7890 Can't find file 'D:OpenServerdomainsprojectstoragegeonamesiso-languagecodes'.
PDO::exec("LOAD DATA LOCAL INFILE 'D:\OpenServer\domains\project\storage\geonames\iso-languagecodes.txt'
    INTO TABLE geonames_iso_language_codes_working IGNORE 1 LINES
        (   iso_639_3,
            iso_639_2,
            iso_639_1,
            language_name,
            @created_at,
            @updated_at)
    SET created_at=NOW(),updated_at=null")

Missing indexes

geonames_admin_1_codes - geonameid -> primary
geonames_admin_1_codes - country_code -> index
geonames_admin_1_codes - admin1_code -> index

geonames_admin_2_codes - geonamieid -> primary
geonames_admin_2_codes - country_code -> index
geonames_admin_2_codes - admin1_code -> index
geonames_admin_2_codes - admin2_code -> index
geonames_admin_2_codes - country_code, admin1_code -> index

Zipcodes

Hi, I noticed that zipcodes table comes empty, is there a way i can force to get zipcodes too, or do i have to implement the zipcodes data download?

Geonames update - file exists check should be dir exists check

It seems commit 1caf30d#diff-4ff216f810727b4379e6b093f6d5c5a7 is breaking the geonames:update command.

The lines added here check whether the file exists and is writeable, before doing a write to this file.
IMO, this should be a directory check, not a check on the file.

Is this correct?

Error stack trace:

/www # php artisan geonames:update --connection=mysql
The database connection name was set to: mysql
Testing database connection...
Confirmed database connection set up correctly.
Starting geonames:update-geonames
    {--connection= : If you want to specify the name of the database connection you want used.}
Downloading the modifications file from geonames.org
Downloaded http://download.geonames.org/export/dump/modifications-2019-06-28.txt

   Exception  : You need to create a directory at: /www/storage/geonames/modifications-2019-06-28.txt

  at /www/vendor/michaeldrennen/geonames/src/Console/UpdateGeonames.php:317
    313|         $localFilePath = GeoSetting::getAbsoluteLocalStoragePath( $this->connectionName ) . DIRECTORY_SEPARATOR . $this->modificationsTxtFileName;
    314|
    315|         // Determine if the local storage path exists and is writable.
    316|         if ( FALSE === file_exists( $localFilePath ) ):
  > 317|             throw new \Exception( "You need to create a directory at: " . $localFilePath );
    318|         endif;
    319|
    320|         if ( FALSE === is_writable( $localFilePath ) ):
    321|             throw new \Exception( "This directory needs to be writable: " . $localFilePath );

  Exception trace:

  1   MichaelDrennen\Geonames\Console\UpdateGeonames::saveRemoteModificationsFile()
      /www/vendor/michaeldrennen/geonames/src/Console/UpdateGeonames.php:138

  2   MichaelDrennen\Geonames\Console\UpdateGeonames::handle()
      /www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32

  Please use the argument -v to see more details.

MyISAM table engine ?

Hello @michaeldrennen ,

Thank you for your great package.
I'm astonished that the table engines are in MyISAM, is there any blocking problem to use InnoDB instead ?

Regards

Laravel 7 not supporting

Hello Michael and thank you for your contribution!
Will be any updates about latest Laravel?

Log file:
Problem 1
- Conclusion: remove laravel/framework v7.9.2
- Conclusion: don't install laravel/framework v7.9.2
- michaeldrennen/geonames v3.0.0 requires illuminate/database ^6.8 -> satisfiable by laravel/framework[6.x-dev], illuminate/database[6.x-dev, v6.10.0, v6.11.0, v6.12.0, v6.13.0, v6.13.1, v6.14.0, v6.15.0, v6.15.1, v6.16.0, v6.17.0, v6.17.1, v6.18.0, v6.18.1, v6.18.10, v6.18.11, v6.18.2, v6.18.3, v6.18.4, v6.18.5, v6.18.6, v6.18.7, v6.18.8, v6.18.9, v6.8.0].
- michaeldrennen/geonames v3.0.1 requires illuminate/database ^6.8 -> satisfiable by laravel/framework[6.x-dev], illuminate/database[6.x-dev, v6.10.0, v6.11.0, v6.12.0, v6.13.0, v6.13.1, v6.14.0, v6.15.0, v6.15.1, v6.16.0, v6.17.0, v6.17.1, v6.18.0, v6.18.1, v6.18.10, v6.18.11, v6.18.2, v6.18.3, v6.18.4, v6.18.5, v6.18.6, v6.18.7, v6.18.8, v6.18.9, v6.8.0].
- Can only install one of: laravel/framework[6.x-dev, v7.9.2].
- don't install illuminate/database 6.x-dev|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.10.0|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.11.0|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.12.0|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.13.0|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.13.1|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.14.0|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.15.0|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.15.1|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.16.0|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.17.0|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.17.1|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.18.0|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.18.1|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.18.10|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.18.11|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.18.2|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.18.3|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.18.4|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.18.5|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.18.6|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.18.7|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.18.8|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.18.9|don't install laravel/framework v7.9.2
- don't install illuminate/database v6.8.0|don't install laravel/framework v7.9.2
- Installation request for laravel/framework (locked at v7.9.2, required as ^7.0) -> satisfiable by laravel/framework[v7.9.2].
- Installation request for michaeldrennen/geonames ^3.0 -> satisfiable by michaeldrennen/geonames[v3.0.0, v3.0.1].

mmap() failed: [12] Cannot allocate memory

Running, "php artisan geonames:install" on a homestead installations eventually runs out of memory. PHP memory usage increases until all available memory is consumed. Not sure is this a system configuration issue or an issue with the alternate names command.

Split file #289 of 2583 has 5000 rows.
Inserting alternate names 1359/5000 [▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░]  27%

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory
PHP Fatal error:  Out of memory (allocated 4495486976) (tried to allocate 16384 bytes) in /vagrant/dr-services/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 330

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory
PHP Fatal error:  Out of memory (allocated 4495486976) (tried to allocate 65536 bytes) in /vagrant/dr-services/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php on line 18

setDatabaseConnectionName() failed:

Hi,
When I try to run php artisan geonames:install I get the following error

 Exception  : setDatabaseConnectionName() failed: There was no connection name passed into the artisan command, and I couldn't find the default connection name from the .env file. You need to have one or the other.

  at /Users/chrisgrim/code/ei/vendor/michaeldrennen/geonames/src/Console/GeonamesConsoleTrait.php:66
    62|         $connectionNameOption = $this->option( 'connection' );//...
    63|         if ( empty( $connectionNameOption ) ):
    64|             $defaultEnvironmentConnectionName = env( 'DB_CONNECTION' );
    65|             if ( empty( $defaultEnvironmentConnectionName ) ) {
  > 66|                 throw new Exception( "setDatabaseConnectionName() failed: There was no connection name passed into the artisan command, and I couldn't find the default connection name from the .env file. You need to have one or the other." );
    67|             }
    68|             $this->connectionName = $defaultEnvironmentConnectionName;
    69|         else:
    70|             $this->connectionName = $connectionNameOption;

  Exception trace:

  1   MichaelDrennen\Geonames\Console\Install::setDatabaseConnectionName()
      /Users/chrisgrim/code/ei/vendor/michaeldrennen/geonames/src/Console/Install.php:63

  2   MichaelDrennen\Geonames\Console\Install::handle()
      /Users/chrisgrim/code/ei/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32

Did I miss something in the setup?
I am able to add data to my database from my app so my .env file is setup correctly.

PHP requirement mismatch with Laravel

Hello !
I tried to install this package with composer require michaeldrennen/geonames unfortunately I got a similar message as #28
So I tried with composer require michaeldrennen/geonames:^7.0 and got:

[InvalidArgumentException]
Package michaeldrennen/geonames at version ^7.0 has a PHP requirement incompatible with your PHP version (7.2.32)

Laravel 7.x (7.19.1 in my case) has PHP ^7.2.5 required.
Should'n't your package requirement match the Laravel one ?

I've managed to install it with composer require michaeldrennen/geonames:^7.0 --ignore-platform-reqs but I'm scared it will mess something up 😨

Thanks for your work 🎉

Question - Is it possible to add countries without deleting existing ones ?

First of all, thank you for this package that makes life easier!

My question is in the title: Is it possible to add countries without deleting existing ones ?

I've already installed US and Canada records
php artisan geonames:install --country=US --country=CA
and I'd like to add Brazil without reinstalling US and Canada
php artisan geonames:install --country=US --country=CA --country=BR
php artisan geonames:add --country=BR equivalent?

Foreign keys

I was just thinking geonames could be laravel-ized and low and behold... !

I don't need the full database of geonames. For example in a current project i need cities with their countries, administrative areas, continents etc for cities with a population over 10,000.

Is there a reason why there is no foreign keys from geonames table to the admin tables, alternate names, hierarchy (parent and child)?

"1071 Specified key was too long" will never be resolved with Schema::defaultStringLength(191)

The problem

I'm testing ^2.0 version of this package and found to install exactly the version 2.0.2 after requiring it through Composer.

When I ran the php artisan migration I'm getting the following error:

Illuminate\Database\QueryException :
SQLSTATE[42000]:
Syntax error or access violation:
1071 Specified key was too long; max key length is 1000 bytes
(SQL: alter table `geonames_alternate_names` add index `geonames_alternate_names_alternate_name_index`(`alternate_name`))

Digging through the migration code I found that it was thrown into 2017_02_11_145951_create_geonames_alternate_names_table.php line 70:

$table->index( 'alternate_name' );

If we comment this line the Artisan's migration command will run without any errors. But I went even deeper into the problem:

Some explanation

The error says that the max key length is 1000 bytes and the above highlighted line is trying to create an index key for the alternate_name column. This column is defined in the same migration file at line 37 as a VARCHAR with length 400 (!!!). When we define the length of a column explicitly how it is done at this line, the code Schema::defaultStringLength(191) may be inserted into boot method of AppServiceProvider.php and will just be ignored (at least by this line) resulting on the same error because the basic Laravel collation is utf8mb4 which uses 4 bytes to each char on a VARCHAR column and 400 * 4 = 1600 bytes which is much greater than the maximum size of 1000 bytes to a key (like specified by the error).

What I recommend to solve it

I understand that creating an index to alternate_name column is useful to make filters when querying geonames_alternate_names table. But this table isn't important to everyone using this package (also depending on how and why we are using it there may have more tables which will not be important though). Also, this column stores something like a CSV data, so it could be parsed and stored in another way to avoid creating a VARCHAR(400).

Also, why not let us publish the migrations and commands and change them as we need?

Don't misunderstand me, the package is awesome, it just need a bit of improvement

Install by country

Hi Michael.

Thanks for the project, again.

I'm facing a problem when I run the install command with a filter by country.
Happens that it's inserting all countries on the database, and just not Australia.

I'm using this:
php artisan geonames:install --country=AU --language=en

Thanks,

Importing data problem

When i'm running

php artisan geonames:install --country=ru --language=ru

i get error :

SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'isHistoric' at row 1 (SQL: insert into geonames_alternate_names_working (alternateNameId, geonameid, isolanguage, alternate_name, isPreferredName, isShortName, isColloquial, isHistoric, updated_at, created_at) values (9528154, 472757, en, Volgograd, 1, 0, 0, 1961, 2018-05-04 09:19:35, 2018-05-04 09:19:35))
/var/www/zdravproduct-app/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664

Looks like isHistoric tinyint but trying insert value '1961'

Geonames updates - Alternate names ?

It seems there is no update for the table geonames_alternate_names, am I right ?
It is quite an important table since this is where the postcode are.

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.