Beispiel #1
0
    def __import_each_record(self, data_source: CDataSetSeqReader, data_target: CTable) -> str:
        data_target.column_list.reset()
        data_source_record = data_source.record_as_dict()
        for column_index in range(data_target.column_list.size()):
            column_obj = data_target.column_list.column_by_index(column_index)
            column_name = column_obj.name
            column_data_set_method = self.__find_column_data_set_method(column_obj, data_source)
            if column_data_set_method is None:
                continue

            column_value_set_type = CUtils.dict_value_by_name(column_data_set_method, self.Name_Type, self.Name_Common)

            if CUtils.equal_ignore_case(column_value_set_type, self.Name_SQL):
                column_value_template = CUtils.dict_value_by_name(column_data_set_method, self.Name_Value, '')
                column_value_template = self.replace_placeholder(column_value_template)
                column_value_template = CUtils.replace_placeholder(column_value_template, data_source_record)
                column_obj.set_sql(column_value_template)
            elif CUtils.equal_ignore_case(column_value_set_type, self.Name_Geometry):
                column_value_template = CUtils.dict_value_by_name(column_data_set_method, self.Name_Value, '')
                column_value_template = self.replace_placeholder(column_value_template)
                column_value_template = CUtils.replace_placeholder(column_value_template, data_source_record)
                column_obj.set_geometry(
                    column_value_template,
                    CUtils.dict_value_by_name(column_data_set_method, self.Name_Srid, None)
                )
            elif CUtils.equal_ignore_case(column_value_set_type, self.Name_Array):
                column_value_template = CUtils.dict_value_by_name(column_data_set_method, self.Name_Value, None)
                if isinstance(column_value_template, list):
                    column_obj.set_array(column_value_template)
                else:
                    column_value_template = CUtils.any_2_str(column_value_template)
                    column_value_template = self.replace_placeholder(column_value_template)
                    column_value_template = CUtils.replace_placeholder(column_value_template,
                                                                       data_source_record)
                    column_obj.set_array_str(column_value_template)
            elif CUtils.equal_ignore_case(column_value_set_type, self.Name_Null):
                column_obj.set_null()
            elif CUtils.equal_ignore_case(column_value_set_type, self.Name_File):
                column_value_template = CUtils.dict_value_by_name(column_data_set_method, self.Name_Value, '')
                column_value_template = self.replace_placeholder(column_value_template)
                column_value_template = CUtils.replace_placeholder(column_value_template, data_source_record)

                file_format = CUtils.dict_value_by_name(column_data_set_method, self.Name_Format, self.Name_Binary)
                file_format = self.replace_placeholder(file_format)
                file_format = CUtils.replace_placeholder(file_format, data_source.record_as_dict())

                file_encoding = CUtils.dict_value_by_name(column_data_set_method, self.Name_Encoding,
                                                          self.Encoding_UTF8)
                file_encoding = self.replace_placeholder(file_encoding)
                file_encoding = CUtils.replace_placeholder(file_encoding, data_source_record)

                column_obj.set_value_from_file(column_value_template, file_format, file_encoding)
            else:
                column_value_template = CUtils.dict_value_by_name(column_data_set_method, self.Name_Value, '')
                column_value_template = self.replace_placeholder(column_value_template)
                column_value_template = CUtils.replace_placeholder(column_value_template, data_source_record)
                column_obj.set_value(column_value_template)
        data_target.save_data()
        return CResult.merge_result(self.Success, '数据入库成功!')
Beispiel #2
0
    def open_target(self) -> CTable:
        option_target = CUtils.dict_value_by_name(self.__config, self.Name_Target, None)
        if option_target is None:
            raise Exception('导入目标未设置, 请检查修正后重试! ')

        target_database = CUtils.dict_value_by_name(option_target, self.Name_DataBase, self.DB_Server_ID_Default)
        target_data_table_name = CUtils.dict_value_by_name(option_target, self.Name_Name, None)
        if CUtils.equal_ignore_case(target_data_table_name, ''):
            raise Exception('导入目标未设置数据表名, 请检查修正后重试! ')

        table_obj = CTable()
        table_obj.load_info(target_database, target_data_table_name)
        return table_obj
    def _do_sync(self) -> str:
        try:
            table_name = CUtils.dict_value_by_name(self.information(), 'table_name', '')
            # 因此类插件的表格情况特殊,为双主键,且要先确定插入还是更新,所以不用table.if_exists()方法
            sql_check = '''
            select aprid from {0} where aprid='{1}'
            '''.format(table_name, self._obj_id)
            record_cheak = CFactory().give_me_db(self._db_id).one_row(sql_check).size()  # 查找记录数
            if record_cheak == 0:  # 记录数为0则拼接插入语句
                insert_or_updata = self.DB_True
            else:  # 记录数不为0则拼接更新语句
                insert_or_updata = self.DB_False

            table = CTable()
            table.load_info(self._db_id, table_name)
            # insert_or_updatad的意义是要先确定是更新还是插入,不能把不该更新的,在插入时是默认值的参数更新
            for field_dict in self.get_sync_dict_list(insert_or_updata):
                field_name = CUtils.dict_value_by_name(field_dict, 'field_name', '')  # 获取字段名
                field_value = CUtils.dict_value_by_name(field_dict, 'field_value', '')  # 获取字段值
                field_value_type = CUtils.dict_value_by_name(field_dict, 'field_value_type', '')  # 获取值类型
                if CUtils.equal_ignore_case(field_value, ''):
                    table.column_list.column_by_name(field_name).set_null()
                elif CUtils.equal_ignore_case(field_value_type, self.DataValueType_Value):
                    table.column_list.column_by_name(field_name).set_value(field_value)
                elif CUtils.equal_ignore_case(field_value_type, self.DataValueType_SQL):
                    table.column_list.column_by_name(field_name).set_sql(field_value)
                elif CUtils.equal_ignore_case(field_value_type, self.DataValueType_Array):
                    table.column_list.column_by_name(field_name).set_array(field_value)
                else:
                    pass

            # 不多执行table.if_exists()多查一次哭,所以不用savedata()方法
            if insert_or_updata:
                result = table.insert_data()
            else:
                result = table.update_data()

            if CResult.result_success(result):
                return CResult.merge_result(
                    self.Success,
                    '对象[{0}]的同步成功! '.format(self._obj_name)
                )
            else:
                return result
        except Exception as error:
            return CResult.merge_result(
                self.Failure,
                '数据检索分发模块在进行数据同步时出现错误:同步的对象[{0}]在处理时出现异常, 详细情况: [{1}]!'.format(
                    self._obj_name,
                    error.__str__()
                )
            )
