Source for file elements.php
Documentation is available at elements.php
* @package Joomla.Platform
* @subpackage Openstreetmap
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
defined('JPATH_PLATFORM') or die();
* Openstreetmap API Elements class for the Joomla Platform
* @package Joomla.Platform
* @subpackage Openstreetmap
* Method to create a node
* @param integer $changeset Changeset id
* @param float $latitude Latitude of the node
* @param float $longitude Longitude of the node
* @param arary $tags Array of tags for a node
* @return array The XML response
public function createNode($changeset, $latitude, $longitude, $tags)
$token =
$this->oauth->getToken();
'oauth_token' =>
$token['key']
// Build the request path.
foreach ($tags as $key =>
$value)
$tag_list .=
'<tag k="' .
$key .
'" v="' .
$value .
'"/>';
$xml =
'<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="JOpenstreetmap">
<node changeset="' .
$changeset .
'" lat="' .
$latitude .
'" lon="' .
$longitude .
'">'
$header['Content-Type'] =
'text/xml';
$response =
$this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header);
* @param integer $changeset Changeset id
* @param array $tags Array of tags for a way
* @param array $nds Node ids to refer
* @return array The XML response
public function createWay($changeset, $tags, $nds)
$token =
$this->oauth->getToken();
'oauth_token' =>
$token['key']
// Build the request path.
foreach ($tags as $key =>
$value)
$tag_list .=
'<tag k="' .
$key .
'" v="' .
$value .
'"/>';
$nd_list .=
'<nd ref="' .
$value .
'"/>';
$xml =
'<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="JOpenstreetmap">
<way changeset="' .
$changeset .
'">'
$header['Content-Type'] =
'text/xml';
$response =
$this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header);
* Method to create a relation
* @param integer $changeset Changeset id
* @param array $tags Array of tags for a relation
* @param array $members Array of members for a relation
* eg: $members = array(array("type"=>"node", "role"=>"stop", "ref"=>"123"), array("type"=>"way", "ref"=>"123"))
* @return array The XML response
$token =
$this->oauth->getToken();
'oauth_token' =>
$token['key']
$base =
'relation/create';
// Build the request path.
foreach ($tags as $key =>
$value)
$tag_list .=
'<tag k="' .
$key .
'" v="' .
$value .
'"/>';
foreach ($members as $member)
if ($member['type'] ==
"node")
$member_list .=
'<member type="' .
$member['type'] .
'" role="' .
$member['role'] .
'" ref="' .
$member['ref'] .
'"/>';
elseif ($member['type'] ==
"way")
$member_list .=
'<member type="' .
$member['type'] .
'" ref="' .
$member['ref'] .
'"/>';
$xml =
'<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="JOpenstreetmap">
<relation relation="' .
$changeset .
'" >'
$header['Content-Type'] =
'text/xml';
$response =
$this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header);
* Method to read an element [node|way|relation]
* @param string $element [node|way|relation]
* @param integer $id Element identifier
* @return array The XML response
* @throws DomainException
if ($element !=
'node' &&
$element !=
'way' &&
$element !=
'relation')
throw
new DomainException("Element should be a node, a way or a relation");
$base =
$element .
'/' .
$id;
// Build the request path.
return $xml_string->$element;
* Method to update an Element [node|way|relation]
* @param string $element [node|way|relation]
* @param string $xml Full reperentation of the element with a version number
* @param integer $id Element identifier
* @return array The xml response
* @throws DomainException
if ($element !=
'node' &&
$element !=
'way' &&
$element !=
'relation')
throw
new DomainException("Element should be a node, a way or a relation");
$token =
$this->oauth->getToken();
'oauth_token' =>
$token['key']
$base =
$element .
'/' .
$id;
// Build the request path.
$header['Content-Type'] =
'text/xml';
$response =
$this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header);
* Method to delete an element [node|way|relation]
* @param string $element [node|way|relation]
* @param integer $id Element identifier
* @param integer $version Element version
* @param integer $changeset Changeset identifier
* @param float $latitude Latitude of the element
* @param float $longitude Longitude of the element
* @return array The XML response
* @throws DomainException
public function deleteElement($element, $id, $version, $changeset, $latitude =
null, $longitude =
null)
if ($element !=
'node' &&
$element !=
'way' &&
$element !=
'relation')
throw
new DomainException("Element should be a node, a way or a relation");
$token =
$this->oauth->getToken();
'oauth_token' =>
$token['key']
$base =
$element .
'/' .
$id;
// Build the request path.
$xml =
'<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="JOpenstreetmap">
<' .
$element .
' id="' .
$id .
'" version="' .
$version .
'" changeset="' .
$changeset .
'"';
if (!empty($latitude) &&
!empty($longitude))
$xml .=
' lat="' .
$latitude .
'" lon="' .
$longitude .
'"';
$header['Content-Type'] =
'text/xml';
$response =
$this->oauth->oauthRequest($path, 'DELETE', $parameters, $xml, $header);
* Method to get history of an element [node|way|relation]
* @param string $element [node|way|relation]
* @param integer $id Element identifier
* @return array The XML response
* @throws DomainException
if ($element !=
'node' &&
$element !=
'way' &&
$element !=
'relation')
throw
new DomainException("Element should be a node, a way or a relation");
$base =
$element .
'/' .
$id .
'/history';
// Build the request path.
return $xml_string->$element;
* Method to get details about a version of an element [node|way|relation]
* @param string $element [node|way|relation]
* @param integer $id Element identifier
* @param integer $version Element version
* @return array The XML response
* @throws DomainException
if ($element !=
'node' &&
$element !=
'way' &&
$element !=
'relation')
throw
new DomainException("Element should be a node, a way or a relation");
$base =
$element .
'/' .
$id .
'/' .
$version;
// Build the request path.
return $xml_string->$element;
* Method to get data about multiple ids of an element [node|way|relation]
* @param string $element [nodes|ways|relations] - use plural word
* @param string $params Comma separated list of ids belonging to type $element
* @return array The XML response
* @throws DomainException
if ($element !=
'nodes' &&
$element !=
'ways' &&
$element !=
'relations')
throw
new DomainException("Element should be nodes, ways or relations");
$single_element =
substr($element, 0, strlen($element) -
1);
// Set the API base, $params is a string with comma seperated values
$base =
$element .
'?' .
$element .
"=" .
$params;
// Build the request path.
return $xml_string->$single_element;
* Method to get relations for an Element [node|way|relation]
* @param string $element [node|way|relation]
* @param integer $id Element identifier
* @return array The XML response
* @throws DomainException
if ($element !=
'node' &&
$element !=
'way' &&
$element !=
'relation')
throw
new DomainException("Element should be a node, a way or a relation");
$base =
$element .
'/' .
$id .
'/relations';
// Build the request path.
return $xml_string->$element;
* Method to get ways for a Node element
* @param integer $id Node identifier
* @return array The XML response
$base =
'node/' .
$id .
'/ways';
// Build the request path.
* Method to get full information about an element [way|relation]
* @param string $element [way|relation]
* @param integer $id Identifier
* @return array The XML response
* @throws DomainException
if ($element !=
'way' &&
$element !=
'relation')
throw
new DomainException("Element should be a way or a relation");
$base =
$element .
'/' .
$id .
'/full';
// Build the request path.
return $xml_string->node;
* Method used by the DWG to hide old versions of elements containing data privacy or copyright infringements
* @param string $element [node|way|relation]
* @param integer $id Element identifier
* @param integer $version Element version
* @param integer $redaction_id Redaction id
* @return array The xml response
* @throws DomainException
public function redaction($element, $id, $version, $redaction_id)
if ($element !=
'node' &&
$element !=
'way' &&
$element !=
'relation')
throw
new DomainException("Element should be a node, a way or a relation");
$token =
$this->oauth->getToken();
'oauth_token' =>
$token['key']
$base =
$element .
'/' .
$id .
'/' .
$version .
'/redact?redaction=' .
$redaction_id;
// Build the request path.
$response =
$this->oauth->oauthRequest($path, 'PUT', $parameters);
Documentation generated on Tue, 19 Nov 2013 15:02:24 +0100 by phpDocumentor 1.4.3