Ejemplo n.º 1
0
    def createTemporalISO(self, profile=None):
        '''Create GRASS Temporal profile based on ISO
        - unknown values are filling by n = '$NULL'
        '''
        n = '$NULL'
        # jinja templates
        if profile is None:
            self.profilePath = 'temporalProfile.xml'
        else:
            self.profilePath = profile
        self.schema_type = '_temporal.xml'
        self.profileName = 'TEMPORAL'

        # OWSLib md object
        self.md.identification = mdutil.MD_DataIdentification_MOD()
        self.md.dataquality = DQ_DataQuality()
        self.md.distribution = MD_Distribution()
        self.md.identification.extent = EX_Extent()
        self.md.identification.extent.boundingBox = EX_GeographicBoundingBox()

        # Metadata on metadata
        val = CI_ResponsibleParty()
        val.organization = mdutil.replaceXMLReservedChar(
            self.md_grass['creator'])
        val.role = 'creator'
        self.md.contact.append(val)

        # Identification/Resource Title
        self.md.identification.title = mdutil.replaceXMLReservedChar(
            self.md_grass['name'])
        self.md.datestamp = mdutil.replaceXMLReservedChar(
            date.today().isoformat())

        # Identification/Resource Type
        self.md.identification.identtype = 'dataset'

        # Identification/Unique Resource Identifier
        self.md.identifier = mdutil.replaceXMLReservedChar(self.md_grass['id'])
        self.md.identification.uricode.append(
            mdutil.replaceXMLReservedChar(self.md_grass['id']))
        self.md.identification.uricodespace.append(n)

        self.md.identification.resourcelanguage.append('English')
        self.md.languagecode = 'English'

        val = CI_Date()
        val.date = mdutil.replaceXMLReservedChar(
            self.md_grass['creation_time'])
        val.type = 'Date of creation'
        self.md.identification.date.append(val)
        val = CI_Date()
        val.date = mdutil.replaceXMLReservedChar(
            self.md_grass['modification_time'])
        val.type = 'Date of last revision'
        self.md.identification.date.append(val)
        # Geographic/BB
        self.md.identification.extent.boundingBox.minx = mdutil.replaceXMLReservedChar(
            self.md_grass['north'])
        self.md.identification.extent.boundingBox.maxx = mdutil.replaceXMLReservedChar(
            self.md_grass['south'])
        self.md.identification.extent.boundingBox.miny = mdutil.replaceXMLReservedChar(
            self.md_grass['east'])
        self.md.identification.extent.boundingBox.maxy = mdutil.replaceXMLReservedChar(
            self.md_grass['west'])

        # Temporal/Temporal Extent
        self.md.identification.temporalextent_start = mdutil.replaceXMLReservedChar(
            self.md_grass['start_time'])
        self.md.identification.temporalextent_end = mdutil.replaceXMLReservedChar(
            self.md_grass['end_time'])

        self.md.identification.temporalType = mdutil.replaceXMLReservedChar(
            self.md_grass['temporal_type'])

        try:
            gran = self.md_grass['granularity'].split(' ')
            self.md.identification.timeUnit = mdutil.replaceXMLReservedChar(
                gran[1])
            self.md.identification.radixT = mdutil.replaceXMLReservedChar(
                gran[0])
            self.md.identification.factor = mdutil.replaceXMLReservedChar('1')
        except:
            self.md.identification.timeUnit = mdutil.replaceXMLReservedChar(
                None)
            self.md.identification.radixT = mdutil.replaceXMLReservedChar(None)
            self.md.identification.factor = mdutil.replaceXMLReservedChar(None)

        self.md.dataquality.lineage = "TODO"
        self.profilePathAbs = os.path.join(self.dirpath, self.profilePath)
