Skip to content

Commit

Permalink
[Fw-port #3817] Implements GNIP #3718 (Worldmap contrib application)
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Jun 6, 2018
1 parent abd6ac9 commit b2c2789
Show file tree
Hide file tree
Showing 132 changed files with 6,278 additions and 668 deletions.
30 changes: 30 additions & 0 deletions geonode/base/migrations/0034_auto_20180606_1543.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.11 on 2018-06-06 15:43
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('base', '0033_auto_20180330_0951'),
]

operations = [
migrations.AlterField(
model_name='resourcebase',
name='metadata_uploaded_preserve',
field=models.BooleanField(default=False, verbose_name='Metadata uploaded preserve'),
),
migrations.AlterField(
model_name='resourcebase',
name='thumbnail_url',
field=models.TextField(blank=True, null=True, verbose_name='Thumbnail url'),
),
migrations.AlterField(
model_name='resourcebase',
name='tkeywords',
field=models.ManyToManyField(blank=True, help_text='formalised word(s) or phrase(s) from a fixed thesaurus used to describe the subject (space or comma-separated', to='base.ThesaurusKeyword', verbose_name='keywords'),
),
]
5 changes: 3 additions & 2 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):
manager=_HierarchicalTagManager)
tkeywords = models.ManyToManyField(
ThesaurusKeyword,
verbose_name=_('keywords'),
help_text=tkeywords_help_text,
blank=True)
regions = models.ManyToManyField(
Expand Down Expand Up @@ -736,7 +737,7 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):

# metadata XML specific fields
metadata_uploaded = models.BooleanField(default=False)
metadata_uploaded_preserve = models.BooleanField(default=False)
metadata_uploaded_preserve = models.BooleanField(_('Metadata uploaded preserve'), default=False)
metadata_xml = models.TextField(
null=True,
default='<gmd:MD_Metadata xmlns:gmd="http://www.isotc211.org/2005/gmd"/>',
Expand All @@ -757,7 +758,7 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):
help_text=_('Is this resource validated from a publisher or editor?'))

# fields necessary for the apis
thumbnail_url = models.TextField(null=True, blank=True)
thumbnail_url = models.TextField(_("Thumbnail url"), null=True, blank=True)
detail_url = models.CharField(max_length=255, null=True, blank=True)
rating = models.IntegerField(default=0, null=True, blank=True)

Expand Down
43 changes: 43 additions & 0 deletions geonode/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def resource_urls(request):
USE_GEOSERVER=settings.USE_GEOSERVER,
USE_NOTIFICATIONS=has_notifications,
USE_MONITORING='geonode.contrib.monitoring' in settings.INSTALLED_APPS and settings.MONITORING_ENABLED,
USE_WORLDMAP=settings.USE_WORLDMAP,
DEFAULT_ANONYMOUS_VIEW_PERMISSION=getattr(settings, 'DEFAULT_ANONYMOUS_VIEW_PERMISSION', False),
DEFAULT_ANONYMOUS_DOWNLOAD_PERMISSION=getattr(settings, 'DEFAULT_ANONYMOUS_DOWNLOAD_PERMISSION', False),
EXIF_ENABLED=getattr(
Expand All @@ -170,4 +171,46 @@ def resource_urls(request):
),
OGC_SERVER=getattr(settings, 'OGC_SERVER', None),
)
if settings.USE_WORLDMAP:
defaults['GEONODE_CLIENT_LOCATION'] = getattr(
settings,
'GEONODE_CLIENT_LOCATION',
'/static/worldmap/worldmap_client/'
)

defaults['USE_HYPERMAP'] = getattr(
settings,
'USE_HYPERMAP',
False
)

# TODO disable DB_DATASTORE setting
defaults['DB_DATASTORE'] = True

defaults['HYPERMAP_REGISTRY_URL'] = settings.HYPERMAP_REGISTRY_URL

defaults['MAPPROXY_URL'] = settings.HYPERMAP_REGISTRY_URL

defaults['SOLR_URL'] = settings.SOLR_URL

defaults['USE_GAZETTEER'] = settings.USE_GAZETTEER

defaults['GOOGLE_API_KEY'] = settings.GOOGLE_API_KEY

defaults['GOOGLE_MAPS_API_KEY'] = settings.GOOGLE_MAPS_API_KEY

defaults['WM_COPYRIGHT_URL'] = getattr(
settings,
'WM_COPYRIGHT_URL',
'http://gis.harvard.edu/'
)

defaults['WM_COPYRIGHT_TEXT'] = getattr(
settings,
'WM_COPYRIGHT_TEXT',
'Center for Geographic Analysis'
)

