原作:南水之源
先看看tms和google服务器发布数据的数据排列:(goole地图与arcgis一样)
我现在手上有tms发布的数据,dom,dem等,现在要用arcgis server来发布这些数据
服务器发布卫片和高程数据都是分层级的,从第0级开始一直到23级,但是一般不一定能有那么精细层级,所以,更具当前有的层级进行发布。
但是arcgis不能直接发布tms格式的数据,所以需要写个小程序重新命名:
我们先看tms格式的数据命名规则以及层级关系:
再看arcgis的命名规则以及层级关系:
从现有tms格式转换成arcgis命名规则代码:
// 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; }