25 #include <boost/algorithm/string.hpp> 27 #include "../../../../common/StringUtils.h" 28 #include "../../../core/Utils.h" 29 #include "../../../core/Exception.h" 42 reader->setValidationScheme(
false);
43 reader->setDoSchema(
false);
44 reader->setIgnoreWhiteSpaces(
true);
45 reader->setCacheGrammarFromParse(
false);
46 reader->setUseCachedGrammarInParse(
false);
48 reader->read(xmlPath);
56 if(!boost::iequals(reader->getElementLocalName(),
"WMS_Capabilities"))
63 while (reader->next())
65 if(boost::iequals(reader->getElementLocalName(),
"Capability"))
78 while (reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(),
"Capability")))
80 if(boost::iequals(reader->getElementLocalName(),
"Request"))
84 else if (boost::iequals(reader->getElementLocalName(),
"Layer"))
97 while (reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(),
"Request")))
100 if(boost::iequals(reader->getElementLocalName(),
"GetCapabilities"))
104 else if(boost::iequals(reader->getElementLocalName(),
"GetMap"))
108 else if(boost::iequals(reader->getElementLocalName(),
"GetFeatureInfo"))
121 if (reader->hasAttrs())
123 for (
size_t i = 0; i < reader->getNumberOfAttrs(); i++)
125 if(boost::iequals(reader->getAttrLocalName(i),
"queryable"))
126 layer.
m_queryable = (reader->getAttrAsInt32(
"queryable") != 0) ?
true :
false;
127 else if (boost::iequals(reader->getAttrLocalName(i),
"cascaded"))
128 layer.
m_cascaded = (reader->getAttrAsInt32(
"cascaded") != 0) ?
true :
false;
129 else if (boost::iequals(reader->getAttrLocalName(i),
"opaque"))
130 layer.
m_opaque = (reader->getAttrAsInt32(
"opaque") != 0) ?
true :
false;
131 else if (boost::iequals(reader->getAttrLocalName(i),
"noSubsets"))
132 layer.
m_noSubsets = (reader->getAttrAsInt32(
"noSubsets") != 0) ?
true :
false;
133 else if (boost::iequals(reader->getAttrLocalName(i),
"fixedWidth"))
134 layer.
m_fixedWidth = (reader->getAttrAsInt32(
"fixedWidth") != 0) ?
true :
false;
135 else if (boost::iequals(reader->getAttrLocalName(i),
"fixedHeight"))
136 layer.
m_fixedHeight = (reader->getAttrAsInt32(
"fixedHeight") != 0) ?
true :
false;
140 std::vector<std::string> crsList;
141 while (reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(),
"Layer")))
143 if(reader->getNodeType() ==
te::xml::VALUE && boost::iequals(reader->getElementLocalName(),
"Name"))
145 layer.
m_name = reader->getElementValue();
147 else if(reader->getNodeType() ==
te::xml::VALUE && boost::iequals(reader->getElementLocalName(),
"Title"))
149 layer.
m_title = reader->getElementValue();
151 else if(reader->getNodeType() ==
te::xml::VALUE && boost::iequals(reader->getElementLocalName(),
"Abstract"))
155 else if(reader->getNodeType() ==
te::xml::VALUE && boost::iequals(reader->getElementLocalName(),
"CRS"))
157 crsList.push_back(reader->getElementValue());
159 else if(reader->getNodeType() ==
te::xml::START_ELEMENT && boost::iequals(reader->getElementLocalName(),
"KeywordList"))
161 std::vector<std::string> keywordList;
163 while (reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(),
"KeywordList")))
165 if(reader->getNodeType() ==
te::xml::VALUE && boost::iequals(reader->getElementLocalName(),
"Keyword"))
167 keywordList.push_back(reader->getElementValue());
173 else if (reader->getNodeType() ==
te::xml::START_ELEMENT && boost::iequals(reader->getElementLocalName(),
"EX_GeographicBoundingBox"))
177 else if (reader->getNodeType() ==
te::xml::START_ELEMENT && boost::iequals(reader->getElementLocalName(),
"BoundingBox") && reader->hasAttrs())
181 else if (boost::iequals(reader->getElementLocalName(),
"Dimension") && reader->hasAttrs())
185 else if (reader->getNodeType() ==
te::xml::START_ELEMENT && boost::iequals(reader->getElementLocalName(),
"Style"))
189 else if(reader->getNodeType() ==
te::xml::VALUE && boost::iequals(reader->getElementLocalName(),
"MinScaleDenominator"))
193 else if(reader->getNodeType() ==
te::xml::VALUE && boost::iequals(reader->getElementLocalName(),
"MaxScaleDenominator"))
197 else if (reader->getNodeType() ==
te::xml::START_ELEMENT && boost::iequals(reader->getElementLocalName(),
"Layer"))
204 layer.
m_crs = crsList;
213 while (reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(),
"EX_GeographicBoundingBox")))
217 if(boost::iequals(reader->getElementLocalName(),
"westBoundLongitude"))
219 else if(boost::iequals(reader->getElementLocalName(),
"eastBoundLongitude"))
221 else if(boost::iequals(reader->getElementLocalName(),
"southBoundLatitude"))
223 else if(boost::iequals(reader->getElementLocalName(),
"northBoundLatitude"))
228 return geoBoundingBox;
235 box.
m_crs = reader->getAttr(
"CRS");
241 box.
m_minX = reader->getAttrAsDouble(
"miny");
242 box.
m_minY = reader->getAttrAsDouble(
"minx");
243 box.
m_maxX = reader->getAttrAsDouble(
"maxy");
244 box.
m_maxY = reader->getAttrAsDouble(
"maxx");
248 box.
m_minX = reader->getAttrAsDouble(
"minx");
249 box.
m_minY = reader->getAttrAsDouble(
"miny");
250 box.
m_maxX = reader->getAttrAsDouble(
"maxx");
251 box.
m_maxY = reader->getAttrAsDouble(
"maxy");
261 for (
unsigned int i = 0; i < reader->getNumberOfAttrs(); i++)
263 if(boost::iequals(reader->getAttrLocalName(i),
"name"))
264 dimension.
m_name = reader->getAttr(
"name");
265 else if (boost::iequals(reader->getAttrLocalName(i),
"units"))
266 dimension.
m_units = reader->getAttr(
"units");
267 else if (boost::iequals(reader->getAttrLocalName(i),
"unitSymbol"))
269 else if (boost::iequals(reader->getAttrLocalName(i),
"default"))
270 dimension.
m_default = reader->getAttr(
"default");
271 else if (boost::iequals(reader->getAttrLocalName(i),
"multipleValues"))
272 dimension.
m_multipleValues = (reader->getAttrAsInt32(
"multipleValues") != 0) ?
true :
false;
273 else if (boost::iequals(reader->getAttrLocalName(i),
"nearestValue"))
274 dimension.
m_nearestValue = (reader->getAttrAsInt32(
"nearestValue") != 0) ?
true :
false;
275 else if (boost::iequals(reader->getAttrLocalName(i),
"current"))
276 dimension.
m_current = (reader->getAttrAsInt32(
"current") != 0) ?
true :
false;
279 if(boost::iequals(dimension.
m_name,
"time"))
281 while (reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(),
"Dimension")))
285 std::string allowedValuesStr = reader->getElementValue();
301 while (reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(),
"Style")))
303 if(reader->getNodeType() ==
te::xml::VALUE && boost::iequals(reader->getElementLocalName(),
"Name"))
305 style.
m_name = reader->getElementValue();
307 else if(reader->getNodeType() ==
te::xml::VALUE && boost::iequals(reader->getElementLocalName(),
"Title"))
309 style.
m_title = reader->getElementValue();
311 else if(reader->getNodeType() ==
te::xml::VALUE && boost::iequals(reader->getElementLocalName(),
"Abstract"))
315 else if(reader->getNodeType() ==
te::xml::START_ELEMENT && boost::iequals(reader->getElementLocalName(),
"LegendURL"))
319 else if(reader->getNodeType() ==
te::xml::START_ELEMENT && boost::iequals(reader->getElementLocalName(),
"StyleSheetURL"))
323 else if(reader->getNodeType() ==
te::xml::START_ELEMENT && boost::iequals(reader->getElementLocalName(),
"StyleURL"))
336 if (reader->hasAttrs())
338 for (
unsigned int i = 0; i < reader->getNumberOfAttrs(); i++)
340 if (boost::iequals(reader->getAttrLocalName(i),
"width"))
341 legendURL.
m_width = reader->getAttrAsInt32(
"width");
342 else if (boost::iequals(reader->getAttrLocalName(i),
"height"))
343 legendURL.
m_height = reader->getAttrAsInt32(
"height");
347 while (reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(),
"LegendURL")))
349 if(reader->getNodeType() ==
te::xml::VALUE && boost::iequals(reader->getElementLocalName(),
"Format"))
351 legendURL.
m_format = reader->getElementValue();
353 else if(boost::iequals(reader->getElementLocalName(),
"OnlineResource") && reader->hasAttrs())
366 for (
unsigned int i = 0; i < reader->getNumberOfAttrs(); i++)
368 if(boost::iequals(reader->getAttrLocalName(i),
"href"))
369 onlineResource.
m_href = reader->getAttr(i);
370 else if (boost::iequals(reader->getAttrLocalName(i),
"type"))
371 onlineResource.
m_type = reader->getAttr(i);
374 return onlineResource;
381 while (reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(),
"StyleSheetURL")))
383 if(reader->getNodeType() ==
te::xml::VALUE && boost::iequals(reader->getElementLocalName(),
"Format"))
385 styleSheet.
m_format = reader->getElementValue();
387 else if(boost::iequals(reader->getElementLocalName(),
"OnlineResource") && reader->hasAttrs())
400 while (reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(),
"StyleURL")))
402 if(reader->getNodeType() ==
te::xml::VALUE && boost::iequals(reader->getElementLocalName(),
"Format"))
404 style.
m_format = reader->getElementValue();
406 else if(boost::iequals(reader->getElementLocalName(),
"OnlineResource") && reader->hasAttrs())
419 while(reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(), operationName)))
421 if(reader->getNodeType() ==
te::xml::VALUE && boost::iequals(reader->getElementLocalName(),
"Format"))
423 operation.
m_formats.push_back(reader->getElementValue());
425 else if (reader->getNodeType() ==
te::xml::START_ELEMENT && boost::iequals(reader->getElementLocalName(),
"DCPType"))
427 while(reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(),
"DCPType")))
429 if (reader->getNodeType() ==
te::xml::START_ELEMENT && boost::iequals(reader->getElementLocalName(),
"HTTP"))
444 while(reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(),
"HTTP")))
446 if (reader->getNodeType() ==
te::xml::START_ELEMENT && boost::iequals(reader->getElementLocalName(),
"Get"))
448 while(reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(),
"Get")))
450 if (reader->getNodeType() ==
te::xml::START_ELEMENT && boost::iequals(reader->getElementLocalName(),
"OnlineResource"))
456 else if (reader->getNodeType() ==
te::xml::START_ELEMENT && boost::iequals(reader->getElementLocalName(),
"Post"))
458 while(reader->next() && !(reader->getNodeType() ==
te::xml::END_ELEMENT && boost::iequals(reader->getElementLocalName(),
"Post")))
460 if (reader->getNodeType() ==
te::xml::START_ELEMENT && boost::iequals(reader->getElementLocalName(),
"OnlineResource"))
virtual Request parseRequest(const std::unique_ptr< te::xml::Reader > &reader)
virtual BoundingBox parseBoundingBox(const std::unique_ptr< te::xml::Reader > &reader)
TECOMMONEXPORT std::vector< std::string > SplitString(const std::string &str, const char &delimiter)
OnlineResource m_onlineResource
virtual Style parseStyle(const std::unique_ptr< te::xml::Reader > &reader)
This XML Schema Document named xlinks xsd has been stored here based on the change request
The Capability WMS 1.3.0 struct.
std::vector< std::string > m_crs
double m_southBoundLatitude
virtual HTTP parseHTTP(const std::unique_ptr< te::xml::Reader > &reader)
StyleSheetURL m_styleSheetURL
TEWSCOREEXPORT bool IsInvertedEPSG(const std::string &epsg)
This function gets true for EPSGs that has inverted axis-order. Otherwise false. This implementation ...
double m_westBoundLongitude
static te::xml::Reader * make()
It creates a new XML reader using the dafault implementation.
#define TE_TR(message)
It marks a string in order to get translated.
std::vector< Layer > m_layers
unsigned int m_fixedWidth
OnlineResource m_onlineResource
boost::error_info< struct tag_error_description, std::string > ErrorDescription
The base type for error report messages.
virtual GeographicBoundingBox parseGeographicBoundingBox(const std::unique_ptr< te::xml::Reader > &reader)
The Capability WMS 1.3.0 struct.
std::vector< std::string > m_formats
virtual Layer parseLayers(const std::unique_ptr< te::xml::Reader > &reader)
virtual OnlineResource parseOnlineResource(const std::unique_ptr< te::xml::Reader > &reader)
std::vector< Dimension > m_dimensions
te::da::DataSourceCapabilities capabilities
std::vector< std::string > m_allowedValues
virtual StyleSheetURL parseStyleSheetURL(const std::unique_ptr< te::xml::Reader > &reader)
std::vector< Style > m_styles
The Dimension WMS 1.3.0 struct.
The Operation WMS 1.3.0 struct.
virtual WMSCapabilities parseCapabilities(const std::string &xmlPath)
Method responsible to parse a WMS XML GetCapabilities file and create an WMSCapabilities instance wit...
The Layer WMS 1.3.0 struct.
virtual LegendURL parseLegendURL(const std::unique_ptr< te::xml::Reader > &reader)
virtual StyleURL parseStyleURL(const std::unique_ptr< te::xml::Reader > &reader)
The OnlineResource WMS 1.3.0 struct.
Base exception class for WS Core Runtime Library.
The LegendURL WMS 1.3.0 struct.
The Style WMS 1.3.0 struct.
double m_northBoundLatitude
OnlineResource m_onlineResource
virtual Dimension parseDimension(const std::unique_ptr< te::xml::Reader > &reader)
double m_minScaleDenominator
The Request WMS 1.3.0 struct.
Operation m_getFeatureInfo
std::vector< std::string > m_keywordList
Operation m_getCapabilities
double m_maxScaleDenominator
The StyleSheeetURL WMS 1.3.0 struct.
double m_eastBoundLongitude
virtual Capability parseCapability(const std::unique_ptr< te::xml::Reader > &reader)
virtual Operation parseOperation(const std::unique_ptr< te::xml::Reader > &reader, const std::string &operationName)
Exception to be used when a XML has an unsupported version by XMLParser.
GeographicBoundingBox m_geoBoundingBox
The GeographicBoundingBox WMS 1.3.0 struct.
unsigned int m_fixedHeight
std::vector< HTTP > m_dcps
The StyleURL WMS 1.3.0 struct.
std::vector< BoundingBox > m_boundingBoxes
The BoundingBox WMS 1.3.0 struct.