├── ArcServer2XYZ.suo
├── ArcServer2XYZ
├── images
│ ├── 1553417581500.png
│ ├── 1553417654409.png
│ ├── 1553417723808.png
│ └── 20190324224748.png
├── bin
│ └── Debug
│ │ ├── SQLite.Interop.dll
│ │ ├── System.Data.SQLite.dll
│ │ ├── MapCacheArcServer2XYZ.exe
│ │ ├── MapCacheArcServer2XYZ.pdb
│ │ ├── MapCacheArcServer2XYZ.vshost.exe
│ │ └── MapCacheArcServer2XYZ.vshost.exe.manifest
├── obj
│ └── x86
│ │ └── Debug
│ │ ├── MapCacheArcServer2XYZ.exe
│ │ ├── MapCacheArcServer2XYZ.pdb
│ │ ├── GenerateResource.read.1.tlog
│ │ ├── GenerateResource.write.1.tlog
│ │ ├── MapCacheArcServer2XYZ.Form1.resources
│ │ ├── DesignTimeResolveAssemblyReferencesInput.cache
│ │ ├── MapCacheArcServer2XYZ.csproj.FileListAbsolute.txt
│ │ └── ArcServer2XYZ.csproj.FileListAbsolute.txt
├── TilesBLL.cs
├── Form1.cs
├── TilesModel.cs
├── Properties
│ └── AssemblyInfo.cs
├── Form1.Designer.cs
├── TilesDAL.cs
├── ArcServer2XYZ.csproj
├── Program.cs
├── Form1.resx
└── DbHelperSQLite.cs
├── README.md
└── ArcServer2XYZ.sln
/ArcServer2XYZ.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ.suo
--------------------------------------------------------------------------------
/ArcServer2XYZ/images/1553417581500.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/images/1553417581500.png
--------------------------------------------------------------------------------
/ArcServer2XYZ/images/1553417654409.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/images/1553417654409.png
--------------------------------------------------------------------------------
/ArcServer2XYZ/images/1553417723808.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/images/1553417723808.png
--------------------------------------------------------------------------------
/ArcServer2XYZ/images/20190324224748.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/images/20190324224748.png
--------------------------------------------------------------------------------
/ArcServer2XYZ/bin/Debug/SQLite.Interop.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/bin/Debug/SQLite.Interop.dll
--------------------------------------------------------------------------------
/ArcServer2XYZ/bin/Debug/System.Data.SQLite.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/bin/Debug/System.Data.SQLite.dll
--------------------------------------------------------------------------------
/ArcServer2XYZ/bin/Debug/MapCacheArcServer2XYZ.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/bin/Debug/MapCacheArcServer2XYZ.exe
--------------------------------------------------------------------------------
/ArcServer2XYZ/bin/Debug/MapCacheArcServer2XYZ.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/bin/Debug/MapCacheArcServer2XYZ.pdb
--------------------------------------------------------------------------------
/ArcServer2XYZ/obj/x86/Debug/MapCacheArcServer2XYZ.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/obj/x86/Debug/MapCacheArcServer2XYZ.exe
--------------------------------------------------------------------------------
/ArcServer2XYZ/obj/x86/Debug/MapCacheArcServer2XYZ.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/obj/x86/Debug/MapCacheArcServer2XYZ.pdb
--------------------------------------------------------------------------------
/ArcServer2XYZ/bin/Debug/MapCacheArcServer2XYZ.vshost.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/bin/Debug/MapCacheArcServer2XYZ.vshost.exe
--------------------------------------------------------------------------------
/ArcServer2XYZ/obj/x86/Debug/GenerateResource.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/obj/x86/Debug/GenerateResource.read.1.tlog
--------------------------------------------------------------------------------
/ArcServer2XYZ/obj/x86/Debug/GenerateResource.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/obj/x86/Debug/GenerateResource.write.1.tlog
--------------------------------------------------------------------------------
/ArcServer2XYZ/obj/x86/Debug/MapCacheArcServer2XYZ.Form1.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/obj/x86/Debug/MapCacheArcServer2XYZ.Form1.resources
--------------------------------------------------------------------------------
/ArcServer2XYZ/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaogis/MapCacheArcServer2XYZ/HEAD/ArcServer2XYZ/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/ArcServer2XYZ/bin/Debug/MapCacheArcServer2XYZ.vshost.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/ArcServer2XYZ/obj/x86/Debug/MapCacheArcServer2XYZ.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | F:\项目代码\2019\200\8MapCache\MapCacheArcServer2XYZ\MapCacheArcServer2XYZ\bin\Debug\MapCacheArcServer2XYZ.exe
2 | F:\项目代码\2019\200\8MapCache\MapCacheArcServer2XYZ\MapCacheArcServer2XYZ\bin\Debug\MapCacheArcServer2XYZ.pdb
3 | F:\项目代码\2019\200\8MapCache\MapCacheArcServer2XYZ\MapCacheArcServer2XYZ\obj\x86\Debug\ResolveAssemblyReference.cache
4 | F:\项目代码\2019\200\8MapCache\MapCacheArcServer2XYZ\MapCacheArcServer2XYZ\obj\x86\Debug\MapCacheArcServer2XYZ.exe
5 | F:\项目代码\2019\200\8MapCache\MapCacheArcServer2XYZ\MapCacheArcServer2XYZ\obj\x86\Debug\MapCacheArcServer2XYZ.pdb
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MapCacheArcServer2XYZ
2 |
3 | 1、ArcServer切片格式转换成谷歌地图(高德地图)XYZ切片格式
4 |
5 | 
6 |
7 | 转换前:
8 |
9 | 
10 |
11 | 转换后:
12 |
13 | 
14 |
15 | 2、png切片保存至mbtiles格式(sqlite数据库)
16 |
17 | 
--------------------------------------------------------------------------------
/ArcServer2XYZ/TilesBLL.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Data;
6 |
7 | namespace MapCacheArcServer2XYZ
8 | {
9 | public class TilesBLL
10 | {
11 | public TilesBLL()
12 | { }
13 |
14 | ///
15 | /// 增加一条数据
16 | ///
17 | public static bool Add(MapCacheArcServer2XYZ.TilesModel model)
18 | {
19 | return MapCacheArcServer2XYZ.TilesDAL.Add(model);
20 | }
21 |
22 | ///
23 | /// 获得数据列表
24 | ///
25 | public static DataSet GetList(string strWhere)
26 | {
27 | return MapCacheArcServer2XYZ.TilesDAL.GetList(strWhere);
28 | }
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ArcServer2XYZ/obj/x86/Debug/ArcServer2XYZ.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | F:\项目代码\2019\200\8MapCache\MapCacheArcServer2XYZ\ArcServer2XYZ\obj\x86\Debug\MapCacheArcServer2XYZ.exe
2 | F:\项目代码\2019\200\8MapCache\MapCacheArcServer2XYZ\ArcServer2XYZ\obj\x86\Debug\MapCacheArcServer2XYZ.pdb
3 | F:\项目代码\2019\200\8MapCache\MapCacheArcServer2XYZ\ArcServer2XYZ\obj\x86\Debug\ResolveAssemblyReference.cache
4 | F:\项目代码\2019\200\8MapCache\MapCacheArcServer2XYZ\ArcServer2XYZ\bin\Debug\MapCacheArcServer2XYZ.exe
5 | F:\项目代码\2019\200\8MapCache\MapCacheArcServer2XYZ\ArcServer2XYZ\bin\Debug\MapCacheArcServer2XYZ.pdb
6 | F:\项目代码\2019\200\8MapCache\MapCacheArcServer2XYZ\ArcServer2XYZ\obj\x86\Debug\MapCacheArcServer2XYZ.Form1.resources
7 | F:\项目代码\2019\200\8MapCache\MapCacheArcServer2XYZ\ArcServer2XYZ\obj\x86\Debug\GenerateResource.read.1.tlog
8 | F:\项目代码\2019\200\8MapCache\MapCacheArcServer2XYZ\ArcServer2XYZ\obj\x86\Debug\GenerateResource.write.1.tlog
9 |
--------------------------------------------------------------------------------
/ArcServer2XYZ.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArcServer2XYZ", "ArcServer2XYZ\ArcServer2XYZ.csproj", "{63DB9222-23EF-41C8-B1B3-7940E0ED7EA0}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {63DB9222-23EF-41C8-B1B3-7940E0ED7EA0}.Debug|x86.ActiveCfg = Debug|x86
13 | {63DB9222-23EF-41C8-B1B3-7940E0ED7EA0}.Debug|x86.Build.0 = Debug|x86
14 | {63DB9222-23EF-41C8-B1B3-7940E0ED7EA0}.Release|x86.ActiveCfg = Release|x86
15 | {63DB9222-23EF-41C8-B1B3-7940E0ED7EA0}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/ArcServer2XYZ/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using MapCacheArcServer2XYZ;
10 | using System.IO;
11 |
12 | namespace MapCacheArcServer2XYZ
13 | {
14 | public partial class Form1 : Form
15 | {
16 | public Form1()
17 | {
18 | InitializeComponent();
19 | DataSet ds = MapCacheArcServer2XYZ.TilesBLL.GetList(" tiles.zoom_level=4 and tiles.tile_row=6 and tiles.tile_column=12 ");
20 | if (ds != null && ds.Tables[0].Rows.Count > 0)
21 | {
22 | byte[] pstream = (byte[])(ds.Tables[0].Rows[0][3]);
23 | //pictureBox1.Image = System.Drawing.Image.FromStream(new MemoryStream(pstream));
24 | //this.pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
25 | // 如果保存成文件:
26 | File.WriteAllBytes(@"d:\4612.png", pstream);
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ArcServer2XYZ/TilesModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace MapCacheArcServer2XYZ
7 | {
8 | [Serializable]
9 | public class TilesModel
10 | {
11 | public TilesModel()
12 | { }
13 | #region Model
14 | private string _zoom_level;
15 |
16 | public string Zoom_level
17 | {
18 | get { return _zoom_level; }
19 | set { _zoom_level = value; }
20 | }
21 | private string _tile_row;
22 |
23 | public string Tile_row
24 | {
25 | get { return _tile_row; }
26 | set { _tile_row = value; }
27 | }
28 | private string _tile_column;
29 |
30 | public string Tile_column
31 | {
32 | get { return _tile_column; }
33 | set { _tile_column = value; }
34 | }
35 | private Byte[] _tile_data;
36 |
37 | public Byte[] Tile_data
38 | {
39 | get { return _tile_data; }
40 | set { _tile_data = value; }
41 | }
42 |
43 |
44 | #endregion
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/ArcServer2XYZ/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("MapCacheArcServer2XYZ")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("MapCacheArcServer2XYZ")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2019")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("037c874f-80c4-4d53-a5df-79ef2bc28c3a")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 内部版本号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ArcServer2XYZ/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace MapCacheArcServer2XYZ
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.pictureBox1 = new System.Windows.Forms.PictureBox();
32 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
33 | this.SuspendLayout();
34 | //
35 | // pictureBox1
36 | //
37 | this.pictureBox1.Location = new System.Drawing.Point(147, 63);
38 | this.pictureBox1.Name = "pictureBox1";
39 | this.pictureBox1.Size = new System.Drawing.Size(256, 256);
40 | this.pictureBox1.TabIndex = 0;
41 | this.pictureBox1.TabStop = false;
42 | //
43 | // Form1
44 | //
45 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
46 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
47 | this.ClientSize = new System.Drawing.Size(543, 386);
48 | this.Controls.Add(this.pictureBox1);
49 | this.Name = "Form1";
50 | this.Text = "Form1";
51 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
52 | this.ResumeLayout(false);
53 |
54 | }
55 |
56 | #endregion
57 |
58 | private System.Windows.Forms.PictureBox pictureBox1;
59 | }
60 | }
--------------------------------------------------------------------------------
/ArcServer2XYZ/TilesDAL.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Data.SQLite;
6 | using System.Data;
7 |
8 | namespace MapCacheArcServer2XYZ
9 | {
10 | public class TilesDAL
11 | {
12 | public TilesDAL()
13 | { }
14 |
15 | #region BasicMethod
16 |
17 |
18 |
19 | ///
20 | /// 增加一条数据
21 | ///
22 | public static bool Add(MapCacheArcServer2XYZ.TilesModel model)
23 | {
24 | StringBuilder strSql = new StringBuilder();
25 | strSql.Append("insert into tiles(");
26 | strSql.Append("zoom_level,tile_row,tile_column,tile_data)");
27 | strSql.Append(" values (");
28 | strSql.Append("@zoom_level,@tile_row,@tile_column,@tile_data)");
29 | SQLiteParameter[] parameters = {
30 | new SQLiteParameter("@zoom_level", DbType.Int32),
31 | new SQLiteParameter("@tile_row", DbType.Int32),
32 | new SQLiteParameter("@tile_column", DbType.Int32),
33 | new SQLiteParameter("@tile_data", DbType.Binary)};
34 | parameters[0].Value = model.Zoom_level;
35 | parameters[1].Value = model.Tile_row;
36 | parameters[2].Value = model.Tile_column;
37 | parameters[3].Value = model.Tile_data;
38 |
39 | int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters);
40 | if (rows > 0)
41 | {
42 | return true;
43 | }
44 | else
45 | {
46 | return false;
47 | }
48 | }
49 |
50 |
51 | ///
52 | /// 获得数据列表
53 | ///
54 | public static DataSet GetList(string strWhere)
55 | {
56 | StringBuilder strSql = new StringBuilder();
57 | strSql.Append("select zoom_level,tile_row,tile_column,tile_data ");
58 | strSql.Append(" FROM tiles ");
59 | if (strWhere.Trim() != "")
60 | {
61 | strSql.Append(" where " + strWhere);
62 | }
63 | return DbHelperSQLite.Query(strSql.ToString());
64 | }
65 |
66 | #endregion BasicMethod
67 | #region ExtensionMethod
68 |
69 | #endregion ExtensionMethod
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/ArcServer2XYZ/ArcServer2XYZ.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {63DB9222-23EF-41C8-B1B3-7940E0ED7EA0}
9 | Exe
10 | Properties
11 | MapCacheArcServer2XYZ
12 | MapCacheArcServer2XYZ
13 | v4.0
14 | Client
15 | 512
16 |
17 |
18 | x86
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | x86
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 | False
41 | bin\Debug\System.Data.SQLite.dll
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | Form
55 |
56 |
57 | Form1.cs
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | Form1.cs
68 |
69 |
70 |
71 |
78 |
--------------------------------------------------------------------------------
/ArcServer2XYZ/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 |
7 | namespace MapCacheArcServer2XYZ
8 | {
9 | class Program
10 | {
11 | static void Main(string[] args)
12 | {
13 | //ArcGISServer切片转换成符合谷歌地图(高德地图)地图切片标准(Z/Y/X)
14 | Arc2XYZ();
15 | //测试图片流
16 | //Form1 f = new Form1();
17 | //f.Show();
18 | Console.WriteLine("转换完成,输入任意键结束!");
19 | Console.ReadLine();
20 | }
21 |
22 | ///
23 | /// 输入缓存路径
24 | ///
25 | ///
26 | public static void Arc2XYZ()
27 | {
28 | string path = "E:\\allyers";
29 |
30 | //创建新地图缓存文件夹
31 | DirectoryInfo dir = new DirectoryInfo(path.Substring(0, path.LastIndexOf("\\")));
32 | dir.CreateSubdirectory("NewMapCache");
33 |
34 | DirectoryInfo root = new DirectoryInfo(path);
35 | DirectoryInfo[] dics = root.GetDirectories();
36 | foreach (DirectoryInfo f in dics)
37 | {
38 | #region Z值转换
39 | //Console.WriteLine(f.Name.ToString());
40 | int z = Convert.ToInt32(f.Name.Replace("L", ""));
41 | DirectoryInfo zDir = new DirectoryInfo(path.Substring(0, path.LastIndexOf("\\")) + "\\NewMapCache");
42 | zDir.CreateSubdirectory(z.ToString());
43 | #endregion
44 |
45 | DirectoryInfo rroot = new DirectoryInfo(f.FullName.ToString());
46 | DirectoryInfo[] rdics = rroot.GetDirectories();
47 | foreach (DirectoryInfo rf in rdics)
48 | {
49 | #region Y值转换
50 | //Console.WriteLine(rf.FullName.ToString());
51 | int y = Convert.ToInt32(rf.Name.Replace("R", "0x"), 16);
52 | DirectoryInfo yDir = new DirectoryInfo(path.Substring(0, path.LastIndexOf("\\")) + "\\NewMapCache\\" + z.ToString());
53 | yDir.CreateSubdirectory(y.ToString());
54 | #endregion
55 | DirectoryInfo croot = new DirectoryInfo(rf.FullName.ToString());
56 | FileInfo[] files = croot.GetFiles();
57 | foreach (FileInfo cf in files)
58 | {
59 | #region X值转换
60 | byte[] bytes = File.ReadAllBytes(cf.FullName.ToString());
61 | int x = Convert.ToInt32(Path.GetFileNameWithoutExtension(cf.FullName).Replace("C", "0x"), 16);
62 | File.Copy(cf.FullName, (path.Substring(0, path.LastIndexOf("\\")) + "\\NewMapCache\\" + z.ToString() + "\\" + y.ToString() + "\\" + x.ToString() + ".png"));
63 | //把png图片保存到Mbtiles文件
64 | //Import2MbTiles(z, y, x, bytes);
65 | Console.WriteLine(cf.FullName.ToString());
66 | #endregion
67 | }
68 | }
69 |
70 | }
71 | }
72 |
73 | //把png图片保存到Mbtiles文件
74 | private static void Import2MbTiles(int z, int y, int x, byte[] bytes)
75 | {
76 | MapCacheArcServer2XYZ.TilesModel tmodel = new TilesModel();
77 | tmodel.Zoom_level = z.ToString();
78 | tmodel.Tile_row = y.ToString();
79 | tmodel.Tile_column = x.ToString();
80 | tmodel.Tile_data = bytes;
81 | bool b = MapCacheArcServer2XYZ.TilesDAL.Add(tmodel);
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/ArcServer2XYZ/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/ArcServer2XYZ/DbHelperSQLite.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Specialized;
4 | using System.Data;
5 | using System.Configuration;
6 | using System.Data.SQLite;
7 | namespace MapCacheArcServer2XYZ
8 | {
9 | ///
10 | /// Copyright (C) 2011 Maticsoft
11 | /// 数据访问基础类(基于SQLite)
12 | /// 可以用户可以修改满足自己项目的需要。
13 | ///
14 | public abstract class DbHelperSQLite
15 | {
16 | //数据库连接字符串(web.config来配置),可以动态更改connectionString支持多数据库.
17 | public static string connectionString = "Data Source=E:\\MapTilesDB.db;Pooling=true;FailIfMissing=false";
18 | public DbHelperSQLite()
19 | {
20 | }
21 |
22 |
23 | #region 公用方法
24 |
25 | public static int GetMaxID(string FieldName, string TableName)
26 | {
27 | string strsql = "select max(" + FieldName + ")+1 from " + TableName;
28 | object obj = GetSingle(strsql);
29 | if (obj == null)
30 | {
31 | return 1;
32 | }
33 | else
34 | {
35 | return int.Parse(obj.ToString());
36 | }
37 | }
38 | public static bool Exists(string strSql)
39 | {
40 | object obj = GetSingle(strSql);
41 | int cmdresult;
42 | if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
43 | {
44 | cmdresult = 0;
45 | }
46 | else
47 | {
48 | cmdresult = int.Parse(obj.ToString());
49 | }
50 | if (cmdresult == 0)
51 | {
52 | return false;
53 | }
54 | else
55 | {
56 | return true;
57 | }
58 | }
59 | public static bool Exists(string strSql, params SQLiteParameter[] cmdParms)
60 | {
61 | object obj = GetSingle(strSql, cmdParms);
62 | int cmdresult;
63 | if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
64 | {
65 | cmdresult = 0;
66 | }
67 | else
68 | {
69 | cmdresult = int.Parse(obj.ToString());
70 | }
71 | if (cmdresult == 0)
72 | {
73 | return false;
74 | }
75 | else
76 | {
77 | return true;
78 | }
79 | }
80 |
81 | #endregion
82 |
83 | #region 执行简单SQL语句
84 |
85 | ///
86 | /// 执行SQL语句,返回影响的记录数
87 | ///
88 | /// SQL语句
89 | /// 影响的记录数
90 | public static int ExecuteSql(string SQLString)
91 | {
92 | using (SQLiteConnection connection = new SQLiteConnection(connectionString))
93 | {
94 | using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection))
95 | {
96 | try
97 | {
98 | connection.Open();
99 | int rows = cmd.ExecuteNonQuery();
100 | return rows;
101 | }
102 | catch (System.Data.SQLite.SQLiteException E)
103 | {
104 | connection.Close();
105 | throw new Exception(E.Message);
106 | }
107 | }
108 | }
109 | }
110 |
111 | ///
112 | /// 执行多条SQL语句,实现数据库事务。
113 | ///
114 | /// 多条SQL语句
115 | public static void ExecuteSqlTran(ArrayList SQLStringList)
116 | {
117 | using (SQLiteConnection conn = new SQLiteConnection(connectionString))
118 | {
119 | conn.Open();
120 | SQLiteCommand cmd = new SQLiteCommand();
121 | cmd.Connection = conn;
122 | SQLiteTransaction tx = conn.BeginTransaction();
123 | cmd.Transaction = tx;
124 | try
125 | {
126 | for (int n = 0; n < SQLStringList.Count; n++)
127 | {
128 | string strsql = SQLStringList[n].ToString();
129 | if (strsql.Trim().Length > 1)
130 | {
131 | cmd.CommandText = strsql;
132 | cmd.ExecuteNonQuery();
133 | }
134 | }
135 | tx.Commit();
136 | }
137 | catch (System.Data.SQLite.SQLiteException E)
138 | {
139 | tx.Rollback();
140 | throw new Exception(E.Message);
141 | }
142 | }
143 | }
144 | ///
145 | /// 执行带一个存储过程参数的的SQL语句。
146 | ///
147 | /// SQL语句
148 | /// 参数内容,比如一个字段是格式复杂的文章,有特殊符号,可以通过这个方式添加
149 | /// 影响的记录数
150 | public static int ExecuteSql(string SQLString, string content)
151 | {
152 | using (SQLiteConnection connection = new SQLiteConnection(connectionString))
153 | {
154 | SQLiteCommand cmd = new SQLiteCommand(SQLString, connection);
155 | SQLiteParameter myParameter = new SQLiteParameter("@content", DbType.String);
156 | myParameter.Value = content;
157 | cmd.Parameters.Add(myParameter);
158 | try
159 | {
160 | connection.Open();
161 | int rows = cmd.ExecuteNonQuery();
162 | return rows;
163 | }
164 | catch (System.Data.SQLite.SQLiteException E)
165 | {
166 | throw new Exception(E.Message);
167 | }
168 | finally
169 | {
170 | cmd.Dispose();
171 | connection.Close();
172 | }
173 | }
174 | }
175 | ///
176 | /// 向数据库里插入图像格式的字段(和上面情况类似的另一种实例)
177 | ///
178 | /// SQL语句
179 | /// 图像字节,数据库的字段类型为image的情况
180 | /// 影响的记录数
181 | public static int ExecuteSqlInsertImg(string strSQL, byte[] fs)
182 | {
183 | using (SQLiteConnection connection = new SQLiteConnection(connectionString))
184 | {
185 | SQLiteCommand cmd = new SQLiteCommand(strSQL, connection);
186 | SQLiteParameter myParameter = new SQLiteParameter("@fs", DbType.Binary);
187 | myParameter.Value = fs;
188 | cmd.Parameters.Add(myParameter);
189 | try
190 | {
191 | connection.Open();
192 | int rows = cmd.ExecuteNonQuery();
193 | return rows;
194 | }
195 | catch (System.Data.SQLite.SQLiteException E)
196 | {
197 | throw new Exception(E.Message);
198 | }
199 | finally
200 | {
201 | cmd.Dispose();
202 | connection.Close();
203 | }
204 | }
205 | }
206 |
207 | ///
208 | /// 执行一条计算查询结果语句,返回查询结果(object)。
209 | ///
210 | /// 计算查询结果语句
211 | /// 查询结果(object)
212 | public static object GetSingle(string SQLString)
213 | {
214 | using (SQLiteConnection connection = new SQLiteConnection(connectionString))
215 | {
216 | using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection))
217 | {
218 | try
219 | {
220 | connection.Open();
221 | object obj = cmd.ExecuteScalar();
222 | if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
223 | {
224 | return null;
225 | }
226 | else
227 | {
228 | return obj;
229 | }
230 | }
231 | catch (System.Data.SQLite.SQLiteException e)
232 | {
233 | connection.Close();
234 | throw new Exception(e.Message);
235 | }
236 | }
237 | }
238 | }
239 | ///
240 | /// 执行查询语句,返回SQLiteDataReader
241 | ///
242 | /// 查询语句
243 | /// SQLiteDataReader
244 | public static SQLiteDataReader ExecuteReader(string strSQL)
245 | {
246 | SQLiteConnection connection = new SQLiteConnection(connectionString);
247 | SQLiteCommand cmd = new SQLiteCommand(strSQL, connection);
248 | try
249 | {
250 | connection.Open();
251 | SQLiteDataReader myReader = cmd.ExecuteReader();
252 | return myReader;
253 | }
254 | catch (System.Data.SQLite.SQLiteException e)
255 | {
256 | throw new Exception(e.Message);
257 | }
258 |
259 | }
260 | ///
261 | /// 执行查询语句,返回DataSet
262 | ///
263 | /// 查询语句
264 | /// DataSet
265 | public static DataSet Query(string SQLString)
266 | {
267 | using (SQLiteConnection connection = new SQLiteConnection(connectionString))
268 | {
269 | DataSet ds = new DataSet();
270 | try
271 | {
272 | connection.Open();
273 | SQLiteDataAdapter command = new SQLiteDataAdapter(SQLString, connection);
274 | command.Fill(ds, "ds");
275 | }
276 | catch (System.Data.SQLite.SQLiteException ex)
277 | {
278 | throw new Exception(ex.Message);
279 | }
280 | return ds;
281 | }
282 | }
283 |
284 |
285 | #endregion
286 |
287 | #region 执行带参数的SQL语句
288 |
289 | ///
290 | /// 执行SQL语句,返回影响的记录数
291 | ///
292 | /// SQL语句
293 | /// 影响的记录数
294 | public static int ExecuteSql(string SQLString, params SQLiteParameter[] cmdParms)
295 | {
296 | using (SQLiteConnection connection = new SQLiteConnection(connectionString))
297 | {
298 | using (SQLiteCommand cmd = new SQLiteCommand())
299 | {
300 | try
301 | {
302 | PrepareCommand(cmd, connection, null, SQLString, cmdParms);
303 | int rows = cmd.ExecuteNonQuery();
304 | cmd.Parameters.Clear();
305 | return rows;
306 | }
307 | catch (System.Data.SQLite.SQLiteException E)
308 | {
309 | throw new Exception(E.Message);
310 | }
311 | }
312 | }
313 | }
314 |
315 |
316 | ///
317 | /// 执行多条SQL语句,实现数据库事务。
318 | ///
319 | /// SQL语句的哈希表(key为sql语句,value是该语句的SQLiteParameter[])
320 | public static void ExecuteSqlTran(Hashtable SQLStringList)
321 | {
322 | using (SQLiteConnection conn = new SQLiteConnection(connectionString))
323 | {
324 | conn.Open();
325 | using (SQLiteTransaction trans = conn.BeginTransaction())
326 | {
327 | SQLiteCommand cmd = new SQLiteCommand();
328 | try
329 | {
330 | //循环
331 | foreach (DictionaryEntry myDE in SQLStringList)
332 | {
333 | string cmdText = myDE.Key.ToString();
334 | SQLiteParameter[] cmdParms = (SQLiteParameter[])myDE.Value;
335 | PrepareCommand(cmd, conn, trans, cmdText, cmdParms);
336 | int val = cmd.ExecuteNonQuery();
337 | cmd.Parameters.Clear();
338 |
339 | trans.Commit();
340 | }
341 | }
342 | catch
343 | {
344 | trans.Rollback();
345 | throw;
346 | }
347 | }
348 | }
349 | }
350 |
351 |
352 | ///
353 | /// 执行一条计算查询结果语句,返回查询结果(object)。
354 | ///
355 | /// 计算查询结果语句
356 | /// 查询结果(object)
357 | public static object GetSingle(string SQLString, params SQLiteParameter[] cmdParms)
358 | {
359 | using (SQLiteConnection connection = new SQLiteConnection(connectionString))
360 | {
361 | using (SQLiteCommand cmd = new SQLiteCommand())
362 | {
363 | try
364 | {
365 | PrepareCommand(cmd, connection, null, SQLString, cmdParms);
366 | object obj = cmd.ExecuteScalar();
367 | cmd.Parameters.Clear();
368 | if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
369 | {
370 | return null;
371 | }
372 | else
373 | {
374 | return obj;
375 | }
376 | }
377 | catch (System.Data.SQLite.SQLiteException e)
378 | {
379 | throw new Exception(e.Message);
380 | }
381 | }
382 | }
383 | }
384 |
385 | ///
386 | /// 执行查询语句,返回SQLiteDataReader
387 | ///
388 | /// 查询语句
389 | /// SQLiteDataReader
390 | public static SQLiteDataReader ExecuteReader(string SQLString, params SQLiteParameter[] cmdParms)
391 | {
392 | SQLiteConnection connection = new SQLiteConnection(connectionString);
393 | SQLiteCommand cmd = new SQLiteCommand();
394 | try
395 | {
396 | PrepareCommand(cmd, connection, null, SQLString, cmdParms);
397 | SQLiteDataReader myReader = cmd.ExecuteReader();
398 | cmd.Parameters.Clear();
399 | return myReader;
400 | }
401 | catch (System.Data.SQLite.SQLiteException e)
402 | {
403 | throw new Exception(e.Message);
404 | }
405 |
406 | }
407 |
408 | ///
409 | /// 执行查询语句,返回DataSet
410 | ///
411 | /// 查询语句
412 | /// DataSet
413 | public static DataSet Query(string SQLString, params SQLiteParameter[] cmdParms)
414 | {
415 | using (SQLiteConnection connection = new SQLiteConnection(connectionString))
416 | {
417 | SQLiteCommand cmd = new SQLiteCommand();
418 | PrepareCommand(cmd, connection, null, SQLString, cmdParms);
419 | using (SQLiteDataAdapter da = new SQLiteDataAdapter(cmd))
420 | {
421 | DataSet ds = new DataSet();
422 | try
423 | {
424 | da.Fill(ds, "ds");
425 | cmd.Parameters.Clear();
426 | }
427 | catch (System.Data.SQLite.SQLiteException ex)
428 | {
429 | throw new Exception(ex.Message);
430 | }
431 | return ds;
432 | }
433 | }
434 | }
435 |
436 |
437 | private static void PrepareCommand(SQLiteCommand cmd, SQLiteConnection conn, SQLiteTransaction trans, string cmdText, SQLiteParameter[] cmdParms)
438 | {
439 | if (conn.State != ConnectionState.Open)
440 | conn.Open();
441 | cmd.Connection = conn;
442 | cmd.CommandText = cmdText;
443 | if (trans != null)
444 | cmd.Transaction = trans;
445 | cmd.CommandType = CommandType.Text;//cmdType;
446 | if (cmdParms != null)
447 | {
448 | foreach (SQLiteParameter parm in cmdParms)
449 | cmd.Parameters.Add(parm);
450 | }
451 | }
452 |
453 | #endregion
454 |
455 |
456 |
457 | }
458 | }
459 |
--------------------------------------------------------------------------------