public static function fromXmlObj(SimpleXMLElement $xmlObj) { $node = new OSM_Objects_Node(); $processedElements = $node->_fromXmlObj($xmlObj); if (!array_key_exists('lat', $node->_attrs)) { throw new OSM_Exception(__CLASS__ . ' should have a "lat" attribute'); } if (!array_key_exists('lon', $node->_attrs)) { throw new OSM_Exception(__CLASS__ . ' should have a "lon" attribute'); } $node->setDirty(false); return $node; }
/** * Tell if the Node is inside the polygon defined by the Relation. * Note: Does not works with multipolygon (outer/inner/...) * * @param OSM_Objects_Node $node2test * @param OSM_Objects_Relation $relation * @return bool */ public function isNodeInsideRelationPolygon(OSM_Objects_Node $node2test, OSM_Objects_Relation $relation) { $poly1 = $this->getPolygon($relation); $poly2 = new \OSM\Tools\Polygon(); $poly2->addv($node2test->getLat(), $node2test->getLon()); return $poly1->isPolyInside($poly2); }
/** * Add a node as a new member in the relation. * * @param OSM_Objects_Node $node * @param type $role * @return OSM_Objects_Relation Fluent interface */ public function addNode(OSM_Objects_Node $node, $role = '') { $member = new OSM_Objects_Member(OSM_Api::OBJTYPE_NODE, $node->getId(), $role); $this->addMember($member); return $this; }