Пример #1
0
 /**
  * @covers GeoServices\GeoObject::getProperties
  */
 public function testGetProperties()
 {
     $this->assertInternalType('array', $this->object->getProperties());
     $fields = array('countryName', 'city', 'latitude', 'longitude', 'zip', 'regionName', 'countryCode', 'isp');
     foreach ($fields as $f) {
         $this->assertContains($f, $this->object->getProperties());
     }
 }
Пример #2
0
	/**
	 * @return array
	 */
	public function getGeometry()
	{
		$geometry = parent::getGeometry();
		if (isset($geometry['coordinates'])) {
			$geometry = $geometry['coordinates'];
		}
		return $geometry;
	}
 /**
  * retrieves data from ws.geonames.org and runs through it
  * creating GeoNames objects as needed and setting parents
  *
  * @param int $id
  *
  * @throws GeoNamesException
  * @access public
  * @return array
  */
 public function hierarchy($id)
 {
     if (!intval($id)) {
         throw new GeoLokupException("Bad id supplied to GeoNamesService::hierarchy");
     }
     $xml = simplexml_load_file(self::URL_BASE . 'hierarchy?geonameId=' . intval($id) . '&style=FULL', null, true);
     $results = array();
     foreach ($xml->children() as $child) {
         if ($child->getName() != 'geoname') {
             continue;
         }
         $geoname = new GeoObject($this, $child);
         if (isset($parent)) {
             $geoname->setParent($parent);
         }
         $parent = $geoname;
         $results[$geoname->geonameId] = $geoname;
     }
     return $results;
 }
Пример #4
0
 function __construct($coordinates, $properties = array(), $options = array())
 {
     parent::__construct(self::TYPE_POLYGON, $coordinates, $properties, $options);
 }
Пример #5
0
 function __construct($latitude, $longitude, $properties = array(), $options = array())
 {
     parent::__construct(self::TYPE_POINT, array('longitude' => $longitude, 'latitude' => $latitude), $properties, $options);
 }