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); }
std::vector<Petition*> WMSLayer::createTileMapPetitions(const G3MRenderContext* rc, const Tile* tile) const { std::vector<Petition*> petitions; const Sector tileSector = tile->getSector(); if (!_sector.touchesWith(tileSector)) { return petitions; } const Sector sector = tileSector.intersection(_sector); if (sector._deltaLatitude.isZero() || sector._deltaLongitude.isZero() ) { return petitions; } //TODO: MUST SCALE WIDTH,HEIGHT const Vector2I tileTextureResolution = _parameters->_tileTextureResolution; //Server name std::string req = _mapServerURL.getPath(); if (req[req.size() - 1] != '?') { req += '?'; } // //If the server refer to itself as localhost... // const int localhostPos = req.find("localhost"); // if (localhostPos != -1) { // req = req.substr(localhostPos+9); // // const int slashPos = req.find("/", 8); // std::string newHost = req.substr(0, slashPos); // // req = newHost + req; // } req += "REQUEST=GetMap&SERVICE=WMS"; switch (_mapServerVersion) { case WMS_1_3_0: { req += "&VERSION=1.3.0"; IStringBuilder* isb = IStringBuilder::newStringBuilder(); isb->addString("&WIDTH="); isb->addInt(tileTextureResolution._x); isb->addString("&HEIGHT="); isb->addInt(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(tileTextureResolution._x); isb->addString("&HEIGHT="); isb->addInt(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=" + _mapLayer; req += "&FORMAT=" + _format; if (_srs != "") { req += "&SRS=" + _srs; } else { req += "&SRS=EPSG:4326"; } //Style if (_style != "") { req += "&STYLES=" + _style; } else { req += "&STYLES="; } //ASKING TRANSPARENCY if (_isTransparent) { req += "&TRANSPARENT=TRUE"; } else { req += "&TRANSPARENT=FALSE"; } if (_extraParameter.compare("") != 0) { req += "&"; req += _extraParameter; } // printf("Request: %s\n", req.c_str()); Petition *petition = new Petition(sector, URL(req, false), getTimeToCache(), getReadExpired(), _isTransparent); petitions.push_back(petition); return petitions; }
std::vector<Petition*> GoogleMapsLayer::createTileMapPetitions(const G3MRenderContext* rc, const Tile* tile) const { std::vector<Petition*> petitions; const Sector tileSector = tile->getSector(); if (!_sector.touchesWith(tileSector)) { return petitions; } const Sector sector = tileSector.intersection(_sector); if (sector._deltaLatitude.isZero() || sector._deltaLongitude.isZero() ) { return petitions; } IStringBuilder* isb = IStringBuilder::newStringBuilder(); // http://maps.googleapis.com/maps/api/staticmap?center=New+York,NY&zoom=13&size=600x300&key=AIzaSyC9pospBjqsfpb0Y9N3E3uNMD8ELoQVOrc&sensor=false /* http://maps.googleapis.com/maps/api/staticmap ?center=New+York,NY &zoom=13 &size=600x300 &key=AIzaSyC9pospBjqsfpb0Y9N3E3uNMD8ELoQVOrc &sensor=false */ isb->addString("http://maps.googleapis.com/maps/api/staticmap?sensor=false"); isb->addString("¢er="); isb->addDouble(tileSector._center._latitude._degrees); isb->addString(","); isb->addDouble(tileSector._center._longitude._degrees); const int level = tile->getLevel(); isb->addString("&zoom="); isb->addInt(level); isb->addString("&size="); isb->addInt(_parameters->_tileTextureResolution._x); isb->addString("x"); isb->addInt(_parameters->_tileTextureResolution._y); isb->addString("&format=jpg"); // isb->addString("&maptype=roadmap); // isb->addString("&maptype=satellite"); isb->addString("&maptype=hybrid"); // isb->addString("&maptype=terrain"); isb->addString("&key="); isb->addString(_key); const std::string path = isb->getString(); delete isb; petitions.push_back( new Petition(tileSector, URL(path, false), getTimeToCache(), getReadExpired(), true) ); return petitions; }