Example #1
0
    def __build_partition_set_gml(self):
        """
        Build GML for PartionSet elemen
        :return: str
        """
        partition_template = self.__read_template_file("partition")

        partitions = ""
        for source_coverage_id in self.source_coverage_ids:
            temp_dict = {"coverageRef": source_coverage_id}
            partition = replace_template_by_dict(partition_template, temp_dict)

            partitions += "\n" + partition

        partition_set_template = self.__read_template_file("partition_set")
        temp_dict = {"Partitions": partitions}
        partition_set = replace_template_by_dict(partition_set_template,
                                                 temp_dict)

        return partition_set
Example #2
0
    def __build_envelope_gml(self):
        """
        Build GML for Envelope element
        :return: str
        """
        axis_extent_template = self.__read_template_file("axis_extent")

        axis_extents = ""
        for axis in self.axes:
            temp_dict = {
                "axisLabel": axis["axisLabel"],
                "resolution": axis["resolution"]
            }
            axis_extent = replace_template_by_dict(axis_extent_template,
                                                   temp_dict)
            axis_extents += "\n" + axis_extent

        envelope_template = self.__read_template_file("envelope")
        temp_dict = {"srsName": self.srs_name, "AxisExtents": axis_extents}
        envelope = replace_template_by_dict(envelope_template, temp_dict)

        return envelope
Example #3
0
    def __generate_gml(self):
        """
        Virtual coverage needs a particular GML format to import
        :return: str
        """
        gml_template = self.__read_template_file("gml_coverage")
        envelope = self.__build_envelope_gml()
        partion_set = self.__build_partition_set_gml()
        metadata = self.__build_metadata()

        temp_dict = {
            "coverage_id": self.coverage_id,
            "Envelope": envelope,
            "PartitionSet": partion_set,
            "Metadata": metadata
        }

        gml = replace_template_by_dict(gml_template, temp_dict)

        return gml
Example #4
0
    def __build_metadata(self):
        """
        Build the GML for Metadata element
        """
        metadata_template = self.__read_template_file("metadata")

        metadata = ""

        if "coverage" in self.options and \
            "metadata" in self.options["coverage"] and \
             "global" in self.options["coverage"]["metadata"]:
            global_metadata_dict = self.options["coverage"]["metadata"][
                "global"]
            metadata_type = self.options["coverage"]["metadata"]["type"]

            serializer = ExtraMetadataSerializerFactory.get_serializer(
                metadata_type)
            result = serializer.serialize(global_metadata_dict)

            temp_dict = {"Metadata": result}
            metadata = replace_template_by_dict(metadata_template, temp_dict)

        return metadata