Subversion Repositories eFlore/Projets.eflore-projets

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1054 jpm 1
#!/bin/bash
2
# Utilisation : ./pbf2mysql-boundary
3
# Paramètres : .
4
# - 1 : nom du fichier .pbf dont on veut extraire les relations boundary (sans extenssion)
5
 
6
ageEnSeconde(){ expr `date +%s` - `stat -c %Y $1`; };
7
 
8
if [ -f pbf2mysql-boundary.cfg ] ; then
9
	source pbf2mysql-boundary.cfg
10
	echo $DATE;
11
else
12
	echo "Veuillez paramétrer le script en renommant le fichier 'pbf2mysql-boundary.defaut.cfg' en 'pbf2mysql-boundary.cfg'."
13
	exit;
14
fi
15
 
16
# Récupération du fichier OSM dont on veut extraire les relations de type boundary vers Mysql
17
FICHIER=$1
18
URL_DOWNLOAD=$2
19
 
20
echo "Export de l'emplacement du binaire Java dans la variable d'environnement JAVACMD";
21
export JAVACMD="$BIN_JAVA"
22
 
23
echo "Export de l'emplacement du dossier tmp pour Osmosis"
24
export JAVACMD_OPTIONS="-Djava.io.tmpdir=${OSMOSIS_DOSSIER_TMP} -Xmx${OSMOSIS_MAX_MEMORY} -server"
25
 
26
#if [ ! -f "${DOSSIER_OSM}/${FICHIER}.osm.pbf" ] || [ `ageEnSeconde "${DOSSIER_OSM}/${FICHIER}.osm.pbf"` -gt 86000 ] ; then
27
#	echo "Téléchargement du nouveau fichier PBF ...";
28
#	wget $URL_DOWNLOAD -O "${DOSSIER_OSM}/${FICHIER}.osm.pbf"
29
#else
30
#	echo "Fichier ${FICHIER}.osm.pbf existant depuis moins d'un jour.";
31
#fi
32
 
33
if [ ! -f "${DOSSIER_OSM}/${FICHIER}_boundary.osm.pbf" ] || [ `ageEnSeconde "${DOSSIER_OSM}/${FICHIER}_boundary.osm.pbf"` -gt 86000 ] ; then
34
	echo "Filtrage du fichier en cours ...";
35
	$BIN_OSMOSIS \
36
		-v \
37
		--read-pbf-fast "${DOSSIER_OSM}/${FICHIER}.osm.pbf" workers=6 \
38
		--tf accept-relations admin_level=* \
39
		--tf accept-relations type=boundary \
40
		--used-way \
41
		--used-node \
42
		--buffer --write-pbf "${DOSSIER_OSM}/${FICHIER}_boundary.osm.pbf"
43
 
44
# Test avec communauté de communes du Haut-Allier
45
# --tf accept-relations admin_level=8 \
46
# --tf accept-relations type=boundary \
47
# --tf accept-relations ref:INSEE=48010,48041,48048,48062,48080,48086,48105,48129,48150 \
48
else
49
	echo "Fichier filtré ${FICHIER}_boundary.osm.pbf existant depuis moins d'un jour.";
50
fi
51
 
52
#------------------------------------------------------------------------------------------------------------
53
# ATTENTION : nécessite ici de reconstruire les relations incomplètes avant d'utiliser ogr2ogr
54
#------------------------------------------------------------------------------------------------------------
55
 
56
if [ ! -f "${DOSSIER_OSM}/${FICHIER}_boundary.osm.pbf" ] ; then
57
	echo "Impossible de trouver ${FICHIER}_boundary.osm.pbf existant depuis moins d'un jour.";
58
else
59
	echo "Importation dans MySQL en cours ...";
60
	$BIN_OGR \
61
		--config OSM_CONFIG_FILE $OSM_CONF_INI \
62
		--config MYSQL_UNIX_PORT $MYSQL_UNIX_PORT \
63
		-overwrite \
64
		-progress \
65
		-f "MySQL" MYSQL:${MYSQL_DATABASE},user=${MYSQL_USER},password=${MYSQL_PASSWORD},host=${MYSQL_HOST},port=${MYSQL_PORT} \
66
		-lco engine=MYISAM \
67
		-lco spatial_index=no \
68
		"${DOSSIER_OSM}/${FICHIER}_boundary.osm.pbf" multipolygons points
69
fi