10 defined(
'JPATH_PLATFORM') or die();
30 public function createChangeset($changesets=array())
32 $token = $this->oauth->getToken();
36 'oauth_token' => $token[
'key'],
37 'oauth_token_secret' => $token[
'secret']
41 $base =
'changeset/create';
44 $path = $this->getOption(
'api.url') . $base;
46 $xml =
'<?xml version="1.0" encoding="UTF-8"?>
47 <osm version="0.6" generator="JOpenstreetmap">';
49 if (!empty($changesets))
52 foreach ($changesets as $tags)
54 $xml .=
'<changeset>';
59 foreach ($tags as $key => $value)
61 $xml .=
'<tag k="' . $key .
'" v="' . $value .
'"/>';
65 $xml .=
'</changeset>';
71 $header[
'Content-Type'] =
'text/xml';
74 $response = $this->oauth->oauthRequest($path,
'PUT', $parameters, $xml, $header);
76 return $response->body;
88 public function readChangeset($id)
91 $base =
'changeset/' . $id;
94 $path = $this->getOption(
'api.url') . $base;
97 $xml_string = $this->sendRequest($path);
99 return $xml_string->changeset;
112 public function updateChangeset($id, $tags = array())
114 $token = $this->oauth->getToken();
118 'oauth_token' => $token[
'key']
122 $base =
'changeset/' . $id;
125 $path = $this->getOption(
'api.url') . $base;
132 foreach ($tags as $key => $value)
134 $tag_list .=
'<tag k="' . $key .
'" v="' . $value .
'"/>';
138 $xml =
'<?xml version="1.0" encoding="UTF-8"?>
139 <osm version="0.6" generator="JOpenstreetmap">
145 $header[
'Content-Type'] =
'text/xml';
148 $response = $this->oauth->oauthRequest($path,
'PUT', $parameters, $xml, $header);
150 $xml_string = simplexml_load_string($response->body);
152 return $xml_string->changeset;
164 public function closeChangeset($id)
166 $token = $this->oauth->getToken();
170 'oauth_token' => $token[
'key']
174 $base =
'changeset/' . $id .
'/close';
177 $path = $this->getOption(
'api.url') . $base;
179 $header[
'format'] =
'text/xml';
182 $this->oauth->oauthRequest($path,
'PUT', $parameters, $header);
194 public function downloadChangeset($id)
197 $base =
'changeset/' . $id .
'/download';
200 $path = $this->getOption(
'api.url') . $base;
203 $xml_string = $this->sendRequest($path);
205 return $xml_string->create;
218 public function expandBBoxChangeset($id, $nodes)
220 $token = $this->oauth->getToken();
224 'oauth_token' => $token[
'key']
228 $base =
'changeset/' . $id .
'/expand_bbox';
231 $path = $this->getOption(
'api.url') . $base;
238 foreach ($nodes as $node)
240 $node_list .=
'<node lat="' . $node[0] .
'" lon="' . $node[1] .
'"/>';
244 $xml =
'<?xml version="1.0" encoding="UTF-8"?>
245 <osm version="0.6" generator="JOpenstreetmap">
251 $header[
'Content-Type'] =
'text/xml';
254 $response = $this->oauth->oauthRequest($path,
'POST', $parameters, $xml, $header);
256 $xml_string = simplexml_load_string($response->body);
258 return $xml_string->changeset;
270 public function queryChangeset($param)
273 $base =
'changesets/' . $param;
276 $path = $this->getOption(
'api.url') . $base;
279 $xml_string = $this->sendRequest($path);
281 return $xml_string->osm;
294 public function diffUploadChangeset($xml, $id)
296 $token = $this->oauth->getToken();
300 'oauth_token' => $token[
'key']
304 $base =
'changeset/' . $id .
'/upload';
307 $path = $this->getOption(
'api.url') . $base;
309 $header[
'Content-Type'] =
'text/xml';
312 $response = $this->oauth->oauthRequest($path,
'POST', $parameters, $xml, $header);
314 $xml_string = simplexml_load_string($response->body);
316 return $xml_string->diffResult;