cga-harvard / geonode

Harvard WorldMap is a heavily modified fork of GeoNode 1.4 which has recently been migrated to GeoNode 2.10. WorldMap is being made available by Harvard's Center for Geographic Analysis to lower the barrier for scholars and others who wish to explore, visualize, edit, collaborate with, and publish geospatial information.
http://cga.harvard.edu
GNU General Public License v3.0
96 stars 29 forks source link

========= WorldMap

Build Requirements

Before starting work on WorldMap, you will need to have the following software installed and in your PATH:

Additionally, WorldMap uses a number of native-code libraries in Python. You can install these libraries manually, or allow the WorldMap setup script to compile them for you. In the latter case, you will need to install a C compiler such as GCC, as well as any requisite development libraries. GCC packages are available for Mac OSX and all Linux distributions; consult your operating system provider for installation instructions.

The native libraries needed include:

For GCC, packages are available for Mac OSX and all Linux distributions; consult your operating system provider for installation instructions. When build PIL from source, ensure that you have development libraries available for libpng, libjpeg, and libgif if you want to be able to use those formats in your WorldMap site.

Install

The following steps should prepare a Python virtual environment for you. Note that you will need to manually create a PostGIS datbase and user first. The default connection settings are stored in src/GeoNodePy/geonode/settings.py: database name: wm_db user: wm_user password: wm_password

Postgres database creation

PostGIS 1.5

create user

create role wm_user password 'wm_password' superuser login;

create wm_db

psql -U postgres -c "create database wm_db with owner wm_user encoding 'UTF8' lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;" psql -U wm_user -d wm_db -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql psql -U wm_user -d wm_db -f /usr/share/postgresql/9.1/contrib/postgis_comments.sql psql -U wm_user -d wm_db -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql

create wmdata

psql -U postgres -c "create database wmdata with owner wm_user encoding 'UTF8' lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;" psql -U wm_user -d wmdata -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql psql -U wm_user -d wmdata -f /usr/share/postgresql/9.1/contrib/postgis_comments.sql psql -U wm_user -d wmdata -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql

PostGIS 2.0+

create user

createuser -P -s -E -l wm_user;

create PostGIS template with legacy GIST operators

createdb -E UTF8 -O wm_user template_postgis psql -U postgres -d template_postgis -c "CREATE EXTENSION postgis;" psql -U postgres -d template_postgis -f geonode/static/geonode/patches/postgis/legacy_gist.sql

create wm_db

createdb -E UTF8 -U wm_user -T template_postgis wm_db

create wmdata

createdb -E UTF8 -U wm_user -T template_postgis wmdata

GeoNode installation

git clone git://github.com/cga-harvard/cga-worldmap.git cga-worldmap

cd cga-worldmap

git submodule update --init

mkvirtualenv worldmap

pip install -r shared/requirements.txt

paver build # see note2 below

django-admin.py createsuperuser --settings=geonode.settings

Start the server: paver host

Once fully started, you should see a message indicating the address of your WorldMap::

Development GeoNode is running at http://localhost:8000/ The GeoNode is an unstoppable machine Press CTRL-C to shut down

This command::

django-admin.py createsuperuser --settings=geonode.settings

can be used to create additional administrative user accounts. The administrative control panel is not linked from the main site, but can be accessed at http://localhost:8000/admin/

Options

For JavaScript Developers

Minified Scripts ................

JavaScript Developers can switch to using unminified scripts and CSS:

  1. Get and run geonode-client:

    $ git clone git://github.com/GeoNode/geonode-client.git geonode-client $ cd geonode-client $ ant init debug

  2. Set the GEONODE_CLIENT_LOCATION entry in :file:src/geonode/settings.py to http://localhost:9090/ and run paver as described above.

