#! /bin/sh

DB=raster

$GEOHOME/geo-ext/loadgeo-ext $DB

monitor -c "destroy roads" $DB
# monitor -c "create roads(geo_pline= path, category=int4, name= text, geo_bbox= box)" $DB

monitor -c "destroy city_areas" $DB
# monitor -c "create city_areas(geo_pline= path, category=int4, name= text, geo_bbox= box)" $DB

monitor -c "destroy cities" $DB
# monitor -c "create cities(geo_loc= point, category=int4, name= text)" $DB

(cd data; $GEOHOME/postgres/dump/loaddb $DB)

monitor -c "define rule road_add is
on append to roads do
replace new (geo_bbox= From2Box(Box2Pln(To2Pln(new.geo_pline))))" $DB

monitor -c "define rule road_repl is
on replace to roads.geo_pline do
replace new (geo_bbox= From2Box(Box2Pln(To2Pln(new.geo_pline))))" $DB

monitor -c "define rule ca_add is
on append to city_areas do
replace new (geo_bbox= From2Box(Box2Pln(To2Pln(new.geo_pline))))" $DB

monitor -c "define rule ca_repl is
on replace to city_areas.geo_pline do
replace new (geo_bbox= From2Box(Box2Pln(To2Pln(new.geo_pline))))" $DB

makespath
