1 <?php
2 /**
3 * @package Joomla.Platform
4 * @subpackage Openstreetmap
5 *
6 * @copyright Copyright (C) 2005 - 2017 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 * @since 13.1
16 * @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer instead
17 */
18 class JOpenstreetmapGps extends JOpenstreetmapObject
19 {
20 /**
21 * Method to retrieve GPS points
22 *
23 * @param float $left Left boundary
24 * @param float $bottom Bottom boundary
25 * @param float $right Right boundary
26 * @param float $top Top boundary
27 * @param integer $page Page number
28 *
29 * @return array The XML response containing GPS points
30 *
31 * @since 13.1
32 */
33 public function retrieveGps($left, $bottom, $right, $top, $page = 0)
34 {
35 // Set the API base
36 $base = 'trackpoints?bbox=' . $left . ',' . $bottom . ',' . $right . ',' . $top . '&page=' . $page;
37
38 // Build the request path.
39 $path = $this->getOption('api.url') . $base;
40
41 // Send the request.
42 $response = $this->oauth->oauthRequest($path, 'GET', array());
43
44 $xml_string = simplexml_load_string($response->body);
45
46 return $xml_string;
47 }
48
49 /**
50 * Method to upload GPS Traces
51 *
52 * @param string $file File name that contains trace points
53 * @param string $description Description on trace points
54 * @param string $tags Tags for trace
55 * @param integer $public 1 for public, 0 for private
56 * @param string $visibility One of the following: private, public, trackable, identifiable
57 * @param string $username Username
58 * @param string $password Password
59 *
60 * @return JHttpResponse The response
61 *
62 * @since 13.1
63 */
64 public function uploadTrace($file, $description, $tags, $public, $visibility, $username, $password)
65 {
66 // Set parameters.
67 $parameters = array(
68 'file' => $file,
69 'description' => $description,
70 'tags' => $tags,
71 'public' => $public,
72 'visibility' => $visibility,
73 );
74
75 // Set the API base
76 $base = 'gpx/create';
77
78 // Build the request path.
79 $path = $this->getOption('api.url') . $base;
80
81 $header['Content-Type'] = 'multipart/form-data';
82
83 $header = array_merge($header, $parameters);
84 $header = array_merge($header, array('Authorization' => 'Basic ' . base64_encode($username . ':' . $password)));
85
86 // Send the request.
87 $response = $this->sendRequest($path, 'POST', $header, array());
88
89 return $response;
90 }
91
92 /**
93 * Method to download Trace details
94 *
95 * @param integer $id Trace identifier
96 * @param string $username Username
97 * @param string $password Password
98 *
99 * @return array The XML response
100 *
101 * @since 13.1
102 */
103 public function downloadTraceMetadetails($id, $username, $password)
104 {
105 // Set the API base
106 $base = 'gpx/' . $id . '/details';
107
108 // Build the request path.
109 $path = $this->getOption('api.url') . $base;
110
111 // Send the request.
112 $xml_string = $this->sendRequest($path, 'GET', array('Authorization' => 'Basic ' . base64_encode($username . ':' . $password)));
113
114 return $xml_string;
115 }
116
117 /**
118 * Method to download Trace data
119 *
120 * @param integer $id Trace identifier
121 * @param string $username Username
122 * @param string $password Password
123 *
124 * @return array The XML response
125 *
126 * @since 13.1
127 */
128 public function downloadTraceMetadata($id, $username, $password)
129 {
130 // Set the API base
131 $base = 'gpx/' . $id . '/data';
132
133 // Build the request path.
134 $path = $this->getOption('api.url') . $base;
135
136 // Send the request.
137 $xml_string = $this->sendRequest($path, 'GET', array('Authorization' => 'Basic ' . base64_encode($username . ':' . $password)));
138
139 return $xml_string;
140 }
141 }
142