Ice Sheet System Model  4.18
Code documentation
KML_LatLonBox.cpp
Go to the documentation of this file.
1 
5 /*Headers:*/
6 /*{{{*/
7 #ifdef HAVE_CONFIG_H
8  #include <config.h>
9 #else
10 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
11 #endif
12 
13 #include "./KML_LatLonBox.h"
14 #include "./KMLFileReadUtils.h"
15 #include "../shared/shared.h"
16 /*}}}*/
17 
18 /*Constructors/destructor/copy*/
20 
21  north = 0.;
22  south = 0.;
23  east = 0.;
24  west = 0.;
25  rotation = 0.;
26 
27 }
28 /*}}}*/
30 
31  ;
32 
33 }
34 /*}}}*/
35 
36 /*Other*/
37 void KML_LatLonBox::Echo(){/*{{{*/
38 
39  _printf_("KML_LatLonBox:\n");
41 
42  _printf_(" north: " << north << "\n");
43  _printf_(" south: " << south << "\n");
44  _printf_(" east: " << east << "\n");
45  _printf_(" west: " << west << "\n");
46  _printf_(" rotation: " << rotation << "\n");
47 }
48 /*}}}*/
50 
51  char indent[81]="";
52 
54 
55  return;
56 }
57 /*}}}*/
58 void KML_LatLonBox::DeepEcho(const char* indent){/*{{{*/
59 
60  _printf_(indent << "KML_LatLonBox:\n");
61  KML_Object::DeepEcho(indent);
62 
63  _printf_(" north: " << north << "\n");
64  _printf_(" south: " << south << "\n");
65  _printf_(" east: " << east << "\n");
66  _printf_(" west: " << west << "\n");
67  _printf_(" rotation: " << rotation << "\n");
68 }
69 /*}}}*/
70 void KML_LatLonBox::Write(FILE* filout,const char* indent){/*{{{*/
71 
72  fprintf(filout,"%s<LatLonBox",indent);
73  WriteAttrib(filout," ");
74  fprintf(filout,">\n");
75  WriteCommnt(filout,indent);
76 
77  KML_Object::Write(filout,indent);
78 
79  fprintf(filout,"%s <north>%0.16g</north>\n",indent,north);
80  fprintf(filout,"%s <south>%0.16g</south>\n",indent,south);
81  fprintf(filout,"%s <east>%0.16g</east>\n",indent,east);
82  fprintf(filout,"%s <west>%0.16g</west>\n",indent,west);
83  fprintf(filout,"%s <rotation>%0.16g</rotation>\n",indent,rotation);
84 
85  fprintf(filout,"%s</LatLonBox>\n",indent);
86 
87  return;
88 }
89 /*}}}*/
90 void KML_LatLonBox::Read(FILE* fid,char* kstr){/*{{{*/
91 
92  char* kstri;
93  int ncom=0;
94  char** pcom=NULL;
95 
96 /* get object attributes and check for solo tag */
97 
98  if (KMLFileTagAttrib(this,
99  kstr))
100  return;
101 
102 /* loop over and process fields within opening and closing tags */
103 
104  while((kstri=KMLFileToken(fid, &ncom,&pcom))){
105  if (!strncmp(kstri,"</LatLonBox",11)) {
106  xDelete<char>(kstri);
107  break;
108  }
109  else if (!strncmp(kstri,"</",2))
110  {_error_("KML_LatLonBox::Read -- Unexpected closing tag " << kstri << ".\n");}
111  else if (strncmp(kstri,"<",1))
112  {_error_("KML_LatLonBox::Read -- Unexpected field \"" << kstri << "\".\n");}
113 
114  else if (!strcmp(kstri,"<north>"))
116  kstri,
117  fid);
118  else if (!strcmp(kstri,"<south>"))
120  kstri,
121  fid);
122  else if (!strcmp(kstri,"<east>"))
124  kstri,
125  fid);
126  else if (!strcmp(kstri,"<west>"))
128  kstri,
129  fid);
130  else if (!strcmp(kstri,"<rotation>"))
132  kstri,
133  fid);
134 
135  else if (!strncmp(kstri,"<",1))
136  KML_Object::Read(fid,kstri);
137 
138  xDelete<char>(kstri);
139  }
140 
141  this->AddCommnt(ncom,pcom);
142 
143  for (ncom=ncom; ncom>0; ncom--)
144  xDelete<char>(pcom[ncom-1]);
145  xDelete<char*>(pcom);
146 
147  return;
148 }
149 /*}}}*/
KML_LatLonBox::~KML_LatLonBox
~KML_LatLonBox()
Definition: KML_LatLonBox.cpp:29
KML_LatLonBox::KML_LatLonBox
KML_LatLonBox()
Definition: KML_LatLonBox.cpp:19
KML_Object::WriteAttrib
virtual void WriteAttrib(FILE *fid, const char *indent)
Definition: KML_Object.cpp:288
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
KMLFileReadUtils.h
: header file for kml file reading utilities.
KMLFileTagAttrib
int KMLFileTagAttrib(KML_Object *kobj, char *ktag)
Definition: KMLFileReadUtils.cpp:287
KML_LatLonBox.h
: header file for kml_latlonbox object
KML_LatLonBox::rotation
double rotation
Definition: KML_LatLonBox.h:22
KML_LatLonBox::Read
void Read(FILE *fid, char *kstr)
Definition: KML_LatLonBox.cpp:90
KML_Object::Read
virtual void Read(FILE *fid, char *kstr)=0
Definition: KML_Object.cpp:143
KMLFileToken
char * KMLFileToken(FILE *fid, int *pncom=NULL, char ***ppcom=NULL)
Definition: KMLFileReadUtils.cpp:18
KML_LatLonBox::west
double west
Definition: KML_LatLonBox.h:21
KML_LatLonBox::Write
void Write(FILE *fid, const char *indent)
Definition: KML_LatLonBox.cpp:70
KML_Object::Write
virtual void Write(FILE *fid, const char *indent)=0
Definition: KML_Object.cpp:122
KML_LatLonBox::east
double east
Definition: KML_LatLonBox.h:20
KML_Object::DeepEcho
virtual void DeepEcho()
Definition: KML_Object.cpp:72
KMLFileTokenParse
int KMLFileTokenParse(int *pival, char *ktag, FILE *fid)
Definition: KMLFileReadUtils.cpp:335
KML_LatLonBox::DeepEcho
void DeepEcho()
Definition: KML_LatLonBox.cpp:49
KML_LatLonBox::south
double south
Definition: KML_LatLonBox.h:19
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
KML_Object::Echo
virtual void Echo()
Definition: KML_Object.cpp:61
KML_LatLonBox::Echo
void Echo()
Definition: KML_LatLonBox.cpp:37
KML_Object::AddCommnt
virtual void AddCommnt(int ncom, char **pcom)
Definition: KML_Object.cpp:301
KML_Object::WriteCommnt
virtual void WriteCommnt(FILE *fid, const char *indent)
Definition: KML_Object.cpp:326
KML_LatLonBox::north
double north
Definition: KML_LatLonBox.h:18