コード例 #1
0
ファイル: FindspotGeo.php プロジェクト: lesleyauk/findsorguk
 /** To string function
  * @access public
  * @return string
  */
 public function __toString()
 {
     if ($this->getWoeid()) {
         $place = $this->_geoplanet->reverseGeocode($this->getLat(), $this->getLon());
         $placeData = $this->_geoplanet->getPlace($place['woeid']);
     } else {
         $placeData = $this->_geoplanet->getPlace($this->getWoeid());
     }
     return $this->buildHtml($placeData);
 }
コード例 #2
0
ファイル: Findspots.php プロジェクト: rwebley/Beowulf---PAS
 /** Function for processing findspot
  * 
  * @param array $data
  */
 protected function _processFindspot($data)
 {
     if (is_array($data)) {
         $conversion = new Pas_Geo_Gridcalc($data['gridref']);
         $results = $conversion->convert();
         $place = new Pas_Service_Geo_Geoplanet($this->_appid);
         $geoHash = new Pas_Geo_Hash();
         $hash = $geoHash->encode($results['decimalLatLon']['decimalLatitude'], $results['decimalLatLon']['decimalLongitude']);
         $data['declong'] = $results['decimalLatLon']['decimalLongitude'];
         $data['declat'] = $results['decimalLatLon']['decimalLatitude'];
         $data['easting'] = $results['easting'];
         $data['northing'] = $results['northing'];
         $data['map10k'] = $results['10kmap'];
         $data['map25k'] = $results['25kmap'];
         $data['fourFigure'] = $results['fourFigureGridRef'];
         $data['accuracy'] = $results['accuracy']['precision'];
         $data['gridlen'] = $results['gridrefLength'];
         $data['geohash'] = $hash;
         $yahoo = $place->reverseGeoCode($results['decimalLatLon']['decimalLatitude'], $results['decimalLatLon']['decimalLongitude']);
         $data['woeid'] = $yahoo['woeid'];
         return $data;
     } else {
         return $data;
     }
 }
コード例 #3
0
 /** Edit crime details
  * @todo messy rewrite
  */
 public function editAction()
 {
     if ($this->_getParam('id', false)) {
         $form = new HeritageCrimeForm();
         $form->submit->setLabel('Update crime');
         $this->view->form = $form;
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $ngr = $form->getValue('gridref');
                 if (!is_null($ngr) || $ngr != "") {
                     $results = $this->GridCalc($ngr);
                     $fourFigure = $this->FourFigure($ngr);
                     $place = new Pas_Service_Geo_Geoplanet($this->_appid);
                     $findelevation = $place->getElevation(NULL, $results['Latitude'], $results['Longitude']);
                     $findwoeid = $place->reverseGeoCode($results['Latitude'], $results['Longitude']);
                     $elevation = $findelevation['elevation'];
                     $woeid = $findwoeid['woeid'];
                 } else {
                     $elevation = NULL;
                     $woeid = NULL;
                 }
                 $updateData = array('subject' => $form->getValue('subject'), 'reporterID' => $form->getValue('reporterID'), 'incidentDate' => $form->getValue('incidentDate'), 'crimeType' => $form->getValue('crimeType'), 'gridref' => $form->getValue('gridref'), 'latitude' => $results['Latitude'], 'longitude' => $results['Longitude'], 'easting' => $results['Easting'], 'northing' => $results['Northing'], 'map10k' => $results['Tenk'], 'map25k' => $results['2pt5K'], 'fourFigure' => $fourFigure, 'description' => $form->getValue('description'), 'updated' => $this->getTimeForForms(), 'updatedBy' => $this->getIdentityForForms(), 'woeid' => $woeid, 'elevation' => $elevation, 'samID' => $form->getValue('samID'), 'evaluation' => $form->getValue('evaluation'), 'reliability' => $form->getValue('reliability'), 'county' => $form->getValue('county'), 'district' => $form->getValue('district'), 'parish' => $form->getValue('parish'), 'intellEvaluation' => $form->getValue('intellEvaluation'), 'reportSubject' => $form->getValue('reportSubject'), 'subjectDetails' => $form->getValue('subjectDetails'), 'reportingPerson' => $form->getValue('reportingPerson'));
                 foreach ($updateData as $key => $value) {
                     if (is_null($value) || $value == "") {
                         $updateData[$key] = NULL;
                     }
                 }
                 $where = array();
                 $where[] = $this->_crimes->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
                 $this->_crimes->update($updateData, $where);
                 $returnID = $this->_getParam('id');
                 $this->_flashMessenger->addMessage('Crime details updated!');
                 $this->_redirect(self::REDIRECT . 'crime/id/' . $returnID);
             } else {
                 $id = (int) $this->_request->getParam('id', 0);
                 if ($id > 0) {
                     $crime = $this->_crimes->getCrime($this->_getParam('id'));
                     if (!is_null($crime['0']['county'])) {
                         $districts = new Places();
                         $district_list = $districts->getDistrictList($crime['0']['county']);
                         $form->district->addMultiOptions(array(NULL => 'Choose district', 'Available districts' => $district_list));
                         if (!is_null($crime['0']['district'])) {
                             $parish_list = $districts->getParishList($crime['0']['district']);
                             $form->parish->addMultiOptions(array(NULL => 'Choose parish', 'Available parishes' => $parish_list));
                         }
                     }
                     $form->populate($formData);
                 }
             }
         } else {
             $id = (int) $this->_request->getParam('id', 0);
             if ($id > 0) {
                 $crime = $this->_crimes->getCrime($this->_getParam('id'));
                 if (!is_null($crime['0']['county'])) {
                     $districts = new Places();
                     $district_list = $districts->getDistrictList($crime['0']['county']);
                     $form->district->addMultiOptions(array(NULL => 'Choose district', 'Available districts' => $district_list));
                     if (!is_null($crime['0']['district'])) {
                         $parish_list = $districts->getParishList($crime['0']['district']);
                         $form->parish->addMultiOptions(array(NULL => 'Choose parish', 'Available parishes' => $parish_list));
                     }
                 }
                 $form->populate($crime['0']);
             }
         }
     } else {
         throw new Exception($this->_missingParameter);
     }
 }