Пример #1
0
 protected function calcCentroid($boundary, $system = '4326')
 {
     $row = $this->db->query("SELECT ST_AsText(ST_Centroid(ST_GeomFromText('{$boundary}', " . kohana::config('sref_notations.internal_srid') . "))) AS wkt")->current();
     $result = array('wkt' => $row->wkt, 'sref' => spatial_ref::internal_wkt_to_sref($row->wkt, intval($system)), 'sref_system' => $system);
     return $result;
 }
Пример #2
0
 /**
  * Allow a service request to triangulate between 2 systems. GET parameters are:
  * 	from_sref
  * 	from_system
  * 	to_system
  *  to_precision (optional)
  */
 public function convert_sref()
 {
     try {
         $wkt = spatial_ref::sref_to_internal_wkt($_GET['from_sref'], $_GET['from_system']);
         if (array_key_exists('precision', $_GET)) {
             $precision = $_GET['precision'];
         } else {
             $precision = null;
         }
         if (array_key_exists('metresAccuracy', $_GET)) {
             $metresAccuracy = $_GET['metresAccuracy'];
         } else {
             $metresAccuracy = null;
         }
         echo spatial_ref::internal_wkt_to_sref($wkt, $_GET['to_system'], $precision, null, $metresAccuracy);
     } catch (Exception $e) {
         $this->handle_error($e);
     }
 }