Skip to content

Commit

Permalink
Readme aktualisieren, Bugs beim installieren entfernen
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoe8495 committed Oct 30, 2016
1 parent 6041b00 commit 0056bb1
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 68 deletions.
7 changes: 2 additions & 5 deletions composer.json
Expand Up @@ -13,13 +13,10 @@
},
"autoload": {
"psr-4": {
"Equi\\Opengeodb\\": "src/"
"Equi\\Opengeodb": "src/"
}
},
"version": "1.0-stable",
"minimum-stability": "stable",
"license": "CC-BY-ND-3.0",
"require": {
"php": ">=5.5.9"
}
"license": "CC-BY-ND-3.0"
}
47 changes: 33 additions & 14 deletions readme.md
Expand Up @@ -7,14 +7,15 @@

## Installieren
### Composer /Artisan
entweder
```
composer require equi/opengeodb-laravel
```

oder in die composer.json die Zeile "equi/opengeodb-laravel": "~1.0", hinzufügen
```
...
"require": {
...
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
....
Expand All @@ -23,18 +24,27 @@ oder in die composer.json die Zeile "equi/opengeodb-laravel": "~1.0", hinzuf
},
...
```

Beim manuellen Updaten noch den Befehl ausführen
```
composer update
```

in die /config/app.php im Array "providers" diese Zeile einfügen
```
Equi\Opengeodb\OpengeodbServiceprovider::class,
```

anschließend default configs/migrations/.. in den /app Ordner kopieren.
```
php artisan vendor:publish
php artisan optimize
```

