#! /bin/sh

DB=${2:-dlg}

set -v

/bin/rm *.copy

dlg2copy

# monitor -c "destroy poly_topology" $DB
# monitor -c "create poly_topology(edge_fn= int4, centroid_fn= int4, l_or_r= char, e_or_i= char)" $DB
# monitor -c "copy poly_topology from \"`pwd`/areas.copy\"" $DB

monitor -c "destroy ${1}l" $DB
monitor -c "create ${1}l (id= int4, start_node= int4, end_node= int4,
  left_area= int4, right_area= int4,
  pln= POLYGON2, attr1= int4, attr2= int4)" $DB
monitor -c "copy ${1}l from \"`pwd`/lines.copy\"" $DB

monitor -c "destroy ${1}c" $DB
monitor -c "create ${1}c (id= int4, pnt= POINT2, attr1= int4, attr2= int4)" $DB
monitor -c "copy ${1}c from \"`pwd`/centers.copy\"" $DB

$GEOHOME/postgres/adddyn ${1}l pln None "" make_pln2_shape '$GEOHOME/geo-ext/Geo2Shapes.o' $DB
$GEOHOME/postgres/adddyn ${1}c pnt None "" make_pnt2_shape '$GEOHOME/geo-ext/Geo2Shapes.o' $DB

/bin/rm *.copy