Beispiel #4
0
    def process_metadata_table(self):
        object_table_id = self._obj_id  # 获取oid
        object_table_data = self._dataset
        metadata_bus_dict = self.get_metadata_bus_dict()
        metadata_table_name = CUtils.dict_value_by_name(
            self.information(), 'metadata_table_name', 'ap_product_metadata')

        metadata_table = CTable()
        metadata_table.load_info(self._db_id, metadata_table_name)
        metadata_table.column_list.column_by_name('id').set_value(
            object_table_id)
        metadata_table.column_list.column_by_name('fid').set_value(
            object_table_id)
        dsometadataxml = object_table_data.value_by_name(
            0, 'dsometadataxml_bus', None)
        metadata_table.column_list.column_by_name('metaxml').set_value(
            dsometadataxml)

        # otherxml = CUtils.dict_value_by_name(metadata_bus_dict, 'otherxml', None)
        # if not CUtils.equal_ignore_case(otherxml, ''):
        #     view_path = settings.application.xpath_one(self.Path_Setting_MetaData_Dir_View, None)
        #     browser_path = CFile.file_path(self._dataset.value_by_name(0, 'dso_browser', None))
        #     file_list = CFile.file_or_dir_fullname_of_path(
        #         CFile.join_file(view_path, browser_path), False, otherxml, CFile.MatchType_Regex
        #     )
        #     if len(file_list) > 0:
        #         metadata_table.column_list.column_by_name('otherxml').set_value(
        #             CFile.file_2_str(file_list[0])
        #         )

        metadata_table.column_list.column_by_name('otherxml').set_value(
            '<?xml version="1.0" encoding="UTF-8"?><root><plugin name="{0}"/></root>'
            .format(
                CUtils.dict_value_by_name(metadata_bus_dict, 'satelliteid',
                                          None)))

        if not metadata_table.if_exists():
            metadata_table.column_list.column_by_name('version').set_value(
                '1.0')
            now_time = CUtils.any_2_str(
                datetime.datetime.now().strftime('%F %T'))
            metadata_table.column_list.column_by_name('addtime').set_value(
                now_time)

        result = metadata_table.save_data()

        return result
Beispiel #5
0
    def parser_metadata_custom(self, parser: CMetaDataParser) -> str:
        """
        自定义的元数据解析, 在所有质检和其他处理之后触发
        :param parser:
        :return:
        """
        meta_data_json = parser.metadata.metadata_json()
        if meta_data_json is None:
            return CResult.merge_result(
                self.Success,
                '数据[{0}]的质检和空间等元数据解析完毕, 但子图层解析有误, 无法获取JSON格式的元数据! '.format(
                    self.file_info.file_name_with_full_path,
                )
            )

        json_data_source = meta_data_json.xpath_one('datasource', None)

        layer_list = meta_data_json.xpath_one(self.Name_Layers, None)
        if layer_list is None:
            return CResult.merge_result(
                self.Success,
                '数据[{0}]的质检和空间等元数据解析完毕, 但子图层解析有误, 元数据中无法找到layers节点! '.format(
                    self.file_info.file_name_with_full_path,
                )
            )

        mdb_ib_id = CFactory().give_me_db(self.file_info.db_server_id).one_value(
            '''
            select dso_ib_id
            from dm2_storage_object
            where dsoid = :object_id
            ''',
            {
                'object_id': parser.object_id
            }
        )

        error_message_list = []
        table = CTable()
        table.load_info(self.file_info.db_server_id, self.TableName_DM_Object)

        for layer in layer_list:
            layer_name = CUtils.dict_value_by_name(layer, self.Name_Name, '')
            if CUtils.equal_ignore_case(layer_name, ''):
                continue

            layer_alias_name = CUtils.dict_value_by_name(layer, self.Name_Description, layer_name)

            layer_metadata_json = CJson()
            layer_metadata_json.set_value_of_name('datasource', json_data_source)
            layer_metadata_json.set_value_of_name('layer_count', 1)
            layer_metadata_json.set_value_of_name('layers', [layer])
            layer_metadata_text = layer_metadata_json.to_json()

            try:
                sql_find_layer_existed = '''
                select dsoid as layer_id_existed
                from dm2_storage_object
                where upper(dsoobjectname) = upper(:layer_name)
                    and dsoparentobjid = :object_id
                '''
                layer_id_existed = CFactory().give_me_db(self.file_info.db_server_id).one_value(
                    sql_find_layer_existed,
                    {
                        'layer_name': layer_name,
                        'object_id': parser.object_id
                    }
                )
                if layer_id_existed is None:
                    layer_id_existed = CUtils.one_id()

                table.column_list.reset()
                table.column_list.column_by_name('dsoid').set_value(layer_id_existed)
                table.column_list.column_by_name('dsoobjectname').set_value(layer_name)
                table.column_list.column_by_name('dsoobjecttype').set_value(
                    CUtils.dict_value_by_name(
                        self.get_information(),
                        self.Plugins_Info_Child_Layer_Plugins_Name,
                        ''
                    )
                )
                table.column_list.column_by_name('dsodatatype').set_value(
                    CUtils.dict_value_by_name(
                        self.get_information(),
                        self.Plugins_Info_Child_Layer_Data_Type,
                        ''
                    )
                )
                table.column_list.column_by_name('dsoalphacode').set_value(CUtils.alpha_text(layer_name))
                table.column_list.column_by_name('dsoaliasname').set_value(layer_alias_name)
                table.column_list.column_by_name('dsoparentobjid').set_value(parser.object_id)
                table.column_list.column_by_name('dso_ib_id').set_value(mdb_ib_id)

                table.column_list.column_by_name('dsometadatatext').set_value(layer_metadata_text)
                table.column_list.column_by_name('dsometadatajson').set_value(layer_metadata_text)
                table.column_list.column_by_name('dsometadataparsestatus').set_value(self.ProcStatus_InQueue)
                table.column_list.column_by_name('dsotagsparsestatus').set_value(self.ProcStatus_InQueue)
                table.column_list.column_by_name('dsodetailparsestatus').set_value(self.ProcStatus_InQueue)
                result = table.save_data()
                if not CResult.result_success(result):
                    error_message_list.append(
                        '图层[{0}]的创建过程出现错误, 详细信息为: {1}'.format(
                            layer_name,
                            CResult.result_message(result)
                        )
                    )
            except Exception as error:
                error_message_list.append('图层[{0}]的创建过程出现错误, 详细信息为: {1}'.format(layer_name, error.__str__()))

        if len(error_message_list) > 0:
            return CResult.merge_result(
                self.Failure,
                '数据[{0}]的质检和空间等元数据解析完毕, 但子图层解析有误, 详细情况如下: \n{1}'.format(
                    self.file_info.file_name_with_full_path,
                    CUtils.list_2_str(error_message_list, '', '\n', '', True)
                )
            )
        else:
            return CResult.merge_result(
                self.Success,
                '数据[{0}]的自定义元数据解析完毕! '.format(
                    self.file_info.file_name_with_full_path,
                )
            )
