Пример #1
0
ustring resource_url_get(const ustring& url, const ustring& templatefile)
/*
 Some urls are given as full ones, e.g. http://bibledit.org.
 These don't need any modification.
 Other urls are given as plain filenames only. It is assumed for these that 
 they are given relative to the resource directory where these reside. 
 These need to be modified so as to include the full path and the file:// prefix.
 */
{
  ustring modified_url(url);
  if (url.find ("http") != 0) {
    ustring path = gw_path_get_dirname(templatefile);
    modified_url = resource_file_prefix();
    modified_url.append(gw_build_filename(path, url));
  }
  return modified_url;
}
Пример #2
0
    QUrl MapAdapterWMS::tileQuery(const int& x, const int& y, const int& controller_zoom) const
    {
        // Get the url's query details.
        QUrlQuery url_query(getBaseUrl());

        // Calculate the number of coordinates per tile.
        const int coord_per_tile_x = 360.0 / projection::get().tilesX(controller_zoom);
        const int coord_per_tile_y = 180.0 / projection::get().tilesY(controller_zoom);

        // Set BBOX (x1,y1,x2,y2).
        url_query.removeQueryItem("BBOX");
        url_query.addQueryItem("BBOX", getBBox(-180 + x * coord_per_tile_x,
                                            90 - (y + 1) * coord_per_tile_y,
                                            (-180 + x * coord_per_tile_x) + coord_per_tile_x,
                                            (90 - (y + 1) * coord_per_tile_y) + coord_per_tile_y));

        // Create a new url with the modified url query.
        QUrl modified_url(getBaseUrl());
        modified_url.setQuery(url_query);

        // Return the modified url.
        return QUrl(modified_url);
    }
Пример #3
0
    void MapAdapterWMS::setBaseUrl(const QUrl& base_url)
    {
        // Get the url's query details.
        QUrlQuery url_query(base_url);

        // Enforce SERVICE (WMS).
        url_query.removeQueryItem("SERVICE");
        url_query.addQueryItem("SERVICE", "WMS");

        // Enforce REQUEST (GetMap).
        url_query.removeQueryItem("REQUEST");
        url_query.addQueryItem("REQUEST", "GetMap");

        // Enforce TILED (TRUE).
        url_query.removeQueryItem("TILED");
        url_query.addQueryItem("TILED", "TRUE");

        // Enforce WIDTH (the tile size).
        url_query.removeQueryItem("WIDTH");
        url_query.addQueryItem("WIDTH", QString::number(ImageManager::get().tileSizePx()));

        // Enforce HEIGHT (the tile size).
        url_query.removeQueryItem("HEIGHT");
        url_query.addQueryItem("HEIGHT", QString::number(ImageManager::get().tileSizePx()));

        // Is VERSION specified?
        if(url_query.hasQueryItem("VERSION") == false)
        {
            // Set the default version (1.1.1).
            /// @todo default to 1.3.0 instead?
            url_query.addQueryItem("VERSION", "1.1.1");
        }

        // Is TRANSPARENT specified?
        if(url_query.hasQueryItem("TRANSPARENT") == false)
        {
            // Set the default transparent (true).
            url_query.addQueryItem("TRANSPARENT", "TRUE");
        }

        // Is LAYERS specified?
        //if(url_query.hasQueryItem("LAYERS") == false)
        //{
        //    // Set the default layers (TBD).
        //    url_query.addQueryItem("LAYERS", TBD);
        //}

        // Is SRS or CRS specified?
        if(url_query.hasQueryItem("SRS") == false &&
                url_query.hasQueryItem("CRS") == false)
        {
            // Set the default srs (projection system value).
            url_query.addQueryItem("SRS", QString("EPSG:") + QString::number(projection::get().epsg()));
            url_query.addQueryItem("CRS", QString("EPSG:") + QString::number(projection::get().epsg()));

            //url_query.addQueryItem("SRS", "EPSG:4326"); // Equirectangular projection (lat/long)
            //url_query.addQueryItem("SRS", "EPSG:900913"); // Google Mercator projection
            //url_query.addQueryItem("SRS", "EPSG:3857"); // Spherical Mercator projection
        }

        // Is STYLES specified?
        if(url_query.hasQueryItem("STYLES") == false)
        {
            // Set the default styles (blank).
            url_query.addQueryItem("STYLES", QString());
        }

        // Is FORMAT specified?
        if(url_query.hasQueryItem("FORMAT") == false)
        {
            // Set the default format (png).
            url_query.addQueryItem("FORMAT", "IMAGE/PNG");
        }

        // Remove BBOX (is added at time of actually query).
        url_query.removeQueryItem("BBOX");

        // Create a new url with the modified url query.
        QUrl modified_url(base_url);
        modified_url.setQuery(url_query);

        // Quick check that the url has a path.
        if(modified_url.path().isEmpty())
        {
            // Set a default path (/wms/).
            modified_url.setPath("/wms/");
        }

        // Set the url path.
        MapAdapter::setBaseUrl(modified_url);
    }