defaults['HYPERMAP_REGISTRY_URL'] = settings.HYPERMAP_REGISTRY_URL

return defaults
8 changes: 4 additions & 4 deletions geonode/contrib/createlayer/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#########################################################################

from django import forms

from django.utils.translation import ugettext as _

GEOMETRY_TYPES = (
('Point', 'Points'),
Expand All @@ -32,9 +32,9 @@ class NewLayerForm(forms.Form):
"""
A form to create an empty layer in PostGIS.
"""
name = forms.CharField(label='Layer name', max_length=255)
title = forms.CharField(label='Layer title', max_length=255)
geometry_type = forms.ChoiceField(choices=GEOMETRY_TYPES)
name = forms.CharField(label=_('Layer name'), max_length=255)
title = forms.CharField(label=_('Layer title'), max_length=255)
geometry_type = forms.ChoiceField(label=_('Geometry type'), choices=GEOMETRY_TYPES)

permissions = forms.CharField(
widget=forms.HiddenInput(
Expand Down
22 changes: 13 additions & 9 deletions geonode/contrib/createlayer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@

logger = logging.getLogger(__name__)

BBOX = [-180, 180, -90, 90]
DATA_QUALITY_MESSAGE = "Created with GeoNode"


def create_layer(name, title, owner_name, geometry_type, attributes=None):
"""
Expand Down Expand Up @@ -70,11 +73,11 @@ def create_gn_layer(workspace, datastore, name, title, owner_name):
title=title,
owner=owner,
uuid=str(uuid.uuid4()),
bbox_x0=-180,
bbox_x1=180,
bbox_y0=-90,
bbox_y1=90,
srid='EPSG:4326',
bbox_x0=BBOX[0],
bbox_x1=BBOX[1],
bbox_y0=BBOX[2],
bbox_y1=BBOX[3],
data_quality_statement=DATA_QUALITY_MESSAGE,
)
return layer

Expand Down Expand Up @@ -142,16 +145,16 @@ def get_or_create_datastore(cat, workspace=None, charset="UTF-8"):
"""

# TODO refactor this and geoserver.helpers._create_db_featurestore
dsname = ogc_server_settings.DATASTORE
# dsname = ogc_server_settings.DATASTORE
dsname = ogc_server_settings.datastore_db['NAME']
if not ogc_server_settings.DATASTORE:
msg = ("To use the createlayer application you must set ogc_server_settings.datastore_db['ENGINE']"
" to 'django.contrib.gis.db.backends.postgis")
logger.error(msg)
raise GeoNodeException(msg)

try:
ds = cat.get_store(dsname, workspace) or\
cat.create_datastore(dsname, workspace=workspace)
ds = cat.get_store(dsname, workspace)
except FailedRequestError:
ds = cat.create_datastore(dsname, workspace=workspace)

Expand Down Expand Up @@ -228,12 +231,13 @@ def create_gs_layer(name, title, geometry_type, attributes=None):
"<nativeName>{native_name}</nativeName>"
"<title>{title}</title>"
"<srs>EPSG:4326</srs>"
"<latLonBoundingBox><minx>-180</minx><maxx>180</maxx><miny>-90</miny><maxy>90</maxy>"
"<latLonBoundingBox><minx>{minx}</minx><maxx>{maxx}</maxx><miny>{miny}</miny><maxy>{maxy}</maxy>"
"<crs>EPSG:4326</crs></latLonBoundingBox>"
"{attributes}"
"</featureType>").format(
name=name.encode('UTF-8', 'strict'), native_name=native_name.encode('UTF-8', 'strict'),
title=title.encode('UTF-8', 'strict'),
minx=BBOX[0], maxx=BBOX[1], miny=BBOX[2], maxy=BBOX[3],
attributes=attributes_block)

url = ('%s/workspaces/%s/datastores/%s/featuretypes'
Expand Down
Empty file.
Empty file.
29 changes: 29 additions & 0 deletions geonode/contrib/worldmap/gazetteer/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from django.contrib import admin

from .models import GazetteerEntry, GazetteerAttribute


class GazetteerEntryAdmin(admin.ModelAdmin):
list_display = (
'layer_name',
'layer_attribute',
'feature_type',
'place_name',
'project',
'username',
)


class GazetteerAttributeAdmin(admin.ModelAdmin):
list_display = (
'layer_name',
'attribute',
'in_gazetteer',
'is_start_date',
'is_end_date',
'date_format',
)


admin.site.register(GazetteerEntry, GazetteerEntryAdmin)
admin.site.register(GazetteerAttribute, GazetteerAttributeAdmin)

0 comments on commit b2c2789

Please sign in to comment.