|
...
|
...
|
@@ -103,12 +103,34 @@ namespace DmpWmts |
|
103
|
103
|
response.sendError(500, "缩略图范围错误:(");
|
|
104
|
104
|
return;
|
|
105
|
105
|
}
|
|
106
|
|
- std::string buff;
|
|
107
|
|
- GetTile(yMinTile,xMinTile,iLevel,buff,buffLen);
|
|
108
|
|
- response.removeHeader("Content-Type");
|
|
109
|
|
- std::string f = (format == "jpg") ? "image/jpg" : "image/png";
|
|
110
|
|
- response.setHeader("Content-Type", f);
|
|
111
|
|
- response.write(buff);
|
|
|
106
|
+
|
|
|
107
|
+
|
|
|
108
|
+ int heigth=abs(yMaxTile-yMinTile);
|
|
|
109
|
+ int width=abs(xMaxTile-xMinTile);
|
|
|
110
|
+ cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 256*(width+1), 256*(heigth+1));
|
|
|
111
|
+ cairo_t *cr =cairo_create (surface);
|
|
|
112
|
+ for( int i = 0 ; i <= width ; i++ )
|
|
|
113
|
+ {
|
|
|
114
|
+ for(int j=0;j<=heigth;j++)
|
|
|
115
|
+ {
|
|
|
116
|
+ std::string strBuff;
|
|
|
117
|
+ GetTile(yMaxTile+j,xMinTile+i,iLevel,strBuff,buffLen);
|
|
|
118
|
+ const char* buff=strBuff.c_str();
|
|
|
119
|
+ st_png_data pngData = {(unsigned char*)buff, 0};
|
|
|
120
|
+ cairo_surface_t *image = cairo_image_surface_create_from_png_stream(cairo_read_func,&pngData);
|
|
|
121
|
+ TileProviderFactory::BufferCopy(image,surface,cr,i*256,j*256);
|
|
|
122
|
+ //cairo_surface_write_to_png (surface, "./wmts.png");
|
|
|
123
|
+ }
|
|
|
124
|
+ }
|
|
|
125
|
+ std::string responseData;
|
|
|
126
|
+ cairo_surface_write_to_png_stream(surface, TileProviderFactory::cairo_write_func, &responseData);
|
|
|
127
|
+
|
|
|
128
|
+ response.removeHeader("Content-Type");
|
|
|
129
|
+ std::string f = (format == "jpg") ? "image/jpg" : "image/png";
|
|
|
130
|
+ response.setHeader("Content-Type", f);
|
|
|
131
|
+ response.write(responseData);
|
|
|
132
|
+ cairo_destroy (cr);
|
|
|
133
|
+ cairo_surface_destroy (surface);
|
|
112
|
134
|
}
|
|
113
|
135
|
|
|
114
|
136
|
bool DmpEsriBundleV1Provider::GetTile(int row, int col, int level,std::string& refbuff,int& length )
|
|
...
|
...
|
@@ -118,7 +140,7 @@ namespace DmpWmts |
|
118
|
140
|
rGroup = rGroup * packSize;
|
|
119
|
141
|
int cGroup = (int)col/packSize;
|
|
120
|
142
|
cGroup = cGroup*packSize;
|
|
121
|
|
- rootPath_="/mnt/d/Code/tiles/gdmap/_alllayers";
|
|
|
143
|
+ //rootPath_="/mnt/d/Code/tiles/gdmap/_alllayers";
|
|
122
|
144
|
std::string bundleBase =GetBundlePath(level,rGroup,cGroup);
|
|
123
|
145
|
std::string bundleFilePath = bundleBase + ".bundle";
|
|
124
|
146
|
std::string bundlxFilePath = bundleBase + ".bundlx";
|
|
...
|
...
|
@@ -157,14 +179,14 @@ namespace DmpWmts |
|
157
|
179
|
+ (long)(buff[3]&0xff) * 16777216;
|
|
158
|
180
|
delete[] buff;
|
|
159
|
181
|
char *imgBuffer = new char[length];
|
|
160
|
|
- fread.read(imgBuffer, length);
|
|
|
182
|
+ fread.read(imgBuffer, length);
|
|
161
|
183
|
fread.close();
|
|
|
184
|
+ refbuff.append(imgBuffer,length);
|
|
|
185
|
+ // const char* test=refbuff.c_str();
|
|
162
|
186
|
// cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 256, 256);
|
|
163
|
|
- // cairo_t *cr =cairo_create (surface);
|
|
164
|
|
- // st_png_data* pPngData;
|
|
165
|
|
- // pPngData->pdata=(unsigned char*)buff;
|
|
166
|
|
- // pPngData->length=length;
|
|
167
|
|
- // cairo_surface_t *image = cairo_image_surface_create_from_png_stream (cairo_read_func,&pPngData);
|
|
|
187
|
+ // cairo_t *cr =cairo_create (surface);
|
|
|
188
|
+ // st_png_data pngData = {(unsigned char*)test, 0};
|
|
|
189
|
+ // cairo_surface_t *image = cairo_image_surface_create_from_png_stream(cairo_read_func,&pngData);
|
|
168
|
190
|
|
|
169
|
191
|
// TileProviderFactory::BufferCopy(image,surface,cr,0,0);
|
|
170
|
192
|
// cairo_surface_write_to_png (surface, "./wmts.png");
|
|
...
|
...
|
@@ -174,11 +196,11 @@ namespace DmpWmts |
|
174
|
196
|
return true;
|
|
175
|
197
|
|
|
176
|
198
|
}
|
|
177
|
|
- // cairo_status_t cairo_read_func (void *closure, unsigned char *data, unsigned int length,DmpServerResponse& response)
|
|
178
|
|
- // {
|
|
179
|
|
- // st_png_data* pPngData = (st_png_data*)closure;
|
|
180
|
|
- // memcpy(data, pPngData->pdata + pPngData->length, length);
|
|
181
|
|
- // pPngData->length += length;
|
|
182
|
|
- // return CAIRO_STATUS_SUCCESS;
|
|
183
|
|
- // }
|
|
|
199
|
+ cairo_status_t DmpEsriBundleV1Provider::cairo_read_func (void *closure, unsigned char *data, unsigned int length)
|
|
|
200
|
+ {
|
|
|
201
|
+ st_png_data* pPngData = (st_png_data*)closure;
|
|
|
202
|
+ memcpy(data, pPngData->pdata + pPngData->length, length);
|
|
|
203
|
+ pPngData->length += length;
|
|
|
204
|
+ return CAIRO_STATUS_SUCCESS;
|
|
|
205
|
+ }
|
|
184
|
206
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|