Ejemplo n.º 2
0
    def createGrassBasicISO(self, profile=None):
        '''Create basic/essential profile based on ISO
        - unknown values are filling by n = '$NULL'
        '''
        try:
            self.md_grass['comments'] = self.md_grass['comments'].replace(
                '\n', '; ')
            self.md_grass['comments'] = self.md_grass['comments'].replace(
                '\\', '')
        except:
            pass

        n = '$NULL'
        # jinja templates
        if profile is None:
            self.profilePath = 'basicProfile.xml'
        else:
            self.profilePath = profile

        # OWSLib md object
        self.md.identification = mdutil.MD_DataIdentification_MOD()
        self.md.dataquality = DQ_DataQuality()
        self.md.distribution = MD_Distribution()
        self.md.identification.extent = EX_Extent()
        self.md.identification.extent.boundingBox = EX_GeographicBoundingBox()

        # Metadata on metadata
        val = CI_ResponsibleParty()
        val.organization = n
        val.email = n
        val.role = n
        self.md.contact.append(val)

        # Identification/Resource Title
        self.md.identification.title = mdutil.replaceXMLReservedChar(
            self.md_grass['title'])
        self.md.datestamp = mdutil.replaceXMLReservedChar(
            date.today().isoformat())

        # Identification/Resource Type
        self.md.identification.identtype = 'dataset'

        # Identification/Unique Resource Identifier
        self.md.identifier = mdutil.replaceXMLReservedChar(str(uuid.uuid4()))
        self.md.identification.uricode.append(n)
        self.md.identification.uricodespace.append(n)

        # Geographic/BB
        self.md.identification.extent.boundingBox.minx = mdutil.replaceXMLReservedChar(
            self.md_grass['north'])
        self.md.identification.extent.boundingBox.maxx = mdutil.replaceXMLReservedChar(
            self.md_grass['south'])
        self.md.identification.extent.boundingBox.miny = mdutil.replaceXMLReservedChar(
            self.md_grass['east'])
        self.md.identification.extent.boundingBox.maxy = mdutil.replaceXMLReservedChar(
            self.md_grass['west'])

        # Conformity/Title
        self.md.dataquality.conformancetitle.append(
            'GRASS GIS basic metadata profile based on ISO 19115, 19139')

        epsg = self.getEPSG()
        if epsg is not None:
            self.md.referencesystem = MD_ReferenceSystem(None)
            self.md.referencesystem.code = 'http://www.opengis.net/def/crs/EPSG/0/%s' % epsg

        #print self.md.referencesystem.code
        # Conformity/Date:
        self.md.dataquality.conformancedate.append(
            mdutil.replaceXMLReservedChar(date.today().isoformat()))
        self.md.dataquality.conformancedatetype.append('publication')

        # Temporal/Date of creation
        val = CI_Date()
        val.date = self.md_grass['dateofcreation']
        val.type = 'creation'
        self.md.identification.date.append(val)

        self.md.identification.uom.append('m')  # TODO

        # different metadata sources for vector and raster
        if self.type == 'raster':
            # Identification/Resource Abstract
            self.md.identification.abstract = mdutil.replaceXMLReservedChar(
                self.md_abstract)
            # Geographic/resolution
            self.md.identification.distance.append(
                mdutil.replaceXMLReservedChar(
                    self.md_grass['nsres']))  # TODO for discuss

            # Quality/Lineage
            try:
                self.md.dataquality.lineage = mdutil.replaceXMLReservedChar(
                    self.md_grass['comments']).replace('\n', '\\n')
            except:
                grass.message(
                    'Native metadata *flag=comments* not found, dataquality.lineage filled by $NULL'
                )
                self.md.dataquality.lineage = n

            self.md.identification.denominators.append(n)
            # Organisation/Responsible Party:
            val = CI_ResponsibleParty()
            val.organization = n  # self.md_grass['creator']
            val.role = n
            val.email = n
            self.md.identification.contact.append(val)

        if self.type == 'vector':

            # Identification/Resource Abstract
            # TODO not enough sources for create abstarce
            self.md.identification.abstract = mdutil.replaceXMLReservedChar(
                self.md_grass['name'])
            self.md.dataquality.lineage = mdutil.replaceXMLReservedChar(
                self.md_vinfo_h).replace('\n', '\\n')

            self.md.identification.denominators.append(self.md_grass['scale'])
            # Organisation/Responsible Party:
            val = CI_ResponsibleParty()
            val.organization = n  # mdutil.replaceXMLReservedChar(getpass.getuser())
            val.email = n
            val.role = n
            self.md.identification.contact.append(val)

        self.profilePathAbs = os.path.join(self.dirpath, self.profilePath)