Note that this requires ant (http://ant.apache.org/) in addition to the above build requirements.

VirtualBox Setup ................

To test the application in different browsers in VirtualBox guests, the following needs to be done before running paver host:

For Java Developers

How WorldMap Finds GeoServer ...........................

Java Developers can point the application at a particular GeoServer instance by setting the GEOSERVER_BASE_URL entry in settings.py to the context path of the GeoServer instance. This should include the trailing slash. For example, the GeoServer used for http://geonode.capra.opengeo.org/ is::

http://geonode.capra.opengeo.org/geoserver/

The default value is http://localhost:8001/geoserver/. The GeoServer module in :file:src/geoserver-geonode-ext/ is configured to provide a GeoServer instance at that port with the following commands::

cd src/geoserver-geonode-ext/
sh startup.sh

.. note:: Normally, mvn jetty:run-war would be sufficient. However, we use the shell script to add some extra parameters to the JVM command-line used to run Jetty in order to workaround a JVM bug that affects GeoNetwork.

If you want to change this service URL, edit :file:src/geonode/settings.py and change the line::

GEOSERVER_BASE_URL="http://localhost:8001/geoserver/"

to indicate the GeoServer URL that you want to use.

To run the Django app when Jetty is started independently, use::

paster serve --reload shared/dev-paste.ini

in the base of your working directory.

Alternative GeoServer Data Directories ......................................

This server defaults to using :file:gs-data/ as the data directory by default. If you need you need to use an alternative data directory, you can specify it by editing startup.sh to specify a different data directory::

-DGEOSERVER_DATA_DIR=/home/me/mydata/ 

For Deployment

Email .....

Adding an email gateway to WorldMap can be very useful, the two main reasons are the ADMINS and REGISTRATION_OPEN settings explained below.

Here is a sample configuration to setup a Gmail account as the email gateway::

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'foo@gmail.com'
EMAIL_HOST_PASSWORD = 'bar'
EMAIL_PORT = 587
EMAIL_USE_TLS = True

More informacion can be found in the django docs::

http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#email-backend

ADMINS ......

When DEBUG=False django will not display the usual error page, but will email the people in the ADMINS tuple with the error traceback::

ADMINS = (
    ('Carlos Valderrama', 'carlos.valderrama@gmail.com'),
    ('Diego Maradona', 'diego.maradona@gmail.com'),
)

REGISTRATION_OPEN .................

In order to let people autoregister to the WorldMap, set::

REGISTRATION_OPEN=True

This needs email to be configured and your website's domain name properly set in the Sites application (the default is example.com)::

http://localhost:8000/admin/sites/site/1

POSTGIS INTEGRATION ................. To automatically import uploaded shapefiles to a PostGIS database, open the settings.py file and set 'DB_DATASTORE' to 'True'. Then assign the appropriate connection values to the other DBDATASTORE* settings below it:

DB_DATASTORE_NAME = '' DB_DATASTORE_USER = '' DB_DATASTORE_PASSWORD = '' DB_DATASTORE_HOST = '<Database hostname (typically localhost)' DB_DATASTORE_PORT = '<Database port (typically 5432)>' DB_DATASTORE_TYPE='postgis'

TILE CACHING ............. Create or edit the 'gwc-gs.xml' file under the gwc directory within your GeoServer data directory:

true true true true true true 4 4 EPSG:900913 image/jpeg image/png image/png

GAZETTEER .............. The gazetteer is disabled by default because it adds a bit of complexity to the setup process. It should be enabled only if PostGIS integration is also enabled.

In your settings.py file:

If you want to enable full-text search for the gazetteer, run the following commands in the DB_DATASTORE database: ALTER TABLE gazetteer_gazetteerentry ADD COLUMN placename_tsv tsvector; CREATE INDEX placename_tsv_index on gazetteer_gazetteerentry using gin(placename_tsv); UPDATE gazetteer_gazetteerentry SET text_search = to_tsvector('english', coalesce(place_name,'')); CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE ON gazetteer_gazetteerentry FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger(placename_tsv, 'pg_catalog.english', place_name);

and then set GAZETTEER_FULLTEXTSEARCH = True in settings

QUEUE .............. WorldMap can now optionally make use of Celery (http://celeryproject.org/) to send certain tasks (updating the gazetteer, updating layer boundaries after creating/editing features) to a job queue where they will be processed later.

In your settings.py file, uncomment the following in INSTALLED_APPS:

The run interval is determined by QUEUE_INTERVAL - the default is 10 minutes.

You will need to manually setup and run the celery processes on your server. For basic instructions on doing so see :file:docs/deploy/celery_queue.txt

ALTERNATE LAYER-SPECIFIC SECURITY SYSTEM ........................................................................................... Place config.xml file in geoserver's data/security/auth/geonodeAuthProvider:

-53e27318:1396869cb2d:-7fef geonodeAuthProvider org.geonode.security.GeoNodeAuthenticationProvider http://localhost:8000/ Change baseUrl if necessary. In WEB-INF/web.xml, add the following, and change the user/password values: org.geonode.security.databaseSecurityClient.url jdbc:postgresql://localhost:5432/worldmap?user=wmuser&password=wmus3r2012 Add the function in src/geoserver-geonode-ext/src/main/resources/org/geonode/security/geonode_authorize_layer.sql to the worldmap database Directory Structure =================== * docs/ - Documentation based on Sphinx * pavement.py - Main build script. * shared/ - Configuration files and support files for the installer. * src/ - Source code for the java, javascript and python modules. Split in: * geonode-client/ - the JavaScript/CSS for general apps (the Map editor, search, embedded viewer...) * GeoNodePy/ - the Python/Django modules. Inside, geonode/ is the "core". * geoserver-geonode-ext/ - the GeoServer extensions used by the GeoNode. Actually, the build script for this project is set up to create a WAR that includes those extensions, not just a bundle with the extension. GPL License ======= WorldMap is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. WorldMap is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with WorldMap. If not, see . WorldMap is Copyright 2014 President and Fellows of Harvard College