Skip to content

Instantly share code, notes, and snippets.

@tomkralidis
Last active June 25, 2017 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomkralidis/ddf5ea8b08ae90df592863cf065bd35f to your computer and use it in GitHub Desktop.
Save tomkralidis/ddf5ea8b08ae90df592863cf065bd35f to your computer and use it in GitHub Desktop.
pycsw profile plugin example
from pycsw.plugins.profiles import profile
class FOO(profile.Profile):
''' FOO class '''
def __init__(self, model, namespaces, context):
self.context = context
self.namespaces = {
'foo': 'http://example.org/foo'
}
self.repository = {
'foo:FooMetadata': {
#'outputschema': 'http://www.isotc211.org/2005/gmd',
'queryables': {
'FooQueryables': {
'foo:cloud_cover': {'xpath': '//foo:cloud_cover', 'dbcol': 'cloud_cover'}
}
}
}
}
profile.Profile.__init__(self,
name='foo',
version='0.1.0',
title='Foo Metadata Application Profile',
url='http://example.org/fooprofile',
namespace=self.namespaces['foo'],
typename='foo:FooMetadata',
outputschema=None,
prefixes=['foo'],
model=model,
core_namespaces=namespaces,
added_namespaces=self.namespaces,
repository=self.repository['foo:FooMetadata'])
def extend_core(self, model, namespaces, config):
''' Extend core configuration '''
pass
def check_parameters(self, kvp):
'''Check for Language parameter in GetCapabilities request'''
return None
def get_extendedcapabilities(self):
''' Add child to ows:OperationsMetadata Element '''
return None
def get_schemacomponents(self):
''' Return schema components as lxml.etree.Element list '''
return []
def check_getdomain(self, kvp):
'''Perform extra profile specific checks in the GetDomain request'''
return None
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc" service="CSW" version="2.0.2" resultType="results" startPosition="1" maxRecords="5" outputFormat="application/xml" outputSchema="http://www.opengis.net/cat/csw/2.0.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd">
<csw:Query typeNames="csw:Record">
<csw:ElementSetName>full</csw:ElementSetName>
<csw:Constraint version="1.1.0">
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>foo:cloud_cover</ogc:PropertyName>
<ogc:Literal>50</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</csw:Constraint>
</csw:Query>
</csw:GetRecords>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment