Skip to content

- Allow for customization of the GeoNode instance for BSVE #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ansible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ You can also change the war used to deploy geoserver with the following variable
* Change the 'DATAQS_APPS' setting to add/remove individual dataqs processors
* Change the 'CELERYBEAT_SCHEDULE' setting to add/remove/modify scheduled dataqs celery tasks

### Additional Customizations

* roles/dataqs/templates/custom_settings.py:
* Replace this file with your own or add/modify/remove settings in the current file
* Any settings and/or apps specified in this file will be added to the GeoNode instance

### Setting up a vagrant box

To configure a local development virtual machine, you will need to have virtualbox and vagrant installed.
Expand Down
13 changes: 7 additions & 6 deletions ansible/roles/dataqs/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,19 @@
strip=1
notify: restart uwsgi

- name: copy settings to geonode application
- name: copy dataqs settings to geonode application
template: src=dataq_settings.py dest={{geonode_root}}/dataq_settings.py
notify: restart uwsgi

- name: copy custom settings to geonode application
template: src=custom_settings.py dest={{geonode_root}}/custom_settings.py

- name: import dataq settings in geonode configuration
lineinfile: name="{{geonode_root}}/local_settings.py" state=present
insertafter="EOF" line="from dataq_settings import *"
notify: restart uwsgi

- name: enable dataq apps in geonode configuration
lineinfile: name={{geonode_root}}/local_settings.py state=present
insertafter=EOF line="dataqs_extend()"
- name: import custom settings in geonode configuration
lineinfile: name="{{geonode_root}}/local_settings.py" state=present
insertafter="EOF" line="from custom_settings import *"
notify: restart uwsgi

- name: install supervisor config for workers
Expand Down
31 changes: 31 additions & 0 deletions ansible/roles/dataqs/templates/custom_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
#########################################################################
#
# Copyright (C) 2012 OpenPlans
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
#########################################################################

# Custom BSVE settings and apps for GeoNode/dataqs.
from settings import INSTALLED_APPS

LANDSCAN_FILEPATH = \
"http://web.ornl.gov/sci/landscan/landscan2011/LS11sample_Cyprus.zip"

CUSTOM_APPS = (
# Insert any custom/additional Django apps here
)

INSTALLED_APPS += CUSTOM_APPS
6 changes: 2 additions & 4 deletions ansible/roles/dataqs/templates/dataq_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

# Django settings for the GeoNode project.
from celery.schedules import crontab
from settings import INSTALLED_APPS

# Append these to INSTALLED_APPS
DATAQS_APPS = (
Expand Down Expand Up @@ -287,7 +288,4 @@
'description': "The Jewish Synagogues dataset is derived from the TGS 2009 Q4 'PlacesofWorship' data layer and contains all Jewish Synagogues in the United States. The remaining portion of this abstract, as well as much of the remaining metadata, references the entire Places of Worship database from which this subset was derived: The Places of Worship dataset is composed of any type of building or portion of a building that is used, constructed, designed, or adapted to be used as a place for religious and spiritual activities. These facilities include, but are not limited to, the following types: chapels, churches, mosques, shrines, synagogues, and temples. The license free Large Protestant Churches, Mosques, Jewish Synagogues, and Roman Catholic Churches in Large Cities datasets were merged together to create the initial data for the Places of Worship dataset. Additional entities have been added from TGS research. This dataset contains Buddhist, Christian, Hindu, Islamic, Judaic, and Sikh places of worship. Unitarian places of worship have been included when a congregation from one of these religions meets at a church owned by a Unitarian congregation. Some Protestant denominations are not currently represented in this dataset. The Places of Worship dataset is not intended to include homes of religious leaders (unless they also serve as a place of organized worship), religious schools (unless they also serve as a place of organized worship for people other than those enrolled in the school), Jewish Mikvahs or Hillel facilities, and buildings that serve a purely administrative purpose. If a building's primary purpose is something other than worship (e.g., a community center, a public school), but a religious group uses the building for worship on a regular basis, it was included in this dataset if it otherwise met the criteria for inclusion. Convents and monasteries are included in this dataset, regardless of whether or not the facilities are open to the public, because religious services are regularly held at these locations. TGS was not tasked with ensuring the completeness of this layer. No entities are included in this dataset for the Commonwealth of the Northern Mariana Islands. On 08/07/2007, TGS ceased making phone calls to verify information about religious locations. Therefore, most entities in this dataset were verified using alternative reference sources such as topographic maps, parcel maps, various sources of imagery, and internet research. The [CONTHOW] (contact how) value for these entities has been set to 'ALT REF'. The website http://www.gettochurch.org was used for verification during processing. As of August 2009, this website is no longer active. Records with '-DOD' appended to the end of the [NAME] value are located on a military base, as defined by the Defense Installation Spatial Data Infrastructure (DISDI) military installations and military range boundaries."
}
]

def dataqs_extend():
from settings import INSTALLED_APPS
INSTALLED_APPS += DATAQS_APPS
INSTALLED_APPS += DATAQS_APPS
39 changes: 23 additions & 16 deletions dataqs/landscan/landscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
# limitations under the License.
###############################################################################
import os
from urllib import urlretrieve
import zipfile

import gdal

from django.conf import settings
from dataqs.helpers import style_exists
from dataqs.processor_base import GeoDataProcessor

Expand All @@ -41,19 +39,28 @@ def get_landscan(self):
Downloads the sample landscan image for Cyprus
"""

url = "http://web.ornl.gov/sci/landscan/" + \
"landscan2011/LS11sample_Cyprus.zip"

zip_dir = os.path.join(self.tmp_dir, "landscan.zip")
urlretrieve(url, zip_dir)

# Open up the zip file
zip_ref = zipfile.ZipFile(zip_dir, 'r')
landscan_dir = os.path.join(self.tmp_dir, "landscan")
zip_ref.extractall(landscan_dir)
zip_ref.close()

return landscan_dir
landscan = getattr(settings, "LANDSCAN_FILEPATH",
"http://web.ornl.gov/sci/landscan/" +
"landscan2011/LS11sample_Cyprus.zip")
print(landscan)
if landscan.startswith("http"):
filepath = os.path.join(self.tmp_dir, landscan.split("/")[-1])
self.download(landscan, filepath)
else:
filepath = landscan

if os.path.splitext(filepath)[1].lower() == ".zip":
# Open up the zip file
zip_ref = zipfile.ZipFile(filepath, 'r')
landscan_dir = os.path.join(self.tmp_dir, "landscan")
zip_ref.extractall(landscan_dir)
zip_ref.close()
print(landscan_dir)
return landscan_dir
else:
# Assume it's a directory
print(filepath)
return filepath

def convert_landscan(self, landscan_dir):
"""
Expand Down
11 changes: 11 additions & 0 deletions local_settings.py.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@ from django.conf import settings

INSTALLED_APPS = settings.INSTALLED_APPS + (
'dataqs',
'dataqs.aqicn',
'dataqs.airnow',
'dataqs.forecastio',
'dataqs.gfms',
'dataqs.gdacs',
'dataqs.hifld',
'dataqs.nasa_gpm',
'dataqs.spei',
'dataqs.usgs_quakes',
'dataqs.gistemp',
'dataqs.worldclim',
)