正在显示
12 个修改的文件
包含
389 行增加
和
112 行删除
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | #include "dmpservermanager.h" |
10 | 10 | #include "dmpserver.h" |
11 | 11 | #include "dmphttputils.h" |
12 | -#include "dmpserverConfig.h" | |
12 | +#include "dmpserverconfig.h" | |
13 | 13 | #include <memory> |
14 | 14 | #include <boost/property_tree/ptree.hpp> |
15 | 15 | #include <boost/property_tree/json_parser.hpp> | ... | ... |
... | ... | @@ -110,6 +110,10 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const |
110 | 110 | // context.response()->removeHeader("Content-Type"); |
111 | 111 | // context.response()->setHeader("Content-Type", "text/xml;charset=utf-8"); |
112 | 112 | // context.response()->write(projData); |
113 | + | |
114 | + | |
115 | + | |
116 | + | |
113 | 117 | } |
114 | 118 | else |
115 | 119 | { | ... | ... |
... | ... | @@ -21,6 +21,7 @@ SET (MAPSERVER_SRCS |
21 | 21 | mapping/dmpmapping.cpp |
22 | 22 | mapping/dmpeditservice.cpp |
23 | 23 | mapping/dmpmappingparameters.cpp |
24 | + mapping/dmpimageinfo.cpp | |
24 | 25 | ) |
25 | 26 | |
26 | 27 | SET (MAPSERVER_HDRS |
... | ... | @@ -42,6 +43,7 @@ SET (MAPSERVER_HDRS |
42 | 43 | mapping/dmpmapping.h |
43 | 44 | mapping/dmpeditservice.h |
44 | 45 | mapping/dmpmappingparameters.h |
46 | + mapping/dmpimageinfo.h | |
45 | 47 | ) |
46 | 48 | |
47 | 49 | ######################################################## | ... | ... |
... | ... | @@ -91,13 +91,6 @@ namespace DmpMapping |
91 | 91 | context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); |
92 | 92 | return false; |
93 | 93 | } |
94 | - | |
95 | - if(!context.serverProject()) | |
96 | - { | |
97 | - LOGGER_ERROR("加载服务信息失败,服务名称是否错误"); | |
98 | - context.response()->writeJson("{\"status\":\"false\",\"message\":\"加载服务信息失败,服务名称是否错误!\"}"); | |
99 | - return false; | |
100 | - } | |
101 | 94 | |
102 | 95 | try |
103 | 96 | { | ... | ... |
1 | +/************************************************************************** | |
2 | +* file: dmpimageinfo.cpp | |
3 | + | |
4 | +* Author: qingxiongf | |
5 | +* Date: 2022-01-04 10:50:35 | |
6 | +* Email: qingxiongf@chinadci.com | |
7 | +* copyright: 广州城市信息研究所有限公司 | |
8 | +***************************************************************************/ | |
9 | +#include <unistd.h> | |
10 | +#include <dirent.h> | |
11 | +#include <stdlib.h> | |
12 | +#include <sys/stat.h> | |
13 | +#include <map> | |
14 | +#include <set> | |
15 | +#include <fontconfig/fontconfig.h> | |
16 | + | |
17 | +#include <boost/foreach.hpp> | |
18 | +#include <boost/lexical_cast.hpp> | |
19 | +#include <boost/algorithm/string.hpp> | |
20 | +#include <boost/date_time.hpp> | |
21 | +#include <boost/property_tree/ptree.hpp> | |
22 | +#include <boost/property_tree/json_parser.hpp> | |
23 | +#include <boost/typeof/typeof.hpp> | |
24 | +#include "dmplogger.h" | |
25 | +#include "dmpserverresponse.h" | |
26 | +#include "dmpserverrequest.h" | |
27 | + | |
28 | +#include "dmpimageinfo.h" | |
29 | + | |
30 | +namespace DmpMapping | |
31 | +{ | |
32 | + void getTypefaceList(const DmpServerContext &context) | |
33 | + { | |
34 | + FcConfig *config = FcInitLoadConfigAndFonts(); | |
35 | + FcPattern *pat = FcPatternCreate(); | |
36 | + FcObjectSet *os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, FC_LANG, FC_FILE, (char *)0); | |
37 | + FcFontSet *fs = FcFontList(config, pat, os); | |
38 | + if (fs == nullptr) | |
39 | + { | |
40 | + context.response()->writeJson("{\"error\":\"load FcFontSet failed\"}"); | |
41 | + return; | |
42 | + } | |
43 | + //printf("Total matching fonts: %d\n", fs->nfont); | |
44 | + boost::property_tree::ptree ptDoc; | |
45 | + boost::property_tree::ptree ptRoot; | |
46 | + | |
47 | + std::map<std::string, std::string> mapFont; | |
48 | + mapFont["SimSun"] = "宋体"; | |
49 | + mapFont["NSimSun"] = "新宋体"; | |
50 | + mapFont["SimHei"] = "黑体"; | |
51 | + mapFont["FangSong"] = "仿宋"; | |
52 | + mapFont["KaiTi"] = "楷体"; | |
53 | + mapFont["LiSu"] = "隶书"; | |
54 | + mapFont["YouYuan"] = "幼圆"; | |
55 | + mapFont["STXihei"] = "华文细黑"; | |
56 | + mapFont["STKaiti"] = "华文楷体"; | |
57 | + mapFont["STSong"] = "华文宋体"; | |
58 | + mapFont["STZhongsong"] = "华文中宋"; | |
59 | + mapFont["STFangsong"] = "华文仿宋"; | |
60 | + mapFont["FZShuTi"] = "方正舒体"; | |
61 | + mapFont["FZYaoti"] = "方正姚体"; | |
62 | + mapFont["STCaiyun"] = "华文彩云"; | |
63 | + mapFont["STHupo"] = "华文琥珀"; | |
64 | + mapFont["STLiti"] = "华文隶书"; | |
65 | + mapFont["STXingkai"] = "华文行楷"; | |
66 | + mapFont["STXinwei"] = "华文新魏"; | |
67 | + mapFont["Microsoft YaHei"] = "微软雅黑"; | |
68 | + mapFont["Microsoft JhengHei"] = "微軟正黑體"; | |
69 | + mapFont["DengXian"] = "等线"; | |
70 | + mapFont["MingLiU"] = "細明體"; | |
71 | + mapFont["MingLiU_HKSCS"] = "細明體_HKSCS"; | |
72 | + mapFont["MingLiU"] = "細明體"; | |
73 | + | |
74 | + std::set<std::string> setFont; | |
75 | + char buff[1000]; | |
76 | + for (int i = 0; fs && i < fs->nfont; ++i) | |
77 | + { | |
78 | + | |
79 | + FcPattern *font = fs->fonts[i]; | |
80 | + FcChar8 *file, *style, *family, *prgname; | |
81 | + if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch && | |
82 | + FcPatternGetString(font, FC_FAMILY, 0, &family) == FcResultMatch && | |
83 | + FcPatternGetString(font, FC_STYLE, 0, &style) == FcResultMatch) | |
84 | + { | |
85 | + sprintf(buff, "%s", family); | |
86 | + if (setFont.find(buff) == setFont.end()) | |
87 | + { | |
88 | + | |
89 | + setFont.insert(buff); | |
90 | + if (mapFont.find(buff) != mapFont.end()) | |
91 | + { | |
92 | + boost::property_tree::ptree ptNode; | |
93 | + ptNode.put("", buff); | |
94 | + ptRoot.push_back(std::make_pair("", ptNode)); | |
95 | + } | |
96 | + } | |
97 | + } | |
98 | + } | |
99 | + | |
100 | + for (std::set<std::string>::iterator iter = setFont.begin(); | |
101 | + iter != setFont.end(); iter++) | |
102 | + { | |
103 | + if (mapFont.find(*iter) == mapFont.end()) | |
104 | + { | |
105 | + boost::property_tree::ptree ptNode; | |
106 | + ptNode.put("", *iter); | |
107 | + ptRoot.push_back(std::make_pair("", ptNode)); | |
108 | + } | |
109 | + } | |
110 | + | |
111 | + FcFontSetDestroy(fs); | |
112 | + | |
113 | + ptDoc.add_child("value", ptRoot); | |
114 | + std::stringstream stream; | |
115 | + write_json(stream, ptDoc); | |
116 | + std::string responseStr = stream.str(); | |
117 | + context.response()->writeJson(responseStr); | |
118 | + } | |
119 | + | |
120 | + void getImage(const DmpServerContext &context) | |
121 | + { | |
122 | + DmpServerParameters params = context.request()->serverParameters(); | |
123 | + std::string name; | |
124 | + params.getValue("name", name); | |
125 | + | |
126 | + std::string imagePath = getFilePath("../symbollib/" + name); | |
127 | + FILE *file = fopen(imagePath.c_str(), "rb"); | |
128 | + | |
129 | + try | |
130 | + { | |
131 | + char buff[1024]; | |
132 | + if (file == 0) | |
133 | + { | |
134 | + context.response()->writeJson("{\"error\":\"open file failed\"}"); | |
135 | + return; | |
136 | + } | |
137 | + | |
138 | + context.response()->removeHeader("Content-Type"); | |
139 | + context.response()->setHeader("Content-Type", "image/png"); | |
140 | + | |
141 | + for (int i = 0; i < 20000; i++) | |
142 | + { | |
143 | + size_t t = fread(buff, 1, sizeof(buff), file); | |
144 | + context.response()->writeContent(buff, t); | |
145 | + | |
146 | + if (t != sizeof(buff)) | |
147 | + break; | |
148 | + } | |
149 | + fclose(file); | |
150 | + return; | |
151 | + } | |
152 | + catch (...) | |
153 | + { | |
154 | + if (file) | |
155 | + fclose(file); | |
156 | + } | |
157 | + context.response()->writeJson("{\"error\":\"Parameter name is null\"}"); | |
158 | + } | |
159 | + | |
160 | + void getImageTypeList(const DmpServerContext &context) | |
161 | + { | |
162 | + DIR *dirp; | |
163 | + struct dirent *dp; | |
164 | + std::string imagePath = getFilePath("../symbollib"); | |
165 | + dirp = opendir(imagePath.c_str()); | |
166 | + | |
167 | + boost::property_tree::ptree ptDoc; | |
168 | + boost::property_tree::ptree ptRoot; | |
169 | + | |
170 | + if (dirp) | |
171 | + { | |
172 | + while ((dp = readdir(dirp)) != NULL) | |
173 | + { | |
174 | + if (dp->d_name == NULL || dp->d_name[0] == '.') | |
175 | + { | |
176 | + continue; | |
177 | + } | |
178 | + | |
179 | + boost::property_tree::ptree ptDir; | |
180 | + | |
181 | + ptDir.add("name", dp->d_name); | |
182 | + ptRoot.push_back(std::make_pair("", ptDir)); | |
183 | + //ptRoot.add_child("imageType",ptDir); | |
184 | + } | |
185 | + closedir(dirp); | |
186 | + } | |
187 | + else | |
188 | + { | |
189 | + LOGGER_ERROR("not find dir " + imagePath); | |
190 | + } | |
191 | + | |
192 | + ptDoc.add_child("value", ptRoot); | |
193 | + std::stringstream stream; | |
194 | + write_json(stream, ptDoc); | |
195 | + std::string responseStr = stream.str(); | |
196 | + context.response()->writeJson(responseStr); | |
197 | + } | |
198 | + | |
199 | + void getImageList(const DmpServerContext &context) | |
200 | + { | |
201 | + DmpServerParameters params = context.request()->serverParameters(); | |
202 | + std::string name; | |
203 | + params.getValue("name", name); | |
204 | + | |
205 | + if (name.empty()) | |
206 | + { | |
207 | + context.response()->writeJson("{\"error\":\"Parameter name is null\"}"); | |
208 | + return; | |
209 | + } | |
210 | + | |
211 | + struct dirent *dp; | |
212 | + std::string imagePath = getFilePath("../symbollib/" + name); | |
213 | + DIR *dirp = opendir(imagePath.c_str()); | |
214 | + | |
215 | + boost::property_tree::ptree ptDoc; | |
216 | + boost::property_tree::ptree ptRoot; | |
217 | + | |
218 | + if (dirp) | |
219 | + { | |
220 | + while ((dp = readdir(dirp)) != NULL) | |
221 | + { | |
222 | + boost::property_tree::ptree ptDir; | |
223 | + if (dp->d_name == NULL || dp->d_name[0] == '.') | |
224 | + { | |
225 | + continue; | |
226 | + } | |
227 | + ptDir.add("name", dp->d_name); | |
228 | + ptDir.add("path", ("../symbollib/" + name + "/" + dp->d_name)); | |
229 | + ptRoot.push_back(std::make_pair("", ptDir)); | |
230 | + } | |
231 | + closedir(dirp); | |
232 | + } | |
233 | + else | |
234 | + { | |
235 | + LOGGER_ERROR("not find dir " + imagePath); | |
236 | + } | |
237 | + | |
238 | + ptDoc.add_child("value", ptRoot); | |
239 | + std::stringstream stream; | |
240 | + write_json(stream, ptDoc); | |
241 | + std::string responseStr = stream.str(); | |
242 | + context.response()->writeJson(responseStr); | |
243 | + } | |
244 | + | |
245 | + std::string getFilePath(const std::string &path) | |
246 | + { | |
247 | + char sz[300] = {0}; | |
248 | + if (getCurrentFolderPath(sz, sizeof(sz)) > 0) | |
249 | + { | |
250 | + std::string s; | |
251 | + s = sz; | |
252 | + size_t t = s.rfind('/'); | |
253 | + sz[t] = 0; | |
254 | + if (path[0] == '/') | |
255 | + { | |
256 | + return path; | |
257 | + } | |
258 | + int i = 0; | |
259 | + if (path[0] == '.') | |
260 | + { | |
261 | + if (path[1] == '.') | |
262 | + { | |
263 | + i++; | |
264 | + s = sz; | |
265 | + t = s.rfind('/'); | |
266 | + sz[t] = 0; | |
267 | + } | |
268 | + i++; | |
269 | + } | |
270 | + if ((sz[t] == '/' || sz[t] == '\\') && (path[i] == '/' || path[i] == '\\')) | |
271 | + { | |
272 | + i++; | |
273 | + } | |
274 | + | |
275 | + int j = t; | |
276 | + for (j = t; i < path.length(); i++, j++) | |
277 | + { | |
278 | + if (path[i] == '\\') | |
279 | + { | |
280 | + sz[j] = '/'; | |
281 | + } | |
282 | + else | |
283 | + { | |
284 | + sz[j] = path[i]; | |
285 | + } | |
286 | + } | |
287 | + sz[j] = 0; | |
288 | + //strcat(sz, path.c_str()); | |
289 | + return sz; | |
290 | + } | |
291 | + else | |
292 | + return 0; | |
293 | + } | |
294 | + | |
295 | + size_t getCurrentFolderPath(char *processdir, size_t len) | |
296 | + { | |
297 | + char *path_end; | |
298 | + if (readlink("/proc/self/exe", processdir, len) <= 0) | |
299 | + return -1; | |
300 | + path_end = strrchr(processdir, '/'); | |
301 | + if (path_end == NULL) | |
302 | + return -1; | |
303 | + ++path_end; | |
304 | + //strcpy(processname, path_end); | |
305 | + *path_end = '\0'; | |
306 | + return (size_t)(path_end - processdir); | |
307 | + } | |
308 | + | |
309 | +} | |
\ No newline at end of file | ... | ... |
1 | +/************************************************************************** | |
2 | +* file: dmpimageinfo.h | |
3 | + | |
4 | +* Author: qingxiongf | |
5 | +* Date: 2022-01-04 10:03:50 | |
6 | +* Email: qingxiongf@chinadci.com | |
7 | +* copyright: 广州城市信息研究所有限公司 | |
8 | +***************************************************************************/ | |
9 | + | |
10 | +#ifndef __dmpimageinfo_h__ | |
11 | +#define __dmpimageinfo_h__ | |
12 | + | |
13 | +#include <map> | |
14 | +#include <memory> | |
15 | +#include <functional> | |
16 | +#include "dmpservercontext.h" | |
17 | + | |
18 | + | |
19 | + | |
20 | +namespace DmpMapping | |
21 | +{ | |
22 | + void getTypefaceList(const DmpServerContext &context) ; //获取字体列表 | |
23 | + void getImageTypeList(const DmpServerContext &context) ; //获取图片目录列表 | |
24 | + void getImageList(const DmpServerContext &context) ; //获取图片列表 | |
25 | + void getImage(const DmpServerContext &context) ; //获取图片 | |
26 | + std::string getFilePath(const std::string& path); | |
27 | + size_t getCurrentFolderPath(char *processdir, size_t len); | |
28 | +} | |
29 | + | |
30 | +#endif // __dmpimageinfo_h__ | |
31 | + | ... | ... |
... | ... | @@ -17,8 +17,11 @@ |
17 | 17 | #include "dmpserverresponse.h" |
18 | 18 | #include "dmplogger.h" |
19 | 19 | #include "../wms/dmpwmsgetmap.h" |
20 | +#include "../wms/dmpwmsparameters.h" | |
20 | 21 | #include "dmpmapping.h" |
21 | 22 | #include "dmpmappingparameters.h" |
23 | +#include "dmpimageinfo.h" | |
24 | + | |
22 | 25 | using namespace std; |
23 | 26 | |
24 | 27 | namespace DmpMapping |
... | ... | @@ -47,10 +50,37 @@ namespace DmpMapping |
47 | 50 | { |
48 | 51 | loadService(context, vectorMappingProjects_); |
49 | 52 | } |
53 | + else if (boost::iequals(request, "editService")) | |
54 | + { | |
55 | + editService(context, vectorMappingProjects_); | |
56 | + } | |
50 | 57 | else if (boost::iequals(request, "getmap")) |
51 | 58 | { |
52 | - DmpWms::writeGetMap(context, params, nullptr); | |
59 | + const std::string map = params.Map(); | |
60 | + if(vectorMappingProjects_.find(map) != vectorMappingProjects_.end()) | |
61 | + { | |
62 | + shared_ptr<DmpProject> project = vectorMappingProjects_.find(map)->second; | |
63 | + const DmpWms::DmpWmsParameters wmsParams(context.request()->serverParameters()); | |
64 | + DmpWms::writeGetMap(context, wmsParams, project.get()); | |
65 | + } | |
66 | + } | |
67 | + else if (boost::iequals(request,"gettypefacelist")) { | |
68 | + getTypefaceList(context); | |
69 | + } | |
70 | + else if (boost::iequals(request,"getimagetyplist")) { | |
71 | + getImageTypeList(context); | |
72 | + } | |
73 | + else if (boost::iequals(request,"getimagelist")) { | |
74 | + getImageList(context); | |
75 | + } | |
76 | + else if (boost::iequals(request,"getimage")) { | |
77 | + getImage(context); | |
53 | 78 | } |
54 | 79 | } |
80 | + | |
81 | + | |
82 | + | |
83 | + | |
84 | + | |
55 | 85 | } |
56 | 86 | ... | ... |
... | ... | @@ -87,4 +87,11 @@ namespace DmpMapping |
87 | 87 | return value; |
88 | 88 | } |
89 | 89 | |
90 | + std::string DmpMappingParameters::Map() const | |
91 | + { | |
92 | + std::string value = ""; | |
93 | + GetStringParameter("MAP",value); | |
94 | + return value; | |
95 | + } | |
96 | + | |
90 | 97 | } // namespace DmpWms |
\ No newline at end of file | ... | ... |
... | ... | @@ -23,6 +23,8 @@ namespace DmpMapping |
23 | 23 | std::string Request() const; //必须 值为GetMap GetCapabilities GetFeatureInfo GetFeatureInfo GetLegendGraphic |
24 | 24 | std::string Version() const; //必须 服务版本, 值为 1.0.0, 1.1.0, 1.1.1, 1.3 |
25 | 25 | |
26 | + std::string Map() const; | |
27 | + | |
26 | 28 | private: |
27 | 29 | bool GetStringParameter(const char* key, std::string &value) const; |
28 | 30 | bool GetIntParameter(const char* key, int& value) const; | ... | ... |
... | ... | @@ -50,7 +50,7 @@ namespace DmpWms |
50 | 50 | { |
51 | 51 | writeGetMap(context,params, project); |
52 | 52 | } |
53 | - else if(boost::iequals(request,"thumbnail")) | |
53 | + else if(boost::iequals(request,"thumbnail") || boost::iequals(request,"getthumbnail")) | |
54 | 54 | { |
55 | 55 | writeThumbnail(context,params, project); |
56 | 56 | } | ... | ... |
... | ... | @@ -125,6 +125,7 @@ namespace DmpWms |
125 | 125 | |
126 | 126 | shared_ptr<Rect> rect (new Rect(maxy, maxx, miny, minx)); |
127 | 127 | mapRenderer.SetExtent(rect); |
128 | + mapRenderer.AddWmsMapLayers(project); | |
128 | 129 | mapRenderer.GetMap(nullptr, nullptr, nullptr, true); |
129 | 130 | string responseData; |
130 | 131 | mapRenderer.ToStream(responseData); | ... | ... |
... | ... | @@ -8,8 +8,6 @@ |
8 | 8 | ***************************************************************************/ |
9 | 9 | #include "dmptmstileprovider.h" |
10 | 10 | #include "dmpserverresponse.h" |
11 | -#include <math.h> | |
12 | -#include "dmplogger.h" | |
13 | 11 | namespace DmpTms |
14 | 12 | { |
15 | 13 | DmpTmsTileProvider::DmpTmsTileProvider(const std::string& root_path) |
... | ... | @@ -45,104 +43,4 @@ namespace DmpTms |
45 | 43 | } |
46 | 44 | fread.close(); |
47 | 45 | } |
48 | - void DmpTmsTileProvider::GetTileThumbnail(DmpTileLayer* dmpTileLayer,DmpServerResponse& respons) | |
49 | - { | |
50 | - int tilematrix=0; | |
51 | - std::string tilePath=dmpTileLayer->getDataSource(); | |
52 | - | |
53 | - //tilePath="/mnt/d/Code/tiles/qgis"; | |
54 | - DmpRectangle rectangle=dmpTileLayer->extent(); | |
55 | - | |
56 | - DmpPoint min=DmpPoint(rectangle.xmin(),rectangle.ymin()); | |
57 | - DmpPoint max=DmpPoint(rectangle.xmax(),rectangle.ymax()); | |
58 | - tilematrix=this->screenMatrixSet(min,max); | |
59 | - int xMinTile, yMinTile,xMaxTile,yMaxTile; | |
60 | - this->degToNum(tilematrix,min.x(),min.y(),xMinTile,yMinTile); | |
61 | - this->degToNum(tilematrix,max.x(),max.y(),xMaxTile,yMaxTile); | |
62 | - int heigth=abs(yMaxTile-yMinTile); | |
63 | - int width=abs(xMaxTile-xMinTile); | |
64 | - | |
65 | - cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 256*(width+1), 256*(heigth+1)); | |
66 | - cairo_t *cr =cairo_create (surface); | |
67 | - for( int i = 0 ; i <= width ; i++ ) | |
68 | - { | |
69 | - for(int j=0;j<=heigth;j++) | |
70 | - { | |
71 | - std::string filepath=tilePath+"/"+std::to_string(tilematrix)+"/"+std::to_string(xMinTile+i)+"/"+std::to_string(yMaxTile+j)+".png"; | |
72 | - cairo_surface_t* image = cairo_image_surface_create_from_png( filepath.c_str()); | |
73 | - this->BufferCopy(image,surface,cr,i*256,j*256); | |
74 | - //cairo_surface_write_to_png (surface, "./tms.png"); | |
75 | - LOGGER_DEBUG(filepath); | |
76 | - } | |
77 | - } | |
78 | - //cairo_surface_write_to_png (surface, "./tms.png"); | |
79 | - std::string responseData; | |
80 | - cairo_surface_write_to_png_stream(surface, cairo_write_func, &responseData); | |
81 | - respons.removeHeader("Content-Type"); | |
82 | - respons.setHeader("Content-Type", "image/png"); | |
83 | - respons.write(responseData); | |
84 | - cairo_destroy (cr); | |
85 | - cairo_surface_destroy (surface); | |
86 | - } | |
87 | - //经纬度到瓦片 | |
88 | - void DmpTmsTileProvider::degToNum(int zoom, double lon_deg, double lat_deg,int& x,int& y) | |
89 | - { | |
90 | - double n = pow(2.0, zoom); | |
91 | - double xtile = n * ((lon_deg + 180) / 360); | |
92 | - //角度转弧度 | |
93 | - double lat_rad = lat_deg * RAD2DEG; | |
94 | - double ytile = n * (1 - (log(tan(lat_rad) + (1 / cos(lat_rad))) / pi)) / 2; | |
95 | - | |
96 | - x = (int)floor(xtile); | |
97 | - y = (int)floor(ytile); | |
98 | - } | |
99 | - //瓦片到经纬度 | |
100 | - // double* DmpTmsTileProvider::numToDeg(int zoom, int xtile, int ytile) | |
101 | - // { | |
102 | - // double n = pow(2.0, zoom); | |
103 | - // double lon_deg = double(xtile) / n * 360.0 - 180.0; | |
104 | - // double lat_rad = atan(sinh(pi * (1 - 2 * ytile / n))); | |
105 | - // double lat_deg = lat_rad * 180.0 / pi; | |
106 | - // double lonlat[2] = {}; | |
107 | - // lonlat[0] = lon_deg; | |
108 | - // lonlat[1] = lat_deg; | |
109 | - // return lonlat; | |
110 | - // } | |
111 | - bool DmpTmsTileProvider::BufferCopy(cairo_surface_t *pClsCSFrom, cairo_surface_t *pClsCSTo, cairo_t *cr,int x,int y) | |
112 | - { | |
113 | - if (pClsCSFrom == NULL||pClsCSTo == NULL) | |
114 | - { | |
115 | - return false; | |
116 | - } | |
117 | - if(cr==NULL) | |
118 | - { | |
119 | - cr = cairo_create (pClsCSTo); | |
120 | - } | |
121 | - cairo_set_source_surface(cr, pClsCSFrom, x, y); | |
122 | - cairo_paint(cr); | |
123 | - return true; | |
124 | - } | |
125 | - cairo_status_t DmpTmsTileProvider::cairo_write_func(void *pbuff, const unsigned char *data, unsigned int length) | |
126 | - { | |
127 | - std::string *responseData = (std::string *)pbuff; | |
128 | - responseData->append((char *)data, length); | |
129 | - return CAIRO_STATUS_SUCCESS; | |
130 | - } | |
131 | - int DmpTmsTileProvider::screenMatrixSet(DmpPoint min,DmpPoint max) | |
132 | - { | |
133 | - int iMatrixSet=4; | |
134 | - for( ; iMatrixSet<=20 ; iMatrixSet++ ) | |
135 | - { | |
136 | - int xMinTile, yMinTile,xMaxTile,yMaxTile; | |
137 | - this->degToNum(iMatrixSet,min.x(),min.y(),xMinTile,yMinTile); | |
138 | - this->degToNum(iMatrixSet,max.x(),max.y(),xMaxTile,yMaxTile); | |
139 | - int heigth=abs(yMaxTile-yMinTile); | |
140 | - int width=abs(xMaxTile-xMinTile); | |
141 | - if((heigth+1)*(width+1)<9 && (heigth+2)*(width+2)>10) | |
142 | - { | |
143 | - break; | |
144 | - } | |
145 | - } | |
146 | - return iMatrixSet; | |
147 | - } | |
148 | 46 | } |
\ No newline at end of file | ... | ... |
请
注册
或
登录
后发表评论