script postgis

This commit is contained in:
2025-09-06 16:17:55 +02:00
parent 6160975a50
commit 093e2b3443

View File

@@ -20,7 +20,7 @@ create index idx_route_geom on route using gist (geom);
create or replace function maj_longueur()
returns trigger as $$
begin
new.longueur := st_length(new.geom);
new.longueur := st_length(new.geom) * 1000;
return new;
end;
$$ language plpgsql;
@@ -48,17 +48,7 @@ create table zone (
-- ************************************************************
INSERT INTO route (source, target, cost, reverse_cost, geom)
SELECT
a.id AS source,
b.id AS target,
1 AS cost,
1 AS reverse_cost,
ST_MakeLine(a.geom, b.geom) AS geom
FROM point a
JOIN point b ON a.id = 6 and b.id = 7;
\COPY point FROM '/tmp/point.csv' (FORMAT CSV, header, ENCODING 'UTF8');
\COPY route FROM '/tmp/route.csv' (FORMAT CSV, header, ENCODING 'UTF8');
\COPY route(id, depart, arrivee, geom) FROM '/tmp/route.csv' (FORMAT CSV, header, ENCODING 'UTF8');
\COPY route_cout FROM '/tmp/route_cout.csv' (FORMAT CSV, header, ENCODING 'UTF8');
\COPY zone FROM '/tmp/zone.csv' (FORMAT CSV, header, ENCODING 'UTF8');