Beispiel #6
0
    def test_all(self):
        table = CTable()
        table.load_info(CResource.DB_Server_ID_Default, 'dm2_storage_object')
        table.column_list.column_by_name('dsoid').set_value('dsoid')
        table.column_list.column_by_name('dsoobjectname').set_value('dsoobjectname')
        table.column_list.column_by_name('dsoobjecttype').set_value('dsoobjecttype')
        table.column_list.column_by_name('dsodatatype').set_value('dsodatatype')
        table.column_list.column_by_name('dsoalphacode').set_value('dsoalphacode')

        table.column_list.column_by_name('dso_obj_lastmodifytime').set_sql('now()')
        table.delete_data()
        table.insert_data()
        if table.if_exists():
            print('row create success')
        else:
            print('row create failure')

        table.column_list.column_by_name('dsoobjectname').set_value('dsoobjectname_update')

        table.column_list.column_by_name('dsometadataxml').set_value('''
<root><test name="中国"/></root>
            ''')
        table.column_list.column_by_name('dsometadatajson').set_value('''
        {"size": {"width": 10020, "height": 5010}, "bands": [{"mask": {"valid": true}, "type": "Byte", "block": {"width": 10020, "height": 1}, "scale": null, "offset": null, "metadata": [], "color_table": {"entrys": [{"color1": 255, "color2": 255, "color3": 255, "color4": 255}, {"color1": 47, "color2": 89, "color3": 74, "color4": 255}, {"color1": 237, "color2": 247, "color3": 252, "color4": 255}, {"color1": 217, "color2": 232, "color3": 252, "color4": 255}, {"color1": 220, "color2": 217, "color3": 239, "color4": 255}, {"color1": 238, "color2": 231, "color3": 232, "color4": 255}, {"color1": 176, "color2": 208, "color3": 252, "color4": 255}, {"color1": 165, "color2": 116, "color3": 144, "color4": 255}, {"color1": 20, "color2": 80, "color3": 152, "color4": 255}, {"color1": 218, "color2": 215, "color3": 217, "color4": 255}, {"color1": 173, "color2": 197, "color3": 222, "color4": 255}, {"color1": 231, "color2": 243, "color3": 243, "color4": 255}, {"color1": 172, "color2": 146, "color3": 117, "color4": 255}, {"color1": 113, "color2": 121, "color3": 134, "color4": 255}, {"color1": 73, "color2": 77, "color3": 54, "color4": 255}, {"color1": 164, "color2": 200, "color3": 209, "color4": 255}, {"color1": 13, "color2": 72, "color3": 145, "color4": 255}, {"color1": 166, "color2": 167, "color3": 195, "color4": 255}, {"color1": 0, "color2": 49, "color3": 121, "color4": 255}, {"color1": 163, "color2": 174, "color3": 160, "color4": 255}, {"color1": 19, "color2": 62, "color3": 125, "color4": 255}, {"color1": 196, "color2": 213, "color3": 199, "color4": 255}, {"color1": 106, "color2": 69, "color3": 57, "color4": 255}, {"color1": 108, "color2": 144, "color3": 199, "color4": 255}, {"color1": 96, "color2": 94, "color3": 64, "color4": 255}, {"color1": 49, "color2": 75, "color3": 43, "color4": 255}, {"color1": 100, "color2": 75, "color3": 84, "color4": 255}, {"color1": 83, "color2": 129, "color3": 72, "color4": 255}, {"color1": 139, "color2": 118, "color3": 99, "color4": 255}, {"color1": 40, "color2": 90, "color3": 49, "color4": 255}, {"color1": 31, "color2": 95, "color3": 165, "color4": 255}, {"color1": 69, "color2": 110, "color3": 99, "color4": 255}, {"color1": 112, "color2": 95, "color3": 88, "color4": 255}, {"color1": 75, "color2": 106, "color3": 62, "color4": 255}, {"color1": 28, "color2": 61, "color3": 31, "color4": 255}, {"color1": 60, "color2": 128, "color3": 63, "color4": 255}, {"color1": 40, "color2": 23, "color3": 18, "color4": 255}, {"color1": 251, "color2": 251, "color3": 254, "color4": 255}, {"color1": 50, "color2": 113, "color3": 55, "color4": 255}, {"color1": 17, "color2": 68, "color3": 24, "color4": 255}, {"color1": 96, "color2": 107, "color3": 89, "color4": 255}, {"color1": 178, "color2": 166, "color3": 125, "color4": 255}, {"color1": 140, "color2": 163, "color3": 148, "color4": 255}, {"color1": 30, "color2": 67, "color3": 111, "color4": 255}, {"color1": 33, "color2": 81, "color3": 39, "color4": 255}, {"color1": 25, "color2": 42, "color3": 21, "color4": 255}, {"color1": 0, "color2": 40, "color3": 102, "color4": 255}, {"color1": 74, "color2": 109, "color3": 46, "color4": 255}, {"color1": 71, "color2": 93, "color3": 54, "color4": 255}, {"color1": 62, "color2": 113, "color3": 62, "color4": 255}, {"color1": 97, "color2": 138, "color3": 77, "color4": 255}, {"color1": 6, "color2": 62, "color3": 136, "color4": 255}, {"color1": 91, "color2": 114, "color3": 104, "color4": 255}, {"color1": 63, "color2": 100, "color3": 58, "color4": 255}, {"color1": 42, "color2": 107, "color3": 176, "color4": 255}, {"color1": 38, "color2": 108, "color3": 53, "color4": 255}, {"color1": 70, "color2": 121, "color3": 66, "color4": 255}, {"color1": 112, "color2": 134, "color3": 81, "color4": 255}, {"color1": 81, "color2": 172, "color3": 88, "color4": 255}, {"color1": 135, "color2": 114, "color3": 80, "color4": 255}, {"color1": 1, "color2": 28, "color3": 81, "color4": 255}, {"color1": 7, "color2": 76, "color3": 131, "color4": 255}, {"color1": 41, "color2": 49, "color3": 28, "color4": 255}, {"color1": 162, "color2": 127, "color3": 101, "color4": 255}, {"color1": 186, "color2": 186, "color3": 113, "color4": 255}, {"color1": 116, "color2": 113, "color3": 76, "color4": 255}, {"color1": 64, "color2": 131, "color3": 199, "color4": 255}, {"color1": 188, "color2": 160, "color3": 148, "color4": 255}, {"color1": 192, "color2": 167, "color3": 126, "color4": 255}, {"color1": 93, "color2": 156, "color3": 92, "color4": 255}, {"color1": 158, "color2": 140, "color3": 92, "color4": 255}, {"color1": 168, "color2": 149, "color3": 104, "color4": 255}, {"color1": 176, "color2": 135, "color3": 107, "color4": 255}, {"color1": 230, "color2": 201, "color3": 154, "color4": 255}, {"color1": 86, "color2": 108, "color3": 68, "color4": 255}, {"color1": 129, "color2": 83, "color3": 63, "color4": 255}, {"color1": 57, "color2": 83, "color3": 58, "color4": 255}, {"color1": 208, "color2": 181, "color3": 139, "color4": 255}, {"color1": 160, "color2": 129, "color3": 84, "color4": 255}, {"color1": 127, "color2": 138, "color3": 97, "color4": 255}, {"color1": 237, "color2": 217, "color3": 162, "color4": 255}, {"color1": 220, "color2": 188, "color3": 148, "color4": 255}, {"color1": 110, "color2": 89, "color3": 61, "color4": 255}, {"color1": 165, "color2": 169, "color3": 111, "color4": 255}, {"color1": 99, "color2": 101, "color3": 57, "color4": 255}, {"color1": 205, "color2": 190, "color3": 154, "color4": 255}, {"color1": 141, "color2": 139, "color3": 104, "color4": 255}, {"color1": 241, "color2": 220, "color3": 177, "color4": 255}, {"color1": 108, "color2": 165, "color3": 105, "color4": 255}, {"color1": 103, "color2": 113, "color3": 67, "color4": 255}, {"color1": 7, "color2": 29, "color3": 5, "color4": 255}, {"color1": 90, "color2": 104, "color3": 121, "color4": 255}, {"color1": 188, "color2": 149, "color3": 113, "color4": 255}, {"color1": 57, "color2": 86, "color3": 48, "color4": 255}, {"color1": 222, "color2": 152, "color3": 124, "color4": 255}, {"color1": 22, "color2": 93, "color3": 35, "color4": 255}, {"color1": 75, "color2": 142, "color3": 69, "color4": 255}, {"color1": 253, "color2": 243, "color3": 193, "color4": 255}, {"color1": 89, "color2": 59, "color3": 41, "color4": 255}, {"color1": 106, "color2": 183, "color3": 105, "color4": 255}, {"color1": 85, "color2": 155, "color3": 220, "color4": 255}, {"color1": 0, "color2": 17, "color3": 62, "color4": 255}, {"color1": 53, "color2": 119, "color3": 187, "color4": 255}, {"color1": 3, "color2": 7, "color3": 2, "color4": 255}, {"color1": 239, "color2": 233, "color3": 200, "color4": 255}, {"color1": 14, "color2": 32, "color3": 12, "color4": 255}, {"color1": 86, "color2": 84, "color3": 62, "color4": 255}, {"color1": 143, "color2": 150, "color3": 91, "color4": 255}, {"color1": 38, "color2": 58, "color3": 53, "color4": 255}, {"color1": 47, "color2": 133, "color3": 68, "color4": 255}, {"color1": 91, "color2": 163, "color3": 227, "color4": 255}, {"color1": 69, "color2": 48, "color3": 32, "color4": 255}, {"color1": 144, "color2": 168, "color3": 103, "color4": 255}, {"color1": 106, "color2": 177, "color3": 120, "color4": 255}, {"color1": 22, "color2": 13, "color3": 8, "color4": 255}, {"color1": 75, "color2": 87, "color3": 64, "color4": 255}, {"color1": 168, "color2": 212, "color3": 151, "color4": 255}, {"color1": 90, "color2": 168, "color3": 98, "color4": 255}, {"color1": 37, "color2": 63, "color3": 39, "color4": 255}, {"color1": 65, "color2": 148, "color3": 80, "color4": 255}, {"color1": 7, "color2": 52, "color3": 13, "color4": 255}, {"color1": 15, "color2": 75, "color3": 41, "color4": 255}, {"color1": 0, "color2": 18, "color3": 43, "color4": 255}, {"color1": 38, "color2": 84, "color3": 120, "color4": 255}, {"color1": 23, "color2": 88, "color3": 48, "color4": 255}, {"color1": 98, "color2": 102, "color3": 76, "color4": 255}, {"color1": 94, "color2": 143, "color3": 90, "color4": 255}, {"color1": 109, "color2": 120, "color3": 100, "color4": 255}, {"color1": 40, "color2": 76, "color3": 56, "color4": 255}, {"color1": 43, "color2": 60, "color3": 78, "color4": 255}, {"color1": 38, "color2": 100, "color3": 46, "color4": 255}, {"color1": 44, "color2": 92, "color3": 150, "color4": 255}, {"color1": 48, "color2": 42, "color3": 27, "color4": 255}, {"color1": 67, "color2": 117, "color3": 177, "color4": 255}, {"color1": 91, "color2": 126, "color3": 83, "color4": 255}, {"color1": 59, "color2": 98, "color3": 77, "color4": 255}, {"color1": 22, "color2": 78, "color3": 143, "color4": 255}, {"color1": 114, "color2": 158, "color3": 223, "color4": 255}, {"color1": 72, "color2": 134, "color3": 76, "color4": 255}, {"color1": 17, "color2": 42, "color3": 107, "color4": 255}, {"color1": 59, "color2": 127, "color3": 108, "color4": 255}, {"color1": 59, "color2": 128, "color3": 165, "color4": 255}, {"color1": 69, "color2": 92, "color3": 99, "color4": 255}, {"color1": 123, "color2": 151, "color3": 104, "color4": 255}, {"color1": 76, "color2": 123, "color3": 103, "color4": 255}, {"color1": 70, "color2": 78, "color3": 41, "color4": 255}, {"color1": 148, "color2": 130, "color3": 113, "color4": 255}, {"color1": 97, "color2": 119, "color3": 69, "color4": 255}, {"color1": 81, "color2": 98, "color3": 65, "color4": 255}, {"color1": 123, "color2": 124, "color3": 85, "color4": 255}, {"color1": 105, "color2": 149, "color3": 95, "color4": 255}, {"color1": 123, "color2": 100, "color3": 74, "color4": 255}, {"color1": 142, "color2": 130, "color3": 84, "color4": 255}, {"color1": 148, "color2": 114, "color3": 70, "color4": 255}, {"color1": 20, "color2": 82, "color3": 26, "color4": 255}, {"color1": 198, "color2": 147, "color3": 103, "color4": 255}, {"color1": 206, "color2": 163, "color3": 117, "color4": 255}, {"color1": 80, "color2": 29, "color3": 38, "color4": 255}, {"color1": 24, "color2": 56, "color3": 84, "color4": 255}, {"color1": 168, "color2": 114, "color3": 82, "color4": 255}, {"color1": 189, "color2": 143, "color3": 96, "color4": 255}, {"color1": 51, "color2": 110, "color3": 127, "color4": 255}, {"color1": 159, "color2": 143, "color3": 118, "color4": 255}, {"color1": 49, "color2": 38, "color3": 52, "color4": 255}, {"color1": 38, "color2": 68, "color3": 28, "color4": 255}, {"color1": 227, "color2": 209, "color3": 173, "color4": 255}, {"color1": 175, "color2": 173, "color3": 139, "color4": 255}, {"color1": 178, "color2": 191, "color3": 147, "color4": 255}, {"color1": 51, "color2": 98, "color3": 53, "color4": 255}, {"color1": 133, "color2": 161, "color3": 123, "color4": 255}, {"color1": 187, "color2": 161, "color3": 106, "color4": 255}, {"color1": 62, "color2": 58, "color3": 46, "color4": 255}, {"color1": 72, "color2": 141, "color3": 207, "color4": 255}, {"color1": 52, "color2": 61, "color3": 27, "color4": 255}, {"color1": 90, "color2": 80, "color3": 48, "color4": 255}, {"color1": 124, "color2": 172, "color3": 104, "color4": 255}, {"color1": 121, "color2": 155, "color3": 89, "color4": 255}, {"color1": 85, "color2": 96, "color3": 78, "color4": 255}, {"color1": 88, "color2": 195, "color3": 84, "color4": 255}, {"color1": 108, "color2": 152, "color3": 126, "color4": 255}, {"color1": 104, "color2": 116, "color3": 89, "color4": 255}, {"color1": 154, "color2": 176, "color3": 140, "color4": 255}, {"color1": 98, "color2": 127, "color3": 116, "color4": 255}, {"color1": 204, "color2": 217, "color3": 178, "color4": 255}, {"color1": 59, "color2": 74, "color3": 69, "color4": 255}, {"color1": 46, "color2": 77, "color3": 103, "color4": 255}, {"color1": 71, "color2": 80, "color3": 108, "color4": 255}, {"color1": 125, "color2": 187, "color3": 197, "color4": 255}, {"color1": 154, "color2": 188, "color3": 200, "color4": 255}, {"color1": 126, "color2": 140, "color3": 165, "color4": 255}, {"color1": 175, "color2": 229, "color3": 253, "color4": 255}, {"color1": 141, "color2": 204, "color3": 207, "color4": 255}, {"color1": 174, "color2": 218, "color3": 228, "color4": 255}, {"color1": 204, "color2": 231, "color3": 238, "color4": 255}, {"color1": 125, "color2": 151, "color3": 187, "color4": 255}, {"color1": 199, "color2": 251, "color3": 255, "color4": 255}, {"color1": 132, "color2": 172, "color3": 183, "color4": 255}, {"color1": 167, "color2": 210, "color3": 224, "color4": 255}, {"color1": 184, "color2": 228, "color3": 232, "color4": 255}, {"color1": 216, "color2": 251, "color3": 253, "color4": 255}, {"color1": 185, "color2": 234, "color3": 244, "color4": 255}, {"color1": 90, "color2": 146, "color3": 186, "color4": 255}, {"color1": 172, "color2": 226, "color3": 242, "color4": 255}, {"color1": 160, "color2": 190, "color3": 196, "color4": 255}, {"color1": 103, "color2": 157, "color3": 182, "color4": 255}, {"color1": 201, "color2": 244, "color3": 244, "color4": 255}, {"color1": 192, "color2": 239, "color3": 251, "color4": 255}, {"color1": 158, "color2": 227, "color3": 254, "color4": 255}, {"color1": 168, "color2": 216, "color3": 233, "color4": 255}, {"color1": 105, "color2": 144, "color3": 171, "color4": 255}, {"color1": 187, "color2": 225, "color3": 222, "color4": 255}, {"color1": 179, "color2": 248, "color3": 255, "color4": 255}, {"color1": 188, "color2": 155, "color3": 177, "color4": 255}, {"color1": 83, "color2": 112, "color3": 143, "color4": 255}, {"color1": 193, "color2": 191, "color3": 202, "color4": 255}, {"color1": 159, "color2": 188, "color3": 209, "color4": 255}, {"color1": 201, "color2": 210, "color3": 221, "color4": 255}, {"color1": 135, "color2": 173, "color3": 197, "color4": 255}, {"color1": 105, "color2": 133, "color3": 184, "color4": 255}, {"color1": 136, "color2": 189, "color3": 217, "color4": 255}, {"color1": 112, "color2": 160, "color3": 171, "color4": 255}, {"color1": 108, "color2": 220, "color3": 255, "color4": 255}, {"color1": 221, "color2": 253, "color3": 227, "color4": 255}, {"color1": 13, "color2": 42, "color3": 73, "color4": 255}, {"color1": 150, "color2": 198, "color3": 230, "color4": 255}, {"color1": 148, "color2": 215, "color3": 235, "color4": 255}, {"color1": 149, "color2": 159, "color3": 189, "color4": 255}, {"color1": 147, "color2": 180, "color3": 214, "color4": 255}, {"color1": 115, "color2": 144, "color3": 181, "color4": 255}, {"color1": 227, "color2": 255, "color3": 255, "color4": 255}, {"color1": 146, "color2": 202, "color3": 252, "color4": 255}, {"color1": 141, "color2": 185, "color3": 235, "color4": 255}, {"color1": 35, "color2": 119, "color3": 138, "color4": 255}, {"color1": 95, "color2": 150, "color3": 172, "color4": 255}, {"color1": 227, "color2": 246, "color3": 218, "color4": 255}, {"color1": 62, "color2": 95, "color3": 140, "color4": 255}, {"color1": 54, "color2": 88, "color3": 115, "color4": 255}, {"color1": 156, "color2": 169, "color3": 179, "color4": 255}, {"color1": 109, "color2": 126, "color3": 153, "color4": 255}, {"color1": 174, "color2": 211, "color3": 212, "color4": 255}, {"color1": 132, "color2": 171, "color3": 211, "color4": 255}, {"color1": 151, "color2": 182, "color3": 192, "color4": 255}, {"color1": 128, "color2": 164, "color3": 187, "color4": 255}, {"color1": 93, "color2": 133, "color3": 162, "color4": 255}, {"color1": 120, "color2": 176, "color3": 205, "color4": 255}, {"color1": 104, "color2": 159, "color3": 197, "color4": 255}, {"color1": 10, "color2": 16, "color3": 89, "color4": 255}, {"color1": 95, "color2": 139, "color3": 206, "color4": 255}, {"color1": 85, "color2": 110, "color3": 184, "color4": 255}, {"color1": 147, "color2": 162, "color3": 214, "color4": 255}, {"color1": 110, "color2": 214, "color3": 115, "color4": 255}, {"color1": 150, "color2": 92, "color3": 94, "color4": 255}, {"color1": 209, "color2": 176, "color3": 176, "color4": 255}, {"color1": 147, "color2": 193, "color3": 128, "color4": 255}, {"color1": 211, "color2": 188, "color3": 180, "color4": 255}, {"color1": 0, "color2": 0, "color3": 0, "color4": 255}], "entry_count": 256, "palette_interpretation_name": "RGB"}, "color_interp": "Palette", "image_structure_metadata": []}], "files": ["/Users/wangxiya/Documents/我的测试数据/11.入库存储/广西影像数据/2772.0-509.0/2772.0-509.0.tif"], "wgs84": {"msg": "boundingbox四至范围从WGS_1984坐标系转wgs_84坐标系转换成功!", "coordinate": {"wkt": "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]", "esri": "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]", "proj4": "+proj=longlat +datum=WGS84 +no_defs"}, "boundingbox": {"top": 89.99999999995, "left": -179.99999899994998, "right": 179.99999887005004, "bottom": -89.99999993704998}}, "driver": {"longname": "GeoTIFF", "shortname": "GTiff"}, "origin": {"geotransform0": -179.99999899994998, "geotransform3": 89.99999999995}, "result": -1, "pyramid": 0, "metadata": ["Area", "2 (pixels/inch)", "IMAGINE TIFF Support\nCopyright 1991 - 1999 by ERDAS, Inc. All Rights Reserved\n@(#)$RCSfile: etif.c $ $Revision: 1.9.1.2 $ $Date: 2001/12/05 00:33:12Z $", "1", "1"], "pixelsize": {"width": 0.0359281435, "height": -0.0359281437}, "coordinate": {"wkt": "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]", "esri": "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]", "proj4": "+proj=longlat +datum=WGS84 +no_defs"}, "boundingbox": {"top": 89.99999999995, "left": -179.99999899994998, "right": 179.99999887005004, "bottom": -89.99999993704998}, "corner_coordinates": {"center": {"x": 5010.0, "y": 2505.0}, "lower_left": {"x": 0, "y": 5010}, "upper_left": {"x": 0, "y": 0}, "lower_right": {"x": 10020, "y": 5010}, "upper_right": {"x": 10020, "y": 0}}, "image_structure_metadata": ["BAND"]}
            ''')
        table.column_list.column_by_name('dsotags').set_array(list([1, 2, 3]))

        table.column_list.column_by_name('dso_geo_wgs84').set_value(
            'POLYGON((-179.99999899995 89.99999999995,179.99999887005 89.99999999995,179.99999887005 -89.99999993705,-179.99999899995 -89.99999993705,-179.99999899995 89.99999999995))')
        table.update_data()
        print('row update success')
        assert True
