Пример #1
0
def main(ARGS):
    def domain_set(lc):
        return ('gml:domainSet gml:RectifiedGrid', {
            'gml:id': lc.layer_pname,
            'dimension': 2
        }, ('gml:limits gml:GridEnvelope', ('gml:low', '0 0'),
            ('gml:high', '215323 125027')), ('gml:axisLabels', 'x y'),
                ('gml:origin gml:Point gml:pos', lc.extent[0], ' ',
                 lc.extent[3]), ('gml:offsetVector',
                                 '0 1'), ('gml:offsetVector', '1 0'))

    def layer1(lc):
        yield 'label', lc.title
        yield 'name', lc.layer_pname
        yield tpl.lon_lat_envelope(lc)
        yield domain_set(lc)
        yield 'supportedCRSs', [('requestResponseCRSs', b.crs.epsg)
                                for b in lc.bounds]
        yield 'supportedFormats formats', 'image/png'

    def doc1():
        yield {'xmlns': 'wcs'}
        for lc in ARGS.layer_caps_list:
            yield 'CoverageOffering', layer1(lc)

    def layer2(lc):
        yield {'gml:id': lc.layer_pname}
        yield 'gml:name', lc.layer_pname

        yield ('gml:boundedBy gml:Envelope', {
            'axisLabels': 'x y',
            'srsDimension': 2,
            'srsName': lc.bounds.crs.uri,
            'uomLabels': 'm m',
        }, ('gml:lowerCorner', lc.extent[0], ' ', lc.extent[2]),
               ('gml:upperCorner', lc.extent[2], ' ', lc.extent[1]))

        yield domain_set(lc)

        yield ('ServiceParameters', ('CoverageSubtype',
                                     'RectifiedGridCoverage'), ('nativeFormat',
                                                                'image/png'))

    def doc2():
        yield {'xmlns': 'wcs'}
        for lc in ARGS.layer_caps_list:
            yield 'CoverageDescription', layer2(lc)

    ##

    if ARGS.version.startswith('1'):
        return tpl.to_xml(ARGS, ('CoverageDescription', doc1()))

    if ARGS.version.startswith('2'):
        return tpl.to_xml(ARGS, ('CoverageDescriptions', doc2()))
Пример #2
0
def main(ARGS):
    def layer(lc):
        yield 'ows:Title', lc.title

        if lc.meta.abstract:
            yield 'ows:Abstract', lc.meta.abstract

        yield tpl.ows_wgs84_bounding_box(lc)

        yield 'ows:Identifier', lc.layer_pname

        if lc.has_legend:
            yield ('Style', ('ows:Identifier', 'default'),
                   ('ows:Title', 'default'), tpl.legend_url(ARGS, lc))

        yield 'Format', 'image/png'

        for tms in ARGS.tile_matrix_sets:
            yield 'TileMatrixSetLink TileMatrixSet', tms.uid

    def matrix_set(tms):
        yield 'ows:Identifier', tms.uid
        yield 'ows:SupportedCRS', tms.crs.epsg

        for tm in tms.matrices:
            yield (
                'TileMatrix',
                ('ows:Identifier', tm.uid),
                ('ScaleDenominator', tm.scale),
                ('TopLeftCorner', tm.x, ' ', tm.y),
                ('TileWidth', tm.tile_width),
                ('TileHeight', tm.tile_height),
                ('MatrixWidth', tm.width),
                ('MatrixHeight', tm.height),
            )

    def contents():
        for lc in ARGS.layer_caps_list:
            yield 'Layer', layer(lc)
        for tms in ARGS.tile_matrix_sets:
            yield 'TileMatrixSet', matrix_set(tms)

    def doc():
        yield {'xmlns': 'wmts', 'version': ARGS.version}

        yield tpl.ows_service_identification(ARGS)
        yield tpl.ows_service_provider(ARGS)

        yield ('ows:OperationsMetadata', ('ows:Operation', {
            'name': 'GetCapabilities'
        }, tpl.ows_service_url(ARGS)), ('ows:Operation', {
            'name': 'GetTile'
        }, tpl.ows_service_url(ARGS)))

        yield 'Contents', contents()

    return tpl.to_xml(ARGS, ('Capabilities', doc()))
