public static function fromXmlObj(SimpleXMLElement $xmlObj) { $way = new OSM_Objects_Way(); $processedElements = $way->_fromXmlObj($xmlObj); foreach ($xmlObj->children() as $child) { if (in_array($child->getName(), $processedElements)) { continue; } //OSM_ZLog::debug(__METHOD__, 'Found child: ', $child->getName()); switch ($child->getName()) { case self::OBJTYPE_ND: $way->addNodeRef((string) $child['ref']); break; default: throw new OSM_Exception('Object "' . $xmlObj->getName() . '" is not supported in relation'); } } $way->setDirty(false); return $way; }
/** * Return all way's nodes coordinates * @return array */ public function &getWayNodesCoordinates(OSM_Objects_Way $way) { $coords = array(); $nodesRef = $way->getNodesRefs(); $n = count($nodesRef); for ($i = 0; $i < $n; $i++) { $node = $this->getNode($nodesRef[$i]); $coords[] = array($node->getLon(), $node->getLat()); } return $coords; }
/** * * @param OSM_Objects_Way $way * @param type $role * @return OSM_Objects_Relation Fluent interface */ public function addWay(OSM_Objects_Way $way, $role = '') { $member = new OSM_Objects_Member(OSM_Api::OBJTYPE_WAY, $way->getId(), $role); $this->addMember($member); return $this; }