⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ellipse.c

📁 给予QT的qps开源最新源码
💻 C
📖 第 1 页 / 共 2 页
字号:
      error_code |= ELLIPSE_NOT_USERDEF_ERROR;
  }
  if (!error_code)
  {
    long i = 0;
    for (i = index-1; i < Number_of_Ellipsoids-1; i++)
      Ellipsoid_Table[i] = Ellipsoid_Table[i+1];

    if (Number_of_Ellipsoids != MAX_ELLIPSOIDS)
      Ellipsoid_Table[i] = Ellipsoid_Table[i+1];
    else
    {
      strcpy(Ellipsoid_Table[i].Name, "");
      strcpy(Ellipsoid_Table[i].Code, "");
      Ellipsoid_Table[i].A = 0;
      Ellipsoid_Table[i].B = 0;
      Ellipsoid_Table[i].Recp_F = 0;  
      Ellipsoid_Table[i].User_Defined = ' ';
    }
    Number_of_Ellipsoids--;
    /*output updated ellipsoid table*/
    PathName = getenv( "ELLIPSOID_DATA" );
    if (PathName != NULL)
    {
      strcpy( FileName, PathName );
      strcat( FileName, "/" );
    }
    else
    {
      strcpy( FileName, "./" );
    }
    strcat( FileName, "ellips.dat" );
    if ((fp = fopen(FileName, "w")) == NULL)
    { /* fatal error */
      return ELLIPSE_FILE_OPEN_ERROR;
    }
    /* write file */
    index = 0;
    while (index < Number_of_Ellipsoids)
    {
      if (Ellipsoid_Table[index].User_Defined)
        fprintf(fp, "*%-29s %-2s %11.3f %12.4f %13.9f \n",
                Ellipsoid_Table[index].Name,
                Ellipsoid_Table[index].Code,
                Ellipsoid_Table[index].A,
                Ellipsoid_Table[index].B,
                Ellipsoid_Table[index].Recp_F);
      else
        fprintf(fp, "%-29s  %-2s %11.3f %12.4f %13.9f \n",
                Ellipsoid_Table[index].Name,
                Ellipsoid_Table[index].Code,
                Ellipsoid_Table[index].A,
                Ellipsoid_Table[index].B,
                Ellipsoid_Table[index].Recp_F);
      index++;
    }
    fclose(fp);
    /* Store WGS84 */
    Ellipsoid_Index(WGS84_Ellipsoid_Code, &WGS84_Index);
    /* Store WGS72 */
    Ellipsoid_Index(WGS72_Ellipsoid_Code, &WGS72_Index);
  }
  return (error_code);
}/* End Delete_Ellipsoid */


long Ellipsoid_Count ( long *Count )
{ /* Begin Ellipsoid_Count */
/*
 *   Count    : The number of ellipsoids in the ellipsoid table. (output)
 *
 * The function Ellipsoid_Count returns the number of ellipsoids in the
 * ellipsoid table.  If the ellipsoid table has been initialized without error,
 * ELLIPSE_NO_ERROR is returned, otherwise ELLIPSE_NOT_INITIALIZED_ERROR
 * is returned.
 */
  long error_code = ELLIPSE_NO_ERROR;
  if (!Ellipsoid_Initialized)
    error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
  *Count = Number_of_Ellipsoids;
  return (error_code);
} /* End Ellipsoid_Count */


long Ellipsoid_Index ( const char *Code,
                       long *Index )
{ /* Begin Ellipsoid_Index */
/*
 *    Code     : 2-letter ellipsoid code.                      (input)
 *    Index    : Index of the ellipsoid in the ellipsoid table with the 
 *                  specified code                             (output)
 *
 *  The function Ellipsoid_Index returns the index of the ellipsoid in 
 *  the ellipsoid table with the specified code.  If ellipsoid code is found, 
 *  ELLIPSE_NO_ERROR is returned, otherwise ELLIPSE_INVALID_CODE_ERROR is 
 *  returned.
 */
  char temp_code[3];
  long error_code = ELLIPSE_NO_ERROR;
  long i = 0;                   /* index for ellipsoid table */
  long j = 0;
  *Index = 0;
  if (Ellipsoid_Initialized)
  {
    while (j < ELLIPSOID_CODE_LENGTH)
    {
      temp_code[j] = toupper(Code[j]);
      j++;
    }
    temp_code[ELLIPSOID_CODE_LENGTH - 1] = 0;
    while ((i < Number_of_Ellipsoids)
           && strcmp(temp_code, Ellipsoid_Table[i].Code))
    {
      i++;
    }
    if (strcmp(temp_code, Ellipsoid_Table[i].Code))
      error_code |= ELLIPSE_INVALID_CODE_ERROR;
    else
      *Index = i+1;
  }
  else
  {
    error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
  }
  return (error_code);
} /* End Ellipsoid_Index */