Пример #3
0
def main(ARGS):
    def elements(lc):
        for name, typ in lc.adhoc_feature_schema.items():
            yield 'xsd:element', {
                'maxOccurs': '1',
                'minOccurs': '0',
                'nillable': 'true',
                'name': name,
                'type': typ,
            }

    def adhoc_feature_schema(lc):
        type_name = lc.feature_pname + 'Type'
        yield ('xsd:complexType', {
            'name': type_name
        }, ('xsd:complexContent', ('xsd:extension', {
            'base': 'gml:AbstractFeatureType'
        }), ('xsd:sequence', elements(lc))))

        yield 'xsd:element', {
            'name': lc.feature_qname,
            'substitutionGroup': 'gml:AbstractFeature',
            'type': type_name
        }

    def schema():
        pfx, _ = xml2.split_name(ARGS.layer_caps_list[0].feature_qname)
        yield {
            'xmlns:xsd': '',
            'xmlns:gml': '',
            'xmlns:' + pfx: '',
            'targetNamespace': xml2.namespaces.uri(pfx),
            'elementFormDefault': 'qualified',
        }

        yield ('xsd:import', {
            'namespace': xml2.namespaces.uri('gml'),
            'schemaLocation': xml2.namespaces.schema('gml')
        })
        for lc in ARGS.layer_caps_list:
            if lc.adhoc_feature_schema:
                yield adhoc_feature_schema(lc)

    ##

    return tpl.to_xml(ARGS, ('xsd:schema', schema()))
Пример #4
0
def main(ARGS):
    def feature(fc):
        pfx, _ = tpl.split_name(fc.qname)
        return (fc.qname, {
            'gml:id': fc.feature.uid
        }, [(pfx + ':' + a.name, a.value) for a in fc.feature.attributes],
                (pfx + ':geometry', fc.shape_element))

    def collection():
        coll = ARGS.collection
        yield {
            'timeStamp': coll.time_stamp,
            'numberMatched': coll.num_matched,
            'numberReturned': coll.num_returned,
        }

        for fc in coll.caps:
            yield 'wfs:member', feature(fc)

    return tpl.to_xml(ARGS, ('wfs:FeatureCollection', collection()))
Пример #5
0
def main(ARGS):
    return tpl.to_xml(ARGS, ('csw:GetRecordByIdResponse', {
        'version': ARGS.version
    }, rec.record(ARGS, ARGS.record)))
Пример #6
0
def main(ARGS):
    return tpl.to_xml(ARGS, rec.record(ARGS, ARGS.record))
