From 77f9be057ed5ac65cbc3c27658e9c51f3cd94750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Baylac-Jacqu=C3=A9?= Date: Mon, 21 Feb 2022 12:47:59 +0100 Subject: [PATCH] Add primitive IPE data ingestor. --- data-ingest/ingest | 59 ++++++++++++++++++++++++++++++++++++++++++++++ notes.org | 48 +++++++++++++++++++++++++++++++++++++ shell.nix | 9 +++++++ 3 files changed, 116 insertions(+) create mode 100755 data-ingest/ingest create mode 100644 notes.org create mode 100644 shell.nix diff --git a/data-ingest/ingest b/data-ingest/ingest new file mode 100755 index 0000000..e2d3082 --- /dev/null +++ b/data-ingest/ingest @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +set -eau -o pipefail + +if [ "$#" -ne 2 ]; then + echo "Usage: ingest path-to-directory-containing-IPE-CSVs path-to-generated-db" + echo "" + exit 1 +fi +fullIpeDirPath=$(realpath "${1}") +fullDbPath=$(realpath "${2}") + +tmpSql=$(mktemp) +clean_tmp () { + rm "${tmpSql}" +} +trap clean_tmp EXIT + +echo "[+] Ingesting IPE ata." +echo " The following files will be ingested." +echo "" +ipeFiles=$(find "${fullIpeDirPath}" -name '*.csv') +cat > "${tmpSql}" <> "${tmpSql}" < "${tmpSql}" < CREATE TABLE points (id INTEGER PRIMARY KEY NOT NULL); + spatialite> SELECT AddGeometryColumn('points','dummypoints',3857,'POINT'); + 1 + spatialite> INSERT INTO points (dummypoints) VALUES(Transform(MakePoint(384998.246399999,6366249.435399996366249.43539999,4964),3857)); + spatialite> select * from points; + 1| + spatialite> select AsText(dummypoints) from points; + + #+END_SRC + +** SRID, quezako? + - Bonne référence: https://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/srid.html + + En pratique, on spécifie le SRID a spatialite en utiliant le code EPSG + + - Projection règlementaire en France: RGF93, EPSG:2154 + - Mercator (OSM/Google Maps): WGS84, EPSG:4326 + + D'après https://geodesie.ign.fr/index.php?page=rgf93, le RGF93 est compatible avec Mercator. + +** DSPs to Ingest +ADTH AISN BEFO BTHD CTYF EURE FI44 NATH NIVE NPDC SART SHSN SIEL SPTH VAUC diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..afde95e --- /dev/null +++ b/shell.nix @@ -0,0 +1,9 @@ +{ pkgs ? import {} }: + +pkgs.mkShell { + buildInputs = [ pkgs.libspatialite ]; + nativeBuildInputs = [ pkgs.sqlite pkgs.cargo pkgs.rustc ]; + shellHook = '' + LD_LIBRARY_PATH=${pkgs.libspatialite}/lib:LD_LIBRARY_PATH + ''; +}