原做:南水之源html
先看看tms和google服務器發佈數據的數據排列:(goole地圖與arcgis同樣)ios
我如今手上有tms發佈的數據,dom,dem等,如今要用arcgis server來發布這些數據小程序
服務器發佈衛片和高程數據都是分層級的,從第0級開始一直到23級,可是通常不必定能有那麼精細層級,因此,更具當前有的層級進行發佈。windows
可是arcgis不能直接發佈tms格式的數據,因此須要寫個小程序從新命名:api
咱們先看tms格式的數據命名規則以及層級關係:服務器
再看arcgis的命名規則以及層級關係:dom
從現有tms格式轉換成arcgis命名規則代碼:google
// Rename.cpp : 定義控制檯應用程序的入口點。 // #include "stdafx.h" #include "iostream" #include <windows.h> #include <string> #include <math.h> #include <shlwapi.h> #pragma comment(lib, "shlwapi.lib") void addArcGisLayer(std::string &_str, int _index) { char c2[20]; sprintf_s(c2, 20, "\\L%02x", _index); _str += c2; //std::cout << _str << std::endl; } std::string addArcGisRow(std::string _str, int _index) { char c[20]; sprintf_s(c, 20, "\\R%08x", _index); _str += c; return _str; } std::string addArcGisColumn(std::string _str, int _index) { char c[20]; sprintf_s(c, 20, "\\C%08x.png", _index); _str += c; return _str; } void addTmsLayer(std::string &_str, int _index) { char c1[20]; sprintf_s(c1, 20, "\\%d", _index); _str += c1; } std::string addTmsColumn(std::string _str, int _index) { char c[20]; sprintf_s(c, 20, "\\%d", _index); _str += c; return _str; } std::string addTmsRow(std::string _str, int _index) { char c[20]; sprintf_s(c, 20, "\\%d.png", _index); _str += c; return _str; } bool createFilePath(std::string str) { LPCSTR filepath = str.c_str(); if (!PathIsDirectory(filepath)) { std::string strbuf = str.substr(0, str.find_last_of('\\')); if (createFilePath(strbuf)) return CreateDirectory(filepath, NULL); else return false; } return true; } int main() { bool ret; std::string str1(""); std::string str2(""); //層級 for (int i=0; i < 11; i++) { str1 = std::string("E:\\Map\\DOM"); str2 = std::string("F:\\Out\\Dom"); //layers addTmsLayer(str1, i); addArcGisLayer(str2, i); //LPCSTR filepath = str2.c_str(); //if (!PathIsDirectory(filepath)) //{ // CreateDirectory(filepath, NULL); //} int jmax = pow(2,(i + 1)); int wmax = pow(2,i); //str1_column LPCSTR l1path = str1.c_str(); if (!PathFileExists(l1path)) continue; for (int j=0; j<jmax;j++) { std::string str1_column = addTmsColumn(str1, j); LPCSTR l1column = str1_column.c_str(); if (!PathFileExists(l1column)) { //std::cout << str1_column << " is no one" << std::endl; continue; } for (int w=0;w<wmax; w++) { std::string real1 = addTmsRow(str1_column, w); LPCSTR l1 = real1.c_str(); if (!PathFileExists(l1)) { //std::cout << real1 << " is no one" << std::endl; continue; } std::string str2_row = addArcGisRow(str2,wmax - 1 - w); createFilePath(str2_row); std::string real2 = addArcGisColumn(str2_row, j); std::cout << real1<<" -----> "<< real2 << std::endl; LPCSTR l2 = real2.c_str(); ret = CopyFile( l1, l2, false); } } } return 0; }