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

📄 datum.c

📁 给予QT的qps开源最新源码
💻 C
📖 第 1 页 / 共 5 页
字号:
    }
    Datum_3Param_Count--;
    Number_of_Datums--;

    for (i = 0; i < Number_of_Datums; i++)
    {
      if (Datum_Table[i]->Type == Three_Param_Datum)
      {
        Datum_Table[i] = &(Datum_Table_3Param[count]);
        count++;
      }
    }
    Datum_Table[Number_of_Datums] = 0x00000000;

    PathName = getenv( "DATUM_DATA" );
    if (PathName != NULL)
    {
      strcpy( FileName, PathName );
      strcat( FileName, "/" );
    }
    else
    {
      strcpy( FileName, "./" );
    }
    strcat( FileName, "3_param.dat" );

    if ((fp_3param = fopen(FileName, "w")) == NULL)
    { /* fatal error */
      return DATUM_3PARAM_FILE_OPEN_ERROR;
    }

    /* write file */
    index = 0;
    while (index < Datum_3Param_Count)
    {
      strcpy( datum_name, "\"" );
      strcat( datum_name, Datum_Table_3Param[index].Name);
      strcat( datum_name, "\"" );
      if (Datum_Table_3Param[index].User_Defined)
        fprintf(fp_3param, "*%-6s %-33s%-2s %4.0f %4.0f %4.0f %4.0f %5.0f %4.0f %4.0f %4.0f %4.0f %4.0f \n",
                Datum_Table_3Param[index].Code,
                datum_name,
                Datum_Table_3Param[index].Ellipsoid_Code,
                Datum_Table_3Param[index].Parameters[0],
                Datum_Table_3Param[index].Sigma_X, 
                Datum_Table_3Param[index].Parameters[1],
                Datum_Table_3Param[index].Sigma_Y, 
                Datum_Table_3Param[index].Parameters[2],
                Datum_Table_3Param[index].Sigma_Z,
                (Datum_Table_3Param[index].South_latitude * 180.0 / PI),
                (Datum_Table_3Param[index].North_latitude * 180.0 / PI),
                (Datum_Table_3Param[index].West_longitude * 180.0 / PI),
                (Datum_Table_3Param[index].East_longitude * 180.0 / PI));
      else
        fprintf(fp_3param, "%-6s  %-33s%-2s %4.0f %4.0f %4.0f %4.0f %5.0f %4.0f %4.0f %4.0f %4.0f %4.0f \n",
                Datum_Table_3Param[index].Code,
                datum_name,
                Datum_Table_3Param[index].Ellipsoid_Code,
                Datum_Table_3Param[index].Parameters[0],
                Datum_Table_3Param[index].Sigma_X, 
                Datum_Table_3Param[index].Parameters[1],
                Datum_Table_3Param[index].Sigma_Y, 
                Datum_Table_3Param[index].Parameters[2],
                Datum_Table_3Param[index].Sigma_Z,
                (Datum_Table_3Param[index].South_latitude * 180.0 / PI),
                (Datum_Table_3Param[index].North_latitude * 180.0 / PI),
                (Datum_Table_3Param[index].West_longitude * 180.0 / PI),
                (Datum_Table_3Param[index].East_longitude * 180.0 / PI));
      index++;
    }
    fclose(fp_3param);
  }
  return (error_code);
} /* End Delete_Datum */


long Datum_Uses_Ellipsoid (const char *Code)

{ /* Begin Datum_Uses_Ellipsoid */
  /*
  *  The function Datum_Uses_Ellipsoid returns 1 if the ellipsoid is in use by a 
  *  user defined datum.  Otherwise, 0 is returned.  
  *
  *  Code               : The ellipsoid code being searched for.    (input)
  */

  char temp_code[DATUM_CODE_LENGTH];
  long length;
  long pos = 0;
  long i = 0;
  long ellipsoid_in_use = FALSE;

  if (Datum_Initialized)
  {
    length = strlen(Code);
    if (length <= (ELLIPSOID_CODE_LENGTH-1))
    {
      strcpy(temp_code,Code);

      /* Convert to upper case */
      for (i=0;i<length;i++)
        temp_code[i] = (char)toupper(temp_code[i]);

      /* Strip blank spaces */
      while (pos < length)
      {
        if (isspace(temp_code[pos]))
        {
          for (i=pos;i<=length;i++)
            temp_code[i] = temp_code[i+1];
          length -= 1;
        }
        else
          pos += 1;
      }
      /* Search for code */
      i = 0;
      while ((i < Number_of_Datums) && (!ellipsoid_in_use))
      {
        if (strcmp(temp_code, Datum_Table[i]->Ellipsoid_Code) == 0)
          ellipsoid_in_use = TRUE;
        i++;
      }
    }
  }
  return (ellipsoid_in_use);
} /* End Datum_Uses_Ellipsoid */


long Datum_Count (long *Count)

{ /* Begin Datum_Count */
  /*
   *  The function Datum_Count returns the number of Datums in the table
   *  if the table was initialized without error.
   *
   *  Count                : number of datums in the datum table     (output)
   */

  long error_code = DATUM_NO_ERROR;

  if (Datum_Initialized)
    *Count = Number_of_Datums;
  else
  {
    *Count = 0;
    error_code |= DATUM_NOT_INITIALIZED_ERROR;
  }
  return (error_code);
} /* End of Datum_Count */


long Datum_3Param_Index( const char *Code,
                         long *Index )

