示例#1
0
 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
示例#2
0
class CQLExtension(object):
    """ Implementation of the OpenSearch `'EO' extension
    <http://docs.opengeospatial.org/is/13-026r8/13-026r8.html>`_.
    """

    namespace = NameSpace("http://a9.com/-/opensearch/extensions/cql/1.0/",
                          "cql")

    def filter(self, qs, parameters):
        mapping, mapping_choices = filters.get_field_mapping_for_model(
            qs.model)
        decoder = CQLExtensionDecoder(parameters)

        cql_text = decoder.cql
        if cql_text:
            ast = ecql.parse(cql_text)
            filter_expressions = ecql.to_filter(ast, mapping, mapping_choices)

            qs = qs.filter(filter_expressions)

        return qs

    def get_schema(self, collection=None, model_class=None):
        return (dict(
            name="cql",
            type="cql",
            profiles=[
                dict(
                    href="http://www.opengis.net/csw/3.0/cql",
                    title=("CQL (Common Query Language) is a query language "
                           "created by the OGC for the Catalogue Web Services "
                           "specification."))
            ]), )
示例#3
0
class TimeExtension(Component):
    """ Implementation of the OpenSearch `'Time' extension
    <http://www.opensearch.org/Specifications/OpenSearch/Extensions/Time/1.0/Draft_1>`_.
    """
    implements(SearchExtensionInterface)

    namespace = NameSpace("http://a9.com/-/opensearch/extensions/time/1.0/",
                          "time")

    def filter(self, qs, parameters):
        decoder = TimeExtensionDecoder(parameters)

        start = decoder.start
        end = decoder.end
        relation = decoder.relation

        if start and end:
            if relation == "intersects":
                qs = qs.filter(Q(begin_time__lte=end) & Q(end_time__gte=start))
            elif relation == "contains":
                qs = qs.filter(Q(begin_time__lte=start) & Q(end_time__gte=end))
            elif relation == "during":
                qs = qs.filter(Q(begin_time__gte=start) & Q(end_time__lte=end))
            elif relation == "disjoint":
                qs = qs.filter(Q(begin_time__gt=end) | Q(end_time__lt=start))
            elif relation == "equals":
                qs = qs.filter(Q(begin_time=start) & Q(end_time=end))
        elif start:
            if relation == "intersects":
                qs = qs.filter(end_time__gte=start)
            elif relation == "contains":
                # not possible for a coverage to contain an open interval
                pass
            elif relation == "during":
                qs = qs.filter(begin_time__gte=start)
            elif relation == "disjoint":
                qs = qs.filter(end_time__lt=start)
            elif relation == "equals":
                qs = qs.filter(begin_time=start)
        elif end:
            if relation == "intersects":
                qs = qs.filter(begin_time__lte=end)
            elif relation == "contains":
                # see above
                pass
            elif relation == "during":
                qs = qs.filter(end_time__lte=end)
            elif relation == "disjoint":
                qs = qs.filter(begin_time__gt=end)
            elif relation == "equals":
                qs = qs.filter(end_time=end)
        return qs

    def get_schema(self):
        return (dict(name="start", type="start"), dict(name="end", type="end"),
                dict(name="timerel",
                     type="relation",
                     options=["intersects", "contains", "disjoint", "equals"]))
示例#4
0
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")
    )
示例#5
0
                ),
            ), 
            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
