[mapserver-users] mapserver and php

Worth Lutz wal3 at mindspring.com
Sun Nov 4 05:37:36 PST 2012


Hi Vince,

 

If you keep the messages on the list it can help others. I don't mind you
sending it to me directly if you are replying to a post of mine as I may see
it sooner.

 

I generally use the unstable repository as it gets updated faster (thus
unstable). I run on the bleeding edge :-).

 

Here is a script which I use to create postgreSQL templates for a PostGIS
database and a pgRouting database. It is a modified version of one found in
the pgRouting site. 

 

It assumes PostGIS version 2 and PostgreSQL may need to be version 9. This
works on my setup using Ubuntu 12.04 and PostgreSQL  9.1 and the
ubuntugis-unstable repository to get MapServer and PostGIS.

 

You may need to run to get the "pg_config" utility which reports various
config information for PostgreSQL:

  

   sudo apt-get install libpq-dev

 

 

# /bin/bash 

#
----------------------------------------------------------------------------
--

# Setup template containing PostGIS and/or pgRouting

#
----------------------------------------------------------------------------
--

#

# To create a GIS database as non-superuser run: 

#

#    "createdb -h hostname -W -T template_postgis mydb

#

# Source:
http://geospatial.nomad-labs.com/2006/12/24/postgis-template-database/

#

# Note: "pg_config" requires "libpq-dev" package

 

if [ -e `pg_config --sharedir` ]

then

     echo "PostGIS installed in" `pg_config --sharedir`

     POSTGIS_SQL_PATH=`pg_config --sharedir`/contrib

else

     POSTGIS_SQL_PATH=/usr/share/postgresql/9.1/contrib/postgis-2.0

     echo "PostGIS path set as $POSTGIS_SQL_PATH"

fi

 

ROUTING_SQL_PATH=/usr/share/postlbs

 

 

# Create "template_postgis"

# -------------------------

if  sudo -u postgres psql --list | grep -q template_postgis ;

then

     echo "PostGIS template already exists!"

else

  echo "Create PostGIS template ..."

  VERSION=$(basename $(pg_config --sharedir))

  echo "PostgreSQL version is $VERSION"

  if [ $VERSION \< 9.1 ];

  then

    # for PostgreSQL less than 9.1

    sudo -u postgres createdb -E UTF8 -T template0 template_postgis

    sudo -u postgres createlang -d template_postgis plpgsql

    

    sudo -u postgres psql --quiet -d template_postgis \

                                  -f $POSTGIS_SQL_PATH/postgis.sql

    sudo -u postgres psql --quiet -d template_postgis \

                                  -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql

    sudo -u postgres psql --quiet -d template_postgis \

                                  -f $POSTGIS_SQL_PATH/postgis_comments.sql

    

    sudo -u postgres psql --quiet -d template_postgis \

                                  -f
$POSTGIS_SQL_PATH/postgis-2.0/rtpostgis.sql

    sudo -u postgres psql --quiet -d template_postgis \ 

                                  -f
$POSTGIS_SQL_PATH/postgis-2.0/raster_comments.sql

    sudo -u postgres psql --quiet -d template_postgis \

                                  -f
$POSTGIS_SQL_PATH/postgis-2.0/topology.sql

    sudo -u postgres psql --quiet -d template_postgis \

                                  -f
$POSTGIS_SQL_PATH/postgis-2.0/topology_comments.sql

    

    sudo -u postgres psql --quiet -d template_postgis \

                                  -c "GRANT ALL ON geometry_columns TO
PUBLIC;"

    sudo -u postgres psql --quiet -d template_postgis \

                                  -c "GRANT ALL ON geography_columns TO
PUBLIC;"

    sudo -u postgres psql --quiet -d template_postgis \

                                  -c "GRANT ALL ON spatial_ref_sys TO
PUBLIC;"

    

    sudo -u postgres psql --quiet -d template_postgis -c "VACUUM FULL;"

    sudo -u postgres psql --quiet -d template_postgis -c "VACUUM FREEZE;"

  else

    # for PostgreSQL 9.1+

    sudo -u postgres createdb -E UTF8 -T template0 template_postgis

    sudo -u postgres psql -d template_postgis -c "CREATE EXTENSION postgis"

    sudo -u postgres psql -d template_postgis -c "CREATE EXTENSION
postgis_topology"

  fi

  sudo -u postgres psql --quiet -d postgres \

       -c "UPDATE pg_database SET datistemplate='true' WHERE
datname='template_postgis';"

  sudo -u postgres psql --quiet -d postgres \

       -c "UPDATE pg_database SET datallowconn='false' WHERE
datname='template_postgis';"

  echo "... template_postgis created."

fi

 

 

# Create "template_routing"

# -------------------------

if  sudo -u postgres psql --list | grep -q template_routing ;

then

  echo "pgRouting template already exists!"

else

  echo "Create pgRouting template ..."

  sudo -u postgres createdb -E UTF8 -T template_postgis template_routing

  

  sudo -u postgres psql --quiet -d template_routing \

                                -f $ROUTING_SQL_PATH/routing_core.sql

  sudo -u postgres psql --quiet -d template_routing \

                                -f
$ROUTING_SQL_PATH/routing_core_wrappers.sql

  sudo -u postgres psql --quiet -d template_routing \

                                -f $ROUTING_SQL_PATH/routing_topology.sql

  sudo -u postgres psql --quiet -d template_routing \

                                -f $ROUTING_SQL_PATH/routing_tsp.sql

  sudo -u postgres psql --quiet -d template_routing \

                                -f
$ROUTING_SQL_PATH/routing_tsp_wrappers.sql

  sudo -u postgres psql --quiet -d template_routing \

                                -f $ROUTING_SQL_PATH/routing_dd.sql

  sudo -u postgres psql --quiet -d template_routing \

                                -f $ROUTING_SQL_PATH/routing_dd_wrappers.sql

  sudo -u postgres psql --quiet -d template_routing \

                                -f $ROUTING_SQL_PATH/matching.sql

  

  sudo -u postgres psql --quiet -d template_routing -c "VACUUM FULL;"

  sudo -u postgres psql --quiet -d template_routing -c "VACUUM FREEZE;"

  

  sudo -u postgres psql --quiet -d postgres \

       -c "UPDATE pg_database SET datistemplate='true' WHERE
datname='template_routing';"

  sudo -u postgres psql --quiet -d postgres \

       -c "UPDATE pg_database SET datallowconn='false' WHERE
datname='template_routing';"

  echo "... template_routing created."

fi

#-------------------------------------------------------------------------

 

 

I hope this helps.

 

Worth

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20121104/c6ff7be5/attachment-0001.html>


More information about the mapserver-users mailing list