def upload_features(tags_lst_obj, token, space_id): conn_info = SpaceConnectionInfo() conn_info.set_(space_id=space_id, token=token) loop = QEventLoop() network = NetManager(app) total = sum(len(lst) for lst in tags_lst_obj.values()) network.network.finished.connect(count_reply(total, loop.quit)) for i, (tags, lst_obj) in enumerate(tags_lst_obj.items()): # print(len(lst_obj[0]["features"]), tags) for obj in lst_obj: reply = network.add_features(conn_info, obj, tags=tags) loop.exec_()
BaseTestWorkerAsync, add_test_fn_params, get_token_space, get_conn_info, AllErrorsDuringTest, ) from test.test_layer_loader import TestReLoader, TestLoader from XYZHubConnector.xyz_qgis.network import NetManager from XYZHubConnector.xyz_qgis.loader import TileLayerLoader, EmptyXYZSpaceError from XYZHubConnector.xyz_qgis.layer import bbox_utils, tile_utils, layer_utils from qgis.core import QgsProject from qgis.PyQt.QtCore import QTimer app = start_app() network = NetManager(app) class TestTileLoader(TestLoader): flag_canvas = False def _test_load_small_layer(self, n_parallel, **kw_start): conn_info = get_conn_info("water") meta = dict(id="unittest", title="unittest", description="unittest") feat_cnt = 527 kw = dict(kw_start) schema = "here" # level, rect = 1, (-165.7,-71.4 , 160.8,93.7) # fail # level, rect = 1, (-180,-90,181,91) # fail # level, rect = 1, (-180,-90,180,90) # ok
from XYZHubConnector.xyz_qgis.network import NetManager from XYZHubConnector.xyz_qgis.network import net_handler from qgis.PyQt.QtCore import QEventLoop from XYZHubConnector.xyz_qgis.models.connection import SpaceConnectionInfo conn_info = SpaceConnectionInfo() conn_info.set_(space_id="DicZ8XTR", token="AdOZrFlyIrXLzbAJeN5Lzts") # minimize total number of features # by generate tags for all levels # smallest step for coord currently is 1 (can be smaller) lst_tags = [format_tags(t, prefix="point") for t in precompute_tags()] # print(lst_tags) print("len tags", len(lst_tags)) tags_lst_obj = make_point_json(lst_tags) print("len set tags", len(set(lst_tags))) print("len tags_lst_obj", len(tags_lst_obj)) loop = QEventLoop() network = NetManager(app) total = sum(len(lst) for lst in tags_lst_obj.values()) print("total obj", total) network.network.finished.connect(count_reply(total, loop.quit)) for i, (tags, lst_obj) in enumerate(tags_lst_obj.items()): # print(len(lst_obj[0]["features"]), tags) for obj in lst_obj: pass reply = network.add_features(conn_info, obj, tags=tags) loop.exec_()
# bounded tags = "point" # rect = [-180, -90, -165, -65] # rect = [-136.7, -61.5, -92.9, -34.0] # level 5 rect = [-136.9, -61.5, -130.9, -55.5] # level 9 # higher level require moore precise coord lst_tiles = tile_utils.bboxToListColRow(*rect, level, tile_schema) print(lst_tiles) validator = BoundedValidator(level, *rect) lst_params = [ dict(tile_schema=tile_schema, tile_id=t, limit=100000, tags=tags) for t in lst_tiles ] total = len(lst_tiles) loop = QEventLoop(app) network = NetManager(app) counter = Counter(total, loop.quit) network.network.finished.connect(validator.check_reply) network.network.finished.connect(counter.count_reply) for i, params in enumerate(lst_params): network.load_features_tile(conn_info, **params) loop.exec_()