|
...
|
...
|
@@ -19,7 +19,7 @@ namespace tileserver |
|
19
|
19
|
DmpEsriTileProvider::DmpEsriTileProvider(const std::string& rootPath)
|
|
20
|
20
|
: DmpTileProvider(rootPath)
|
|
21
|
21
|
{
|
|
22
|
|
- // this->_rootPath ="/mnt/d/Data/tile/ShareMap2014/Layers/_alllayers/";
|
|
|
22
|
+ //rootPath_ ="/mnt/d/Code/tiles/SD_2014/Layers/_alllayers";
|
|
23
|
23
|
}
|
|
24
|
24
|
|
|
25
|
25
|
std::string DmpEsriTileProvider::IntToHex8Str(const int num)
|
|
...
|
...
|
@@ -36,7 +36,7 @@ namespace tileserver |
|
36
|
36
|
std::string row_str = "R" + IntToHex8Str(row);
|
|
37
|
37
|
std::string col_str = "C" + IntToHex8Str(col);
|
|
38
|
38
|
|
|
39
|
|
- std::string tile_path = rootPath_ + level_str + "/"+ row_str+"/"+ col_str + "." + format;
|
|
|
39
|
+ std::string tile_path = rootPath_ +"/"+ level_str + "/"+ row_str+"/"+ col_str + "." + format;
|
|
40
|
40
|
|
|
41
|
41
|
std::ifstream fread(tile_path, std::ifstream::binary);
|
|
42
|
42
|
if(!fread)
|
|
...
|
...
|
@@ -70,8 +70,8 @@ namespace tileserver |
|
70
|
70
|
DmpRectangle rectangle=dmpTileLayer->extent();
|
|
71
|
71
|
std::string format=dmpTileLayer->getFormat();
|
|
72
|
72
|
|
|
73
|
|
- DmpPoint min=DmpPoint(rectangle.xmin(),rectangle.ymin());
|
|
74
|
|
- DmpPoint max=DmpPoint(rectangle.xmax(),rectangle.ymax());
|
|
|
73
|
+ DmpPoint min=DmpPoint(rectangle.xmin(),rectangle.ymax());
|
|
|
74
|
+ DmpPoint max=DmpPoint(rectangle.xmax(),rectangle.ymin());
|
|
75
|
75
|
std::vector<DmpTileMatrixSet*> tileMatrixSets;
|
|
76
|
76
|
dmpTileLayer->getTileMatrixSets(tileMatrixSets);
|
|
77
|
77
|
double resolution;
|
|
...
|
...
|
@@ -97,16 +97,41 @@ namespace tileserver |
|
97
|
97
|
TileProviderFactory::BufferCopy(image,surface,cr,i*256,j*256);
|
|
98
|
98
|
}
|
|
99
|
99
|
//TileProviderFactory::BufferCopy(image,surface,cr,i*256,j*256);
|
|
100
|
|
- //cairo_surface_write_to_png (surface, "./wmts.png");
|
|
|
100
|
+
|
|
101
|
101
|
}
|
|
102
|
102
|
}
|
|
|
103
|
+ cairo_surface_write_to_png (surface, "./wmts.png");
|
|
|
104
|
+ cairo_surface_t* newimage=surface;
|
|
|
105
|
+
|
|
|
106
|
+ int w,h;
|
|
|
107
|
+ w = cairo_image_surface_get_width (newimage);
|
|
|
108
|
+ h = cairo_image_surface_get_height (newimage);
|
|
|
109
|
+ DmpPoint topLeft;
|
|
|
110
|
+ TileProviderFactory::RowColToPoint(origin,xMinTile,yMaxTile,resolution,topLeft);
|
|
|
111
|
+
|
|
|
112
|
+ DmpPoint clipPoint;
|
|
|
113
|
+ int wClip,hClip;
|
|
|
114
|
+ TileProviderFactory::GetClipBox(topLeft,min,max,resolution,clipPoint,wClip,hClip);
|
|
|
115
|
+
|
|
|
116
|
+ cairo_surface_t *surface0 = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,wClip, hClip);
|
|
|
117
|
+ cairo_t *cr0 =cairo_create (surface0);
|
|
|
118
|
+
|
|
|
119
|
+ //cairo_rectangle(cr0,clipPoint.x(),clipPoint.y(),wClip,hClip);
|
|
|
120
|
+ cairo_rectangle(cr0,0,0,wClip,hClip);
|
|
|
121
|
+ cairo_set_source_surface (cr0, surface,-clipPoint.x(), -clipPoint.y());
|
|
|
122
|
+ cairo_clip(cr0);
|
|
|
123
|
+ cairo_paint(cr0);
|
|
|
124
|
+
|
|
|
125
|
+
|
|
103
|
126
|
std::string responseData;
|
|
104
|
|
- cairo_surface_write_to_png_stream(surface, TileProviderFactory::cairo_write_func, &responseData);
|
|
|
127
|
+ cairo_surface_write_to_png_stream(surface0, TileProviderFactory::cairo_write_func, &responseData);
|
|
105
|
128
|
|
|
106
|
129
|
response.removeHeader("Content-Type");
|
|
107
|
130
|
std::string f = (format == "jpg") ? "image/jpg" : "image/png";
|
|
108
|
131
|
response.setHeader("Content-Type", f);
|
|
109
|
|
- response.write(responseData);
|
|
|
132
|
+ response.write(responseData);
|
|
|
133
|
+ // cairo_destroy (cr0);
|
|
|
134
|
+ // cairo_surface_destroy (surface0);
|
|
110
|
135
|
cairo_destroy (cr);
|
|
111
|
136
|
cairo_surface_destroy (surface);
|
|
112
|
137
|
}
|
|
...
|
...
|
@@ -115,14 +140,13 @@ namespace tileserver |
|
115
|
140
|
std::string level_str = "L" + DmpWmtsUtils::IntToFormatStr(level);
|
|
116
|
141
|
std::string row_str = "R" + IntToHex8Str(row);
|
|
117
|
142
|
std::string col_str = "C" + IntToHex8Str(col);
|
|
118
|
|
-
|
|
119
|
|
- reTilePath = rootPath_ + level_str + "/"+ row_str+"/"+ col_str + "." + format;
|
|
|
143
|
+ std::string f = (format == "image/jpg") ? "jpg" : "png";
|
|
|
144
|
+ reTilePath = rootPath_ + "/"+level_str + "/"+ row_str+"/"+ col_str + "." + f;
|
|
120
|
145
|
|
|
121
|
|
- std::ifstream fread(reTilePath, std::ifstream::binary);
|
|
|
146
|
+ std::ifstream fread(reTilePath, std::ifstream::binary);
|
|
122
|
147
|
if(!fread)
|
|
123
|
148
|
{
|
|
124
|
149
|
return false;
|
|
125
|
150
|
}
|
|
126
|
|
-
|
|
127
|
151
|
}
|
|
128
|
152
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|