{ /* Begin Datum_3Param_Index */
  /*
   *  The function Datum_3Param_Index returns the index of the datum with the 
   *  specified code.
   *
   *  Code    : The datum code being searched for.                    (input)
   *  Index   : The index of the datum in the table with the          (output)
   *              specified code.
   */
  char temp_code[DATUM_CODE_LENGTH];
  long error_code = DATUM_NO_ERROR;
  long length;
  long pos = 0;
  long i = 0;

  *Index = 0;
  if (Datum_Initialized)
  {
    length = strlen(Code);
    if (length > (DATUM_CODE_LENGTH-1))
      error_code |= DATUM_INVALID_CODE_ERROR;
    else
    {
      strcpy(temp_code,Code);

      /* Convert to upper case */
      for (i=0;i<length;i++)
        temp_code[i] = (char)toupper(temp_code[i]);

      /* Strip blank spaces */
      while (pos < length)
      {
        if (isspace(temp_code[pos]))
        {
          for (i=pos;i<=length;i++)
            temp_code[i] = temp_code[i+1];
          length -= 1;
        }
        else
          pos += 1;
      }
      /* Search for code */
      i = 0;
      while (i < Datum_3Param_Count && strcmp(temp_code, Datum_Table_3Param[i].Code))
      {
        i++;
      }
      if (i == Datum_3Param_Count || strcmp(temp_code, Datum_Table_3Param[i].Code))
        error_code |= DATUM_INVALID_CODE_ERROR;
      else
        *Index = i+1;
    }
  }
  else
  {
    error_code |= DATUM_NOT_INITIALIZED_ERROR;
  }
  return (error_code);
} /* End Datum_3Param_Index */


long Datum_Index( const char *Code,
                  long *Index )

{ /* Begin Datum_Index */
  /*
   *  The function Datum_Index returns the index of the datum with the 
   *  specified code.
   *
   *  Code    : The datum code being searched for.                    (input)
   *  Index   : The index of the datum in the table with the          (output)
   *              specified code.
   */
  char temp_code[DATUM_CODE_LENGTH];
  long error_code = DATUM_NO_ERROR;
  long length;
  long pos = 0;
  long i = 0;

  *Index = 0;
  if (Datum_Initialized)
  {
    length = strlen(Code);
    if (length > (DATUM_CODE_LENGTH-1))
      error_code |= DATUM_INVALID_CODE_ERROR;
    else
    {
      strcpy(temp_code,Code);

      /* Convert to upper case */
      for (i=0;i<length;i++)
        temp_code[i] = (char)toupper(temp_code[i]);

      /* Strip blank spaces */
      while (pos < length)
      {
        if (isspace(temp_code[pos]))
        {
          for (i=pos;i<=length;i++)
            temp_code[i] = temp_code[i+1];
          length -= 1;
        }
        else
          pos += 1;
      }
      /* Search for code */
      i = 0;
      while (i < Number_of_Datums && strcmp(temp_code, Datum_Table[i]->Code))
      {
        i++;
      }
      if (i == Number_of_Datums || strcmp(temp_code, Datum_Table[i]->Code))
        error_code |= DATUM_INVALID_CODE_ERROR;
      else
        *Index = i+1;
    }
  }
  else
  {
    error_code |= DATUM_NOT_INITIALIZED_ERROR;
  }
  return (error_code);
} /* End Datum_Index */


long Datum_Code (const long Index,
                 char *Code)
{ /* Begin Datum_Code */
  /*
   *  The function Datum_Code returns the 5-letter code of the datum
   *  referenced by index.
   *
   *  Index   : The index of a given datum in the datum table.        (input)
   *  Code    : The datum Code of the datum referenced by Index.      (output)
   */

  long error_code = DATUM_NO_ERROR;

  if (Datum_Initialized)
  {
    if (Index > 0 && Index <= Number_of_Datums)
      strcpy(Code, Datum_Table[Index-1]->Code);
    else
      error_code |= DATUM_INVALID_INDEX_ERROR;
  }
  else
  {
    error_code |= DATUM_NOT_INITIALIZED_ERROR;
  }
  return (error_code);
} /* End Datum_Code */


long Datum_Name (const long Index,
                 char *Name)
{ /* Begin Datum_Name */
  /*
   *  The function Datum_Name returns the name of the datum referenced by
   *  index.
   *
   *  Index   : The index of a given datum in the datum table.        (input)
   *  Name    : The datum Name of the datum referenced by Index.      (output)
   */

  long error_code = DATUM_NO_ERROR;

  if (Datum_Initialized)
  {
    if ((Index > 0) && (Index <= Number_of_Datums))
      strcpy(Name, Datum_Table[Index-1]->Name);
    else
      error_code |= DATUM_INVALID_INDEX_ERROR;
  }
  else
  {
    error_code |= DATUM_NOT_INITIALIZED_ERROR;
  }
  return (error_code);
} /* End Datum_Name */


long Datum_Ellipsoid_Code (const long Index,
                           char *Code)
{ /* Begin Datum_Ellipsoid_Code */
  /*
   *  The function Datum_Ellipsoid_Code returns the 2-letter ellipsoid code 
   *  for the ellipsoid associated with the datum referenced by index.
   *
   *  Index   : The index of a given datum in the datum table.          (input)
   *  Code    : The ellipsoid code for the ellipsoid associated with    (output)
   *               the datum referenced by index.
   */

  long error_code = DATUM_NO_ERROR;

  if (Datum_Initialized)
  {
    if ((Index < 1) || (Index > Number_of_Datums))
      error_code |= DATUM_INVALID_INDEX_ERROR;
    else
      strcpy(Code, Datum_Table[Index-1]->Ellipsoid_Code);
  }
  else

⌨️ 快捷键说明

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