Permalink
Browse files

Merge pull request #6 from tomkralidis/csw

CSW modifications
  • Loading branch information...
2 parents 7ab176c + 550c915 commit 6523fe46ee41dcb2299ea6582d7d7827773f8672 @ahinz ahinz committed Jul 2, 2012
@@ -24,7 +24,7 @@
'pycsw:CRS': 'csw_crs',
'pycsw:AlternateTitle': 'title_alternate',
'pycsw:RevisionDate': 'date_revision',
- 'pycsw:CreationDate': 'created_by',
+ 'pycsw:CreationDate': 'created',
'pycsw:PublicationDate': 'date_publication',
'pycsw:OrganizationName': 'organization',
'pycsw:SecurityConstraints': 'securityconstraints',
@@ -7,7 +7,6 @@
from django.db.models import Q
from django.conf import settings
from django.contrib.auth.models import User
-from django.contrib.sites.models import Site
from django.template.defaultfilters import slugify
from django.db.models.signals import post_save
@@ -160,8 +159,9 @@ def __unicode__(self):
# CSW specific properties
@property
def csw_identifier(self):
- domain = Site.objects.get_current().domain
- fqrhn = '.'.join((reversed(domain.split('.'))))
+ if not settings.SITEHOST:
+ raise RuntimeError('settings.SITEHOST is not set')
+ fqrhn = '.'.join((reversed(settings.SITEHOST.split('.'))))
return 'urn:x-odc:resource:%s::%d' % (fqrhn, self.id)
@property
@@ -184,8 +184,7 @@ def csw_links(self):
for url in self.url_set.all():
tmp = '%s,%s,%s,%s' % (url.url_label, url.url_type.url_type, 'WWW:DOWNLOAD-1.0-http--download', url.url)
links.append(tmp)
- domain = Site.objects.get_current().domain
- abs_url = 'http://%s%s' % (domain, self.get_absolute_url())
+ abs_url = '%s%s' % (gen_website_url(), self.get_absolute_url())
link = '%s,%s,%s,%s' % (self.name, self.name, 'WWW:LINK-1.0-http--link', abs_url)
links.append(link)
return '^'.join(links)
@@ -224,11 +223,10 @@ def nspath(ns, element):
for tag in self.tags.all():
etree.SubElement(record, nspath(nsmap['dc'], 'subject')).text = tag.tag_name
-
+
etree.SubElement(record, nspath(nsmap['dc'], 'format')).text = str(self.data_formats)
- domain = Site.objects.get_current().domain
- abs_url = 'http://%s%s' % (domain, self.get_absolute_url())
+ abs_url = '%s%s' % (gen_website_url(), self.get_absolute_url())
etree.SubElement(record, nspath(nsmap['dct'], 'references'), scheme='WWW:LINK-1.0-http--link').text = abs_url
for link in self.url_set.all():
@@ -241,6 +239,8 @@ def nspath(ns, element):
etree.SubElement(record, nspath(nsmap['dc'], 'date')).text = str(self.created)
etree.SubElement(record, nspath(nsmap['dc'], 'creator')).text = str(self.csw_creator)
+ etree.SubElement(record, nspath(nsmap['dc'], 'coverage')).text = self.area_of_interest
+
geom = loads(self.wkt_geometry)
bounds = geom.envelope.bounds
dimensions = str(geom.envelope._ndim)
@@ -348,3 +348,18 @@ class ODPUserProfile(models.Model):
can_notify = models.BooleanField(default=False)
user = models.ForeignKey(User, unique=True)
+
+def gen_website_url():
+ if not settings.SITEHOST:
+ raise RuntimeError('settings.SITEHOST is not set')
+ if not settings.SITEPORT:
+ raise RuntimeError('settings.SITEPORT is not set')
+
+ scheme = 'http'
+ port = ':%d' % settings.SITEPORT
+
+ if settings.SITEPORT == 443:
+ scheme = 'https'
+ if settings.SITEPORT == 80:
+ port = ''
+ return '%s://%s%s' % (scheme, settings.SITEHOST, port)
@@ -181,6 +181,11 @@
'csw',
)
+# the hostname of the deployment
+SITEHOST = None
+# the port which the deployment runs on
+SITEPORT = None
+
# pycsw configuration
CSW = {
'server': {
@@ -191,9 +191,10 @@ <h2 id="description">{{resource.short_description|safe}}</h2>
<div class="tab_container" id="content_data">
<ul class="tab_header">
- <li class="tab_button"><a href="#data-tab">DATA</a></li>
+ <li class="tab_button"><a href="#tab_data" onclick="odp.trackEvent('Resource Data', 'Data', 'Resource', {{resource.id}});return false;">DATA</a></li>
+ <li class="tab_button"><a href="#tab_metadata" onclick="odp.trackEvent('Resource Data', 'Metadata', 'Resource', {{resource.id}});return false;">METADATA</a></li>
</ul>
- <div class="tab_body" id="#data-tab">
+ <div class="tab_body" id="tab_data">
{% if resource.get_grouped_urls.Data %}
<div class="data_block">
<div class="url_header">
@@ -248,6 +249,18 @@ <h2 id="description">{{resource.short_description|safe}}</h2>
<div class="clear"></div>
</div>
+
+ <div class="tab_body" id="tab_metadata">
+ <div class="data_block">
+ <div class="info_label">XML Metadata</div>
+ <div class="info_data">
+ <a href="{{SITE_ROOT}}/csw/?service=CSW&amp;version=2.0.2&amp;request=GetRecordById&amp;id={{resource.csw_identifier}}">Dublin Core</a>
+ <a href="{{SITE_ROOT}}/csw/?service=CSW&amp;version=2.0.2&amp;request=GetRecordById&amp;id={{resource.csw_identifier}}&amp;outputschema=http://www.opengis.net/cat/csw/csdgm">FGDC</a>
+ <a href="{{SITE_ROOT}}/csw/?service=CSW&amp;version=2.0.2&amp;request=GetRecordById&amp;id={{resource.csw_identifier}}&amp;outputschema=http://www.isotc211.org/2005/gmd">TC211</a>
+ </div>
+ </div>
+ </div>
+
</div>
<div class="tab_container" id="content_ratings">
@@ -38,7 +38,11 @@ <h1 id="results_label">All Records</h1>
{% endif %}
<div id="results_header">
<div id="results_info">
+ {% if results.count == 1 %}
+ <h2 id="count">{{results.count}} RESULT</h2>
+ {% else %}
<h2 id="count">{{results.count}} RESULTS</h2>
+ {% endif %}
<div id="filter">
<ul>
<li id="filter_application"><a href="javascript:void()" onClick="odp.getFiltered('application');return false;" class="url_image" ></a></li>
@@ -24,6 +24,7 @@ <h2 class="grid">About</h2>
<li id="contact"><a href="{{SITE_ROOT}}/contact/">Contact</a></li>
<li id="terms"><a href="{{SITE_ROOT}}/terms/">Terms</a></li>
<li id="feeds"><a href="{{SITE_ROOT}}/feeds/">RSS Feeds</a></li>
+ <li id="feeds"><a href="{{SITE_ROOT}}/csw/?service=CSW&amp;version=2.0.2&amp;request=GetCapabilities">OGC Catalogue Service</a></li>
{% if perms.opendata.change_resource %}
<li class="separator"></li>
<li id="admin"><a href="{{SITE_ROOT}}/_admin_">Administration</a></li>
View
@@ -67,6 +67,8 @@ Update the database settings in settings.py. You'll probably have to update "nam
}
}
+Open Data Catalog supports the [OGC Catalogue Service] (http://www.opengeospatial.org/standards/specifications/catalog) specification (CSW) using [pycsw](http://pycsw.org). CSW settings can be set/modified in `settings.CSW`. As well, `settings.SITEHOST` and `settings.SITEPORT` must be set accordingly for your deployment environment.
+
### Creating the database scheme
To create the scheme we use django "syncdb" command
@@ -113,7 +115,7 @@ Django can run via mod_wsgi on Apache as well. Add the following to a new Apache
import django.conf
import django.utils
- django.utils.translation.activate(jangod.conf.settings.LANGUAGE_CODE)
+ django.utils.translation.activate(django.conf.settings.LANGUAGE_CODE)
import django.core.handlers.wsgi

0 comments on commit 6523fe4

Please sign in to comment.