source: subversion/applications/rendering/wms/class.backend_osmxapi.php @ 9331

Last change on this file since 9331 was 9330, checked in by isortega, 11 years ago

WMS now features basic osmarender support (only z17), as well as more bugs.

File size: 2.0 KB
Line 
1<?php
2
3/// @author Iván Sánchez Ortega <ivan@sanchezortega.es>
4
5/**
6    OSM WMS ("OpenStreetMap Web Map Service")
7    Copyright (C) 2008, Iván Sánchez Ortega
8
9    This program is free software: you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation, either version 3 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21*/   
22
23/// Backend for using the OSM eXtended API to retrieve the data
24
25/// TODO: backend factory.
26
27class backend_osmxapi extends backend_api
28{
29
30//      const base_api_url = "http://www.informationfreeway.org";
31       
32        static $base_api_url = "http://osmxapi.hypercube.telascience.org";
33       
34       
35        /// Returns an URL to retrieve the data from. Might be a live HTTP URL, or a local temporary .osm file.
36        /// TODO: projection, projection, projection.
37        function data_url($bbox)
38        {
39
40                list($left,$bottom,$right,$top) = explode(',',$bbox);
41               
42                if ( !is_numeric($left) ||
43                     !is_numeric($bottom) ||
44                     !is_numeric($right) ||
45                     !is_numeric($top))
46                        trigger_error("Coordinates of the bounding box are not numbers!",E_USER_ERROR);
47               
48               
49                // The arbitrary limit of 2 degrees can be changed as desired.
50                if ( ($top-$bottom > 2) || ($right-$left > 2) )
51                        trigger_error("OSM eXtended API backend won't accept a request greater than 2 degrees (measured in latitude-longitude). Please request a smaller area.",E_USER_ERROR);
52               
53               
54                return self::$base_api_url . "/api/0.5/*[*=*][bbox=$left,$bottom,$right,$top]";
55        }
56       
57
58        /// get_data_as_osm uses the same code as the parent class (backend_api) - only the URL is different, and that's handled by data_url().
59}
60
61
62
63
Note: See TracBrowser for help on using the repository browser.