1 : /******************************************************************************
2 : * $Id: minidriver_worldwind.cpp 18020 2009-11-14 14:33:20Z rouault $
3 : *
4 : * Project: WMS Client Driver
5 : * Purpose: Implementation of Dataset and RasterBand classes for WMS
6 : * and other similar services.
7 : * Author: Adam Nowacki, nowak@xpam.de
8 : *
9 : ******************************************************************************
10 : * Copyright (c) 2007, Adam Nowacki
11 : *
12 : * Permission is hereby granted, free of charge, to any person obtaining a
13 : * copy of this software and associated documentation files (the "Software"),
14 : * to deal in the Software without restriction, including without limitation
15 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 : * and/or sell copies of the Software, and to permit persons to whom the
17 : * Software is furnished to do so, subject to the following conditions:
18 : *
19 : * The above copyright notice and this permission notice shall be included
20 : * in all copies or substantial portions of the Software.
21 : *
22 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 : * DEALINGS IN THE SOFTWARE.
29 : ****************************************************************************/
30 :
31 : #include "stdinc.h"
32 :
33 1059 : CPP_GDALWMSMiniDriverFactory(WorldWind)
34 :
35 0 : GDALWMSMiniDriver_WorldWind::GDALWMSMiniDriver_WorldWind() {
36 0 : }
37 :
38 0 : GDALWMSMiniDriver_WorldWind::~GDALWMSMiniDriver_WorldWind() {
39 0 : }
40 :
41 0 : CPLErr GDALWMSMiniDriver_WorldWind::Initialize(CPLXMLNode *config) {
42 0 : CPLErr ret = CE_None;
43 :
44 0 : if (ret == CE_None) {
45 0 : const char *base_url = CPLGetXMLValue(config, "ServerURL", "");
46 0 : if (base_url[0] != '\0') {
47 : /* Try the old name */
48 0 : base_url = CPLGetXMLValue(config, "ServerUrl", "");
49 : }
50 0 : if (base_url[0] != '\0') {
51 0 : m_base_url = base_url;
52 : } else {
53 0 : CPLError(CE_Failure, CPLE_AppDefined, "GDALWMS, WorldWind mini-driver: ServerURL missing.");
54 0 : ret = CE_Failure;
55 : }
56 : }
57 :
58 0 : m_dataset = CPLGetXMLValue(config, "Layer", "");
59 0 : m_projection_wkt = ProjToWKT("EPSG:4326");
60 :
61 0 : return ret;
62 : }
63 :
64 0 : void GDALWMSMiniDriver_WorldWind::GetCapabilities(GDALWMSMiniDriverCapabilities *caps) {
65 0 : caps->m_capabilities_version = 1;
66 0 : caps->m_has_arb_overviews = 0;
67 0 : caps->m_has_image_request = 0;
68 0 : caps->m_has_tiled_image_requeset = 1;
69 0 : caps->m_max_overview_count = 32;
70 0 : }
71 :
72 0 : void GDALWMSMiniDriver_WorldWind::ImageRequest(CPLString *url, const GDALWMSImageRequestInfo &iri) {
73 0 : }
74 :
75 0 : void GDALWMSMiniDriver_WorldWind::TiledImageRequest(CPLString *url, const GDALWMSImageRequestInfo &iri, const GDALWMSTiledImageRequestInfo &tiri) {
76 0 : const GDALWMSDataWindow *data_window = m_parent_dataset->WMSGetDataWindow();
77 0 : int worldwind_y = static_cast<int>(floor(((data_window->m_y1 - data_window->m_y0) / (iri.m_y1 - iri.m_y0)) + 0.5)) - tiri.m_y - 1;
78 : // http://worldwind25.arc.nasa.gov/tile/tile.aspx?T=geocover2000&L=0&X=86&Y=39
79 0 : *url = m_base_url;
80 0 : URLAppendF(url, "&T=%s", m_dataset.c_str());
81 0 : URLAppendF(url, "&L=%d", tiri.m_level);
82 0 : URLAppendF(url, "&X=%d", tiri.m_x);
83 0 : URLAppendF(url, "&Y=%d", worldwind_y);
84 0 : }
85 :
86 0 : const char *GDALWMSMiniDriver_WorldWind::GetProjectionInWKT() {
87 0 : return m_projection_wkt.c_str();
88 : }
|