GmlPoint.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Gdata
  17. * @subpackage Geo
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Gdata_Extension
  24. */
  25. require_once 'Zend/Gdata/Extension.php';
  26. /**
  27. * @see Zend_Gdata_Geo
  28. */
  29. require_once 'Zend/Gdata/Geo.php';
  30. /**
  31. * @see Zend_Gdata_Geo_Extension_GmlPos
  32. */
  33. require_once 'Zend/Gdata/Geo/Extension/GmlPos.php';
  34. /**
  35. * Represents the gml:point element used by the Gdata Geo extensions.
  36. *
  37. * @category Zend
  38. * @package Zend_Gdata
  39. * @subpackage Geo
  40. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  41. * @license http://framework.zend.com/license/new-bsd New BSD License
  42. */
  43. class Zend_Gdata_Geo_Extension_GmlPoint extends Zend_Gdata_Extension
  44. {
  45. protected $_rootNamespace = 'gml';
  46. protected $_rootElement = 'Point';
  47. /**
  48. * The position represented by this GmlPoint
  49. *
  50. * @var Zend_Gdata_Geo_Extension_GmlPos
  51. */
  52. protected $_pos = null;
  53. /**
  54. * Create a new instance.
  55. *
  56. * @param Zend_Gdata_Geo_Extension_GmlPos $pos (optional) Pos to which this
  57. * object should be initialized.
  58. */
  59. public function __construct($pos = null)
  60. {
  61. $this->registerAllNamespaces(Zend_Gdata_Geo::$namespaces);
  62. parent::__construct();
  63. $this->setPos($pos);
  64. }
  65. /**
  66. * Retrieves a DOMElement which corresponds to this element and all
  67. * child properties. This is used to build an entry back into a DOM
  68. * and eventually XML text for application storage/persistence.
  69. *
  70. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  71. * @return DOMElement The DOMElement representing this element and all
  72. * child properties.
  73. */
  74. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  75. {
  76. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  77. if ($this->_pos !== null) {
  78. $element->appendChild($this->_pos->getDOM($element->ownerDocument));
  79. }
  80. return $element;
  81. }
  82. /**
  83. * Creates individual Entry objects of the appropriate type and
  84. * stores them as members of this entry based upon DOM data.
  85. *
  86. * @param DOMNode $child The DOMNode to process
  87. */
  88. protected function takeChildFromDOM($child)
  89. {
  90. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  91. switch ($absoluteNodeName) {
  92. case $this->lookupNamespace('gml') . ':' . 'pos';
  93. $pos = new Zend_Gdata_Geo_Extension_GmlPos();
  94. $pos->transferFromDOM($child);
  95. $this->_pos = $pos;
  96. break;
  97. }
  98. }
  99. /**
  100. * Get the value for this element's pos attribute.
  101. *
  102. * @see setPos
  103. * @return Zend_Gdata_Geo_Extension_GmlPos The requested attribute.
  104. */
  105. public function getPos()
  106. {
  107. return $this->_pos;
  108. }
  109. /**
  110. * Set the value for this element's distance attribute.
  111. *
  112. * @param Zend_Gdata_Geo_Extension_GmlPos $value The desired value for this attribute
  113. * @return Zend_Gdata_Geo_Extension_GmlPoint Provides a fluent interface
  114. */
  115. public function setPos($value)
  116. {
  117. $this->_pos = $value;
  118. return $this;
  119. }
  120. }