コード例 #1
0
ファイル: submit.php プロジェクト: s-a-r-id/geograph-project
 if ($exif['GPS']['GPSLatitudeRef'] == 'S') {
     $lat *= -1;
 }
 if (is_array($exif['GPS']['GPSLongitude'])) {
     $deg = FractionToDecimal($exif['GPS']['GPSLongitude'][0]);
     $min = FractionToDecimal($exif['GPS']['GPSLongitude'][1]);
     $sec = FractionToDecimal($exif['GPS']['GPSLongitude'][2]);
     $long = ExifConvertDegMinSecToDD($deg, $min, $sec);
 } else {
     //not sure if this will ever happen but it could?
     $long = $exif['GPS']['GPSLongitude'];
 }
 if ($exif['GPS']['GPSLongitudeRef'] == 'W') {
     $long *= -1;
 }
 list($e, $n, $reference_index) = $conv->wgs84_to_national($lat, $long);
 list($_POST['photographer_gridref'], $len) = $conv->national_to_gridref(intval($e), intval($n), 0, $reference_index);
 if (isset($exif['GPS']['GPSDestLatitude'])) {
     if (is_array($exif['GPS']['GPSDestLatitude'])) {
         $deg = FractionToDecimal($exif['GPS']['GPSDestLatitude'][0]);
         $min = FractionToDecimal($exif['GPS']['GPSDestLatitude'][1]);
         $sec = FractionToDecimal($exif['GPS']['GPSDestLatitude'][2]);
         $lat = ExifConvertDegMinSecToDD($deg, $min, $sec);
     } else {
         //not sure if this will ever happen but it could?
         $lat = $exif['GPS']['GPSDestLatitude'];
     }
     if ($exif['GPS']['GPSDestLatitudeRef'] == 'S') {
         $lat *= -1;
     }
     if (is_array($exif['GPS']['GPSDestLongitude'])) {
コード例 #2
0
 /**
  *
  */
 function setByFullGridRef($gridreference, $setnatfor4fig = false, $allowzeropercent = false, $recalc = false)
 {
     global $CONF, $MESSAGES;
     $matches = array();
     $isfour = false;
     if (preg_match("/\\b([a-zA-Z]{1,3}) ?(\\d{1,5})[ \\.](\\d{1,5})\\b/", $gridreference, $matches) and strlen($matches[2]) == strlen($matches[3])) {
         list($prefix, $e, $n) = array($matches[1], $matches[2], $matches[3]);
         $length = strlen($matches[2]);
         $natgrlen = $length * 2;
     } elseif (preg_match("/\\b([a-zA-Z]{1,3}) ?(\\d{0,10})\\b/", $gridreference, $matches) and strlen($matches[2]) % 2 == 0) {
         $natgrlen = strlen($matches[2]);
         $length = $natgrlen / 2;
         list($prefix, $e, $n) = array($matches[1], substr($matches[2], 0, $length), substr($matches[2], -$length));
     }
     if (!empty($prefix)) {
         $gridref = sprintf("%s%02d%02d", strtoupper($prefix), intval($e / 1000), intval($n / 1000));
         $ok = false;
         if ($recalc) {
             $db =& $this->_getDB();
             $prefix = strtoupper($prefix);
             $sql = "select * from gridprefix where prefix='{$prefix}' limit 1";
             $row = $db->GetRow($sql);
             if (count($row)) {
                 require_once 'geograph/conversions.class.php';
                 $conv = new Conversions();
                 $ri = $row['reference_index'];
                 $fe = intval($e) + ($row['origin_x'] - $CONF['origins'][$ri][0]) * 1000;
                 $fn = intval($n) + ($row['origin_y'] - $CONF['origins'][$ri][1]) * 1000;
                 $latlong = $conv->national_to_wgs84($fe, $fn, $ri);
                 if (count($latlong)) {
                     $enr = $conv->wgs84_to_national($latlong[0], $latlong[1]);
                     if (count($enr)) {
                         $ri2 = $enr[2];
                         $fe2 = $enr[0];
                         $fn2 = $enr[1];
                         if ($ri2 != $ri) {
                             // we got a new ri
                             if ($length == 1) {
                                 $shift = 5000;
                             } elseif ($length == 0) {
                                 $shift = 50000;
                             } else {
                                 $shift = 0;
                             }
                             $e2 = round($enr[0], $length - 5) + $shift;
                             $n2 = round($enr[1], $length - 5) + $shift;
                             $x = floor($e2 / 1000) + $CONF['origins'][$ri2][0];
                             $y = floor($n2 / 1000) + $CONF['origins'][$ri2][1];
                             $ok = $this->loadFromPosition($x, $y);
                             if ($ok) {
                                 $prefix = $this->gridsquare;
                                 $e = sprintf("%05d", $e2 % 100000);
                                 $n = sprintf("%05d", $n2 % 100000);
                                 $gridref = $this->grid_reference;
                             }
                         }
                     }
                 }
             }
         }
         if (!$ok) {
             $ok = $this->_setGridRef($gridref, $allowzeropercent);
         }
         if ($ok && (!$isfour || $setnatfor4fig)) {
             //we could be reassigning the square!
             unset($this->nateastings);
             //use this function to work out the major easting/northing then convert to our exact values
             $eastings = $this->getNatEastings();
             $northings = $this->getNatNorthings();
             $emajor = floor($eastings / 100000);
             $nmajor = floor($northings / 100000);
             $this->nateastings = $emajor . sprintf("%05d", $e);
             $this->natnorthings = $nmajor . sprintf("%05d", $n);
             $this->natgrlen = $natgrlen;
             $this->precision = pow(10, 6 - $natgrlen / 2) / 10;
         } else {
             $this->precision = 1000;
         }
     } else {
         $ok = false;
         $this->_error(sprintf($MESSAGES['class_gridsquare']['gridref_invalid'], htmlentities($gridreference)));
     }
     return $ok;
 }