提交 d07ecb20472cc1831c235171f393463a615f04de
Merge branch 'master' of http://gitlab.ctune.cn/DMapServer/DMapServer4.1
正在显示
7 个修改的文件
包含
63 行增加
和
33 行删除
| @@ -102,8 +102,8 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | @@ -102,8 +102,8 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | ||
| 102 | LOGGER_INFO("服务发布成功"); | 102 | LOGGER_INFO("服务发布成功"); |
| 103 | std::string url; | 103 | std::string url; |
| 104 | std::string http="http://"+context.request()->domain()+":"+context.request()->port(); | 104 | std::string http="http://"+context.request()->domain()+":"+context.request()->port(); |
| 105 | - | ||
| 106 | - url=http+"/DMap/Services/"+name+"/TileServer/tmsService?REQUEST=GetThumbnail"; | 105 | + |
| 106 | + url=http+"/DMap/Services/"+name+"/"+serverType+"/tmsService?REQUEST=GetThumbnail"; | ||
| 107 | context.response()->write("{\"status\":\""+std::to_string(flag)+"\",\"url\":\""+url+"\",\"message\":\"Pulish service successful!\"}"); | 107 | context.response()->write("{\"status\":\""+std::to_string(flag)+"\",\"url\":\""+url+"\",\"message\":\"Pulish service successful!\"}"); |
| 108 | // std::string projData; | 108 | // std::string projData; |
| 109 | // DmpServerUtils::Base64Decode(project, &projData); | 109 | // DmpServerUtils::Base64Decode(project, &projData); |
| @@ -72,7 +72,7 @@ namespace DmpTms | @@ -72,7 +72,7 @@ namespace DmpTms | ||
| 72 | cairo_surface_t* image = cairo_image_surface_create_from_png( filepath.c_str()); | 72 | cairo_surface_t* image = cairo_image_surface_create_from_png( filepath.c_str()); |
| 73 | this->BufferCopy(image,surface,cr,i*256,j*256); | 73 | this->BufferCopy(image,surface,cr,i*256,j*256); |
| 74 | //cairo_surface_write_to_png (surface, "./tms.png"); | 74 | //cairo_surface_write_to_png (surface, "./tms.png"); |
| 75 | - LOGGER_DEBUG(filepath); | 75 | + //LOGGER_DEBUG(filepath); |
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| 78 | //cairo_surface_write_to_png (surface, "./tms.png"); | 78 | //cairo_surface_write_to_png (surface, "./tms.png"); |
| @@ -103,12 +103,34 @@ namespace DmpWmts | @@ -103,12 +103,34 @@ namespace DmpWmts | ||
| 103 | response.sendError(500, "缩略图范围错误:("); | 103 | response.sendError(500, "缩略图范围错误:("); |
| 104 | return; | 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 | bool DmpEsriBundleV1Provider::GetTile(int row, int col, int level,std::string& refbuff,int& length ) | 136 | bool DmpEsriBundleV1Provider::GetTile(int row, int col, int level,std::string& refbuff,int& length ) |
| @@ -118,7 +140,7 @@ namespace DmpWmts | @@ -118,7 +140,7 @@ namespace DmpWmts | ||
| 118 | rGroup = rGroup * packSize; | 140 | rGroup = rGroup * packSize; |
| 119 | int cGroup = (int)col/packSize; | 141 | int cGroup = (int)col/packSize; |
| 120 | cGroup = cGroup*packSize; | 142 | cGroup = cGroup*packSize; |
| 121 | - rootPath_="/mnt/d/Code/tiles/gdmap/_alllayers"; | 143 | + //rootPath_="/mnt/d/Code/tiles/gdmap/_alllayers"; |
| 122 | std::string bundleBase =GetBundlePath(level,rGroup,cGroup); | 144 | std::string bundleBase =GetBundlePath(level,rGroup,cGroup); |
| 123 | std::string bundleFilePath = bundleBase + ".bundle"; | 145 | std::string bundleFilePath = bundleBase + ".bundle"; |
| 124 | std::string bundlxFilePath = bundleBase + ".bundlx"; | 146 | std::string bundlxFilePath = bundleBase + ".bundlx"; |
| @@ -157,14 +179,14 @@ namespace DmpWmts | @@ -157,14 +179,14 @@ namespace DmpWmts | ||
| 157 | + (long)(buff[3]&0xff) * 16777216; | 179 | + (long)(buff[3]&0xff) * 16777216; |
| 158 | delete[] buff; | 180 | delete[] buff; |
| 159 | char *imgBuffer = new char[length]; | 181 | char *imgBuffer = new char[length]; |
| 160 | - fread.read(imgBuffer, length); | 182 | + fread.read(imgBuffer, length); |
| 161 | fread.close(); | 183 | fread.close(); |
| 184 | + refbuff.append(imgBuffer,length); | ||
| 185 | + // const char* test=refbuff.c_str(); | ||
| 162 | // cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 256, 256); | 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 | // TileProviderFactory::BufferCopy(image,surface,cr,0,0); | 191 | // TileProviderFactory::BufferCopy(image,surface,cr,0,0); |
| 170 | // cairo_surface_write_to_png (surface, "./wmts.png"); | 192 | // cairo_surface_write_to_png (surface, "./wmts.png"); |
| @@ -174,11 +196,11 @@ namespace DmpWmts | @@ -174,11 +196,11 @@ namespace DmpWmts | ||
| 174 | return true; | 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 | } |
| @@ -22,13 +22,13 @@ namespace DmpWmts | @@ -22,13 +22,13 @@ namespace DmpWmts | ||
| 22 | DmpEsriBundleV1Provider(const std::string& rootPath); | 22 | DmpEsriBundleV1Provider(const std::string& rootPath); |
| 23 | void WriteTile(const int row, const int col, const int level, const std::string& format, DmpServerResponse& response) override; | 23 | void WriteTile(const int row, const int col, const int level, const std::string& format, DmpServerResponse& response) override; |
| 24 | void GetTileThumbnail(DmpTileLayer* dmpTileLayer,DmpServerResponse& response) override; | 24 | void GetTileThumbnail(DmpTileLayer* dmpTileLayer,DmpServerResponse& response) override; |
| 25 | - bool GetTile(const int row,const int col,const int level,std::string& refbuff,int& length); | ||
| 26 | - //static cairo_status_t cairo_read_func (void *closure, unsigned char *data, unsigned int length); | 25 | + bool GetTile(const int row,const int col,const int level,std::string& rebuff,int& length); |
| 26 | + static cairo_status_t cairo_read_func (void *closure, unsigned char *data, unsigned int length); | ||
| 27 | }; | 27 | }; |
| 28 | - // struct st_png_data | ||
| 29 | - // { | ||
| 30 | - // unsigned char* pdata; | ||
| 31 | - // unsigned int length; | ||
| 32 | - // }; | 28 | + struct st_png_data |
| 29 | + { | ||
| 30 | + unsigned char* pdata; | ||
| 31 | + unsigned int length; | ||
| 32 | + }; | ||
| 33 | } | 33 | } |
| 34 | #endif //__dmpesribundlev1provider_h__ | 34 | #endif //__dmpesribundlev1provider_h__ |
| @@ -31,7 +31,7 @@ namespace DmpWmts | @@ -31,7 +31,7 @@ namespace DmpWmts | ||
| 31 | { | 31 | { |
| 32 | std::string tileVersion= dmpTileLayer->getVendor(); | 32 | std::string tileVersion= dmpTileLayer->getVendor(); |
| 33 | std::string tilePath=dmpTileLayer->getDataSource(); | 33 | std::string tilePath=dmpTileLayer->getDataSource(); |
| 34 | - //std::string tilePath_ = "/mnt/d/Code/tiles/gdmap/_alllayers"; | 34 | + //tilePath = "/mnt/d/Code/tiles/gdmap/_alllayers"; |
| 35 | //std::string tileVersion_ = "ESRI_V1"; | 35 | //std::string tileVersion_ = "ESRI_V1"; |
| 36 | int iver=StringToVector(tileVersion); | 36 | int iver=StringToVector(tileVersion); |
| 37 | Vendor version = (Vendor)boost::lexical_cast<int>(iver); | 37 | Vendor version = (Vendor)boost::lexical_cast<int>(iver); |
| @@ -151,4 +151,11 @@ namespace DmpWmts | @@ -151,4 +151,11 @@ namespace DmpWmts | ||
| 151 | cairo_paint(cr); | 151 | cairo_paint(cr); |
| 152 | return true; | 152 | return true; |
| 153 | } | 153 | } |
| 154 | + cairo_status_t TileProviderFactory::cairo_write_func(void *pbuff, const unsigned char *data, unsigned int length) | ||
| 155 | + { | ||
| 156 | + std::string *responseData = (std::string *)pbuff; | ||
| 157 | + responseData->append((char *)data, length); | ||
| 158 | + return CAIRO_STATUS_SUCCESS; | ||
| 159 | + } | ||
| 160 | + | ||
| 154 | } | 161 | } |
| @@ -42,11 +42,12 @@ namespace DmpWmts | @@ -42,11 +42,12 @@ namespace DmpWmts | ||
| 42 | static int screenTileMatrix(DmpPoint& min,DmpPoint& max,std::vector<DmpTileMatrixSet*>& tileMatrixSets,double& resolution,DmpPoint& origin); | 42 | static int screenTileMatrix(DmpPoint& min,DmpPoint& max,std::vector<DmpTileMatrixSet*>& tileMatrixSets,double& resolution,DmpPoint& origin); |
| 43 | static void PointToRowCol(DmpPoint& point,DmpPoint& origin,double resolution,int& xTile,int& yTile); | 43 | static void PointToRowCol(DmpPoint& point,DmpPoint& origin,double resolution,int& xTile,int& yTile); |
| 44 | static bool GetTileScale(DmpTileLayer* dmpTileLayer,int& iLevel,int& xMinTile,int& yMinTile,int& xMaxTile,int& yMaxTile); | 44 | static bool GetTileScale(DmpTileLayer* dmpTileLayer,int& iLevel,int& xMinTile,int& yMinTile,int& xMaxTile,int& yMaxTile); |
| 45 | + static cairo_status_t cairo_write_func(void *pbuff, const unsigned char *data, unsigned int length); | ||
| 45 | 46 | ||
| 46 | private: | 47 | private: |
| 47 | TileProviderFactory(); | 48 | TileProviderFactory(); |
| 48 | }; | 49 | }; |
| 49 | - | 50 | + |
| 50 | 51 | ||
| 51 | } | 52 | } |
| 52 | #endif //__dmptileproviderfactory_h__ | 53 | #endif //__dmptileproviderfactory_h__ |
请
注册
或
登录
后发表评论