27 #include "../common/StringUtils.h"
28 #include "../geometry/Envelope.h"
33 #include <boost/lexical_cast.hpp>
43 for(
char** i = subdatasets; *i != 0; i = i + 2)
45 std::string request = std::string(*i);
46 std::string title = std::string(*(i + 1));
49 std::size_t pos = request.find(
"=");
50 assert(pos != std::string::npos);
51 request = request.substr(pos + 1);
54 pos = title.find(
"=");
55 assert(pos != std::string::npos);
56 title = title.substr(pos + 1);
58 std::map<std::string, std::string> kvps;
63 currentLayerInfo.
m_title = title;
67 info[currentLayerInfo.
m_name] = currentLayerInfo;
75 assert(kvp.find(
"LAYERS") != kvp.end());
76 info.
m_name = kvp.find(
"LAYERS")->second;
78 std::map<std::string, std::string>::const_iterator it = kvp.find(
"BBOX");
84 info.
m_srs = it->second;
88 info.
m_srs = it->second;
90 it = kvp.find(
"VERSION");
103 assert(!request.empty());
110 std::map<std::string, std::string> kvp;
114 std::map<std::string, std::string>::const_iterator it = kvp.find(
"LAYER");
125 it = kvp.find(
"WIDTH");
130 it = kvp.find(
"HEIGHT");
135 it = kvp.find(
"FORMAT");
142 const std::string& width,
143 const std::string& height,
144 const std::string& format,
145 const std::string& bbox)
147 assert(!serverUrl.empty());
150 std::string url = serverUrl;
151 if(url.find(
"WMS:") != std::string::npos)
153 std::size_t pos = serverUrl.find(
":");
154 url = url.substr(pos + 1);
158 std::string request =
"<GDAL_WMS>";
161 request +=
"<Service name=\"WMS\">";
162 request +=
"<Version>" + info.
m_version +
"</Version>";
163 request +=
"<ServerUrl>" + url +
"</ServerUrl>";
164 request +=
"<SRS>" + info.
m_srs +
"</SRS>";
165 request +=
"<ImageFormat>" + format +
"</ImageFormat>";
166 request +=
"<Transparent>TRUE</Transparent>";
167 request +=
"<Layers>" + info.
m_name +
"</Layers>";
168 request +=
"</Service>";
171 std::string ulx, uly, lrx, lry;
178 request +=
"<DataWindow>";
179 request +=
"<UpperLeftX>" + ulx +
"</UpperLeftX>";
180 request +=
"<UpperLeftY>" + lry +
"</UpperLeftY>";
181 request +=
"<LowerRightX>" + lrx +
"</LowerRightX>";
182 request +=
"<LowerRightY>" + uly +
"</LowerRightY>";
183 request +=
"<SizeX>" + width +
"</SizeX>";
184 request +=
"<SizeY>" + height +
"</SizeY>";
185 request +=
"</DataWindow>";
187 request +=
"<BandsCount>4</BandsCount>";
190 request +=
"<BlockSizeX>" + width +
"</BlockSizeX>";
191 request +=
"<BlockSizeY>" + height +
"</BlockSizeY>";
194 request +=
"<Cache>";
195 request +=
"<Path>./gdalwmscache</Path>";
196 request +=
"<Depth>2</Depth>";
197 request +=
"</Cache>";
199 request +=
"</GDAL_WMS>";
205 std::string& ulx, std::string& uly,
206 std::string& lrx, std::string& lry)
208 std::vector<std::string> values;
211 assert(values.size() == 4);
220 std::string& ulx, std::string& uly,
221 std::string& lrx, std::string& lry)
223 ulx = boost::lexical_cast<std::string>(e.
m_llx);
224 uly = boost::lexical_cast<std::string>(e.
m_lly);
225 lrx = boost::lexical_cast<std::string>(e.
m_urx);
226 lry = boost::lexical_cast<std::string>(e.
m_ury);
231 std::string ulx, uly, lrx, lry;
234 return ulx +
"," + uly +
"," + lrx +
"," + lry;
void GetBBOXValues(const std::string &bbox, std::string &ulx, std::string &uly, std::string &lrx, std::string &lry)
#define TE_WMS_DEFAULT_WIDTH
It specifies the default width used on GetMap request.
std::string m_pseudoGetMapRequest
Informations about WMS Layers.
#define TE_WMS_DEFAULT_IMAGE_FORMAT
It specifies the default image format used on GetMap request.
double m_urx
Upper right corner x-coordinate.
void ExtractKVP(const std::string &kvpStr, std::map< std::string, std::string > &kvp, const std::string &kvpDelimiter="&", const std::string &kvDelimiter="=", bool toUpper=false)
It extracts a key-value map from a string.
std::string BuildGetMapRequest(const std::string &serverUrl, const WMSLayerInfo &info, const std::string &width, const std::string &height, const std::string &format, const std::string &bbox="")
Configuration flags for the TerraLib WMS module.
std::string GetBBOX(const te::gm::Envelope &e)
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
double m_llx
Lower left corner x-coordinate.
#define TE_WMS_DEFAULT_HEIGHT
It specifies the default height used on GetMap request.
An Envelope defines a 2D rectangular region.
void BuildLayersInfo(char **subdatasets, std::map< std::string, WMSLayerInfo > &info)
void ExtractRequestValues(const std::string &request, std::string &layer, std::string &width, std::string &height, std::string &format)
Utility functions for WMS driver.
double m_lly
Lower left corner y-coordinate.
double m_ury
Upper right corner y-coordinate.
WMSLayerInfo BuildLayerInfo(const std::map< std::string, std::string > &kvp)