Exemplo n.º 1
0
def create_thumbnail(root_elem, thumbnail_url, thumbnail_desc=None):
    data_ident_elements = root_elem.findall(
        './gmd:identificationInfo/gmd:MD_DataIdentification', namespaces)
    for data_ident_elem in data_ident_elements:
        prevSiblingNames = [
            'gmd:citation', 'gmd:abstract', 'gmd:purpose', 'gmd:credit',
            'gmd:status', 'gmd:pointOfContact', 'gmd:resourceMaintenance'
        ]
        graphicOverviewElem = ET.Element(
            "{http://www.isotc211.org/2005/gmd}graphicOverview")
        insertAfter(data_ident_elem, graphicOverviewElem, prevSiblingNames,
                    namespaces)
        #grov = ET.SubElement(data_ident_elements[0], "{http://www.isotc211.org/2005/gmd}graphicOverview")
        brgr = ET.SubElement(
            graphicOverviewElem,
            "{http://www.isotc211.org/2005/gmd}MD_BrowseGraphic")
        file_name = ET.SubElement(
            brgr, "{http://www.isotc211.org/2005/gmd}fileName")
        file_name_str = ET.SubElement(
            file_name, "{http://www.isotc211.org/2005/gco}CharacterString")
        file_name_str.text = thumbnail_url
        if thumbnail_desc:
            file_desc = ET.SubElement(
                brgr, "{http://www.isotc211.org/2005/gmd}fileDescription")
            file_desc_str = ET.SubElement(
                file_desc, "{http://www.isotc211.org/2005/gco}CharacterString")
            file_desc_str.text = thumbnail_desc
        file_type = ET.SubElement(
            brgr, "{http://www.isotc211.org/2005/gmd}fileType")
        file_type_str = ET.SubElement(
            file_type, "{http://www.isotc211.org/2005/gco}CharacterString")
        file_type_str.text = u'gvsigol thumbnail'
Exemplo n.º 2
0
def create_extent(root_elem, minx, miny, maxx, maxy):
    data_ident_elements = root_elem.findall(
        './gmd:identificationInfo/gmd:MD_DataIdentification', namespaces)
    for data_ident_elem in data_ident_elements:
        prevSiblingNames = [
            'gmd:citation', 'gmd:abstract', 'gmd:purpose', 'gmd:credit',
            'gmd:status', 'gmd:pointOfContact', 'gmd:resourceMaintenance',
            'gmd:spatialRepresentationType', 'gmd:spatialResolution',
            'gmd:language', 'gmd:characterSet', 'gmd:topicCategory',
            'gmd:environmentDescription'
        ]
        extentElem = ET.Element("{http://www.isotc211.org/2005/gmd}extent")
        insertAfter(data_ident_elem, extentElem, prevSiblingNames, namespaces)
        #extentElem = ET.SubElement(data_ident_elem, "{http://www.isotc211.org/2005/gmd}extent")
        exExtentElem = ET.SubElement(
            extentElem, "{http://www.isotc211.org/2005/gmd}EX_Extent")
        geogExtentElem = ET.SubElement(
            exExtentElem,
            "{http://www.isotc211.org/2005/gmd}geographicElement")
        exGeogBBElem = ET.SubElement(
            geogExtentElem,
            "{http://www.isotc211.org/2005/gmd}EX_GeographicBoundingBox")
        westBoundLongElem = ET.SubElement(
            exGeogBBElem,
            "{http://www.isotc211.org/2005/gmd}westBoundLongitude")
        decimalElem = ET.SubElement(
            westBoundLongElem, "{http://www.isotc211.org/2005/gco}Decimal")
        decimalElem.text = minx
        eastBoundLongElem = ET.SubElement(
            exGeogBBElem,
            "{http://www.isotc211.org/2005/gmd}eastBoundLongitude")
        decimalElem = ET.SubElement(
            eastBoundLongElem, "{http://www.isotc211.org/2005/gco}Decimal")
        decimalElem.text = maxx
        southBoundLatElem = ET.SubElement(
            exGeogBBElem,
            "{http://www.isotc211.org/2005/gmd}southBoundLatitude")
        decimalElem = ET.SubElement(
            southBoundLatElem, "{http://www.isotc211.org/2005/gco}Decimal")
        decimalElem.text = miny
        northBoundLatElem = ET.SubElement(
            exGeogBBElem,
            "{http://www.isotc211.org/2005/gmd}northBoundLatitude")
        decimalElem = ET.SubElement(
            northBoundLatElem, "{http://www.isotc211.org/2005/gco}Decimal")
        decimalElem.text = maxy
