Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
gps.php
Aller à la documentation de ce fichier.
1 <?php
2 /**
3  * @package Joomla.Platform
4  * @subpackage Openstreetmap
5  *
6  * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
7  * @license GNU General Public License version 2 or later; see LICENSE
8  */
9 
10 defined('JPATH_PLATFORM') or die();
11 
12 /**
13  * Openstreetmap API GPS class for the Joomla Platform
14  *
15  * @package Joomla.Platform
16  * @subpackage Openstreetmap
17  * @since 13.1
18  */
20 {
21  /**
22  * Method to retrieve GPS points
23  *
24  * @param float $left Left boundary
25  * @param float $bottom Bottom boundary
26  * @param float $right Right boundary
27  * @param float $top Top boundary
28  * @param integer $page Page number
29  *
30  * @return array The XML response containing GPS points
31  *
32  * @since 13.1
33  */
34  public function retrieveGps($left, $bottom, $right, $top, $page = 0)
35  {
36  // Set the API base
37  $base = 'trackpoints?bbox=' . $left . ',' . $bottom . ',' . $right . ',' . $top . '&page=' . $page;
38 
39  // Build the request path.
40  $path = $this->getOption('api.url') . $base;
41 
42  // Send the request.
43  $response = $this->oauth->oauthRequest($path, 'GET', array());
44 
45  $xml_string = simplexml_load_string($response->body);
46 
47  return $xml_string;
48  }
49 
50  /**
51  * Method to upload GPS Traces
52  *
53  * @param string $file File name that contains trace points
54  * @param string $description Description on trace points
55  * @param string $tags Tags for trace
56  * @param integer $public 1 for public, 0 for private
57  * @param string $visibility One of the following: private, public, trackable, identifiable
58  * @param string $username Username
59  * @param string $password Password
60  *
61  * @return JHttpResponse The response
62  *
63  * @since 13.1
64  */
65  public function uploadTrace($file, $description, $tags, $public, $visibility, $username, $password)
66  {
67  // Set parameters.
68  $parameters = array(
69  'file' => $file,
70  'description' => $description,
71  'tags' => $tags,
72  'public' => $public,
73  'visibility' => $visibility
74  );
75 
76  // Set the API base
77  $base = 'gpx/create';
78 
79  // Build the request path.
80  $path = $this->getOption('api.url') . $base;
81 
82  $header['Content-Type'] = 'multipart/form-data';
83 
84  $header = array_merge($header, $parameters);
85  $header = array_merge($header, array('Authorization' => 'Basic ' . base64_encode($username . ':' . $password)));
86 
87  // Send the request.
88  $response = $this->sendRequest($path, 'POST', $header, array());
89 
90  return $response;
91  }
92 
93  /**
94  * Method to download Trace details
95  *
96  * @param integer $id Trace identifier
97  * @param string $username Username
98  * @param string $password Password
99  *
100  * @return array The XML response
101  *
102  * @since 13.1
103  */
104  public function downloadTraceMetadetails($id, $username, $password)
105  {
106  // Set the API base
107  $base = 'gpx/' . $id . '/details';
108 
109  // Build the request path.
110  $path = $this->getOption('api.url') . $base;
111 
112  // Send the request.
113  $xml_string = $this->sendRequest($path, 'GET', array('Authorization' => 'Basic ' . base64_encode($username . ':' . $password)));
114 
115  return $xml_string;
116  }
117 
118  /**
119  * Method to download Trace data
120  *
121  * @param integer $id Trace identifier
122  * @param string $username Username
123  * @param string $password Password
124  *
125  * @return array The XML response
126  *
127  * @since 13.1
128  */
129  public function downloadTraceMetadata($id, $username, $password)
130  {
131  // Set the API base
132  $base = 'gpx/' . $id . '/data';
133 
134  // Build the request path.
135  $path = $this->getOption('api.url') . $base;
136 
137  // Send the request.
138  $xml_string = $this->sendRequest($path, 'GET', array('Authorization' => 'Basic ' . base64_encode($username . ':' . $password)));
139 
140  return $xml_string;
141  }
142 }