def handle(self, request, collection_id=None, format_name=None): decoder = OpenSearch11BaseDecoder(request.GET) if collection_id: qs = models.Collection.objects.get( identifier=collection_id ).eo_objects.all() else: qs = models.Collection.objects.all() if decoder.search_terms: # TODO: search descriptions, summary etc once available qs = qs.filter(identifier__icontains=decoder.search_terms) namespaces = NameSpaceMap() all_parameters = {} for search_extension in self.search_extensions: # get all search extension related parameters and translate the name # to the actual parameter name params = dict( (parameter["type"], request.GET[parameter["name"]]) for parameter in search_extension.get_schema() if parameter["name"] in request.GET ) qs = search_extension.filter(qs, params) namespaces.add(search_extension.namespace) all_parameters[search_extension.namespace.prefix] = params total_count = len(qs) if decoder.start_index and not decoder.count: qs = qs[decoder.start_index:] elif decoder.start_index and decoder.count: qs = qs[decoder.start_index:decoder.start_index+decoder.count] elif decoder.count: qs = qs[:decoder.count] try: result_format = next( result_format for result_format in self.result_formats if result_format.name == format_name ) except StopIteration: raise Http404("No such result format '%s'." % format_name) search_context = SearchContext( total_count, decoder.start_index, decoder.count, len(qs), all_parameters, namespaces ) return ( result_format.encode(request, collection_id, qs, search_context), result_format.mimetype )
def __init__(self, search_extensions): ns_os = NameSpace("http://a9.com/-/spec/opensearch/1.1/", None) self.ns_param = ns_param = NameSpace( "http://a9.com/-/spec/opensearch/extensions/parameters/1.0/", "parameters" ) nsmap = NameSpaceMap(ns_os, ns_param) for search_extension in search_extensions: nsmap.add(search_extension.namespace) self.OS = ElementMaker(namespace=ns_os.uri, nsmap=nsmap) self.PARAM = ElementMaker(namespace=ns_param.uri, nsmap=nsmap) self.search_extensions = search_extensions
def __init__(self, search_extensions): ns_os = NameSpace("http://a9.com/-/spec/opensearch/1.1/", None) self.ns_param = ns_param = NameSpace( "http://a9.com/-/spec/opensearch/extensions/parameters/1.0/", "parameters") ns_atom = NameSpace("http://www.w3.org/2005/Atom", "atom") nsmap = NameSpaceMap(ns_os, ns_param, ns_atom) for search_extension in search_extensions: nsmap.add(search_extension.namespace) self.OS = ElementMaker(namespace=ns_os.uri, nsmap=nsmap) self.PARAM = ElementMaker(namespace=ns_param.uri, nsmap=nsmap) self.ATOM = ElementMaker(namespace=ns_atom.uri, nsmap=nsmap) self.search_extensions = search_extensions
class WCS20GeoTIFFEncodingExtensionXMLDecoder(xml.Decoder): compression = xml.Parameter("wcs:Extension/geotiff:parameters/geotiff:compression/text()", num="?", type=compression_enum, locator="geotiff:compression") jpeg_quality = xml.Parameter("wcs:Extension/geotiff:parameters/geotiff:jpeg_quality/text()", num="?", type=int, locator="geotiff:jpeg_quality") predictor = xml.Parameter("wcs:Extension/geotiff:parameters/geotiff:predictor/text()", num="?", type=predictor_enum, locator="geotiff:predictor") interleave = xml.Parameter("wcs:Extension/geotiff:parameters/geotiff:interleave/text()", num="?", type=interleave_enum, locator="geotiff:interleave") tiling = xml.Parameter("wcs:Extension/geotiff:parameters/geotiff:tiling/text()", num="?", type=boolean, locator="geotiff:tiling") tileheight = xml.Parameter("wcs:Extension/geotiff:parameters/geotiff:tileheight/text()", num="?", type=parse_multiple_16, locator="geotiff:tileheight") tilewidth = xml.Parameter("wcs:Extension/geotiff:parameters/geotiff:tilewidth/text()", num="?", type=parse_multiple_16, locator="geotiff:tilewidth") namespaces = NameSpaceMap( ns_wcs, NameSpace("http://www.opengis.net/gmlcov/geotiff/1.0", "geotiff") )
# THE SOFTWARE. #------------------------------------------------------------------------------- from lxml.builder import ElementMaker from eoxserver.core.util.xmltools import NameSpace, NameSpaceMap from eoxserver.core.util.timetools import isoformat from eoxserver.resources.coverages import crss # namespace declarations ns_gml = NameSpace("http://www.opengis.net/gml/3.2", "gml") ns_gmlcov = NameSpace("http://www.opengis.net/gmlcov/1.0", "gmlcov") ns_om = NameSpace("http://www.opengis.net/om/2.0", "om") ns_eop = NameSpace("http://www.opengis.net/eop/2.0", "eop") nsmap = NameSpaceMap(ns_gml, ns_gmlcov, ns_om, ns_eop) # Element factories GML = ElementMaker(namespace=ns_gml.uri, nsmap=nsmap) GMLCOV = ElementMaker(namespace=ns_gmlcov.uri, nsmap=nsmap) OM = ElementMaker(namespace=ns_om.uri, nsmap=nsmap) EOP = ElementMaker(namespace=ns_eop.uri, nsmap=nsmap) class GML32Encoder(object): def encode_linear_ring(self, ring, sr): frmt = "%.3f %.3f" if sr.projected else "%.8f %.8f" swap = crss.getAxesSwapper(sr.srid) pos_list = " ".join(frmt % swap(*point) for point in ring)
), encoder.content_type, 400 ) class WMS13Decoder(kvp.Decoder): width = kvp.Parameter(type=int, num="?") height = kvp.Parameter(type=int, num="?") format = kvp.Parameter(num="?") bgcolor = kvp.Parameter(num="?") exceptions = kvp.Parameter(num="?", type=lower, default="xml") ns_ogc = NameSpace("http://www.opengis.net/ogc", "ogc") nsmap = NameSpaceMap(ns_ogc) OGC = ElementMaker(namespace=ns_ogc.uri, nsmap=nsmap) class WMS13ExceptionXMLEncoder(XMLEncoder): def encode_exception(self, message, code, locator=None): attributes = { "code": code } if locator: attributes["locator"] = locator return OGC("ServiceExceptionReport", OGC("ServiceException", str(message), **attributes ),
def handle(self, request, collection_id=None, format_name=None): if request.method == "GET": request_parameters = request.GET elif request.method == "POST": request_parameters = request.POST else: raise Exception("Invalid request method '%s'." % request.method) decoder = OpenSearch11BaseDecoder(request_parameters) if collection_id: qs = models.Collection.objects.get( identifier=collection_id ).eo_objects.all() else: qs = models.Collection.objects.all() if decoder.search_terms: # TODO: search descriptions, summary etc once available qs = qs.filter(identifier__icontains=decoder.search_terms) namespaces = NameSpaceMap() all_parameters = {} for search_extension in self.search_extensions: # get all search extension related parameters and translate the name # to the actual parameter name params = dict( (parameter["type"], request_parameters[parameter["name"]]) for parameter in search_extension.get_schema() if parameter["name"] in request_parameters ) qs = search_extension.filter(qs, params) namespaces.add(search_extension.namespace) all_parameters[search_extension.namespace.prefix] = params total_count = len(qs) if decoder.start_index and not decoder.count: qs = qs[decoder.start_index:] elif decoder.start_index and decoder.count: qs = qs[decoder.start_index:decoder.start_index+decoder.count] elif decoder.count: qs = qs[:decoder.count] elif decoder.count == 0: if collection_id: qs = models.Collection.objects.none() else: qs = models.EOObject.objects.none() try: result_format = next( result_format for result_format in self.result_formats if result_format.name == format_name ) except StopIteration: raise Http404("No such result format '%s'." % format_name) default_page_size = 100 # TODO: make this configurable search_context = SearchContext( total_count, decoder.start_index, decoder.count or default_page_size, len(qs), all_parameters, namespaces ) return ( result_format.encode(request, collection_id, qs, search_context), result_format.mimetype )
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. #------------------------------------------------------------------------------- from eoxserver.core.decoders import kvp, xml, upper, typelist from eoxserver.core.util.xmltools import NameSpace, NameSpaceMap from eoxserver.services.ows.version import parse_version_string ns_xlink = NameSpace("http://www.w3.org/1999/xlink", "xlink") ns_ows10 = NameSpace("http://www.opengis.net/ows/1.0", "ows10") ns_ows11 = NameSpace("http://www.opengis.net/ows/1.1", "ows11") ns_ows20 = NameSpace("http://www.opengis.net/ows/2.0", "ows20") nsmap = NameSpaceMap(ns_ows10, ns_ows11, ns_ows20) def get_decoder(request): """ Convenience function to return the right OWS Common request deocder for the given `django.http.HttpRequest`. """ if request.method == "GET": return OWSCommonKVPDecoder(request.GET) elif request.method == "POST": # TODO: this may also be in a different format. return OWSCommonXMLDecoder(request.body) class OWSCommonKVPDecoder(kvp.Decoder): service = kvp.Parameter("service", type=upper, num="?")
# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # ------------------------------------------------------------------------------ from lxml.builder import E, ElementMaker from eoxserver.core.util.xmltools import XMLEncoder, NameSpace, NameSpaceMap ns_xlink = NameSpace("http://www.w3.org/1999/xlink", "xlink") nsmap = NameSpaceMap(ns_xlink) E_WITH_XLINK = ElementMaker(nsmap=nsmap) class WMS11Encoder(XMLEncoder): def encode_capabilities(self, config, ows_url, srss, formats, info_formats, layer_descriptions): return E( "WMT_MS_Capabilities", E( "Service", E("Name", config.name), E("Title", config.title), E("Abstract", config.abstract), E("KeywordList", *[E("Keyword", keyword) for keyword in config.keywords]),
from django.conf import settings import traceback from itertools import chain from lxml import etree from lxml.builder import ElementMaker from eoxserver.core.util.xmltools import XMLEncoder, NameSpace, NameSpaceMap from eoxserver.services.ows.dispatch import filter_handlers ns_xlink = NameSpace("http://www.w3.org/1999/xlink", "xlink") ns_ows = NameSpace("http://www.opengis.net/ows/2.0", "ows", "http://schemas.opengis.net/ows/2.0/owsAll.xsd") ns_xml = NameSpace("http://www.w3.org/XML/1998/namespace", "xml") nsmap = NameSpaceMap(ns_ows) OWS = ElementMaker(namespace=ns_ows.uri, nsmap=nsmap) class OWS20Encoder(XMLEncoder): def get_conf(self): raise NotImplementedError def get_http_service_url(self, request): conf = self.get_conf() if conf.http_service_url: return conf.http_service_url from eoxserver.services.urls import get_http_service_url return get_http_service_url(request) def encode_reference(self, node_name, href, reftype="simple"):
InvalidScaleExtentException, ScaleAxisUndefinedException) # namespace declarations ns_ogc = NameSpace("http://www.opengis.net/ogc", "ogc") ns_wcs = NameSpace("http://www.opengis.net/wcs/2.0", "wcs") ns_crs = NameSpace("http://www.opengis.net/wcs/crs/1.0", "crs") ns_rsub = NameSpace("http://www.opengis.net/wcs/range-subsetting/1.0", "rsub") ns_eowcs = NameSpace("http://www.opengis.net/wcs/wcseo/1.0", "wcseo", "http://schemas.opengis.net/wcs/wcseo/1.0/wcsEOAll.xsd") ns_swe = NameSpace("http://www.opengis.net/swe/2.0", "swe") ns_int = NameSpace("http://www.opengis.net/wcs/interpolation/1.0", "int") ns_scal = NameSpace("http://www.opengis.net/wcs/scaling/1.0", "scal") # namespace map nsmap = NameSpaceMap(ns_xlink, ns_ogc, ns_ows, ns_gml, ns_gmlcov, ns_wcs, ns_crs, ns_rsub, ns_eowcs, ns_om, ns_eop, ns_swe, ns_int, ns_scal) # Element factories WCS = ElementMaker(namespace=ns_wcs.uri, nsmap=nsmap) CRS = ElementMaker(namespace=ns_crs.uri, nsmap=nsmap) EOWCS = ElementMaker(namespace=ns_eowcs.uri, nsmap=nsmap) SWE = ElementMaker(namespace=ns_swe.uri, nsmap=nsmap) INT = ElementMaker(namespace=ns_int.uri, nsmap=nsmap) SUBSET_RE = re.compile(r'(\w+)\(([^,]*)(,([^)]*))?\)') SCALEAXIS_RE = re.compile(r'(\w+)\(([^)]*)\)') SCALESIZE_RE = SCALEAXIS_RE SCALEEXTENT_RE = re.compile(r'(\w+)\(([^:]*):([^)]*)\)')
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # ------------------------------------------------------------------------------ from lxml.builder import ElementMaker from eoxserver.core.config import get_eoxserver_config from eoxserver.core.util.xmltools import NameSpace, NameSpaceMap from eoxserver.services.ows.common.config import CapabilitiesConfigReader from eoxserver.services.ows.common.v20.encoders import OWS20Encoder from eoxserver.services.ows.common.v20.encoders import ns_xlink, ns_ows ns_dseo = NameSpace("http://www.opengis.net/dseo/1.0", "dseo") nsmap = NameSpaceMap(ns_xlink, ns_ows, ns_dseo) DSEO = ElementMaker(namespace=ns_dseo.uri, nsmap=nsmap) class DSEO10CapabilitiesXMLEncoder(OWS20Encoder): def encode_capabilities(self, request, sections): conf = CapabilitiesConfigReader(get_eoxserver_config()) all_sections = "all" in sections caps = [] if all_sections or "serviceidentification" in sections: caps.append(self.encode_service_identification("DSEO", conf, [])) if all_sections or "serviceprovider" in sections: caps.append(self.encode_service_provider(conf))
def handle(self, request, collection_id=None, format_name=None): if request.method == "GET": request_parameters = request.GET elif request.method == "POST": request_parameters = request.POST else: raise Exception("Invalid request method '%s'." % request.method) decoder = OpenSearch11BaseDecoder(request_parameters) if collection_id: # search for products in that collection and coverages not # associated with a product but contained in this collection ModelClass = get_opensearch_record_model() qs = ModelClass.objects.all() if ModelClass == models.EOObject: qs = qs.filter( Q(product__collections__identifier=collection_id) | Q(coverage__collections__identifier=collection_id, coverage__parent_product__isnull=True) ).select_subclasses() else: qs = qs.filter(collections__identifier=collection_id) else: qs = models.Collection.objects.all() if decoder.search_terms: # TODO: search descriptions, summary etc once available qs = qs.filter(identifier__icontains=decoder.search_terms) namespaces = NameSpaceMap() all_parameters = {} for search_extension_class in get_extensions(): # get all search extension related parameters and translate the name # to the actual parameter name search_extension = search_extension_class() params = dict( (parameter["type"], request_parameters[parameter["name"]]) for parameter in search_extension.get_schema( model_class=qs.model) if parameter["name"] in request_parameters) qs = search_extension.filter(qs, params) namespaces.add(search_extension.namespace) all_parameters[search_extension.namespace.prefix] = params if not qs.ordered: qs = qs.order_by('begin_time') # use [:] here, otherwise the queryset would be evaluated and return # lists upon slicing total_count = qs[:].count() # read the configuration and determine the count parameter conf = OpenSearchConfigReader(get_eoxserver_config()) requested_count = min( decoder.count if decoder.count is not None else conf.default_count, conf.max_count) start_index = decoder.start_index # if count is zero, then return an 'empty' queryset if requested_count == 0: qs = models.EOObject.objects.none() else: qs = qs[start_index:start_index + requested_count] result_count = qs[:].count() try: result_format = next(result_format() for result_format in get_formats() if result_format.name == format_name) except StopIteration: raise Http404("No such result format '%s'." % format_name) search_context = SearchContext(total_count, start_index, requested_count, result_count, all_parameters, namespaces) return (result_format.encode(request, collection_id, qs, search_context), result_format.mimetype)
from django.contrib.gis.geos import Polygon, MultiPolygon from eoxserver.core.util.timetools import parse_iso8601 from eoxserver.core.util.xmltools import parse, NameSpace, NameSpaceMap from eoxserver.core.util.iteratortools import pairwise from eoxserver.core import Component, implements from eoxserver.core.decoders import xml from eoxserver.resources.coverages.metadata.interfaces import ( MetadataReaderInterface ) NS_EOP = NameSpace("http://www.opengis.net/eop/2.0", "eop") NS_OM = NameSpace("http://www.opengis.net/om/2.0", "om") NS_GML = NameSpace("http://www.opengis.net/gml/3.2", "gml") nsmap = NameSpaceMap(NS_EOP, NS_OM, NS_GML) class EOOMFormatReader(Component): implements(MetadataReaderInterface) def test(self, obj): tree = parse(obj) return tree is not None and tree.getroot().tag == NS_EOP("EarthObservation") def read(self, obj): tree = parse(obj) if tree is not None: decoder = EOOMFormatDecoder(tree) return { "identifier": decoder.identifier,
NS_SAR_20 = NameSpace("http://www.opengis.net/sar/2.0", "sar") NS_ATM_20 = NameSpace("http://www.opengis.net/atm/2.0", "atm") namespaces_20 = [NS_EOP_20, NS_OPT_20, NS_SAR_20, NS_ATM_20] NS_EOP_21 = NameSpace("http://www.opengis.net/eop/2.1", "eop") NS_OPT_21 = NameSpace("http://www.opengis.net/opt/2.1", "opt") NS_SAR_21 = NameSpace("http://www.opengis.net/sar/2.1", "sar") NS_ATM_21 = NameSpace("http://www.opengis.net/atm/2.1", "atm") namespaces_21 = [NS_EOP_21, NS_OPT_21, NS_SAR_21, NS_ATM_21] NS_OM = NameSpace("http://www.opengis.net/om/2.0", "om") NS_GML = NameSpace("http://www.opengis.net/gml/3.2", "gml") nsmap_20 = NameSpaceMap(NS_GML, NS_OM, *namespaces_20) nsmap_21 = NameSpaceMap(NS_GML, NS_OM, *namespaces_21) nsmap_gml = NameSpaceMap(NS_GML) class EOOMFormatReader(Component): def test(self, obj): tree = parse(obj) tag = tree.getroot().tag if tree is not None else None return tree is not None and tag in [ ns('EarthObservation') for ns in namespaces_20 + namespaces_21 ] def read(self, obj): tree = parse(obj) if tree is not None:
from django.urls import reverse from django.utils.http import urlencode from eoxserver.core.util.xmltools import etree, NameSpace, NameSpaceMap, typemap from eoxserver.core.util.timetools import isoformat from eoxserver.services.opensearch.formats.base import (BaseFeedResultFormat, ns_opensearch, ns_dc, ns_atom, ns_media, ns_owc) # namespace declarations ns_georss = NameSpace("http://www.georss.org/georss", "georss") ns_gml = NameSpace("http://www.opengis.net/gml", "gml") # namespace map nsmap = NameSpaceMap(ns_georss, ns_gml, ns_opensearch, ns_dc, ns_atom, ns_media, ns_owc) # Element factories GEORSS = ElementMaker(namespace=ns_georss.uri, nsmap=nsmap) GML = ElementMaker(namespace=ns_gml.uri, nsmap=nsmap) RSS = ElementMaker(typemap=typemap) class RSSResultFormat(BaseFeedResultFormat): """ RSS result format. """ mimetype = "application/rss+xml" name = "rss" def encode(self, request, collection_id, queryset, search_context):
# ------------------------------------------------------------------------------ try: from itertools import izip_longest except ImportError: from itertools import zip_longest as izip_longest from lxml.builder import ElementMaker from eoxserver.core.util.xmltools import XMLEncoder, NameSpace, NameSpaceMap # namespace declarations ns_cis = NameSpace("http://www.opengis.net/gml/1.1", "cis") ns_swe = NameSpace("http://www.opengis.net/swe/2.0", "swe") nsmap = NameSpaceMap(ns_cis, ns_swe) # Element factories CIS = ElementMaker(namespace=ns_cis.uri, nsmap=nsmap) SWE = ElementMaker(namespace=ns_swe.uri, nsmap=nsmap) class CIS11XMLEncoder(XMLEncoder): def encode_axis_extent(self, axis, origin, size): if axis.regular: return CIS( 'axisExtent', axisLabel=axis.name, uomLabel=axis.uom, lowerBound=str(origin), upperBound=str(origin + (axis.offset * size)),
def cleanup(self, driver, datasource, filename): """ Perform any necessary cleanup steps, like removing the temporary file. """ driver.DeleteDataSource(filename) ns_atom = NameSpace("http://www.w3.org/2005/Atom", "atom") ns_opensearch = NameSpace("http://a9.com/-/spec/opensearch/1.1/", "opensearch") ns_dc = NameSpace("http://purl.org/dc/elements/1.1/", "dc") ns_georss = NameSpace("http://www.georss.org/georss", "georss") ns_media = NameSpace("http://search.yahoo.com/mrss/", "media") ns_owc = NameSpace("http://www.opengis.net/owc/1.0", "owc") nsmap = NameSpaceMap(ns_atom, ns_dc, ns_georss, ns_media, ns_owc) ATOM = ElementMaker(namespace=ns_atom.uri) OS = ElementMaker(namespace=ns_opensearch.uri) DC = ElementMaker(namespace=ns_dc.uri, nsmap=nsmap) GEORSS = ElementMaker(namespace=ns_georss.uri, nsmap=nsmap) MEDIA = ElementMaker(namespace=ns_media.uri, nsmap=nsmap) OWC = ElementMaker(namespace=ns_owc.uri, nsmap=nsmap) class BaseFeedResultFormat(BaseResultFormat): """ Abstract base component for feed result formats like RSS and atom. Adds functionality to encode the paging mechanisms by using ``atom:link``s. """ abstract = True
from django.contrib.gis.geos import Polygon, MultiPolygon from eoxserver.core.util.timetools import parse_iso8601 from eoxserver.core.util.xmltools import NameSpace, NameSpaceMap from eoxserver.core.util.iteratortools import pairwise from eoxserver.core.decoders import xml NS_GSC = NameSpace("http://earth.esa.int/gsc", "gsc") NS_EOP = NameSpace("http://earth.esa.int/eop", "eop") NS_OPT = NameSpace("http://earth.esa.int/opt", "opt") NS_SAR = NameSpace("http://earth.esa.int/sar", "sar") NS_ATM = NameSpace("http://earth.esa.int/atm", "atm") NS_GML = NameSpace("http://www.opengis.net/gml", "gml") nsmap = NameSpaceMap(NS_GML, NS_GSC, NS_EOP, NS_OPT, NS_SAR, NS_ATM) nsmap_gml = NameSpaceMap(NS_GML) def parse_ring(string): raw_coords = [float(v) for v in string.split()] return [(lon, lat) for lat, lon in pairwise(raw_coords)] def parse_polygon_xml(elem): return Polygon( parse_ring( elem.xpath("gml:exterior/gml:LinearRing/gml:posList", namespaces=nsmap_gml)[0].text.strip()), *[ parse_ring(poslist_elem.text.strip()) for poslist_elem in elem.xpath(
#------------------------------------------------------------------------------- # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies of this Software or works derived from this Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. #------------------------------------------------------------------------------- from eoxserver.core.util.xmltools import NameSpace, NameSpaceMap ns_xlink = NameSpace("http://www.w3.org/1999/xlink", "xlink") ns_ogc = NameSpace("http://www.opengis.net/ogc", "ogc") ns_ows = NameSpace("http://www.opengis.net/ows/1.1", "ows") ns_wcs = NameSpace("http://www.opengis.net/wcs/1.1", "wcs") nsmap = NameSpaceMap(ns_xlink, ns_ogc, ns_ows, ns_wcs)
from django.contrib.gis.geos import Polygon, MultiPolygon from eoxserver.core.util.xmltools import parse, NameSpace, NameSpaceMap from eoxserver.core.util.timetools import parse_iso8601 from eoxserver.core.util.iteratortools import pairwise from eoxserver.core import Component, implements from eoxserver.core.decoders import xml from eoxserver.resources.coverages.metadata.interfaces import ( MetadataReaderInterface ) NS_GMD = NameSpace("http://www.isotc211.org/2005/gmd", "gmd") NS_GML = NameSpace("http://www.opengis.net/gml", "gml") NS_GCO = NameSpace("http://www.isotc211.org/2005/gco", "gco") nsmap = NameSpaceMap(NS_GMD, NS_GCO, NS_GML) class InspireFormatReader(Component): implements(MetadataReaderInterface) def test(self, obj): tree = parse(obj) return tree is not None and tree.getroot().tag == NS_GMD("MD_Metadata") def read(self, obj): tree = parse(obj) if tree is not None: decoder = InspireFormatDecoder(tree) return { "identifier": decoder.identifier,
# copies of this Software or works derived from this Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. #------------------------------------------------------------------------------- # pylint: disable=invalid-name, unused-import from lxml.builder import ElementMaker from eoxserver.core.util.xmltools import NameSpace, NameSpaceMap, ns_xsi from eoxserver.services.ows.common.v11.encoders import ( ns_xlink, ns_xml, ns_ows, OWS ) # namespace declarations ns_wps = NameSpace( "http://www.opengis.net/wps/1.0.0", "wps", "http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd" ) # namespace map nsmap = NameSpaceMap(ns_xlink, ns_xml, ns_ows, ns_wps) # Element factories WPS = ElementMaker(namespace=ns_wps.uri, nsmap=nsmap) NIL = ElementMaker() # nil-name