Exemplo n.º 3
0
def create_transfer_options(root_elem,
                            qualified_name,
                            spatialRepresentationType,
                            title,
                            wms_endpoint,
                            wfs_endpoint=None,
                            wcs_endpoint=None):
    distribInfoElements = root_elem.findall(
        './gmd:distributionInfo/gmd:MD_Distribution', namespaces)

    if len(distribInfoElements) == 0:
        distributionInfoElem = ET.SubElement(
            root_elem, "{http://www.isotc211.org/2005/gmd}distributionInfo")
        MD_DistributionElem = ET.SubElement(
            distributionInfoElem,
            "{http://www.isotc211.org/2005/gmd}MD_Distribution")
        distribInfoElements = [MD_DistributionElem]

    for distribInfoElem in distribInfoElements:
        if spatialRepresentationType == 'vector':
            create_distrib_format(distribInfoElem, 'Shapefile', 'SHP 1.0')
        elif spatialRepresentationType == 'grid':
            create_distrib_format(distribInfoElem, 'TIF', 'GeoTiff 1.0')
        prevSiblingNames = ['gmd:distributionFormat', 'gmd:distributor']
        transferOptionsElem = ET.Element(
            "{http://www.isotc211.org/2005/gmd}transferOptions")
        insertAfter(distribInfoElem, transferOptionsElem, prevSiblingNames,
                    namespaces)
        MD_DigitalTransferOptionsElem = ET.SubElement(
            transferOptionsElem,
            "{http://www.isotc211.org/2005/gmd}MD_DigitalTransferOptions")
        create_online_resource(MD_DigitalTransferOptionsElem, wms_endpoint,
                               'OGC:WMS', qualified_name, title)
        if wfs_endpoint:
            create_online_resource(MD_DigitalTransferOptionsElem, wfs_endpoint,
                                   'OGC:WFS', qualified_name, title)
        if wcs_endpoint:
            create_online_resource(MD_DigitalTransferOptionsElem, wcs_endpoint,
                                   'OGC:WCS', qualified_name, title)
Exemplo n.º 4
0
def create_distrib_format(parent, name, version, specification=None):
    distributionFormatElem = ET.Element(
        "{http://www.isotc211.org/2005/gmd}distributionFormat")
    MD_FormatElem = ET.SubElement(
        distributionFormatElem, "{http://www.isotc211.org/2005/gmd}MD_Format")
    nameElem = ET.SubElement(MD_FormatElem,
                             "{http://www.isotc211.org/2005/gmd}name")
    nameElemCharStr = ET.SubElement(
        nameElem, "{http://www.isotc211.org/2005/gco}CharacterString")
    nameElemCharStr.text = name
    versionElem = ET.SubElement(MD_FormatElem,
                                "{http://www.isotc211.org/2005/gmd}version")
    versionElemCharStr = ET.SubElement(
        versionElem, "{http://www.isotc211.org/2005/gco}CharacterString")
    versionElemCharStr.text = version
    if specification is not None:
        specificationElem = ET.SubElement(
            MD_FormatElem, "{http://www.isotc211.org/2005/gmd}specification")
        specificationElemCharStr = ET.SubElement(
            specificationElem,
            "{http://www.isotc211.org/2005/gco}CharacterString")
        specificationElemCharStr.text = specification
    insertAfter(parent, distributionFormatElem, [], namespaces)