/** * Get the fields that are used to store geo coordinates for the first index for this collection. * @param string $collection The name of the collection * @throws FinderException * @return array|null */ public function getGeoFieldsForAQL($collection) { $indices = $this->_toolbox->getCollectionManager()->listIndices($collection, true); foreach ($indices as $index => $info) { //If this is the first geo index we encounter if ($info['type'] == "geo1" || $info['type'] == "geo2") { return $info['fields']; } } return null; }
/** * Get the coordinates (latitude and longitude) from this pod's first geo index if it exists. * @return null|array */ public function getCoordinates() { $fields = $this->_toolbox->getCollectionManager()->getGeoFieldsForAQL($this->getType()); //A geo1 index (field is an array with the coordinates). if ($fields) { if (count($fields) == 1) { $field = $this->get($fields[0]); return array('latitude' => $field[0], 'longitude' => $field[1]); //A geo2 index (2 fields each representing latitue and longitude). } else { $latitude = $this->get($fields[0]); $longitude = $this->get($fields[1]); return array('latitude' => $latitude, 'longitude' => $longitude); } } return null; }
/** * @covers Paradox\Toolbox::getCollectionManager */ public function testGetCollectionManager() { $this->assertInstanceOf('Paradox\\toolbox\\CollectionManager', $this->toolbox->getCollectionManager(), 'Getting the collection manager did not return a Paradox\\toolbox\\CollectionManager'); }