示例#1
0
 /**
  * Convert a WGS84 latitude and longitude to an UTM reference
  *
  * Reference values for transformation are taken from OS document
  * "A Guide to Coordinate Systems in Great Britain"
  * @return UTMRef
  */
 public function toUTMRef()
 {
     $this->toWGS84();
     $longitudeZone = (int) (($this->lng + 180) / 6) + 1;
     // Special zone for Norway
     if ($this->lat >= 56 && $this->lat < 64 && $this->lng >= 3 && $this->lng < 12) {
         $longitudeZone = 32;
     } elseif ($this->lat >= 72 && $this->lat < 84) {
         // Special zones for Svalbard
         if ($this->lng >= 0 && $this->lng < 9) {
             $longitudeZone = 31;
         } elseif ($this->lng >= 9 && $this->lng < 21) {
             $longitudeZone = 33;
         } elseif ($this->lng >= 21 && $this->lng < 33) {
             $longitudeZone = 35;
         } elseif ($this->lng >= 33 && $this->lng < 42) {
             $longitudeZone = 37;
         }
     }
     $UTMZone = $this->getUTMLatitudeZoneLetter($this->lat);
     $UTM = new UTMRef(0, 0, 0, $UTMZone, $longitudeZone);
     //dummy to get reference data
     $scale = $UTM->getScaleFactor();
     $N0 = $UTM->getOriginNorthing();
     $E0 = $UTM->getOriginEasting();
     $phi0 = $UTM->getOriginLatitude();
     $lambda0 = $UTM->getOriginLongitude();
     $coords = $this->toTransverseMercatorEastingNorthing($scale, $E0, $N0, $phi0, $lambda0);
     if ($this->lat < 0) {
         $coords['N'] += 10000000;
     }
     return new UTMRef(round($coords['E']), round($coords['N']), $this->h, $UTMZone, $longitudeZone);
 }
示例#2
0
 /**
  * Convert a WGS84 latitude and longitude to an UTM reference
  *
  * Reference values for transformation are taken from OS document
  * "A Guide to Coordinate Systems in Great Britain"
  * @return UTMRef
  */
 public function toUTMRef()
 {
     if ($this->refEll != RefEll::WGS84()) {
         trigger_error('Current co-ordinates are in a non-WGS84 datum', E_USER_WARNING);
     }
     $longitudeZone = (int) (($this->lng + 180) / 6) + 1;
     // Special zone for Norway
     if ($this->lat >= 56 && $this->lat < 64 && $this->lng >= 3 && $this->lng < 12) {
         $longitudeZone = 32;
     }
     // Special zones for Svalbard
     if ($this->lat >= 72 && $this->lat < 84) {
         if ($this->lng >= 0 && $this->lng < 9) {
             $longitudeZone = 31;
         } else {
             if ($this->lng >= 9 && $this->lng < 21) {
                 $longitudeZone = 33;
             } else {
                 if ($this->lng >= 21 && $this->lng < 33) {
                     $longitudeZone = 35;
                 } else {
                     if ($this->lng >= 33 && $this->lng < 42) {
                         $longitudeZone = 37;
                     }
                 }
             }
         }
     }
     $UTMZone = $this->getUTMLatitudeZoneLetter($this->lat);
     $UTM = new UTMRef(0, 0, $UTMZone, $longitudeZone);
     //dummy to get reference data
     $scale = $UTM->getScaleFactor();
     $N0 = $UTM->getOriginNorthing();
     $E0 = $UTM->getOriginEasting();
     $phi0 = $UTM->getOriginLatitude();
     $lambda0 = $UTM->getOriginLongitude();
     $coords = $this->toTransverseMercatorEastingNorthing($scale, $E0, $N0, $phi0, $lambda0);
     if ($this->lat < 0) {
         $coords['N'] += 10000000;
     }
     return new UTMRef($coords['E'], $coords['N'], $UTMZone, $longitudeZone);
 }