Пример #7
0
def main(ARGS):
    def caps_11():
        pass

    def formats(verb):
        return [('Format', f) for f in ARGS.supported_formats[verb]]

    def meta_links(md):
        for ml in md.metaLinks:
            yield ('MetadataURL', {
                'type': ml.type
            }, ('Format', ml.formatName),
                   tpl.online_resource(ARGS.url_for(ml.url)))

    def service_meta():
        md = ARGS.service_meta

        yield 'Name', md.name
        yield 'Title', md.title

        if md.abstract:
            yield 'Abstract', md.abstract

        yield tpl.keywords(md)
        yield tpl.online_resource(ARGS.service_url)

        yield ('ContactInformation',
               ('ContactPersonPrimary', ('ContactPerson', md.contactPerson),
                ('ContactOrganization', md.contactOrganization)),
               ('ContactPosition', md.contactPosition),
               ('ContactAddress', ('AddressType',
                                   'postal'), ('Address', md.contactAddress),
                ('City', md.contactCity), ('StateOrProvince', md.contactArea),
                ('PostCode', md.contactZip), ('Country', md.contactCountry)),
               ('ContactVoiceTelephone', md.contactPhone),
               ('ContactElectronicMailAddress', md.contactEmail))

        if md.fees:
            yield 'Fees', md.fees
        if md.accessConstraints:
            yield 'AccessConstraints', md.accessConstraints

        yield meta_links(md)

    def service_misc():
        # s = ARGS.service.layer_limit
        # if s:
        #     yield ('LayerLimit', s)
        #
        # s = ARGS.service.get('max_size')
        # if s:
        #     yield ('MaxWidth', s[0])
        #     yield ('MaxHeight', s[1])
        pass

    def layer13_content(lc):
        md = lc.meta

        yield 'Name', lc.layer_pname
        yield 'Title', lc.title

        if md.abstract:
            yield 'Abstract', md.abstract

        yield tpl.keywords(md)

        if md.attribution:
            yield 'Attribution Title', md.attribution

        if md.authorityUrl:
            yield 'AuthorityURL', {
                'name': md.authorityName
            }, tpl.online_resource(md.authorityUrl)

        if md.authorityIdentifier:
            yield 'Identifier', {
                'authority': md.authorityName
            }, md.authorityIdentifier

        yield meta_links(md)

        for b in lc.bounds:
            yield 'CRS', b.crs.epsg

        yield ('EX_GeographicBoundingBox',
               ('westBoundLongitude', lc.extent4326[0]), ('eastBoundLongitude',
                                                          lc.extent4326[2]),
               ('southBoundLatitude', lc.extent4326[1]), ('northBoundLatitude',
                                                          lc.extent4326[3]))

        for b in lc.bounds:
            yield ('BoundingBox', {
                'CRS': b.crs.epsg,
                'minx': b.extent[1] if b.crs.is_geographic else b.extent[0],
                'miny': b.extent[0] if b.crs.is_geographic else b.extent[1],
                'maxx': b.extent[3] if b.crs.is_geographic else b.extent[2],
                'maxy': b.extent[2] if b.crs.is_geographic else b.extent[3],
            })

        if lc.has_legend:
            yield 'Style', ('Name',
                            'default'), ('Title',
                                         'default'), tpl.legend_url(ARGS, lc)

        if not lc.children:
            yield 'MinScaleDenominator', lc.min_scale
            yield 'MaxScaleDenominator', lc.max_scale

        for c in reversed(lc.children):
            yield layer13(c)

    def layer13(lc):
        return 'Layer', {
            'queryable': 1 if lc.has_search else 0
        }, layer13_content(lc)

    def caps_13():
        url = tpl.dcp_service_url(ARGS)

        yield ('Request', ('GetCapabilities', formats('getcapabilities'),
                           url), ('GetMap', formats('getmap'), url),
               ('GetFeatureInfo', formats('getfeatureinfo'), url),
               ('sld:GetLegendGraphic', formats('getlegendgraphic'), url))

        yield 'Exception Format', 'XML'

        if ARGS.with_inspire_meta:
            yield 'inspire_vs:ExtendedCapabilities', tpl.inspire_extended_capabilities(
                ARGS)

        yield layer13(ARGS.layer_root_caps)

    def doc13():
        yield {
            'version': ARGS.version,
            'updateSequence': ARGS.service.update_sequence,
            'xmlns': 'wms',
        }
        yield 'Service', service_meta(), service_misc()
        yield 'Capability', caps_13()

    ####

    if ARGS.version == '1.1.0':
        pass

    elif ARGS.version == '1.1.1':
        pass

    elif ARGS.version == '1.3.0':
        return tpl.to_xml(ARGS, ('WMS_Capabilities', doc13()))
