Go to the documentation of this file.00001
00002
00003 #include <stdio.h>
00004 #include <string.h>
00005 #include <math.h>
00006 #include <stdlib.h>
00007
00008
00009 #include "GeomagnetismHeader.h"
00010
00011 #include "EGM9615.h"
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 int main()
00032 {
00033 MAGtype_MagneticModel * MagneticModels[1], *TimedMagneticModel;
00034 MAGtype_Ellipsoid Ellip;
00035 MAGtype_CoordSpherical CoordSpherical;
00036 MAGtype_CoordGeodetic CoordGeodetic;
00037 MAGtype_Date UserDate;
00038 MAGtype_GeoMagneticElements GeoMagneticElements;
00039 MAGtype_Geoid Geoid;
00040 char ans[20], b;
00041 char filename[] = "WMM.COF";
00042 char VersionDate_Large[] = "$Date: 2012-04-20 14:59:13 -0600 (Fri, 20 Apr 2012) $";
00043 char VersionDate[12];
00044 int NumTerms, Flag = 1, nMax = 0;
00045 int epochs = 1;
00046
00047
00048 strncpy(VersionDate, VersionDate_Large + 39, 11);
00049 VersionDate[11] = '\0';
00050 MAG_robustReadMagModels(filename, &MagneticModels, epochs);
00051 if(nMax < MagneticModels[0]->nMax) nMax = MagneticModels[0]->nMax;
00052 NumTerms = ((nMax + 1) * (nMax + 2) / 2);
00053 TimedMagneticModel = MAG_AllocateModelMemory(NumTerms);
00054 if(MagneticModels[0] == NULL || TimedMagneticModel == NULL)
00055 {
00056 MAG_Error(2);
00057 }
00058 MAG_SetDefaults(&Ellip, &Geoid);
00059
00060
00061
00062
00063
00064
00065 Geoid.GeoidHeightBuffer = GeoidHeightBuffer;
00066 Geoid.Geoid_Initialized = 1;
00067
00068 b = MAG_GeomagIntroduction_WMM(MagneticModels[0], VersionDate);
00069 while(Flag == 1 && b != 'x')
00070 {
00071 if(MAG_GetUserInput(MagneticModels[0], &Geoid, &CoordGeodetic, &UserDate) == 1)
00072 {
00073 MAG_GeodeticToSpherical(Ellip, CoordGeodetic, &CoordSpherical);
00074 MAG_TimelyModifyMagneticModel(UserDate, MagneticModels[0], TimedMagneticModel);
00075 MAG_Geomag(Ellip, CoordSpherical, CoordGeodetic, TimedMagneticModel, &GeoMagneticElements);
00076 MAG_CalculateGridVariation(CoordGeodetic, &GeoMagneticElements);
00077 MAG_PrintUserData(GeoMagneticElements, CoordGeodetic, UserDate, TimedMagneticModel, &Geoid);
00078 }
00079 printf("\n\n Do you need more point data ? (y or n) \n ");
00080 fgets(ans, 20, stdin);
00081 switch(ans[0]) {
00082 case 'Y':
00083 case 'y':
00084 Flag = 1;
00085 break;
00086 case 'N':
00087 case 'n':
00088 Flag = 0;
00089 break;
00090 default:
00091 Flag = 0;
00092 break;
00093 }
00094
00095 }
00096
00097
00098 MAG_FreeMagneticModelMemory(TimedMagneticModel);
00099 MAG_FreeMagneticModelMemory(MagneticModels[0]);
00100
00101 return 0;
00102 }
world_magnetic_model
Author(s): National Geophysical Data Center (NGDC, Boulder CO, USA), British Geological Survey (BGS, Edinburgh, Scotland)
autogenerated on Sat Jul 26 2014 07:02:19