示例#6
0
class EarthObservationExtension(object):
    """ Implementation of the OpenSearch `'EO' extension
    <http://docs.opengeospatial.org/is/13-026r8/13-026r8.html>`_.
    """

    namespace = NameSpace("http://a9.com/-/opensearch/extensions/eo/1.0/",
                          "eo")

    def filter(self, qs, parameters):
        mapping, mapping_choices = filters.get_field_mapping_for_model(
            qs.model)
        decoder = EarthObservationExtensionDecoder(parameters)

        query_filters = []
        for filter_name, db_accessor in mapping.items():
            value = getattr(decoder, filter_name, None)

            if value:
                attr = filters.attribute(filter_name, mapping)
                if isinstance(value, list):
                    query_filters.append(filters.contains(attr, value))
                elif isinstance(value, dict):
                    if 'min' in value:
                        query_filters.append(
                            filters.compare(
                                attr, value['min'],
                                '>=' if value['min_inclusive'] else '>',
                                mapping_choices))
                    if 'max' in value:
                        query_filters.append(
                            filters.compare(
                                attr, value['max'],
                                '<=' if value['max_inclusive'] else '<',
                                mapping_choices))
                else:
                    query_filters.append(
                        filters.compare(attr, value, '=', mapping_choices))

        if query_filters:
            qs = qs.filter(filters.combine(query_filters, 'AND'))

        return qs

    def get_schema(self, collection=None, model_class=None):
        mapping, mapping_choices = filters.get_field_mapping_for_model(
            model_class or models.Product, True)

        schema = []
        summary = None
        if collection:
            summary = self._load_product_summary(collection)

        for key, value in mapping.items():
            param = dict(name=key, type=key)

            if summary:
                param_summary = summary.get(key)

                # leave out all parameters not present in the summary
                if not self._is_param_summary_valid(param_summary):
                    continue

                # insert information from the parameter summary
                if isinstance(param_summary, list):
                    param['options'] = param_summary
                elif isinstance(param_summary, dict):
                    min_ = param_summary.get('min')
                    max_ = param_summary.get('max')
                    if min_ is not None:
                        param['min'] = min_
                    if max_ is not None:
                        param['max'] = max_

            # use the mapping choices to get a list of options, if possible
            if 'options' not in param and value in mapping_choices:
                param['options'] = list(mapping_choices[value].keys())

            schema.append(param)

        return schema

    def _load_product_summary(self, collection):
        try:
            summary = json.loads(
                collection.collection_metadata.product_metadata_summary)
            return {
                filters._to_camel_case(key): value
                for key, value in summary.items()
            }
        except models.CollectionMetadata.DoesNotExist:
            pass
        return None

    def _is_param_summary_valid(self, param_summary):
        if not param_summary:
            return False

        elif isinstance(param_summary, dict):
            return param_summary.get('min') or param_summary.get('max')

        return True
示例#7
0
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#-------------------------------------------------------------------------------

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)
示例#8
0
#-------------------------------------------------------------------------------
# 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)
示例#9
0
# 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.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.
示例#10
0
class GeoExtension(object):
    """ Implementation of the OpenSearch `'Geo' extension draft
    <http://www.opensearch.org/Specifications/OpenSearch/Extensions/Geo/1.0/Draft_2>`_.
    Currently all parameters apart from the ``name`` are supported. The point
    plus radius with the relation type ``contains`` requires a PostGIS database
    backend.
    """

    namespace = NameSpace("http://a9.com/-/opensearch/extensions/geo/1.0/",
                          "geo")

    def filter(self, qs, parameters):
        decoder = GeoExtensionDecoder(parameters)

        geom = decoder.box or decoder.geometry
        lon, lat = decoder.lon, decoder.lat
        distance = decoder.radius
        relation = decoder.relation
        uid = decoder.uid

        if geom:
            if relation == "intersects":
                qs = qs.filter(footprint__intersects=geom)
            elif relation == "contains":
                qs = qs.filter(footprint__coveredby=geom)
            elif relation == "disjoint":
                qs = qs.filter(footprint__disjoint=geom)

        elif lon is not None and lat is not None and distance is not None:
            geom = Point(lon, lat)
            if relation == "intersects":
                qs = qs.filter(footprint__distance_lte=(geom, distance))
            elif relation == "contains":
                # TODO: right?, also only available on postgis
                qs = qs.filter(footprint__dwithin=(geom, distance))
            elif relation == "disjoint":
                qs = qs.filter(footprint__distance_gt=(geom, distance))
        elif lon is not None and lat is not None:
            geom = Point(lon, lat)
            if relation == "intersects":
                qs = qs.filter(footprint__intersects=geom)
            elif relation == "contains":
                qs = qs.filter(footprint__coveredby=geom)
            elif relation == "disjoint":
                qs = qs.filter(footprint__disjoint=geom)

        if uid:
            qs = qs.filter(identifier=uid)

        return qs

    def get_schema(self, collection=None, model_class=None):
        return (
            dict(name="bbox", type="box"),
            dict(name="geom",
                 type="geometry",
                 profiles=[
                     dict(href="http://www.opengis.net/wkt/LINESTRING",
                          title="This service accepts WKT LineStrings"),
                     dict(href="http://www.opengis.net/wkt/POINT",
                          title="This service accepts WKT Point"),
                     dict(href="http://www.opengis.net/wkt/POLYGON",
                          title="This service accepts WKT Polygons"),
                     dict(href="http://www.opengis.net/wkt/MULTILINESTRING",
                          title="This service accepts WKT Multi-LineStrings"),
                     dict(href="http://www.opengis.net/wkt/MULTIPOINT",
                          title="This service accepts WKT Multi-Point"),
                     dict(href="http://www.opengis.net/wkt/MULTIPOLYGON",
                          title="This service accepts WKT Multi-Polygons"),
                 ]), dict(name="lon", type="lon"), dict(name="lat",
                                                        type="lat"),
            dict(name="r", type="radius"),
            dict(name="georel",
                 type="relation",
                 options=["intersects", "contains",
                          "disjoint"]), dict(name="uid", type="uid"))