Пример #8
0
def main(ARGS):
    def doc_iso():
        yield {'xmlns': 'csw', 'version': ARGS.version}

        yield tpl.ows_service_identification(ARGS)
        yield tpl.ows_service_provider(ARGS)

        yield ('ows:OperationsMetadata', ('ows:Operation', {
            'name': 'GetCapabilities'
        }, tpl.ows_service_url(ARGS)), ('ows:Operation', {
            'name': 'GetRecords'
        }, tpl.ows_service_url(ARGS, post=True), ('ows:Parameter', {
            'name': 'typeName'
        }, ('ows:AllowedValues ows:Value', 'csw:Record')), ('ows:Parameter', {
            'name':
            'outputFormat'
        }, ('ows:AllowedValues ows:Value',
            'application/xml')), ('ows:Parameter', {
                'name': 'outputSchema'
            }, ('ows:AllowedValues ows:Value',
                'http://www.opengis.net/cat/csw/2.0.2')), ('ows:Parameter', {
                    'name': 'resultType'
                }, ('ows:AllowedValues ows:Value',
                    'results')), ('ows:Parameter', {
                        'name': 'ElementSetName'
                    }, ('ows:AllowedValues ows:Value',
                        'full')), ('ows:Parameter', {
                            'name': 'CONSTRAINTLANGUAGE'
                        }, ('ows:AllowedValues ows:Value', 'Filter')),
                                        ('ows:Parameter', {
                                            'name': 'version'
                                        }, ('ows:AllowedValues ows:Value',
                                            ARGS.version))),
               ('ows:Operation', {
                   'name': 'DescribeRecord'
               }, tpl.ows_service_url(ARGS), ('ows:Parameter', {
                   'name': 'typeName'
               }, ('ows:AllowedValues ows:Value',
                   'gmd:MD_Metadata')), ('ows:Parameter', {
                       'name': 'outputFormat'
                   }, ('ows:AllowedValues ows:Value', 'application/xml')),
                ('ows:Parameter', {
                    'name': 'schemaLanguage'
                }, ('ows:AllowedValues ows:Value',
                    'http://www.w3.org/XML/Schema')), ('ows:Parameter', {
                        'name': 'resultType'
                    }, ('ows:AllowedValues ows:Value',
                        'results')), ('ows:Parameter', {
                            'name': 'ElementSetName'
                        }, ('ows:AllowedValues ows:Value',
                            'full')), ('ows:Parameter', {
                                'name': 'CONSTRAINTLANGUAGE'
                            }, ('ows:AllowedValues ows:Value',
                                'Filter')), ('ows:Parameter', {
                                    'name': 'version'
                                }, ('ows:AllowedValues ows:Value',
                                    ARGS.version))), ('ows:Constraint', {
                                        'name': 'IsoProfiles'
                                    }, ('ows:AllowedValues ows:Value',
                                        'http://www.isotc211.org/2005/gmd')),
               ('inspire_vs:ExtendedCapabilities',
                tpl.inspire_extended_capabilities(ARGS)))

        yield ('ogc:Filter_Capabilities', ('ogc:Spatial_Capabilities',
                                           ('ogc:Spatial_Operators ogc:BBOX',
                                            '')),
               ('ogc:Scalar_Capabilities', ('ogc:Logical_Operators', ''),
                ('ogc:Comparison_Operators', ('ogc:Simple_Comparisons', ''),
                 ('ogc:Like', ''), ('ogc:NullCheck', ''))))

    if ARGS.profile == 'ISO':
        return tpl.to_xml(ARGS, ('Capabilities', doc_iso()))
