def prepare_geojson_layer(self, data_id: str, layer_name: str): """ 根据上传到iportal的geojson数据,生成Layer Args: data_id: 数据在iPortal中的id layer_name: 图层名称 Returns: Layer信息 """ layer = Layer() layer.prjCoordSys = PrjCoordSys() layer.prjCoordSys.epsgCode = 4326 layer.name = layer_name layer.layerType = LayerType.FEATURE_LAYER layer.isVisible = True layer.title = layer_name layer.identifier = 'THEME' layer.datasourceName = 'true' layer.cartoCSS = '{"isAddFile":true,"needTransform":"needTransform"}' layer.url = self._portal._base_url + '/datas/' + str( data_id) + '/content.json' layer.themeSettings = '{"filter" : "", "vectorType": "REGION", "type" : "VECTOR"}' return layer
def __prepare_base_layer(self, type: OnlineBaseLayerType): base_layers = [] if type in (OnlineBaseLayerType.DEFAULT, OnlineBaseLayerType.TIANDITU): base_layer = Layer() base_layer.url = 'http://t1.tianditu.cn' base_layer.title = '天地图' base_layer.zindex = 0 base_layer.layerType = LayerType.BASE_LAYER base_layer.name = '天地图' base_layer.isVisible = True base_layer.type = SourceType.TIANDITU_VEC base_layer_text = Layer() base_layer_text.url = 'http://t1.tianditu.cn' base_layer_text.title = '天地图-标签' base_layer_text.zindex = 1 base_layer_text.layerType = LayerType.OVERLAY_LAYER base_layer_text.name = '天地图-标签' base_layer_text.isVisible = True base_layer_text.type = SourceType.TIANDITU_VEC base_layers = base_layers + [base_layer, base_layer_text] elif type is OnlineBaseLayerType.CHINADARK: base_layer = Layer() base_layer.layerType = LayerType.BASE_LAYER base_layer.isVisible = True base_layer.prjCoordSys = PrjCoordSys() base_layer.prjCoordSys.epsgCode = 3857 base_layer.type = SourceType.SUPERMAP_REST base_layer.title = 'China_Dark' base_layer.url = 'https://www.supermapol.com/proxy/iserver/services/map_China/rest/maps/China_Dark' base_layers = base_layers + [base_layer] elif type is OnlineBaseLayerType.CHINALIGHT: base_layer = Layer() base_layer.layerType = LayerType.BASE_LAYER base_layer.isVisible = True base_layer.prjCoordSys = PrjCoordSys() base_layer.prjCoordSys.epsgCode = 3857 base_layer.type = SourceType.SUPERMAP_REST base_layer.title = 'China_Light' base_layer.url = 'https://www.supermapol.com/iserver/services/map_China/rest/maps/China_Light' base_layers = base_layers + [base_layer] elif type is OnlineBaseLayerType.CHINABLUEDRAK: base_layer = Layer() base_layer.layerType = LayerType.BASE_LAYER base_layer.isVisible = True base_layer.prjCoordSys = PrjCoordSys() base_layer.prjCoordSys.epsgCode = 3857 base_layer.type = SourceType.CLOUD base_layer.identifier = 'blue-black' base_layer.title = '中国_蓝黑' base_layer.name = 'cloud_layername' base_layer.url = 'http://t3.supermapcloud.com/MapService/getGdp?&x=${x}&y=${y}&z=${z}' base_layers = base_layers + [base_layer] elif type is OnlineBaseLayerType.GOOGLE: base_layer = Layer() base_layer.layerType = LayerType.BASE_LAYER base_layer.isVisible = True base_layer.type = SourceType.GOOGLE base_layer.title = '谷歌地图' base_layer.name = 'google_layername' base_layer.identifier = 'china' base_layer.url = 'http://mt3.google.cn/vt/lyrs=m&hl=zh-CN&gl=cn&x=${x}&y=${y}&z=${z}&scale=${z}' base_layers = base_layers + [base_layer] elif type is OnlineBaseLayerType.GAODE: base_layer = Layer() base_layer.layerType = LayerType.BASE_LAYER base_layer.isVisible = True base_layer.type = SourceType.CLOUD base_layer.title = '高德地图' base_layer.name = 'cloud_layername' base_layer.url = 'http://t2.supermapcloud.com/FileService/image' base_layers = base_layers + [base_layer] elif type is OnlineBaseLayerType.BING: base_layer = Layer() base_layer.layerType = LayerType.BASE_LAYER base_layer.isVisible = True base_layer.type = SourceType.BING base_layer.title = '必应地图' base_layer.name = 'bing_layername' base_layers = base_layers + [base_layer] elif type is OnlineBaseLayerType.OPENSTREET: base_layer = Layer() base_layer.layerType = LayerType.BASE_LAYER base_layer.isVisible = True base_layer.type = SourceType.OSM base_layer.title = 'OpenStreet' base_layer.name = 'osm_layername' base_layers = base_layers + [base_layer] elif type is OnlineBaseLayerType.TIANDITUIMAGE: base_layer = Layer() base_layer.layerType = LayerType.BASE_LAYER base_layer.isVisible = True base_layer.type = SourceType.TIANDITU_IMG base_layer.title = '天地图影像' base_layer.name = 'tianditu_layername' base_layer.url = 'http://t1.tianditu.cn' base_layer_text = Layer() base_layer_text.url = 'http://t1.tianditu.cn' base_layer_text.title = '天地图影像_路网' base_layer_text.name = 'tianditu_text_name' base_layer_text.zindex = 1 base_layer_text.layerType = LayerType.OVERLAY_LAYER base_layer_text.name = '天地图影像_路网' base_layer_text.isVisible = True base_layer_text.type = SourceType.TIANDITU_VEC base_layers = base_layers + [base_layer, base_layer_text] elif type is OnlineBaseLayerType.TIANDITUTERRAIN: base_layer = Layer() base_layer.layerType = LayerType.BASE_LAYER base_layer.isVisible = True base_layer.type = SourceType.TIANDITU_TER base_layer.title = '天地图地形' base_layer.name = 'tianditu_layername' base_layer.url = 'http://t1.tianditu.cn' base_layer_text = Layer() base_layer_text.url = 'http://t1.tianditu.cn' base_layer_text.title = '天地图地形_路网' base_layer_text.name = 'tianditu_text_name' base_layer_text.zindex = 1 base_layer_text.layerType = LayerType.OVERLAY_LAYER base_layer_text.name = '天地图地形_路网' base_layer_text.isVisible = True base_layer_text.type = SourceType.TIANDITU_VEC base_layers = base_layers + [base_layer, base_layer_text] elif type is OnlineBaseLayerType.BAIDU: base_layer = Layer() base_layer.layerType = LayerType.BASE_LAYER base_layer.isVisible = True base_layer.type = SourceType.BAIDU base_layer.title = '百度地图' base_layer.name = '百度图层' base_layer.url = 'http://online1.map.bdimg.com' base_layers = base_layers + [base_layer] return base_layers