Repository Public
1#!/bin/bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : KA Maps Engine8# File : server/pipeline/geo/02_load_raw.sh9# Module : server10# Repository : https://git.spboucher.ai/ka-maps-engine11# Created : 2026-12-0112# Last Modified : 2026-12-0113#14# Author : Simon-Pierre Boucher15# Position : Professor of Finance16# Institution : Université du Québec en Outaouais (UQO)17# Organization : SP Boucher18# Website : https://spboucher.ai19# Git : https://git.spboucher.ai20#21# Preferred Contact: support@spboucher.ai22# Technical Contact: dev@spboucher.ai23# Security/Admin : admin@spboucher.ai24#25# Copyright (c) 202626# Simon-Pierre Boucher27# All rights reserved where applicable. This file is governed by the28# applicable project license, copyright notices and relevant law.29# Existing third-party rights and notices remain unaffected.30#31# License : None specified (no license file in this repository)32#33# Do not embed credentials, private keys, access tokens,34# certificates or confidential personal information.35#36# =============================================================================37# END OF SP BOUCHER SOURCE HEADER38# =============================================================================3940# KA Maps — chargement brut des sources dans le schéma geo (tables raw_*), sans transformation.41set -euo pipefail42HERE=$(cd "$(dirname "$0")" && pwd); . "$HERE/env.sh"43PGC="PG:host=$PGHOST port=$PGPORT dbname=$PGDATABASE user=$PGUSER password=$PGPASSWORD"44ogr() { ogr2ogr -f PostgreSQL "$PGC" -overwrite -lco SCHEMA=$GEO_SCHEMA -lco GEOMETRY_NAME=geom -lco FID=ogc_fid \45 -lco UNLOGGED=ON --config PG_USE_COPY YES -t_srs EPSG:4326 -dim XY "$@"; }4647# Registre national d'adresses (province 24)48first=149for f in "$SRC"/nar/Addresses/Address_24*.csv; do50 if [ $first = 1 ]; then csv_load raw_nar "$f"; first=0; else csv_append raw_nar "$f"; fi51done52# Base de données ouvertes d'adresses (2021)53csv_load raw_oda "$SRC/oda/ODA_QC_v1.csv"54# Adresses municipales55csv_load raw_mtl "$SRC/muni/montreal.csv"56csv_load raw_vdq "$SRC/muni/quebec.csv"57csv_load raw_sherbrooke "$SRC/muni/sherbrooke.csv"58csv_load raw_saguenay "$SRC/muni/saguenay.csv"59csv_load raw_levis "$SRC/muni/levis.csv"60ogr -nln raw_gatineau "$SRC/muni/gatineau.geojson"61# Codes postaux (ISQ, CP Territoires)62csv_load raw_cp "$SRC/cp/cp_territoires.csv"63# Découpages administratifs et réseau routier (MRNF)64for l in munic_s arron_s mrc_s regio_s; do ogr -nln raw_sda_$l -nlt MULTIPOLYGON "$SRC/sda/SDA.gpkg" $l; done65ogr -nln raw_aq_routes -nlt LINESTRING "$SRC/aq/AQreseau.gpkg" AQ_ROUTES66# Quartiers municipaux67for q in mtl_reference mtl_sociologiques quebec longueuil trois_rivieres levis; do68 ogr -nln raw_q_$q -nlt MULTIPOLYGON "$SRC/quartiers/$q.geojson"69done70$PSQL -Atc "SELECT c.relname, c.reltuples::bigint FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = '$GEO_SCHEMA' AND c.relname LIKE 'raw_%' AND c.relkind = 'r' ORDER BY 1"71echo LOAD_DONE72