Пример #9
0
def main(ARGS):
    def constraint(name, value):
        ns, n = name.split(':')
        return ns + ':Constraint', {
            'name': n
        }, ('ows:NoValues', ), ('ows:DefaultValue', value)

    def val(value):
        return 'ows:Value', value

    def operations(default_count=1000):
        versions = [val(v) for v in ARGS.service.supported_versions]

        yield ('ows:Operation', {
            'name': 'GetCapabilities'
        }, tpl.ows_service_url(ARGS), ('ows:Parameter', {
            'name': 'AcceptVersions'
        }, ('ows:AllowedValues', versions)), ('ows:Parameter', {
            'name': 'AcceptFormats'
        }, ('ows:AllowedValues', val('text/xml'))))

        yield ('ows:Operation', {
            'name': 'DescribeFeatureType'
        }, tpl.ows_service_url(ARGS), ('ows:Parameter', {
            'name': 'OutputFormat'
        }, ('ows:AllowedValues', val('text/xml; subtype=gml/3.2.1'))))

        yield ('ows:Operation', {
            'name': 'GetFeature'
        }, tpl.ows_service_url(ARGS, get=True, post=True), ('ows:Parameter', {
            'name':
            'OutputFormat'
        }, ('ows:AllowedValues', val('text/xml; subtype=gml/3.2.1'))),
               ('ows:Parameter', {
                   'name': 'ResultType'
               }, ('ows:AllowedValues', val('results'), val('hits'))))

        yield 'ows:Parameter', {
            'name': 'version'
        }, ('ows:AllowedValues', versions)

        yield (
            constraint('ows:ImplementsBasicWFS', 'TRUE'),
            constraint('ows:KVPEncoding', 'TRUE'),
            constraint('ows:ImplementsTransactionalWFS', 'FALSE'),
            constraint('ows:ImplementsLockingWFS', 'FALSE'),
            constraint('ows:XMLEncoding', 'FALSE'),
            constraint('ows:SOAPEncoding', 'FALSE'),
            constraint('ows:ImplementsInheritance', 'FALSE'),
            constraint('ows:ImplementsRemoteResolve', 'FALSE'),
            constraint('ows:ImplementsResultPaging', 'FALSE'),
            constraint('ows:ImplementsStandardJoins', 'FALSE'),
            constraint('ows:ImplementsSpatialJoins', 'FALSE'),
            constraint('ows:ImplementsTemporalJoins', 'FALSE'),
            constraint('ows:ImplementsFeatureVersioning', 'FALSE'),
            constraint('ows:ManageStoredQueries', 'FALSE'),
            constraint('ows:CountDefault', default_count),
        )

        yield 'ows:Constraint', {
            'name': 'QueryExpressions'
        }, ('ows:AllowedValues', val('wfs:Query'))

        if ARGS.with_inspire_meta:
            yield 'ows:ExtendedCapabilities inspire_dls:ExtendedCapabilities', tpl.inspire_extended_capabilities(
                ARGS)

    def filters():
        yield (
            'fes:Conformance',
            constraint('fes:ImplementsAdHocQuery', 'TRUE'),
            constraint('fes:ImplementsMinSpatialFilter', 'TRUE'),
            constraint('fes:ImplementsQuery', 'TRUE'),
            constraint('fes:ImplementsResourceId', 'TRUE'),
            constraint('fes:ImplementsMinStandardFilter', 'TRUE'),
            constraint('fes:ImplementsMinTemporalFilter', 'TRUE'),
            constraint('fes:ImplementsExtendedOperators', 'FALSE'),
            constraint('fes:ImplementsFunctions', 'FALSE'),
            constraint('fes:ImplementsMinimumXPath', 'FALSE'),
            constraint('fes:ImplementsSorting', 'FALSE'),
            constraint('fes:ImplementsSpatialFilter', 'FALSE'),
            constraint('fes:ImplementsStandardFilter', 'FALSE'),
            constraint('fes:ImplementsTemporalFilter', 'FALSE'),
            constraint('fes:ImplementsVersionNav', 'FALSE'),
        )

        yield 'fes:Id_Capabilities fes:ResourceIdentifier', {
            'name': 'fes:ResourceId'
        }

        yield (
            'fes:Spatial_Capabilities',
            ('fes:GeometryOperands fes:GeometryOperand', {
                'name': 'gml:Envelope'
            }),
            ('fes:SpatialOperators fes:SpatialOperator', {
                'name': 'BBOX'
            }),
        )

    def feature_type(lc):
        yield 'Name', lc.feature_qname
        yield 'Title', lc.title
        yield 'Abstract', lc.meta.abstract

        for n, b in enumerate(lc.bounds):
            if n == 0:
                yield 'DefaultCRS', b.crs.urn
            else:
                yield 'OtherCRS', b.crs.urn

        yield tpl.ows_wgs84_bounding_box(lc)

        for ml in lc.meta.metaLinks:
            yield 'MetadataURL', {'xlink:href': ARGS.url_for(ml.url)}

    def caps():
        yield {
            'version': ARGS.version,
            'xmlns': 'wfs',
        }

        for lc in ARGS.layer_caps_list:
            pfx, _ = tpl.split_name(lc.feature_qname)
            yield {'xmlns:' + pfx: ''}

        yield tpl.ows_service_identification(ARGS)
        yield tpl.ows_service_provider(ARGS)

        yield 'ows:OperationsMetadata', operations()

        yield ('FeatureTypeList', [('FeatureType', feature_type(lc))
                                   for lc in ARGS.layer_caps_list])

        yield 'fes:Filter_Capabilities', filters()

    ##

    return tpl.to_xml(ARGS, ('WFS_Capabilities', caps()))
