| | |
| | | /MySqlCtrl |
| | | /CutTiles |
| | | /MoonExp/Sources/Test.png |
| | | /MoonExp/Sources/log.txt |
| | |
| | | <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="imgPath" value="E:\terrait\TianJin\ExportMap\MoonExp\Sources\Test.png"/> |
| | | <property key="wmsUrl" value="http://219.153.49.10:7511/sj_raster/v6/wmts/service/system/10000201/1?ak=mf72ff9295c740ec0f37e61433e8a3ad8d"/> |
| | | <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"/> |
| | | </customproperties> |
| | | <Atlas filenamePattern="'output_'||@atlas_featurenumber" filterFeatures="0" enabled="0" coverageLayer="" sortFeatures="0" hideCoverage="0" pageNameExpression=""/> |
| | | </Layout> |
| | |
| | | |
| | | # æ·»å åºå¾ï¼layer.isValid()ï¼layer.metadataUri()ï¼layer.providerType() |
| | | def add_map_layer(prj, layout, args): |
| | | wms_url = layout.customProperty("wmsUrl") |
| | | if wms_url is None: |
| | | print("WmsUrl is None.") |
| | | return |
| | | uris = layout.customProperty("wmsUrl").split(',') |
| | | for uri in uris: |
| | | if uri is None: |
| | | continue |
| | | url = "crs=ESRI:104903&dpiMode=7&format=image/png&layers=Default&styles=default&tileMatrixSet=GoogleCRS84Quad01&url=" + uri |
| | | print("WMSå°åï¼" + url) |
| | | |
| | | url = "crs=ESRI:104903&dpiMode=7&format=image/png&layers=Default&styles=default&tileMatrixSet=GoogleCRS84Quad01&url=" + wms_url |
| | | print("WMSå°åï¼" + url) |
| | | |
| | | layer = QgsRasterLayer(url, "WmsLayer", "wms") |
| | | prj.addMapLayer(layer) |
| | | layer = QgsRasterLayer(url, "WmsLayer", "wms") |
| | | prj.addMapLayer(layer) |
| | | |
| | | |
| | | # åå§å |
| | |
| | | string[] scales = scaleStr.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); |
| | | double minX = double.Parse(minXYZ[0]), minY = double.Parse(minXYZ[1]), minZ = double.Parse(minXYZ[2]); |
| | | double maxX = double.Parse(maxXYZ[0]), maxY = double.Parse(maxXYZ[1]), maxZ = double.Parse(maxXYZ[2]); |
| | | double x = (minX + maxX) / 2, y = (minY + maxY) / 2, z = maxZ, scale = Math.Round(1 / double.Parse(scales[0]), 2); |
| | | double x = (minX + maxX) / 2, y = (minY + maxY) / 2, z = maxZ, scale = Math.Round(1 / double.Parse(scales[0]), 2) / 10; |
| | | |
| | | string url = ExportUtil.LFServer + "/publish/selectCsTransform?token=" + Tools.Token + "&x=" + x + "&y=" + y + "&epsg=" + epsg; |
| | | rs = ExportUtil.GetData(url); |
| | |
| | | public String wmtsUrl { set; get; } |
| | | |
| | | /// <summary> |
| | | /// å¾å±IDéå |
| | | /// </summary> |
| | | public List<int> layerIds { set; get; } |
| | | |
| | | /// <summary> |
| | | /// 设置é»è®¤å¼ |
| | | /// </summary> |
| | | public void SetDefault() |
| | |
| | | if (string.IsNullOrWhiteSpace(scale)) scale = string.Empty; |
| | | if (string.IsNullOrWhiteSpace(resolution)) resolution = string.Empty; |
| | | if (string.IsNullOrWhiteSpace(date)) date = DateTime.Now.ToString("yyyy.MM.dd"); |
| | | if (null == layerIds) layerIds = new List<int>(); |
| | | |
| | | this.dpi = GetDpi(this.pageSize); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Web; |
| | | |
| | | namespace MoonExp.cs |
| | | { |
| | | /// <summary> |
| | | /// DataTableä¸å®ä½ç±»ç¸äºè½¬æ¢ |
| | | /// </summary> |
| | | public class ModelHandler |
| | | { |
| | | /// <summary> |
| | | /// å¡«å
对象å表 |
| | | /// </summary> |
| | | public static List<T> FillModel<T>(DataTable dt) where T : new() |
| | | { |
| | | if (dt == null || dt.Rows.Count == 0) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | List<T> list = new List<T>(); |
| | | BindingFlags flag = BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance; |
| | | PropertyInfo[] pis = typeof(T).GetProperties(); |
| | | |
| | | foreach (DataRow dr in dt.Rows) |
| | | { |
| | | T t = new T(); |
| | | foreach (PropertyInfo pi in pis) |
| | | { |
| | | object val = dr[pi.Name] == DBNull.Value ? null : dr[pi.Name]; |
| | | t.GetType().GetProperty(pi.Name, flag).SetValue(t, val, null); |
| | | } |
| | | |
| | | list.Add(t); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å¡«å
DataTable |
| | | /// </summary> |
| | | public static DataTable FillDataTable<T>(List<T> list) where T : new() |
| | | { |
| | | if (list == null || list.Count == 0) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | DataTable dt = CreateDataTable<T>(); |
| | | PropertyInfo[] pis = typeof(T).GetProperties(); |
| | | |
| | | foreach (T t in list) |
| | | { |
| | | DataRow dr = dt.NewRow(); |
| | | foreach (PropertyInfo pi in pis) |
| | | { |
| | | dr[pi.Name] = pi.GetValue(t, null); |
| | | } |
| | | } |
| | | |
| | | return dt; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å建DataTable |
| | | /// </summary> |
| | | public static DataTable CreateDataTable<T>() where T : new() |
| | | { |
| | | DataTable dt = new DataTable(typeof(T).Name); |
| | | |
| | | PropertyInfo[] pis = typeof(T).GetProperties(); |
| | | foreach (PropertyInfo pi in pis) |
| | | { |
| | | dt.Columns.Add(new DataColumn(pi.Name, pi.PropertyType)); |
| | | } |
| | | |
| | | return dt; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Web; |
| | | |
| | | namespace MoonExp.Models |
| | | { |
| | | public class SysRes |
| | | { |
| | | public SysRes() { } |
| | | |
| | | public int id { set; get; } |
| | | |
| | | public string url { set; get; } |
| | | |
| | | public string surl { set; get; } |
| | | } |
| | | } |
| | |
| | | <DependentUpon>Global.asax</DependentUpon> |
| | | </Compile> |
| | | <Compile Include="Models\ExportArgs.cs" /> |
| | | <Compile Include="Models\ModelHandler.cs" /> |
| | | <Compile Include="Models\ResponseMsg.cs" /> |
| | | <Compile Include="Models\SysRes.cs" /> |
| | | <Compile Include="Models\SysTask.cs" /> |
| | | <Compile Include="Models\XYZArgs.cs" /> |
| | | <Compile Include="Properties\AssemblyInfo.cs" /> |
| | |
| | | using Npgsql; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Configuration; |
| | | using System.Data.Common; |
| | | using System.Diagnostics; |
| | | using System.IO; |
| | |
| | | /// </summary> |
| | | public static readonly string BaseDir = AppDomain.CurrentDomain.BaseDirectory; |
| | | |
| | | /// <summary> |
| | | /// è·å设置 |
| | | /// </summary> |
| | | public static string GetSetting(string key) |
| | | { |
| | | return ConfigurationManager.AppSettings[key]; |
| | | } |
| | | |
| | | private static PostgreHelper _dbHelper; |
| | | |
| | | /// <summary> |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Configuration; |
| | | using System.Data; |
| | | using System.Diagnostics; |
| | | using System.IO; |
| | | using System.Linq; |
| | |
| | | return i.ToString(); |
| | | } |
| | | |
| | | private static readonly string selectResSql = "select a.id, a.url, b.url || case when length(b.args) > 0 then '?' || b.args else '' end \"surl\" from lf.sys_layer a left join lf.sys_res b on a.resid = b.id where a.category = 3 and a.is_layer = 1 and a.id in ({0})"; |
| | | |
| | | public ExportUtil() { } |
| | | |
| | | /// <summary> |
| | | /// çæ |
| | | /// </summary> |
| | |
| | | .Replace("{date}", DateTime.Now.ToString("yyyy.MM.dd")) |
| | | .Replace("{layers}", args.layers) |
| | | .Replace("{imgPath}", imgPath) |
| | | .Replace("{wmsUrl}", null == args.wmtsUrl ? string.Empty : args.wmtsUrl); |
| | | .Replace("{wmsUrl}", getWmtsUrl(args)); |
| | | |
| | | File.WriteAllText(qptFile, xml); |
| | | } |
| | |
| | | |
| | | return str; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åWMTSå°åï¼å¤ä¸ªä»¥è±æéå·éå¼ |
| | | /// </summary> |
| | | public static string getWmtsUrl(ExportArgs args) |
| | | { |
| | | List<string> list = new List<string>(); |
| | | foreach (int id in args.layerIds) |
| | | { |
| | | List<string> resList = SelectMapUrls(id); |
| | | if (null != resList && resList.Count > 0) |
| | | { |
| | | list.AddRange(resList); |
| | | } |
| | | } |
| | | |
| | | if (0 == list.Count) |
| | | { |
| | | string defaultUrl = Tools.GetSetting("wmtsUrl"); |
| | | if (!string.IsNullOrEmpty(defaultUrl)) list.Add(defaultUrl); |
| | | } |
| | | |
| | | string wmtsUrl = string.Join(",", list); |
| | | |
| | | return wmtsUrl; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢å°å¾Url |
| | | /// </summary> |
| | | public static List<string> SelectMapUrls(int id) |
| | | { |
| | | string sql = string.Format(selectResSql, id); |
| | | DataTable dt = Tools.DBHelper.GetDataTable(sql); |
| | | if (null == dt || 0 == dt.Rows.Count) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | List<SysRes> resList = ModelHandler.FillModel<SysRes>(dt); |
| | | if (null == resList || 0 == resList.Count) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | List<string> list = new List<string>(); |
| | | foreach (SysRes res in resList) |
| | | { |
| | | if (!string.IsNullOrEmpty(res.surl)) |
| | | { |
| | | list.Add(res.surl); |
| | | continue; |
| | | } |
| | | if (!string.IsNullOrEmpty(res.url)) |
| | | { |
| | | list.Add(res.url); |
| | | } |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | } |
| | | } |
| | |
| | | ymin: 30.690466, |
| | | ymax: 37.871048, |
| | | xmax: 112.534648, |
| | | wmtsUrl: "http://219.153.49.10:7511/sj_raster/v6/wmts/service/system/10000201/1?ak=mf72ff9295c740ec0f37e61433e8a3ad8d" |
| | | //wmtsUrl: "http://219.153.49.10:7511/sj_raster/v6/wmts/service/system/10000201/1?ak=mf72ff9295c740ec0f37e61433e8a3ad8d" |
| | | layerIds: [82, 79, 87] |
| | | }; |
| | | |
| | | ajax("Export/Start", "POST", JSON.stringify(data), null, null, function (rs) { |