Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
tombejo_gis_client:shapefile2postgis [2016/04/28 10:22] f.rauch_girona.de angelegt |
— (aktuell) | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | <?php\\ | ||
- | \\ | ||
- | \\ | ||
- | if (!$argv[1]) {\\ | ||
- | echo "erstes argument muss datenbankname sein";\\ | ||
- | exit;\\ | ||
- | }\\ | ||
- | \\ | ||
- | if (!$argv[2]) {\\ | ||
- | echo "zweites argument muss dateipfad sein";\\ | ||
- | exit;\\ | ||
- | }\\ | ||
- | \\ | ||
- | $dir = $argv[2];\\ | ||
- | \\ | ||
- | \\ | ||
- | \\ | ||
- | $files = scandir($dir);\\ | ||
- | foreach($files as $file) {\\ | ||
- | \\ | ||
- | if (endsWith($file,".shp")) {\\ | ||
- | $f = str_replace(".shp","",$file);\\ | ||
- | echo "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL PG:'host=postgresql.cqubs0xna6kf.eu-west-1.rds.amazonaws.com port=5432 dbname={$argv[1]} password=postgresql active_schema=public user=postgresql' -lco DIM=2 {$dir}/{$file} $f -overwrite -lco GEOMETRY_NAME=geom -lco FID=id -nlt PROMOTE_TO_MULTI%%\%%n";\\ | ||
- | \\ | ||
- | }\\ | ||
- | }\\ | ||
- | \\ | ||
- | \\ | ||
- | \\ | ||
- | function endsWith($haystack, $needle) {\\ | ||
- | // search forward starting from end minus needle length characters\\ | ||
- | return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== false);\\ | ||
- | } | ||