1 : <?php
2 : /**
3 : * Relation.php
4 : * 25-Apr-2011
5 : *
6 : * PHP Version 5
7 : *
8 : * @category Services
9 : * @package Services_OpenStreetMap
10 : * @author Ken Guest <kguest@php.net>
11 : * @license BSD http://www.opensource.org/licenses/bsd-license.php
12 : * @version Release: @package_version@
13 : * @link Relation.php
14 : */
15 :
16 : /**
17 : * Services_OpenStreetMap_Relation
18 : *
19 : * @category Services
20 : * @package Services_OpenStreetMap
21 : * @author Ken Guest <kguest@php.net>
22 : * @license BSD http://www.opensource.org/licenses/bsd-license.php
23 : * @link Relation.php
24 : */
25 : class Services_OpenStreetMap_Relation extends Services_OpenStreetMap_Object
26 : {
27 : protected $type = 'relation';
28 :
29 : protected $members = array();
30 :
31 : /**
32 : * Return all members of the relation.
33 : *
34 : * @return void
35 : */
36 : public function getMembers()
37 : {
38 0 : return $this->members;
39 : }
40 :
41 : /**
42 : * type
43 : *
44 : * @return string
45 : */
46 : public function getType()
47 : {
48 1 : return $this->type;
49 : }
50 :
51 : /**
52 : * addMember
53 : *
54 : * @todo add member to relation
55 : * @return void
56 : */
57 : public function addMember()
58 : {
59 0 : }
60 :
61 : /**
62 : * remove a member from the relation.
63 : *
64 : * @todo remove member from relation
65 : * @return void
66 : */
67 : public function removeMember()
68 : {
69 0 : }
70 :
71 : /**
72 : * setXml
73 : *
74 : * @param SimpleXMLElement $xml OSM XML
75 : *
76 : * @return Services_OpenStreetMap_Relation
77 : */
78 : public function setXml(SimpleXMLElement $xml)
79 : {
80 1 : $this->xml = $xml->saveXML();
81 1 : $obj = $xml->xpath('//' . $this->getType());
82 1 : foreach ($obj[0]->children() as $child) {
83 1 : $childname = $child->getName();
84 1 : if ($childname == 'tag') {
85 1 : $key = (string) $child->attributes()->k;
86 1 : if ($key != '') {
87 1 : $this->tags[$key] = (string) $child->attributes()->v;
88 1 : }
89 1 : } elseif ($childname == 'member') {
90 1 : $this->members[] = array(
91 1 : 'type'=> (string) $child->attributes()->type,
92 1 : 'ref'=> (string) $child->attributes()->ref,
93 1 : 'role'=> (string) $child->attributes()->role,
94 : );
95 :
96 1 : }
97 1 : }
98 1 : $this->obj = $obj;
99 1 : return $this;
100 : }
101 : }
102 : // vim:set et ts=4 sw=4:
103 : ?>
|