data-ingest: Create a spatial index on the building geodata

This commit is contained in:
Félix Baylac-Jacqué 2022-02-21 19:00:11 +01:00
parent 6c8c3b138d
commit 2890656b8a
2 changed files with 23 additions and 1 deletions

View file

@ -15,7 +15,7 @@ clean_tmp () {
}
trap clean_tmp EXIT
echo "[+] Ingesting IPE ata."
echo "[+] Ingesting IPE data."
echo " The following files will be ingested."
echo ""
ipeFiles=$(find "${fullIpeDirPath}" -name '*.csv')
@ -53,7 +53,13 @@ UPDATE ipe SET ImmeubleGeoPoint =
2154)
,4326);
EOF
sqlite3 "${fullDbPath}" < "${tmpSql}"
echo "[+] Creating Rtree index (spatial index). We're almost done."
cat > "${tmpSql}" <<EOF
SELECT load_extension("mod_spatialite");
SELECT CreateSpatialIndex('ipe','ImmeubleGeoPoint');
EOF
sqlite3 "${fullDbPath}" < "${tmpSql}"
echo "[+] SQLite database generated at ${fullDbPath}"

View file

@ -46,3 +46,19 @@
** DSPs to Ingest
ADTH AISN BEFO BTHD CTYF EURE FI44 NATH NIVE NPDC SART SHSN SIEL SPTH VAUC
** Requête sur l'Index Spatial
#+BEGIN_SRC sql
SELECT * FROM ipe
WHERE ROWID = (
SELECT ROWID FROM SpatialIndex
WHERE f_table_name = 'ipe'
AND search_frame = BuildMBR(
-1.405456066131592,
43.53722495535158,
-1.3643002510070803,
43.54475322429539,
4326)
);
#+END_SRC