URL WMSLayer::getFeatureInfoURL(const Geodetic2D& position, const Sector& tileSector) const { if (!_sector.touchesWith(tileSector)) { return URL::nullURL(); } const Sector sector = tileSector.intersection(_sector); //Server name std::string req = _queryServerURL.getPath(); if (req[req.size()-1] != '?') { req += '?'; } //If the server refer to itself as localhost... int pos = req.find("localhost"); if (pos != -1) { req = req.substr(pos+9); int pos2 = req.find("/", 8); std::string newHost = req.substr(0, pos2); req = newHost + req; } req += "REQUEST=GetFeatureInfo&SERVICE=WMS"; //SRS if (_srs != "") { req += "&SRS=" + _srs; } else { req += "&SRS=EPSG:4326"; } switch (_queryServerVersion) { case WMS_1_3_0: { req += "&VERSION=1.3.0"; IStringBuilder* isb = IStringBuilder::newStringBuilder(); isb->addString("&WIDTH="); isb->addInt(_parameters->_tileTextureResolution._x); isb->addString("&HEIGHT="); isb->addInt(_parameters->_tileTextureResolution._y); isb->addString("&BBOX="); isb->addDouble( toBBOXLatitude( sector._lower._latitude ) ); isb->addString(","); isb->addDouble( toBBOXLongitude( sector._lower._longitude ) ); isb->addString(","); isb->addDouble( toBBOXLatitude( sector._upper._latitude ) ); isb->addString(","); isb->addDouble( toBBOXLongitude( sector._upper._longitude ) ); req += isb->getString(); delete isb; req += "&CRS=EPSG:4326"; break; } case WMS_1_1_0: default: { // default is 1.1.1 req += "&VERSION=1.1.1"; IStringBuilder* isb = IStringBuilder::newStringBuilder(); isb->addString("&WIDTH="); isb->addInt(_parameters->_tileTextureResolution._x); isb->addString("&HEIGHT="); isb->addInt(_parameters->_tileTextureResolution._y); isb->addString("&BBOX="); isb->addDouble( toBBOXLongitude( sector._lower._longitude ) ); isb->addString(","); isb->addDouble( toBBOXLatitude( sector._lower._latitude ) ); isb->addString(","); isb->addDouble( toBBOXLongitude( sector._upper._longitude ) ); isb->addString(","); isb->addDouble( toBBOXLatitude( sector._upper._latitude ) ); req += isb->getString(); delete isb; break; } } req += "&LAYERS=" + _queryLayer; req += "&QUERY_LAYERS=" + _queryLayer; req += "&INFO_FORMAT=text/plain"; const IMathUtils* mu = IMathUtils::instance(); double u; double v; if (_parameters->_mercator) { u = sector.getUCoordinate(position._longitude); v = MercatorUtils::getMercatorV(position._latitude); } else { const Vector2D uv = sector.getUVCoordinates(position); u = uv._x; v = uv._y; } //X and Y //const Vector2D uv = sector.getUVCoordinates(position); const long long x = mu->round( (u * _parameters->_tileTextureResolution._x) ); const long long y = mu->round( (v * _parameters->_tileTextureResolution._y) ); IStringBuilder* isb = IStringBuilder::newStringBuilder(); isb->addString("&X="); isb->addLong(x); isb->addString("&Y="); isb->addLong(y); req += isb->getString(); delete isb; return URL(req, false); }