Beispiel #7
0
    def process_ndi_table(self):
        object_table_id = self._obj_id  # 获取oid
        metadata_bus_dict = self.get_metadata_bus_dict()
        ndi_table_name = CUtils.dict_value_by_name(self.information(),
                                                   'ndi_table_name',
                                                   'ap_product_ndi')

        ndi_table = CTable()
        ndi_table.load_info(self._db_id, ndi_table_name)
        ndi_table.column_list.column_by_name('id').set_value(object_table_id)

        productname = CUtils.dict_value_by_name(metadata_bus_dict,
                                                'productname', None)
        if CUtils.equal_ignore_case(productname, ''):
            productname = self._dataset.value_by_name(0, 'dsoobjectname', None)
        ndi_table.column_list.column_by_name('rid').set_value(productname)
        ndi_table.column_list.column_by_name('fid').set_value(object_table_id)
        ndi_table.column_list.column_by_name('satelliteid').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'satelliteid', None))
        ndi_table.column_list.column_by_name('sensorid').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'sensorid', None))
        ndi_table.column_list.column_by_name('topleftlatitude').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'topleftlatitude',
                                      None))
        ndi_table.column_list.column_by_name('topleftlongitude').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'topleftlongitude',
                                      None))
        ndi_table.column_list.column_by_name('toprightlatitude').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'toprightlatitude',
                                      None))
        ndi_table.column_list.column_by_name('toprightlongitude').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'toprightlongitude',
                                      None))
        ndi_table.column_list.column_by_name('bottomrightlatitude').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'bottomrightlatitude',
                                      None))
        ndi_table.column_list.column_by_name('bottomrightlongitude').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict,
                                      'bottomrightlongitude', None))
        ndi_table.column_list.column_by_name('bottomleftlatitude').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'bottomleftlatitude',
                                      None))
        ndi_table.column_list.column_by_name('bottomleftlongitude').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'bottomleftlongitude',
                                      None))
        ndi_table.column_list.column_by_name('centerlatitude').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'centerlatitude',
                                      None))
        ndi_table.column_list.column_by_name('centerlongitude').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'centerlongitude',
                                      None))

        transformimg = CUtils.dict_value_by_name(metadata_bus_dict,
                                                 'transformimg', None)
        if not CUtils.equal_ignore_case(transformimg, ''):
            view_path = settings.application.xpath_one(
                self.Path_Setting_MetaData_Dir_View, None)
            browser_path = CFile.file_path(
                self._dataset.value_by_name(0, 'dso_browser', None))
            file_list = CFile.file_or_dir_fullname_of_path(
                CFile.join_file(view_path, browser_path), False, transformimg,
                CFile.MatchType_Regex)
            if len(file_list) > 0:
                ndi_table.column_list.column_by_name('transformimg').set_value(
                    '{0}{1}'.format(
                        CFile.sep(),
                        CFile.join_file(browser_path,
                                        CFile.file_name(file_list[0]))))

        ndi_table.column_list.column_by_name('filesize').set_sql('''
            (select sum(dodfilesize) from dm2_storage_obj_detail where dodobjectid='{0}')
            '''.format(object_table_id))
        ndi_table.column_list.column_by_name('dataexist').set_value(0)
        ndi_table.column_list.column_by_name('centertime').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'centertime', None))

        resolution = CUtils.dict_value_by_name(metadata_bus_dict, 'resolution',
                                               None)
        if not CUtils.equal_ignore_case(resolution, ''):
            ndi_table.column_list.column_by_name('resolution').set_value(
                resolution)
        else:
            ndi_table.column_list.column_by_name('resolution').set_value(0)

        rollangle = CUtils.dict_value_by_name(metadata_bus_dict, 'rollangle',
                                              0)
        if CUtils.equal_ignore_case(rollangle, ''):
            rollangle = 0
        ndi_table.column_list.column_by_name('rollangle').set_value(rollangle)
        cloudpercent = CUtils.dict_value_by_name(metadata_bus_dict,
                                                 'cloudpercent', 0)
        if CUtils.equal_ignore_case(cloudpercent, ''):
            cloudpercent = 0
        ndi_table.column_list.column_by_name('cloudpercent').set_value(
            cloudpercent)
        ndi_table.column_list.column_by_name('dataum').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'dataum', None))
        ndi_table.column_list.column_by_name('acquisition_id').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'acquisition_id',
                                      None))

        result = ndi_table.save_data()

        return result
