#! /usr/bin/bash

# Lae keskkonnamuutujad
source env.sh
# Testimise piirkond
psql ${CONNECTION_NAME} -c "
-- Valga halduspiirkonna järgi
DROP TABLE IF EXISTS ${destination_schema}.test_links;
CREATE TABLE ${destination_schema}.test_links AS
SELECT   h.eid,
  h.highway,
  h.surface,
  h.oneway,
  h.maxspeed,
  h.name,
  ST_Transform(h.geom, 3301) AS geom
FROM ${destination_schema}.links h
JOIN ${destination_schema}.administrative p
  ON ST_Intersects(h.geom, p.geom)
WHERE p.name like 'Valga%' AND p.admin_level = '7';
"
