|
| 1 | +#!/bin/bash |
| 2 | +LOG="../../import-contours.log" |
| 3 | +cd out/out_contours |
| 4 | + |
| 5 | +import() |
| 6 | +{ |
| 7 | + X=$1 |
| 8 | + gunzip $X |
| 9 | + ogr2ogr -explodecollections -a_srs epsg:3857 -append -f "PostgreSQL" 'PG:dbname='contours2'' -nln contours -lco DIM=2 ${X%.*} |
| 10 | + gzip ${X%.*} |
| 11 | + echo $(date)' '$X' done'>> $LOG |
| 12 | + #~ echo $X |
| 13 | + #~ sleep 2 |
| 14 | +} |
| 15 | +#~ X="contours_47-6.shp.gz" |
| 16 | +for X in *.shp.gz; |
| 17 | +do |
| 18 | + count=`jobs -p | wc -l` |
| 19 | + echo $count |
| 20 | + while [ `jobs -p | wc -l` -ge 3 ] |
| 21 | + do |
| 22 | + sleep 5 |
| 23 | + done |
| 24 | + import $X & |
| 25 | +done |
| 26 | + |
| 27 | +echo $(date) 'analyse'>> $LOG |
| 28 | +echo "VACUUM ANALYSE;" | psql -d contours2 |
| 29 | +echo $(date)' '$X' done'>> $LOG |
| 30 | +echo 'DONE'>> $LOG |
| 31 | + |
| 32 | + |
| 33 | +exit 0 |
| 34 | +#~ |
| 35 | +createdb -U mapnik contours2 |
| 36 | +psql -d contours2 -U mapnik -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis.sql |
| 37 | +psql -d contours2 -U mapnik -f /usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys.sql |
| 38 | + |
| 39 | +Note: projection not recognized: wkb_geometry | geometry(MultiLineString,900914) | |
| 40 | +SELECT UpdateGeometrySRID('contours','wkb_geometry',3857); |
| 41 | +ogr2ogr -a_srs epsg:3857 -append -f "PostgreSQL" 'PG:dbname='contours2'' -nln contours -nlt MULTILINESTRING -lco DIM=2 ${X%.*} |
| 42 | + |
| 43 | +#~ #echo "ALTER USER mapnik WITH PASSWORD 'mapnik';" | psql -d contour # not usefull |
| 44 | +#~ exit |
| 45 | +#~ dropdb contours |
| 46 | +#~ |
| 47 | +#~ # test: |
| 48 | +#~ 457 GB |
| 49 | +#~ select count(*) from contours where ST_intersects(way, ST_MakeEnvelope(-180,72,180,85)); |
| 50 | +#~ echo "select count(*) from contours where ST_intersects(way, ST_MakeEnvelope(-180,72,180,85));" | psql -d contours |
| 51 | +#~ |
| 52 | +#~ 963GB |
| 53 | +#~ echo "vacuum;" | psql -d contours |
| 54 | +#~ # size of the db: |
| 55 | +#~ cd /var/lib/postgresql/8.4/main/base |
| 56 | +#~ du -sh * |
| 57 | +#~ |
| 58 | +#~ shared_buffers = 256MB |
| 59 | +#~ time shp2pgsql -a -g way N06E124 contours | psql -U mapnik -q contour |
| 60 | +#~ real 6m45.981s |
| 61 | +#~ user 1m0.400s |
| 62 | +#~ sys 0m15.977s |
| 63 | +#~ |
| 64 | +#~ shared_buffers = 4100MB |
| 65 | +#~ sudo /etc/init.d/postgresql-8.4 restart |
| 66 | +#~ # get the shmmax value from message |
| 67 | +#~ sudo sysctl -w kernel.shmmax=4403486720 #(temporary) |
| 68 | +#~ sudo nano /etc/sysctl.conf |
| 69 | +#~ kernel.shmmax=4403486720 #(permanent) |
| 70 | +#~ sudo /etc/init.d/postgresql-8.4 restart |
| 71 | +#~ time shp2pgsql -a -g way N06E124 contours | psql -U mapnik -q contour |
| 72 | +#~ real 6m45.998s |
| 73 | +#~ user 1m0.092s |
| 74 | +#~ sys 0m16.669s |
| 75 | +#~ => disk is the limiting factor? |
| 76 | + |
| 77 | + |
| 78 | +#~ echo "ALTER TABLE contour ADD COLUMN contour3857 geometry(LINESTRING,3857);" | psql -d contours #(long 5h ??) |
| 79 | +#~ echo "ALTER TABLE contour drop column contour3857;" | psql -d contours |
| 80 | +#~ echo $(date) ": table dropped" |
| 81 | +#~ echo "SELECT AddGeometryColumn ('contour','contour3857',3857,'LINESTRING',2, false);" | psql -d contours |
| 82 | +#~ echo $(date) ": AddGeometryColumn done" |
| 83 | +#~ echo "UPDATE contour SET contour3857=ST_Transform(wkb_geometry,3857);" | psql -d contours |
| 84 | +#~ echo $(date) ": table updated" |
| 85 | +echo "SELECT DropGeometryColumn ('contour','wkb_geometry');" | psql -d contours |
| 86 | +echo $(date) ": DropGeometryColumn done" |
| 87 | +#~ echo "CREATE INDEX contour3857_geom_idx ON contour USING gist (contour3857);" | psql -d contours pas nécessaire ! |
| 88 | +#~ echo date ": Index done" |
| 89 | +echo "CREATE INDEX contours_idx ON contours USING gist (contours);" | psql -d contours2 |
0 commit comments