### Fehlende Dateien suchen
[OpenGeoDB](http://opengeodb.giswiki.org/wiki/OpenGeoDB) -> [Downloads](http://www.fa-technik.adfc.de/code/opengeodb/)
Welche Dateien braucht ihr?
#### Welche Dateien braucht ihr?
Pflicht:
```
opengeodb-begin.sql
opengeodb-end.sql
opengeodb_hier.sql
changes.sql
Expand All @@ -55,7 +65,9 @@ LIhier.sql
Extra.sql // Übergeordnete inhalte (Europa, Amerika, ...) und dazugehörige Sprachen (Deutschland = Germany ...)
```

Die Dateien scheinen veraltet diese werden aber in changes.sql aktualisiert
Die Dateien scheinen veraltet diese werden aber in changes.sql aktualisiert
#### wohin damit?
Standardmäßig unter __/opengeodb/sql__ oder den festgelegten Ordner in der Config unter __storageopengodbsql__

### Konfiguration config/opengeodb.php

Expand All @@ -69,19 +81,22 @@ return [
'mapcolor' => [
'black'=>[0, 0, 0],
'white'=>[255, 255, 255],
'red'=>[255, 0, 0],
'green'=>[178, 237, 90],
'blue'=>[148, 208, 255],
'grey'=>[148, 208, 255],
'darkgrey'=>[148, 208, 255],
'Therme'=>[255, 0, 0],
'Freizeitbad'=>[178, 237, 90],
'Sauna'=>[148, 208, 255],
'Anderes Bad'=>[148, 208, 255],
'Bad'=>[148, 208, 255],
'Hallenbad'=>[148, 208, 255],
'yellow'=>[148, 208, 255],
'pink'=>[148, 208, 255],
'land'=>[20, 20, 20],
'bund'=>[125, 125, 125],
'kreis'=>[200, 200, 200],
],
// Anzahl => radisgröße
'incresscolor' => 'black',
'radiusdata' => [
1 => 7,
2 => 10,
Expand All @@ -92,12 +107,16 @@ return [
```

### Datenbanken erstellen und füllen

```
php artisan migrate --seed
composer dump-autoload
php artisan migrate
php artisan db:seed --class=OpengeodbSeeder
```

Für manche PHP Konfiguration ist die de.sql zu groß hierfür könnt ihr folgendes versuchen:
```
php -d memory_limit=256M artisan migrate --seed
php -d memory_limit=256M artisan db:seed --class=OpengeodbSeeder
```

## Einbinden/Benutzen
Expand Down
26 changes: 13 additions & 13 deletions src/Equi/Opengeodb/data/config/opengeodb.php
Expand Up @@ -5,15 +5,16 @@
'storagemap' => "/opengeodb/map",
'storagee00' => "/opengeodb/e00",
'storageopengodbsql' => "/opengeodb/sql",

'mapcolor' => [
'white'=>[255, 255, 255],
'red'=>[255, 0, 0],
'black'=>[0, 0, 0],
'green'=>[178, 237, 90],
'blue'=>[148, 208, 255],
'grey'=>[148, 208, 255],
'darkgrey'=>[148, 208, 255],
'white'=>[255, 255, 255],
'Therme'=>[255, 0, 0],
'Freizeitbad'=>[178, 237, 90],
'Sauna'=>[148, 208, 255],
'Anderes Bad'=>[148, 208, 255],
'Bad'=>[148, 208, 255],
'Hallenbad'=>[148, 208, 255],
'yellow'=>[148, 208, 255],
'pink'=>[148, 208, 255],

Expand All @@ -22,13 +23,12 @@
'kreis'=>[200, 200, 200],
],

'incresscolor' => 'black',

'radiusdata' => [
1 => 2,
2 => 3,
3 => 4,
4 => 5,
5 => 6,
6 => 4
1 => 7,
2 => 10,
5 => 14,
]

];
78 changes: 42 additions & 36 deletions src/Equi/Opengeodb/data/seeds/OpengeodbSeeder.php
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Database\Seeder;
use Symfony\Component\Console\Output\ConsoleOutput;
use Illuminate\Support\Facades\Storage;

class OpengeodbSeeder extends Seeder
{
Expand All @@ -12,23 +13,21 @@ class OpengeodbSeeder extends Seeder
*/
public function run()
{
$this->importfile("AT.sql");
$this->importfile("AThier.sql");
$this->importfile("BE.sql");
$this->importfile("BEhier.sql");
$this->importfile("LI.sql");
$this->importfile("LIhier.sql");
$this->importfile("CH.sql");
$this->importfile("CHhier.sql");
$this->importfile("DE.sql");
$this->importfile("DEhier.sql");
$this->importfile("opengeodb-end.sql");
$this->importfile("opengeodb_hier.sql");
$this->importfile("extra.sql");
$output = new ConsoleOutput();
$output->writeln('Starting');
$sqlfiles = ["AT.sql", "AThier.sql","BE.sql","BEhier.sql","LI.sql","LIhier.sql","CH.sql","CHhier.sql","DE.sql","DEhier.sql"];
foreach($sqlfiles as $filename){
if (Storage::exists(Config::get('opengeodb.storageopengodbsql'). "/" .$filename))
$this->importfile($filename);
}
DB::table('geodb_textdata')->where("date_type_until","0")->delete();
$this->importfile("changes.sql", true);

$output = new ConsoleOutput();
$sqlfiles = ["opengeodb-end.sql","opengeodb_hier.sql","extra.sql","changes.sql"];
foreach($sqlfiles as $filename){
if (Storage::exists(Config::get('opengeodb.storageopengodbsql'). "/" .$filename))
$this->importfile($filename, true);
}

$output->writeln('Creating Index');
Schema::table('geodb_type_names', function ($table) {
$table->index('type_id');
Expand Down Expand Up @@ -86,42 +85,49 @@ public function run()
$table->index('valid_since');
$table->index('valid_until');
});
DB::table('geodb_mapcoords')->insert(["loc_id" => "105", "fromlat" => 5.5, "fromlon" => 47, "tolat" => 15.5, "tolon" => 55]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "108", "fromlat" => 11, "fromlon" => 51, "tolat" => 15, "tolon" => 53.5]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "110", "fromlat" => 7, "fromlon" => 47, "tolat" => 11, "tolon" => 50]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "111", "fromlat" => 8, "fromlon" => 47, "tolat" => 14.5, "tolon" => 51]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "113", "fromlat" => 7.5, "fromlon" => 49, "tolat" => 10.5, "tolon" => 52]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "115", "fromlat" => 10, "fromlon" => 53, "tolat" => 14.5, "tolon" => 55]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "116", "fromlat" => 5.5, "fromlon" => 51, "tolat" => 12, "tolon" => 55]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "117", "fromlat" => 5.5, "fromlon" => 50, "tolat" => 10, "tolon" => 53]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "118", "fromlat" => 5.5, "fromlon" => 48.5, "tolat" => 9, "tolon" => 51.5]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "119", "fromlat" => 7, "fromlon" => 53, "tolat" => 12, "tolon" => 55]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "120", "fromlat" => 5.5, "fromlon" => 49, "tolat" => 8, "tolon" => 50]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "121", "fromlat" => 11, "fromlon" => 50, "tolat" => 15.5, "tolon" => 52]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "122", "fromlat" => 10, "fromlon" => 50.5, "tolat" => 13.5, "tolon" => 53.5]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "123", "fromlat" => 9.5, "fromlon" => 50, "tolat" => 13, "tolon" => 52]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "106", "fromlat" => 9, "fromlon" => 46, "tolat" => 18, "tolon" => 50]);
DB::table('geodb_mapcoords')->insert(["loc_id" => "107", "fromlat" => 5, "fromlon" => 45.5, "tolat" => 11, "tolon" => 48]);
$this->insertmapcoords(["loc_id" => "105", "fromlat" => 5.5, "fromlon" => 47, "tolat" => 15.5, "tolon" => 55]);
$this->insertmapcoords(["loc_id" => "108", "fromlat" => 11, "fromlon" => 51, "tolat" => 15, "tolon" => 53.5]);
$this->insertmapcoords(["loc_id" => "110", "fromlat" => 7, "fromlon" => 47, "tolat" => 11, "tolon" => 50]);
$this->insertmapcoords(["loc_id" => "111", "fromlat" => 8, "fromlon" => 47, "tolat" => 14.5, "tolon" => 51]);
$this->insertmapcoords(["loc_id" => "113", "fromlat" => 7.5, "fromlon" => 49, "tolat" => 10.5, "tolon" => 52]);
$this->insertmapcoords(["loc_id" => "115", "fromlat" => 10, "fromlon" => 53, "tolat" => 14.5, "tolon" => 55]);
$this->insertmapcoords(["loc_id" => "116", "fromlat" => 5.5, "fromlon" => 51, "tolat" => 12, "tolon" => 55]);
$this->insertmapcoords(["loc_id" => "117", "fromlat" => 5.5, "fromlon" => 50, "tolat" => 10, "tolon" => 53]);
$this->insertmapcoords(["loc_id" => "118", "fromlat" => 5.5, "fromlon" => 48.5, "tolat" => 9, "tolon" => 51.5]);
$this->insertmapcoords(["loc_id" => "119", "fromlat" => 7, "fromlon" => 53, "tolat" => 12, "tolon" => 55]);
$this->insertmapcoords(["loc_id" => "120", "fromlat" => 5.5, "fromlon" => 49, "tolat" => 8, "tolon" => 50]);
$this->insertmapcoords(["loc_id" => "121", "fromlat" => 11, "fromlon" => 50, "tolat" => 15.5, "tolon" => 52]);
$this->insertmapcoords(["loc_id" => "122", "fromlat" => 10, "fromlon" => 50.5, "tolat" => 13.5, "tolon" => 53.5]);
$this->insertmapcoords(["loc_id" => "123", "fromlat" => 9.5, "fromlon" => 50, "tolat" => 13, "tolon" => 52]);
$this->insertmapcoords(["loc_id" => "106", "fromlat" => 9, "fromlon" => 46, "tolat" => 18, "tolon" => 50]);
$this->insertmapcoords(["loc_id" => "107", "fromlat" => 5, "fromlon" => 45.5, "tolat" => 11, "tolon" => 48]);
Schema::table('geodb_mapcoords', function ($table) {
$table->index('loc_id');
});
}

public function insertmapcoords($fields){
try{
DB::table('geodb_mapcoords')->insert($fields);
} catch (\Exception $ex){
}
}

public function importfile($filename, $ignoreerror = false){
if (!Illuminate\Support\Facades\Storage::exists(Config::get('opengeodb.storageopengodbsql')."/" .$filename))
return;
$output = new ConsoleOutput();
$sql = Illuminate\Support\Facades\Storage::get(Config::get('opengeodb.storageopengodbsql'). "/" .$filename);
$sql = Storage::get(Config::get('opengeodb.storageopengodbsql'). "/" .$filename);

$statements = explode("\n", $sql);
$output->writeln('Starte Datei:' . Config::get('opengeodb.storageopengodbsql'). "/" .$filename . " Zeilen: ");
$lines = count($statements);
$output->writeln('Starte Datei:' . $filename. " Zeilen: ". $lines);
DB::beginTransaction();
for($i=0; $i<$lines; $i++)
{
//if (is_int($i/ 1000)) $output->writeln(date("H:i:s") .': Run '.$i.' of ' .$lines);
{
$line = preg_replace('!/\*.*?\*/!s', '', $statements[$i]);
//$output->writeln('Zeile:' . $line);
if (!empty(str_replace("\r", "", $line)) && $line != "BEGIN;" && $line != "COMMIT;" && strpos($line, "create index") === false){
if (strpos($line,"geodb_floatdata")) $line = str_replace(",0,", ",null,", $line);
if ($ignoreerror){
try{
DB::statement($line);
Expand Down

0 comments on commit 0056bb1

Please sign in to comment.