Пример #10
0
def main(ARGS):
    def service1():
        md = ARGS.service_meta

        yield 'Name', ARGS.service.name
        yield 'Title', md.title

        if md.abstract:
            yield 'Abstract', md.abstract

        yield tpl.keywords(md)

        if md.fees:
            yield 'Fees', md.fees
        if md.accessConstraints:
            yield 'AccessConstraints', md.accessConstraints

        yield ('responsibleParty', ('individualName', md.contactPerson),
               ('organisationName', md.contactOrganization),
               ('positionName', md.contactPosition), (
                   'contactInfo',
                   ('phone voice', md.contactPhone),
                   ('deliveryPoint', md.contactAddress),
                   ('city', md.contactCity),
                   ('administrativeArea', md.contactArea),
                   ('postalCode', md.contactZip),
                   ('country', md.contactCountry),
                   ('electronicMailAddress', md.contactEmail),
               ))

    def content1():
        for lc in ARGS.layer_caps_list:
            yield ('CoverageOfferingBrief', ('label', lc.title),
                   ('name', lc.layer_pname), tpl.lon_lat_envelope(lc))

    def doc1():
        yield {
            'xmlns': 'wcs',
            'version': ARGS.version,
        }

        yield 'Service', service1()

        yield ('Capability Request', ('GetCapabilities',
                                      tpl.dcp_service_url(ARGS)),
               ('DescribeCoverage', tpl.dcp_service_url(ARGS)),
               ('GetCoverage', tpl.dcp_service_url(ARGS)))

        yield 'ContentMetadata', content1()

    def content2():
        for lc in ARGS.layer_caps_list:
            yield ('CoverageSummary', ('CoverageId', lc.layer_pname),
                   ('CoverageSubtype', 'RectifiedGridCoverage'),
                   ('Title', lc.title), ('Abstract', lc.meta.abstract),
                   tpl.ows_wgs84_bounding_box(lc))

    def doc2():
        yield {
            'xmlns': 'wcs',
            'version': ARGS.version,
        }

        yield tpl.ows_service_identification(ARGS)
        yield tpl.ows_service_provider(ARGS)

        yield ('ows:OperationsMetadata', ('ows:Operation', {
            'name': 'GetCapabilities'
        }, tpl.ows_service_url(ARGS)), ('ows:Operation', {
            'name': 'DescribeCoverage'
        }, tpl.ows_service_url(ARGS)), ('ows:Operation', {
            'name': 'GetCoverage'
        }, tpl.ows_service_url(ARGS)))

        yield 'ServiceMetadata formatSupported', 'image/png'
        yield 'Contents', content2()

    ##

    if ARGS.version.startswith('1'):
        return tpl.to_xml(ARGS, ('WCS_Capabilities', doc1()))

    if ARGS.version.startswith('2'):
        return tpl.to_xml(ARGS, ('Capabilities', doc2()))