Beispiel #8
0
    def process_main_table(self):
        object_table_id = self._obj_id  # 获取oid
        object_table_data = self._dataset
        metadata_bus_dict = self.get_metadata_bus_dict()
        main_table_name = CUtils.dict_value_by_name(self.information(),
                                                    'main_table_name',
                                                    'ap_product')

        main_table = CTable()
        main_table.load_info(self._db_id, main_table_name)
        main_table.column_list.column_by_name('id').set_value(object_table_id)
        productname = CUtils.dict_value_by_name(metadata_bus_dict,
                                                'productname', None)
        if CUtils.equal_ignore_case(productname, ''):
            productname = object_table_data.value_by_name(
                0, 'dsoobjectname', None)
        main_table.column_list.column_by_name('productname').set_value(
            productname)
        main_table.column_list.column_by_name('producttype').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'producttype', None))
        main_table.column_list.column_by_name('regioncode').set_null()
        main_table.column_list.column_by_name('productattribute').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'productattribute',
                                      None))

        centerlatitude = CUtils.dict_value_by_name(metadata_bus_dict,
                                                   'centerlatitude', None)
        centerlongitude = CUtils.dict_value_by_name(metadata_bus_dict,
                                                    'centerlongitude', None)
        centerlonlat = '{0},{1}'.format(centerlongitude, centerlatitude)
        main_table.column_list.column_by_name('centerlonlat').set_value(
            centerlonlat)

        main_table.column_list.column_by_name('geomwkt').set_sql('''
            st_astext(
            (select dso_geo_wgs84 from dm2_storage_object where dsoid='{0}')
            )
            '''.format(object_table_id))
        main_table.column_list.column_by_name('geomobj').set_sql('''
            (select dso_geo_wgs84 from dm2_storage_object where dsoid='{0}')
            '''.format(object_table_id))
        main_table.column_list.column_by_name('browserimg').set_value(
            '{0}{1}'.format(
                CFile.sep(),
                object_table_data.value_by_name(0, 'dso_browser', None)))
        main_table.column_list.column_by_name('thumbimg').set_value(
            '{0}{1}'.format(
                CFile.sep(),
                object_table_data.value_by_name(0, 'dso_thumb', None)))
        main_table.column_list.column_by_name('publishdate').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'publishdate', None))
        main_table.column_list.column_by_name('copyright').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'copyright', None))

        dso_time = object_table_data.value_by_name(0, 'dso_time', None)
        dso_time_json = CJson()
        dso_time_json.load_obj(dso_time)
        imgdate = dso_time_json.xpath_one('time', None)
        if not CUtils.equal_ignore_case(imgdate, ''):
            main_table.column_list.column_by_name('imgdate').set_value(
                imgdate[0:4])
        else:
            main_table.column_list.column_by_name('imgdate').set_null()

        main_table.column_list.column_by_name('starttime').set_value(
            dso_time_json.xpath_one('start_time', None))
        main_table.column_list.column_by_name('endtime').set_value(
            dso_time_json.xpath_one('end_time', None))
        resolution = CUtils.any_2_str(
            CUtils.dict_value_by_name(metadata_bus_dict, 'resolution', None))
        if not CUtils.equal_ignore_case(resolution, ''):
            if '/' in resolution:
                resolution_list = resolution.split('/')
                temp_list = list()
                for resolution in resolution_list:
                    temp_list.append(CUtils.to_decimal(resolution, -1))
                temp_list = list(set(temp_list))  # 去重
                if -1 in temp_list:
                    temp_list.remove(-1)
                if len(temp_list) > 0:
                    main_table.column_list.column_by_name(
                        'resolution').set_value(min(temp_list))
                else:
                    main_table.column_list.column_by_name(
                        'resolution').set_value(0)
            else:
                main_table.column_list.column_by_name('resolution').set_value(
                    resolution)
        else:
            main_table.column_list.column_by_name('resolution').set_value(0)

        main_table.column_list.column_by_name('filesize').set_sql('''
            (select sum(dodfilesize) from dm2_storage_obj_detail where dodobjectid='{0}')
            '''.format(object_table_id))

        productid = CUtils.dict_value_by_name(metadata_bus_dict, 'productid',
                                              None)
        if CUtils.equal_ignore_case(productid, ''):
            object_type = object_table_data.value_by_name(0, 'dsodatatype', '')
            if CUtils.equal_ignore_case(object_type, self.Name_Dir):
                main_table.column_list.column_by_name('productid').set_value(
                    object_table_data.value_by_name(0, 'dsoobjectname', None))
            elif CUtils.equal_ignore_case(object_type, self.Name_File):
                main_table.column_list.column_by_name('productid').set_sql('''
                    (SELECT dsffilename FROM dm2_storage_file WHERE dsf_object_id = '{0}')
                    '''.format(object_table_id))
            else:
                main_table.column_list.column_by_name('productid').set_null()
        else:
            main_table.column_list.column_by_name('productid').set_value(
                productid)

        main_table.column_list.column_by_name('remark').set_value(
            CUtils.dict_value_by_name(metadata_bus_dict, 'remark', None))
        main_table.column_list.column_by_name('extent').set_sql('''
            (select dso_geo_bb_wgs84 from dm2_storage_object where dsoid='{0}')
            '''.format(object_table_id))
        main_table.column_list.column_by_name('proj').set_null()  # 原始数据保持空

        main_table.column_list.column_by_name('dataid').set_value(
            object_table_id)
        main_table.column_list.column_by_name('shplog').set_null()

        if not main_table.if_exists():
            now_time = CUtils.any_2_str(
                datetime.datetime.now().strftime('%F %T'))
            main_table.column_list.column_by_name('addtime').set_value(
                now_time)
            main_table.column_list.column_by_name('isdel').set_value(0)
            main_table.column_list.column_by_name('projectnames').set_value(
                'productname')
        result = main_table.save_data()

        return result