long Ellipsoid_Name ( const long Index,
                      char *Name ) 
{ /* Begin Ellipsoid_Name */
/*
 *    Index   : Index of a given ellipsoid.in the ellipsoid table with the
 *                 specified index                             (input)
 *    Name    : Name of the ellipsoid referencd by index       (output)
 *
 *  The Function Ellipsoid_Name returns the name of the ellipsoid in 
 *  the ellipsoid table with the specified index.  If index is valid, 
 *  ELLIPSE_NO_ERROR is returned, otherwise ELLIPSE_INVALID_INDEX_ERROR is
 *  returned.
 */

  long error_code = ELLIPSE_NO_ERROR;

  strcpy(Name,"");
  if (Ellipsoid_Initialized)
  {
    if ((Index < 1) || (Index > Number_of_Ellipsoids))
      error_code |= ELLIPSE_INVALID_INDEX_ERROR;
    else
      strcpy(Name, Ellipsoid_Table[Index-1].Name);
  }
  else
    error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
  return (error_code);
} /* End Ellipsoid_Name */


long Ellipsoid_Code ( const long Index,
                      char *Code ) 
{ /* Begin Ellipsoid_Code */
/*
 *    Index    : Index of a given ellipsoid in the ellipsoid table (input)
 *    Code     : 2-letter ellipsoid code.                          (output)
 *
 *  The Function Ellipsoid_Code returns the 2-letter code for the 
 *  ellipsoid in the ellipsoid table with the specified index.  If index is 
 *  valid, ELLIPSE_NO_ERROR is returned, otherwise ELLIPSE_INVALID_INDEX_ERROR 
 *  is returned.
 */

  long error_code = ELLIPSE_NO_ERROR;

  strcpy(Code,"");
  if (Ellipsoid_Initialized)
  {
    if ((Index < 1) || (Index > Number_of_Ellipsoids))
      error_code |= ELLIPSE_INVALID_INDEX_ERROR;
    else
      strcpy(Code, Ellipsoid_Table[Index-1].Code);
  }
  else
    error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
  return (error_code);
} /* End Ellipsoid_Code */


long Ellipsoid_Parameters ( const long Index,
                            double *a,
                            double *f )
{ /* Begin Ellipsoid_Parameters */
/*
 *    Index    : Index of a given ellipsoid in the ellipsoid table (input)
 *    a        : Semi-major axis, in meters, of ellipsoid          (output)
 *    f        : Flattening of ellipsoid.                          (output)
 *
 *  The function Ellipsoid_Parameters returns the semi-major axis and flattening
 *  for the ellipsoid with the specified index.  If index is valid,
 *  ELLIPSE_NO_ERROR is returned, otherwise ELLIPSE_INVALID_INDEX_ERROR is 
 *  returned.
 */

  long error_code = ELLIPSE_NO_ERROR;

  *a = 0;
  *f = 0;
  if (Ellipsoid_Initialized)
  {
    if ((Index < 1) || (Index > Number_of_Ellipsoids))
    {
      error_code |= ELLIPSE_INVALID_INDEX_ERROR;
    }
    else
    {
      *a = Ellipsoid_Table[Index-1].A;
      *f = 1 / Ellipsoid_Table[Index-1].Recp_F;
    }
  }
  else
    error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
  return (error_code);
} /* End Ellipsoid_Parameters */


long Ellipsoid_Eccentricity2 ( const long Index,
                               double *e2 )
{ /* Begin Ellipsoid_Eccentricity2 */
/*
 *    Index    : Index of a given ellipsoid in the ellipsoid table (input)
 *    e2       : Square of eccentricity of ellipsoid               (output)
 *
 *  The function Ellipsoid_Eccentricity2 returns the square of the 
 *  eccentricity for the ellipsoid with the specified index.  If index is 
 *  valid, ELLIPSE_NO_ERROR is returned, otherwise ELLIPSE_INVALID_INDEX_ERROR 
 *  is returned.
 */
  double f;
  long error_code = ELLIPSE_NO_ERROR;

  *e2 = 0;
  if (Ellipsoid_Initialized)
  {
    if ((Index < 1) || (Index > Number_of_Ellipsoids))
    {
      error_code |= ELLIPSE_INVALID_INDEX_ERROR;
    }
    else
    {
      f = 1 / Ellipsoid_Table[Index-1].Recp_F;
      *e2 = 2 * f - f * f;
    }
  }
  else
    error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
  return (error_code);
} /* End Ellipsoid_Eccentricity2 */


long Ellipsoid_User_Defined ( const long Index,
							                long *result )

