예제 #1
0
long Convert_OSSIM_MGRS_To_Geodetic (const char* OSSIM_MGRS, 
                               double *Latitude, 
                               double *Longitude)
/*
 *    OSSIM_MGRS       : OSSIM_MGRS coordinate string           (output)
 *    Latitude   : Latitude in radians              (input)
 *    Longitude  : Longitude in radians             (input)
 *  
 */
{ /* Convert_OSSIM_MGRS_To_Geodetic */
  long error_code = OSSIM_MGRS_NO_ERROR;
  long Zone;
  long Letters[OSSIM_MGRS_LETTERS];
  char Hemisphere;
  double Easting;
  double Northing;
  long In_Precision;
  error_code = Break_OSSIM_MGRS_String (OSSIM_MGRS, &Zone, Letters, &Easting, &Northing, &In_Precision);
  if (!error_code)
  {
     if (Zone)
     {
        error_code |= Convert_OSSIM_MGRS_To_UTM (OSSIM_MGRS, &Zone, &Hemisphere, &Easting, &Northing);
        Set_UTM_Parameters (OSSIM_MGRS_a, OSSIM_MGRS_f, 0);
        error_code |= Convert_UTM_To_Geodetic (Zone, Hemisphere, Easting, Northing, Latitude, Longitude);
     }
     else
     {
        error_code |= Convert_OSSIM_MGRS_To_UPS (OSSIM_MGRS, &Hemisphere, &Easting, &Northing);
        Set_UPS_Parameters (OSSIM_MGRS_a, OSSIM_MGRS_f);
        error_code |= Convert_UPS_To_Geodetic (Hemisphere, Easting, Northing, Latitude, Longitude);
     }
  }
  return (error_code);
} /* END OF Convert_OSSIM_MGRS_To_Geodetic */
예제 #2
0
파일: mgrs.c 프로젝트: dwyerk/mgrs
long Convert_MGRS_To_Geodetic (char* MGRS,
                               double *Latitude,
                               double *Longitude)
/*
 * The function Convert_MGRS_To_Geodetic converts an MGRS coordinate string
 * to Geodetic (latitude and longitude) coordinates
 * according to the current ellipsoid parameters.  If any errors occur,
 * the error code(s) are returned by the function, otherwise UTM_NO_ERROR
 * is returned.
 *
 *    MGRS       : MGRS coordinate string           (input)
 *    Latitude   : Latitude in radians              (output)
 *    Longitude  : Longitude in radians             (output)
 *
 */
{ /* Convert_MGRS_To_Geodetic */
  long zone;
  char hemisphere;
  double easting;
  double northing;
  long zone_exists;
  long temp_error_code = MGRS_NO_ERROR;
  long error_code = MGRS_NO_ERROR;

  error_code = Check_Zone(MGRS, &zone_exists);
  if (!error_code)
  {
    if (zone_exists)
    {
      error_code |= Convert_MGRS_To_UTM (MGRS, &zone, &hemisphere, &easting, &northing);
      if(!error_code || (error_code & MGRS_LAT_WARNING))
      {
        temp_error_code = Set_UTM_Parameters (MGRS_a, MGRS_f, 0);
        if(!temp_error_code)
        {
          temp_error_code = Convert_UTM_To_Geodetic (zone, hemisphere, easting, northing, Latitude, Longitude);
          if(temp_error_code)
          {
            if((temp_error_code & UTM_ZONE_ERROR) || (temp_error_code & UTM_HEMISPHERE_ERROR))
              error_code |= MGRS_STRING_ERROR;
            if(temp_error_code & UTM_EASTING_ERROR)
              error_code |= MGRS_EASTING_ERROR;
            if(temp_error_code & UTM_NORTHING_ERROR)
              error_code |= MGRS_NORTHING_ERROR;
          }
        }
        else
        {
          if(temp_error_code & UTM_A_ERROR)
            error_code |= MGRS_A_ERROR;
          if(temp_error_code & UTM_INV_F_ERROR)
            error_code |= MGRS_INV_F_ERROR;
          if(temp_error_code & UTM_ZONE_OVERRIDE_ERROR)
            error_code |= MGRS_ZONE_ERROR;
        }
      }
    }
    else
    {
      error_code |= Convert_MGRS_To_UPS (MGRS, &hemisphere, &easting, &northing);
      if(!error_code)
      {
        temp_error_code = Set_UPS_Parameters (MGRS_a, MGRS_f);
        if(!temp_error_code)
        {
          temp_error_code = Convert_UPS_To_Geodetic (hemisphere, easting, northing, Latitude, Longitude);
          if(temp_error_code)
          {
            if(temp_error_code & UPS_HEMISPHERE_ERROR)
              error_code |= MGRS_STRING_ERROR;
            if(temp_error_code & UPS_EASTING_ERROR)
              error_code |= MGRS_EASTING_ERROR;
            if(temp_error_code & UPS_LAT_ERROR)
              error_code |= MGRS_NORTHING_ERROR;
          }
        }
        else
        {
          if(temp_error_code & UPS_A_ERROR)
            error_code |= MGRS_A_ERROR;
          if(temp_error_code & UPS_INV_F_ERROR)
            error_code |= MGRS_INV_F_ERROR;
        }
      }
    }
  }
  return (error_code);
} /* END OF Convert_MGRS_To_Geodetic */