Ejemplo n.º 3
0
    def createTemporalISO(self, profile=None):
        """Create GRASS Temporal profile based on ISO
        - unknown values are filling by n = '$NULL'
        """
        n = "$NULL"
        # jinja templates
        if profile is None:
            self.profilePath = "temporalProfile.xml"
        else:
            self.profilePath = profile
        self.schema_type = "_temporal.xml"
        self.profileName = "TEMPORAL"

        # OWSLib md object
        self.md.identification = mdutil.MD_DataIdentification_MOD()
        self.md.dataquality = DQ_DataQuality()
        self.md.distribution = MD_Distribution()
        self.md.identification.extent = EX_Extent()
        self.md.identification.extent.boundingBox = EX_GeographicBoundingBox()

        # Metadata on metadata
        val = CI_ResponsibleParty()
        val.organization = mdutil.replaceXMLReservedChar(self.md_grass["creator"])
        val.role = "creator"
        self.md.contact.append(val)

        # Identification/Resource Title
        self.md.identification.title = mdutil.replaceXMLReservedChar(
            self.md_grass["name"]
        )
        self.md.datestamp = mdutil.replaceXMLReservedChar(date.today().isoformat())

        # Identification/Resource Type
        self.md.identification.identtype = "dataset"

        # Identification/Unique Resource Identifier
        self.md.identifier = mdutil.replaceXMLReservedChar(self.md_grass["id"])
        self.md.identification.uricode.append(
            mdutil.replaceXMLReservedChar(self.md_grass["id"])
        )
        self.md.identification.uricodespace.append(n)

        self.md.identification.resourcelanguage.append("English")
        self.md.languagecode = "English"

        val = CI_Date()
        val.date = mdutil.replaceXMLReservedChar(self.md_grass["creation_time"])
        val.type = "Date of creation"
        self.md.identification.date.append(val)
        val = CI_Date()
        val.date = mdutil.replaceXMLReservedChar(self.md_grass["modification_time"])
        val.type = "Date of last revision"
        self.md.identification.date.append(val)
        # Geographic/BB
        self.md.identification.extent.boundingBox.minx = mdutil.replaceXMLReservedChar(
            self.md_grass["north"]
        )
        self.md.identification.extent.boundingBox.maxx = mdutil.replaceXMLReservedChar(
            self.md_grass["south"]
        )
        self.md.identification.extent.boundingBox.miny = mdutil.replaceXMLReservedChar(
            self.md_grass["east"]
        )
        self.md.identification.extent.boundingBox.maxy = mdutil.replaceXMLReservedChar(
            self.md_grass["west"]
        )

        # Temporal/Temporal Extent
        self.md.identification.temporalextent_start = mdutil.replaceXMLReservedChar(
            self.md_grass["start_time"]
        )
        self.md.identification.temporalextent_end = mdutil.replaceXMLReservedChar(
            self.md_grass["end_time"]
        )

        self.md.identification.temporalType = mdutil.replaceXMLReservedChar(
            self.md_grass["temporal_type"]
        )

        try:
            gran = self.md_grass["granularity"].split(" ")
            self.md.identification.timeUnit = mdutil.replaceXMLReservedChar(gran[1])
            self.md.identification.radixT = mdutil.replaceXMLReservedChar(gran[0])
            self.md.identification.factor = mdutil.replaceXMLReservedChar("1")
        except:
            self.md.identification.timeUnit = mdutil.replaceXMLReservedChar(None)
            self.md.identification.radixT = mdutil.replaceXMLReservedChar(None)
            self.md.identification.factor = mdutil.replaceXMLReservedChar(None)

        self.md.dataquality.lineage = "TODO"
        self.profilePathAbs = os.path.join(self.dirpath, self.profilePath)