示例#11
0
# THE SOFTWARE.
#-------------------------------------------------------------------------------

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:
示例#12
0
from lxml.builder import ElementMaker
try:
    from django.core.urlresolvers import reverse
except ImportError:
    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.
    """
示例#13
0
class GeoExtension(Component):
    """ Implementation of the OpenSearch `'Geo' extension draft
    <http://www.opensearch.org/Specifications/OpenSearch/Extensions/Geo/1.0/Draft_2>`_.
    Currently all parameters apart from the ``name`` are supported. The point
    plus radius with the relation type ``contains`` requires a PostGIS database
    backend.
    """
    implements(SearchExtensionInterface)

    namespace = NameSpace(
        "http://a9.com/-/opensearch/extensions/geo/1.0/", "geo"
    )

    def filter(self, qs, parameters):
        decoder = GeoExtensionDecoder(parameters)

        geom = decoder.box or decoder.geometry
        lon, lat = decoder.lon, decoder.lat
        distance = decoder.radius
        relation = decoder.relation
        uid = decoder.uid

        if geom:
            if relation == "intersects":
                qs = qs.filter(footprint__intersects=geom)
            elif relation == "contains":
                qs = qs.filter(footprint__coveredby=geom)
            elif relation == "disjoint":
                qs = qs.filter(footprint__disjoint=geom)

        elif lon is not None and lat is not None and distance is not None:
            geom = Point(lon, lat)
            if relation == "intersects":
                qs = qs.filter(footprint__distance_lte=(geom, distance))
            elif relation == "contains":
                # TODO: right?, also only available on postgis
                qs = qs.filter(footprint__dwithin=(geom, distance))
            elif relation == "disjoint":
                qs = qs.filter(footprint__distance_gt=(geom, distance))
        elif lon is not None and lat is not None:
            geom = Point(lon, lat)
            if relation == "intersects":
                qs = qs.filter(footprint__intersects=geom)
            elif relation == "contains":
                qs = qs.filter(footprint__coveredby=geom)
            elif relation == "disjoint":
                qs = qs.filter(footprint__disjoint=geom)

        if uid:
            qs = qs.filter(identifier=uid)

        return qs

    def get_schema(self):
        return (
            dict(name="bbox", type="box"),
            dict(name="geom", type="geometry"),
            dict(name="lon", type="lon"),
            dict(name="lat", type="lat"),
            dict(name="r", type="radius"),
            dict(name="georel", type="relation",
                options=["intersects", "contains", "disjoint"]
            ),
            dict(name="uid", type="uid")
        )
示例#14
0
from django.utils.six import string_types

from eoxserver.core.util.xmltools import NameSpace, NameSpaceMap, ns_xsi
from eoxserver.core.util.timetools import parse_iso8601
from eoxserver.services.subset import Trim, Slice, is_temporal, all_axes
from eoxserver.services.gml.v32.encoders import (ns_gml, ns_gmlcov, ns_om,
                                                 ns_eop, GML, GMLCOV, OM, EOP)
from eoxserver.services.ows.common.v20.encoders import ns_xlink, ns_ows, OWS
from eoxserver.services.exceptions import (
    InvalidSubsettingException, InvalidAxisLabelException,
    NoSuchFieldException, InvalidFieldSequenceException,
    InterpolationMethodNotSupportedException, InvalidScaleFactorException,
    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
示例#15
0
from django.template.loader import render_to_string
from django.conf import settings

from eoxserver.core.util.xmltools import etree, NameSpace, NameSpaceMap, typemap
from eoxserver.core.util.timetools import isoformat
from eoxserver.resources.coverages import models
from eoxserver.services.opensearch.formats.base import (
    BaseFeedResultFormat, ns_georss, ns_media, ns_owc
)
from eoxserver.services.opensearch.config import (
    DEFAULT_EOXS_OPENSEARCH_SUMMARY_TEMPLATE
)


# namespace declarations
ns_atom = NameSpace("http://www.w3.org/2005/Atom", None)
ns_opensearch = NameSpace("http://a9.com/-/spec/opensearch/1.1/", "opensearch")
ns_gml = NameSpace("http://www.opengis.net/gml", "gml")
ns_dc = NameSpace("http://purl.org/dc/elements/1.1/", "dc")

# namespace map
nsmap = NameSpaceMap(ns_atom, ns_opensearch, ns_dc, ns_georss, ns_media, ns_owc)

# Element factories
ATOM = ElementMaker(namespace=ns_atom.uri, nsmap=nsmap, typemap=typemap)
OS = ElementMaker(namespace=ns_opensearch.uri, nsmap=nsmap)
GML = ElementMaker(namespace=ns_gml.uri, nsmap=nsmap)
DC = ElementMaker(namespace=ns_dc.uri, nsmap=nsmap)


class AtomResultFormat(BaseFeedResultFormat):
示例#16
0
# 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 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:
示例#17
0
# 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 lxml.builder import ElementMaker

from eoxserver.core.util.xmltools import XMLEncoder, NameSpace, NameSpaceMap

ns_wms = NameSpace("http://www.opengis.net/wms")
ns_xlink = NameSpace("http://www.w3.org/1999/xlink", "xlink")
nsmap = NameSpaceMap(ns_wms, ns_xlink)

WMS = ElementMaker(namespace=ns_wms.uri, nsmap=nsmap)


class WMS13Encoder(XMLEncoder):
    def encode_capabilities(self, config, ows_url, srss, formats, info_formats,
                            layer_descriptions):
        return WMS(
            "WMS_Capabilities",
            WMS(
                "Service",
                WMS("Name", config.name),
                WMS("Title", config.title),
示例#18
0
# 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 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:
示例#19
0
# 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 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):
示例#20
0
# 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 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.decoders import xml, to_dict, InvalidParameterException
from eoxserver.core import Component

NS_EOP_20 = NameSpace("http://www.opengis.net/eop/2.0", "eop")
NS_OPT_20 = NameSpace("http://www.opengis.net/opt/2.0", "opt")
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")
示例#21
0
# 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.
# ------------------------------------------------------------------------------

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,
示例#22
0
            inline with the :meth:`create_fields` method.
        """
        feature.SetGeometry(
            ogr.CreateGeometryFromWkb(str(eo_object.footprint.wkb)))
        feature.SetField("id", eo_object.identifier.encode("utf-8"))
        feature.SetField("begin_time", isoformat(eo_object.begin_time))
        feature.SetField("end_time", isoformat(eo_object.end_time))

    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)
示例#23
0
# 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 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)]

示例#24
0
# 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 ElementMaker
from lxml.etree import ProcessingInstruction, ElementTree
from django.conf import settings
from eoxserver.core.util.xmltools import XMLEncoder, NameSpace, NameSpaceMap


ns_xlink = NameSpace("http://www.w3.org/1999/xlink", "xlink")
ns_ows = NameSpace("http://www.opengis.net/ows/1.1", "ows", "http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.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 OWS11ExceptionXMLEncoder(XMLEncoder):
    def encode_exception(self, message, version, code, locator=None):
        exception_attributes = {
            "exceptionCode": code
        }

        if locator:
            exception_attributes["locator"] = locator
示例#25
0
# 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 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",
示例#26
0
# 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