{ /* Begin Ellipsoid_User_Defined */
/*
 *    Index    : Index of a given ellipsoid in the ellipsoid table (input)
 *    result   : Indicates whether specified ellipsoid is user defined (1)
 *               or not (0)                                        (output)
 *
 *  The function Ellipsoid_User_Defined returns 1 if the ellipsoid is user 
 *  defined.  Otherwise, 0 is returned.  If index is valid ELLIPSE_NO_ERROR is
 *  returned, otherwise ELLIPSE_INVALID_INDEX_ERROR is returned.
 */

  long error_code = ELLIPSE_NO_ERROR;

  *result = FALSE;

  if (Ellipsoid_Initialized)
  {
    if ((Index < 1) || (Index > Number_of_Ellipsoids))
      error_code |= ELLIPSE_INVALID_INDEX_ERROR;
    else
    {
      if (Ellipsoid_Table[Index-1].User_Defined)
        *result = TRUE;
    }
  }
  else
    error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
  return (error_code);
} /* End Ellipsoid_User_Defined */


long WGS84_Parameters ( double *a,
                        double *f )
{ /* Begin WGS84_Parameters */
/*
 *    a      : Semi-major axis, in meters, of ellipsoid       (output)
 *    f      : Flattening of ellipsoid                        (output)
 *
 *  The function WGS84_Parameters returns the semi-major axis and the
 *  flattening for the WGS84 ellipsoid.  If the ellipsoid table was 
 *  initialized successfully, ELLIPSE_NO_ERROR is returned, otherwise 
 *  ELLIPSE_NOT_INITIALIZED_ERROR is returned.
 */

  long error_code = ELLIPSE_NO_ERROR;

  *a = 0;
  *f = 0;
  if (Ellipsoid_Initialized)
  {
    *a = Ellipsoid_Table[WGS84_Index-1].A;
    *f = 1 / Ellipsoid_Table[WGS84_Index-1].Recp_F;
  }
  else
    error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
  return (error_code);
} /* End WGS84_Parameters */


long WGS84_Eccentricity2 ( double *e2 )
{ /* Begin WGS84_Eccentricity2 */
/*
 *    e2    : Square of eccentricity of WGS84 ellipsoid      (output)
 *
 *  The function WGS84_Eccentricity2 returns the square of the 
 *  eccentricity for the WGS84 ellipsoid.  If the ellipsoid table was 
 *  initialized successfully, ELLIPSE_NO_ERROR is returned, otherwise 
 *  ELLIPSE_NOT_INITIALIZED_ERROR is returned.
 */

  long error_code = ELLIPSE_NO_ERROR;
  double f;

  *e2 = 0;
  if (Ellipsoid_Initialized)
  {
    f = 1 / Ellipsoid_Table[WGS84_Index-1].Recp_F;
    *e2 = 2 * f - f * f;
  }
  else
    error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
  return (error_code);
} /* End WGS84_Eccentricity2 */


long WGS72_Parameters( double *a,
                       double *f )
{ /* Begin WGS72_Parameters */
/*
 *    a    : Semi-major axis, in meters, of ellipsoid        (output)
 *    f    : Flattening of ellipsoid                         (output)
 *
 *  The function WGS72_Parameters returns the semi-major axis and the 
 *  flattening for the WGS72 ellipsoid.  If the ellipsoid table was 
 *  initialized successfully, ELLIPSE_NO_ERROR is returned, otherwise 
 *  ELLIPSE_NOT_INITIALIZED_ERROR is returned.
 */

  long error_code = ELLIPSE_NO_ERROR;

  *a = 0;
  *f = 0;
  if (Ellipsoid_Initialized)
  {
    *a = Ellipsoid_Table[WGS72_Index-1].A;
    *f = 1 / Ellipsoid_Table[WGS72_Index-1].Recp_F;
  }
  else
    error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
  return (error_code);
} /* End WGS72_Parameters */


long WGS72_Eccentricity2 ( double *e2 )
{ /* Begin WGS72_Eccentricity2 */
/*
 *    e2     : Square of eccentricity of WGS84 ellipsoid     (output)
 *
 *  The function WGS72_Eccentricity2 returns the square of the 
 *  eccentricity for the WGS72 ellipsoid.  If the ellipsoid table was 
 *  initialized successfully, ELLIPSE_NO_ERROR is returned, otherwise 
 *  ELLIPSE_NOT_INITIALIZED_ERROR is returned.
 */

  long error_code = ELLIPSE_NO_ERROR;
  double f;

  *e2 = 0;
  if (Ellipsoid_Initialized)
  {
    f = 1 / Ellipsoid_Table[WGS72_Index-1].Recp_F;
    *e2 = 2 * f - f * f;
  }
  else
    error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
  return (error_code);
} /* End WGS72_Eccentricity2 */


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -