def patch_after_feature_change( self, workspace, layer, ): if self.is_aborted(): raise AbortedException info = layman_util.get_publication_info( workspace, LAYER_TYPE, layer, context={'keys': ['file', 'native_crs']}) file_type = info['file']['file_type'] if file_type == settings.FILE_TYPE_RASTER: return if file_type != settings.FILE_TYPE_VECTOR: raise NotImplementedError(f"Unknown file type: {file_type}") bbox = geoserver.get_layer_bbox(workspace, layer) crs = info['native_crs'] gs_util.patch_feature_type(workspace, layer, auth=settings.LAYMAN_GS_AUTH, bbox=bbox, crs=crs) wfs.clear_cache(workspace) if self.is_aborted(): raise AbortedException
def patch_after_feature_change( self, workspace, layer, ): if self.is_aborted(): raise AbortedException file_type = layman_util.get_publication_info(workspace, LAYER_TYPE, layer, context={'keys': ['file']})['file']['file_type'] if file_type == settings.FILE_TYPE_VECTOR: bbox = geoserver.get_layer_bbox(workspace, layer) geoserver_workspace = wms.get_geoserver_workspace(workspace) info = layman_util.get_publication_info(workspace, LAYER_TYPE, layer, context={'keys': ['style_type', 'native_crs', ], }) style_type = info['style_type'] crs = info['native_crs'] lat_lon_bbox = bbox_util.transform(bbox, crs, crs_def.EPSG_4326) if style_type == 'sld': gs_util.patch_feature_type(geoserver_workspace, layer, auth=settings.LAYMAN_GS_AUTH, bbox=bbox, crs=crs, lat_lon_bbox=lat_lon_bbox) elif style_type == 'qml': gs_util.patch_wms_layer(geoserver_workspace, layer, auth=settings.LAYMAN_GS_AUTH, bbox=bbox, crs=crs, lat_lon_bbox=lat_lon_bbox) elif file_type != settings.FILE_TYPE_RASTER: raise NotImplementedError(f"Unknown file type: {file_type}") wms.clear_cache(workspace) if self.is_aborted(): raise AbortedException
def patch_layer(workspace, layername, title, description, access_rights=None): if not get_layer_info(workspace, layername): return geoserver_workspace = get_geoserver_workspace(workspace) info = layman_util.get_publication_info(workspace, LAYER_TYPE, layername, context={ 'keys': [ 'style_type', 'file', ], }) file_type = info['file']['file_type'] if file_type == settings.FILE_TYPE_VECTOR: if info['style_type'] == 'sld': gs_util.patch_feature_type(geoserver_workspace, layername, title=title, description=description, auth=settings.LAYMAN_GS_AUTH) if info['style_type'] == 'qml': gs_util.patch_wms_layer(geoserver_workspace, layername, title=title, description=description, auth=settings.LAYMAN_GS_AUTH) elif file_type == settings.FILE_TYPE_RASTER: store = get_geotiff_store_name(layername) gs_util.patch_coverage(geoserver_workspace, layername, store, title=title, description=description, auth=settings.LAYMAN_GS_AUTH) else: raise NotImplementedError(f"Unknown file type: {file_type}") clear_cache(workspace) if access_rights and access_rights.get('read'): security_read_roles = gs_common.layman_users_to_geoserver_roles( access_rights['read']) gs_util.ensure_layer_security_roles(geoserver_workspace, layername, security_read_roles, 'r', settings.LAYMAN_GS_AUTH) if access_rights and access_rights.get('write'): security_write_roles = gs_common.layman_users_to_geoserver_roles( access_rights['write']) gs_util.ensure_layer_security_roles(geoserver_workspace, layername, security_write_roles, 'w', settings.LAYMAN_GS_AUTH)
def patch_layer(workspace, layername, title, description, access_rights=None): geoserver_workspace = get_geoserver_workspace(workspace) info = layer_util.get_layer_info(workspace, layername, context={'keys': ['style_type'], }) if info['style_type'] == 'sld': gs_util.patch_feature_type(geoserver_workspace, layername, title=title, description=description, auth=settings.LAYMAN_GS_AUTH) clear_cache(workspace) if access_rights and access_rights.get('read'): security_read_roles = gs_common.layman_users_to_geoserver_roles(access_rights['read']) gs_util.ensure_layer_security_roles(geoserver_workspace, layername, security_read_roles, 'r', settings.LAYMAN_GS_AUTH) if access_rights and access_rights.get('write'): security_write_roles = gs_common.layman_users_to_geoserver_roles(access_rights['write']) gs_util.ensure_layer_security_roles(geoserver_workspace, layername, security_write_roles, 'w', settings.LAYMAN_GS_AUTH)
def patch_after_feature_change( self, workspace, layer, ): if self.is_aborted(): raise AbortedException bbox = geoserver.get_layer_bbox(workspace, layer) gs_util.patch_feature_type(workspace, layer, auth=settings.LAYMAN_GS_AUTH, bbox=bbox) wfs.clear_cache(workspace) if self.is_aborted(): raise AbortedException
def patch_layer(workspace, layername, title, description, access_rights=None): if not get_layer_info(workspace, layername): return info = layman_util.get_publication_info(workspace, LAYER_TYPE, layername, context={'keys': ['file', ]}) file_type = info['file']['file_type'] if file_type != settings.FILE_TYPE_VECTOR: raise NotImplementedError(f"Unknown file type: {file_type}") gs_util.patch_feature_type(workspace, layername, title=title, description=description, auth=settings.LAYMAN_GS_AUTH) clear_cache(workspace) if access_rights and access_rights.get('read'): security_read_roles = gs_common.layman_users_to_geoserver_roles(access_rights['read']) gs_util.ensure_layer_security_roles(workspace, layername, security_read_roles, 'r', settings.LAYMAN_GS_AUTH) if access_rights and access_rights.get('write'): security_write_roles = gs_common.layman_users_to_geoserver_roles(access_rights['write']) gs_util.ensure_layer_security_roles(workspace, layername, security_write_roles, 'w', settings.LAYMAN_GS_AUTH)
def patch_after_feature_change( self, workspace, layer, ): if self.is_aborted(): raise AbortedException bbox = geoserver.get_layer_bbox(workspace, layer) geoserver_workspace = wms.get_geoserver_workspace(workspace) style_type = layman_util.get_publication_info(workspace, LAYER_TYPE, layer, context={'keys': ['style_type'], })['style_type'] if style_type == 'sld': gs_util.patch_feature_type(geoserver_workspace, layer, auth=settings.LAYMAN_GS_AUTH, bbox=bbox) elif style_type == 'qml': gs_util.patch_wms_layer(geoserver_workspace, layer, auth=settings.LAYMAN_GS_AUTH, bbox=bbox) wms.clear_cache(workspace) if self.is_aborted(): raise AbortedException
def patch_layer(workspace, layername, title, description, access_rights=None): gs_util.patch_feature_type(workspace, layername, title=title, description=description, auth=settings.LAYMAN_GS_AUTH) clear_cache(workspace) if access_rights and access_rights.get('read'): security_read_roles = gs_common.layman_users_to_geoserver_roles( access_rights['read']) gs_util.ensure_layer_security_roles(workspace, layername, security_read_roles, 'r', settings.LAYMAN_GS_AUTH) if access_rights and access_rights.get('write'): security_write_roles = gs_common.layman_users_to_geoserver_roles( access_rights['write']) gs_util.ensure_layer_security_roles(workspace, layername, security_write_roles, 'w', settings.LAYMAN_GS_AUTH)
def crop_bbox(): logger.info(f' Crop bounding boxes') query = f'''select w.name, p.type, p.name, ST_XMIN(p.bbox) as xmin, ST_YMIN(p.bbox) as ymin, ST_XMAX(p.bbox) as xmax, ST_YMAX(p.bbox) as ymax from {DB_SCHEMA}.publications p inner join {DB_SCHEMA}.workspaces w on w.id = p.id_workspace where st_xMin(p.bbox) < -20026376.39 or st_yMin(p.bbox) < -20048966.10 or st_xMax(p.bbox) > 20026376.39 or st_yMax(p.bbox) > 20048966.10 ;''' publications = db_util.run_query(query) for workspace, publ_type, publication, xmin, ymin, xmax, ymax in publications: info = layman_util.get_publication_info(workspace, publ_type, publication, context={'keys': ['style_type', 'file', 'uuid', 'native_crs', ], }) original_bbox = (xmin, ymin, xmax, ymax) cropped_bbox = ( max(original_bbox[0], -20026376.39), max(original_bbox[1], -20048966.10), min(original_bbox[2], 20026376.39), min(original_bbox[3], 20048966.10), ) query = f'''update {DB_SCHEMA}.publications set bbox = ST_MakeBox2D(ST_Point(%s, %s), ST_Point(%s ,%s)) where type = %s and name = %s and id_workspace = (select w.id from {DB_SCHEMA}.workspaces w where w.name = %s);''' params = cropped_bbox + (publ_type, publication, workspace,) db_util.run_statement(query, params) if publ_type == LAYER_TYPE: file_type = info['file']['file_type'] assert file_type == settings.FILE_TYPE_VECTOR crs = info['native_crs'] # WFS bbox = geoserver.get_layer_bbox(workspace, publication) gs_util.patch_feature_type(workspace, publication, auth=settings.LAYMAN_GS_AUTH, bbox=bbox, crs=crs) gs_wfs.clear_cache(workspace) # WMS style_type = info['style_type'] geoserver_workspace = gs_wms.get_geoserver_workspace(workspace) if style_type == 'sld': gs_util.patch_feature_type(geoserver_workspace, publication, auth=settings.LAYMAN_GS_AUTH, bbox=bbox, crs=crs) elif style_type == 'qml': qgis_wms.save_qgs_file(workspace, publication) gs_util.patch_wms_layer(geoserver_workspace, publication, auth=settings.LAYMAN_GS_AUTH, bbox=bbox, crs=crs) gs_wms.clear_cache(workspace) # Thumbnail layer_thumbnail.generate_layer_thumbnail(workspace, publication) # Micka soap layer_micka_soap.patch_layer(workspace, publication, metadata_properties_to_refresh=['extent']) md_props = layer_util.get_metadata_comparison(workspace, publication, cached=False) assert md_props['metadata_properties']['extent']['equal'], f'{md_props}' elif publ_type == MAP_TYPE: # Micka soap map_micka_soap.patch_map(workspace, publication, metadata_properties_to_refresh=['extent'])