| | |
| | | /CutTiles |
| | | /MoonExp/Sources/Test.png |
| | | /MoonExp/Sources/log.txt |
| | | /ExportMap/Sources/bak/*.qpt |
| | |
| | | </dataDefinedProperties> |
| | | <customproperties/> |
| | | </LayoutObject> |
| | | <Extent ymax="64.40696224962117356" ymin="9.87192880480477086" xmin="64.38422237834893735" xmax="152.1417474619615291"/> |
| | | <Extent ymax="-15.777073" ymin="31.089563" xmin="-11.9472810" xmax="3.365208"/> |
| | | <crs> |
| | | <spatialrefsys> |
| | | <wkt>GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["unknown"],AREA["World"],BBOX[-90,-180,90,180]],ID["EPSG",4326]]</wkt> |
| | |
| | | <property value="0" key="imageCropMarginTop"/> |
| | | <property value="false" key="imageCropToContents"/> |
| | | <property value="true" key="singleFile"/> |
| | | <property key="layers" value="geo_albedo_feature_point,geo_alkaline_rock_suite,geo_cliff_annotation,geo_construction_unit_boundary,copernican_craters_180,geo_age_not_determined,moon"/> |
| | | <property key="layers" value="geo_magnesian_rock_suite,geo_kreep_basalt,geo_alkaline_rock_suite,lunar_place_name"/> |
| | | <property key="imgPath" value="E:\terrait\TianJin\ExportMap\MoonExp\Sources\Test.png"/> |
| | | <property key="wmsUrl" value="http://172.16.2.10:50005/sj_raster/v6/wmts/service/system/10000201/5?ak=mf72ff9295c740ec0f37e61433e8a3ad8d,http://219.153.49.10:7511/sj_raster/v6/wmts/service/system/10000201/1?ak=mf72ff9295c740ec0f37e61433e8a3ad8d"/> |
| | | <property key="wmsUrl" value="http://219.153.49.10:7511/sj_raster/v6/wmts/service/system/10000201/1?ak=mf72ff9295c740ec0f37e61433e8a3ad8d"/> |
| | | </customproperties> |
| | | <Atlas filenamePattern="'output_'||@atlas_featurenumber" filterFeatures="0" enabled="0" coverageLayer="" sortFeatures="0" hideCoverage="0" pageNameExpression=""/> |
| | | </Layout> |
| | |
| | | import sys |
| | | import math |
| | | import argparse |
| | | from qgis.core import * |
| | | from qgis.gui import * |
| | | from qgis.core import * |
| | | from qgis.PyQt.QtGui import * |
| | | from qgis.PyQt.QtXml import * |
| | | from qgis.PyQt.QtCore import * |
| | | from qgis.PyQt.QtWidgets import * |
| | | from qgis.PyQt.QtXml import * |
| | | |
| | | |
| | | # 获取完整路径 |
| | |
| | | |
| | | |
| | | # 设置图层可见性 |
| | | def set_item_visibility(root_node, show_layers): |
| | | def set_item_visibility(root_node, layout, show_layers): |
| | | print(root_node.name() + ': Group') |
| | | for node in root_node.children(): |
| | | # QgsLayerTreeLayer |
| | | if isinstance(node, QgsLayerTreeGroup): |
| | | set_item_visibility(node, show_layers) |
| | | if node.name() == "底图": |
| | | add_raster_layer(node, layout) |
| | | else: |
| | | set_item_visibility(node, layout, show_layers) |
| | | # QgsRasterLayer, QgsVectorLayer |
| | | else: |
| | | name = node.layer().name() |
| | |
| | | node.setItemVisibilityChecked(flag) |
| | | |
| | | |
| | | # 添加Raster图层:QgsLayerTreeGroup |
| | | def add_raster_layer(node, layout): |
| | | wmsUrl = layout.customProperty("wmsUrl") |
| | | if wmsUrl is None: |
| | | print("wmsUrl 为空!") |
| | | return |
| | | uris = wmsUrl.split(',') |
| | | # uris = uris[::-1] |
| | | |
| | | i = 0 |
| | | for uri in uris: |
| | | i = i + 1 |
| | | if uri is None: |
| | | continue |
| | | url = "crs=ESRI:104903&dpiMode=7&format=image/png&layers=Default&styles=default&tileMatrixSet=GoogleCRS84Quad01&url=" + uri |
| | | print("WMTS地址:" + url) |
| | | |
| | | layer = QgsRasterLayer(url, "WmsLayer_" + str(i), "wms") |
| | | if layer.isValid(): |
| | | ls = project.layerStore() |
| | | ls.addMapLayer(layer) |
| | | node.addLayer(layer) |
| | | |
| | | |
| | | # 添加底图:layer.isValid(),layer.metadataUri(),layer.providerType() |
| | | def add_map_layer(prj, layout, args): |
| | | def add_map_layer(prj, layout): |
| | | uris = layout.customProperty("wmsUrl").split(',') |
| | | for uri in uris: |
| | | if uri is None: |
| | |
| | | print("WMS地址:" + url) |
| | | |
| | | layer = QgsRasterLayer(url, "WmsLayer", "wms") |
| | | # if layer.isValid(): |
| | | prj.addMapLayer(layer) |
| | | |
| | | |
| | |
| | | |
| | | # 加载工程 |
| | | args = get_args() |
| | | prj = QgsProject.instance() |
| | | # prj.read(r'Test.qgz') |
| | | prj.read(os.path.join(args.src, args.qgz)) |
| | | print("FileName: " + prj.fileName()) |
| | | project = QgsProject.instance() |
| | | # project.read(r'Test.qgz') |
| | | project.read(os.path.join(args.src, args.qgz)) |
| | | print("FileName: " + project.fileName()) |
| | | |
| | | # layout = QgsPrintLayout(prj) |
| | | layout = QgsLayout(prj) |
| | | # layout = QgsPrintLayout(project) |
| | | layout = QgsLayout(project) |
| | | # layout.initializeDefaults() |
| | | |
| | | # 加载模板 |
| | |
| | | # "阀室", "站场", "管道中心线", "矢量注记", "矢量图", "高德影像注记", "高德影像", "影像注记", "影像图" |
| | | # showLayers = ["阀室", "管道中心线", "矢量注记", "矢量图"] |
| | | showLayers = layout.customProperty("layers").split(',') |
| | | root = prj.layerTreeRoot() |
| | | root = project.layerTreeRoot() |
| | | |
| | | # set_layers_valid(prj, showLayers) |
| | | set_item_visibility(root, showLayers) |
| | | add_map_layer(prj, layout, args) |
| | | # set_layers_valid(project, showLayers) |
| | | set_item_visibility(root, layout, showLayers) |
| | | # add_map_layer(project, layout) |
| | | |
| | | # sm = layout.itemById(r'说明') |
| | | '''table = layout.multiFrames()[0] |
| | |
| | | # layout.updateBounds() |
| | | layout.renderContext() |
| | | layout.refresh() |
| | | # project.write("C:/360/a.qgz") |
| | | |
| | | # 导出 |
| | | exporter = QgsLayoutExporter(layout) |
| | |
| | | <connectionStrings/> |
| | | <system.web> |
| | | <compilation debug="true" targetFramework="4.5.2"/> |
| | | <!-- 会话超时时间(默认20,分钟) --> |
| | | <sessionState mode="InProc" timeout="10080"></sessionState> |
| | | <!-- maxRequestLength是上传文件时最大size(单位是KB,默认值是4096kb),executionTimeout是请求session(单位是秒,默认值是110s) --> |
| | | <httpRuntime maxRequestLength="2147483647" executionTimeout="8640000"/> |
| | | <pages controlRenderingCompatibilityVersion="4.0"/> |
| | |
| | | |
| | | string cmd = string.Format("\"C:\\Program Files\\Skyline\\TerraBuilder\\TerraBuilder.exe\" -script \"{0}\"", js); // -DisablePrint |
| | | ReloadTB(); |
| | | err = Tools.ExecCmd(new List<string> { cmd }); |
| | | err = Tools.ExecCmdForWin(new List<string> { cmd }); |
| | | isBusy = false; |
| | | |
| | | return File.Exists(MptPath) ? MoveMpt(MptPath, sourcePath) : null; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 执行命令 |
| | | /// </summary> |
| | | /// <param name="list">命令集合</param> |
| | | public static string ExecCmdForWin(List<string> list, bool noWin = false) |
| | | { |
| | | string str = null; |
| | | Process p = null; |
| | | try |
| | | { |
| | | p = new Process(); |
| | | p.StartInfo.FileName = "cmd.exe"; |
| | | p.StartInfo.UseShellExecute = false; |
| | | p.StartInfo.CreateNoWindow = noWin; |
| | | p.StartInfo.RedirectStandardInput = true; |
| | | p.StartInfo.RedirectStandardOutput = true; |
| | | p.StartInfo.RedirectStandardError = true; |
| | | p.Start(); |
| | | |
| | | StreamWriter si = p.StandardInput; |
| | | StreamReader se = p.StandardError; |
| | | |
| | | LogOut.Info("cmd = " + string.Join(",", list)); |
| | | si.AutoFlush = true; |
| | | foreach (string cmd in list) |
| | | { |
| | | si.WriteLine(cmd); |
| | | } |
| | | si.WriteLine("exit"); |
| | | |
| | | str = se.ReadToEnd(); |
| | | se.Close(); |
| | | si.Close(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); |
| | | str = ex.Message; |
| | | } |
| | | finally |
| | | { |
| | | if (p != null) |
| | | { |
| | | p.Close(); |
| | | } |
| | | } |
| | | return str; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 创建数据发布类 |
| | | /// </summary> |
| | | public static SysPublish NewPublish(SysMeta meta, XYZArgs args, string url, string path) |
| | |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Net.Http; |
| | | using System.Security; |
| | | using System.Web.Http; |
| | | |
| | | namespace MoonExp.Controllers |
| | |
| | | [HttpGet] |
| | | public string Test() |
| | | { |
| | | string str = "http://219.153.49.10:7511/sj_raster/v6/wmts/service/system/10000201/1?ak=mf72ff9295c740ec0f37e61433e8a3ad8d&a=1"; |
| | | string escapeStr = SecurityElement.Escape(str); |
| | | |
| | | return DateTime.Now.ToString("yyyyy-MM-dd HH:mm:ss"); |
| | | } |
| | | |
| | |
| | | import sys |
| | | import math |
| | | import argparse |
| | | from qgis.core import * |
| | | from qgis.gui import * |
| | | from qgis.core import * |
| | | from qgis.PyQt.QtGui import * |
| | | from qgis.PyQt.QtXml import * |
| | | from qgis.PyQt.QtCore import * |
| | | from qgis.PyQt.QtWidgets import * |
| | | from qgis.PyQt.QtXml import * |
| | | |
| | | |
| | | # 获取完整路径 |
| | |
| | | |
| | | |
| | | # 设置图层可见性 |
| | | def set_item_visibility(root_node, show_layers): |
| | | def set_item_visibility(root_node, layout, show_layers): |
| | | print(root_node.name() + ': Group') |
| | | for node in root_node.children(): |
| | | # QgsLayerTreeLayer |
| | | if isinstance(node, QgsLayerTreeGroup): |
| | | set_item_visibility(node, show_layers) |
| | | if node.name() == "底图": |
| | | add_raster_layer(node, layout) |
| | | else: |
| | | set_item_visibility(node, layout, show_layers) |
| | | # QgsRasterLayer, QgsVectorLayer |
| | | else: |
| | | name = node.layer().name() |
| | |
| | | node.setItemVisibilityChecked(flag) |
| | | |
| | | |
| | | # 添加Raster图层:QgsLayerTreeGroup |
| | | def add_raster_layer(node, layout): |
| | | wmsUrl = layout.customProperty("wmsUrl") |
| | | if wmsUrl is None: |
| | | print("wmsUrl 为空!") |
| | | return |
| | | uris = wmsUrl.split(',') |
| | | # uris = uris[::-1] |
| | | |
| | | i = 0 |
| | | for uri in uris: |
| | | i = i + 1 |
| | | if uri is None: |
| | | continue |
| | | url = "crs=ESRI:104903&dpiMode=7&format=image/png&layers=Default&styles=default&tileMatrixSet=GoogleCRS84Quad01&url=" + uri |
| | | print("WMTS地址:" + url) |
| | | |
| | | layer = QgsRasterLayer(url, "WmsLayer_" + str(i), "wms") |
| | | if layer.isValid(): |
| | | ls = project.layerStore() |
| | | ls.addMapLayer(layer) |
| | | node.addLayer(layer) |
| | | |
| | | |
| | | # 添加底图:layer.isValid(),layer.metadataUri(),layer.providerType() |
| | | def add_map_layer(prj, layout, args): |
| | | def add_map_layer(prj, layout): |
| | | uris = layout.customProperty("wmsUrl").split(',') |
| | | for uri in uris: |
| | | if uri is None: |
| | |
| | | print("WMS地址:" + url) |
| | | |
| | | layer = QgsRasterLayer(url, "WmsLayer", "wms") |
| | | # if layer.isValid(): |
| | | prj.addMapLayer(layer) |
| | | |
| | | |
| | |
| | | |
| | | # 加载工程 |
| | | args = get_args() |
| | | prj = QgsProject.instance() |
| | | # prj.read(r'Test.qgz') |
| | | prj.read(os.path.join(args.src, args.qgz)) |
| | | print("FileName: " + prj.fileName()) |
| | | project = QgsProject.instance() |
| | | # project.read(r'Test.qgz') |
| | | project.read(os.path.join(args.src, args.qgz)) |
| | | print("FileName: " + project.fileName()) |
| | | |
| | | # layout = QgsPrintLayout(prj) |
| | | layout = QgsLayout(prj) |
| | | # layout = QgsPrintLayout(project) |
| | | layout = QgsLayout(project) |
| | | # layout.initializeDefaults() |
| | | |
| | | # 加载模板 |
| | |
| | | # "阀室", "站场", "管道中心线", "矢量注记", "矢量图", "高德影像注记", "高德影像", "影像注记", "影像图" |
| | | # showLayers = ["阀室", "管道中心线", "矢量注记", "矢量图"] |
| | | showLayers = layout.customProperty("layers").split(',') |
| | | root = prj.layerTreeRoot() |
| | | root = project.layerTreeRoot() |
| | | |
| | | # set_layers_valid(prj, showLayers) |
| | | set_item_visibility(root, showLayers) |
| | | add_map_layer(prj, layout, args) |
| | | # set_layers_valid(project, showLayers) |
| | | set_item_visibility(root, layout, showLayers) |
| | | # add_map_layer(project, layout) |
| | | |
| | | # sm = layout.itemById(r'说明') |
| | | '''table = layout.multiFrames()[0] |
| | |
| | | # layout.updateBounds() |
| | | layout.renderContext() |
| | | layout.refresh() |
| | | # project.write("C:/360/a.qgz") |
| | | |
| | | # 导出 |
| | | exporter = QgsLayoutExporter(layout) |
| | |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Security; |
| | | using System.Text; |
| | | using System.Web; |
| | | |
| | |
| | | |
| | | string wmtsUrl = string.Join(",", list); |
| | | |
| | | return wmtsUrl; |
| | | return SecurityElement.Escape(wmtsUrl); |
| | | } |
| | | |
| | | /// <summary> |