Ice Sheet System Model  4.18
Code documentation
KML_GroundOverlay.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_Object.h"
14 #include "./KML_LatLonBox.h"
15 #include "./KML_GroundOverlay.h"
16 #include "./KMLFileReadUtils.h"
17 #include "../shared/shared.h"
18 /*}}}*/
19 
20 /*Constructors/destructor/copy*/
22 
23  altitude = 0.;
24  memcpy(altmode,"clampToGround",(strlen("clampToGround")+1)*sizeof(char));
25 
26  llbox =NULL;
27 
28 }
29 /*}}}*/
31 
32  if (llbox) {
33  delete llbox;
34  llbox =NULL;
35  }
36 
37 }
38 /*}}}*/
39 
40 /*Other*/
42 
43  _printf_("KML_GroundOverlay:\n");
45 
46  _printf_(" altitude: " << altitude << "\n");
47  _printf_(" altmode: " << altmode << "\n");
48  _printf_(" llbox: " << llbox << "\n");
49 }
50 /*}}}*/
52 
53  char indent[81]="";
54 
56 
57  return;
58 }
59 /*}}}*/
60 void KML_GroundOverlay::DeepEcho(const char* indent){/*{{{*/
61 
62  char indent2[81];
63 
64  _printf_(indent << "KML_GroundOverlay:\n");
65  KML_Overlay::DeepEcho(indent);
66 
67  memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
68  strcat(indent2," ");
69 
70  _printf_(indent<<" altitude: " << altitude << "\n");
71  _printf_(indent<<" altmode: " << altmode << "\n");
72  if (llbox)
73  llbox->DeepEcho(indent2);
74  else
75  _printf_(indent<<" llbox: " << llbox << "\n");
76 }
77 /*}}}*/
78 void KML_GroundOverlay::Write(FILE* filout,const char* indent){/*{{{*/
79 
80  char indent2[81];
81 
82  fprintf(filout,"%s<GroundOverlay",indent);
83  WriteAttrib(filout," ");
84  fprintf(filout,">\n");
85  WriteCommnt(filout,indent);
86 
87  KML_Overlay::Write(filout,indent);
88 
89  memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
90 
91  strcat(indent2," ");
92 
93  fprintf(filout,"%s <altitude>%0.16g</altitude>\n",indent,altitude);
94  fprintf(filout,"%s <altitudeMode>%s</altitudeMode>\n",indent,altmode);
95  if (llbox)
96  llbox->Write(filout,indent2);
97 
98  fprintf(filout,"%s</GroundOverlay>\n",indent);
99 
100  return;
101 }
102 /*}}}*/
103 void KML_GroundOverlay::Read(FILE* fid,char* kstr){/*{{{*/
104 
105  char* kstri;
106  int ncom=0;
107  char** pcom=NULL;
108 
109 /* get object attributes and check for solo tag */
110 
111  if (KMLFileTagAttrib(this,
112  kstr))
113  return;
114 
115 /* loop over and process fields within opening and closing tags */
116 
117  while((kstri=KMLFileToken(fid, &ncom,&pcom))){
118  if (!strncmp(kstri,"</GroundOverlay",15)) {
119  xDelete<char>(kstri);
120  break;
121  }
122  else if (!strncmp(kstri,"</",2))
123  {_error_("KML_GroundOverlay::Read -- Unexpected closing tag " << kstri << ".\n");}
124  else if (strncmp(kstri,"<",1))
125  {_error_("KML_GroundOverlay::Read -- Unexpected field \"" << kstri << "\".\n");}
126 
127  else if (!strcmp(kstri,"<altitude>"))
129  kstri,
130  fid);
131  else if (!strcmp(kstri,"<altitudeMode>"))
133  kstri,
134  fid);
135  else if (!strncmp(kstri,"<LatLonBox",10)) {
136  llbox =new KML_LatLonBox();
137  llbox ->Read(fid,kstri);
138  }
139 
140  else if (!strncmp(kstri,"<",1))
141  KML_Overlay::Read(fid,kstri);
142 
143  xDelete<char>(kstri);
144  }
145 
146  this->AddCommnt(ncom,pcom);
147 
148  for(ncom=ncom; ncom>0; ncom--)
149  xDelete<char>(pcom[ncom-1]);
150  xDelete<char*>(pcom);
151 
152  return;
153 }
154 /*}}}*/
KML_Object.h
: header file for kml_object abstract object
KML_Object::WriteAttrib
virtual void WriteAttrib(FILE *fid, const char *indent)
Definition: KML_Object.cpp:288
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
KML_Overlay::Write
void Write(FILE *fid, const char *indent)
Definition: KML_Overlay.cpp:74
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_GROUNDOVERLAY_ALTMODE_LENGTH
#define KML_GROUNDOVERLAY_ALTMODE_LENGTH
Definition: KML_GroundOverlay.h:8
KML_LatLonBox::Read
void Read(FILE *fid, char *kstr)
Definition: KML_LatLonBox.cpp:90
KML_GroundOverlay::llbox
KML_LatLonBox * llbox
Definition: KML_GroundOverlay.h:23
KML_GroundOverlay::Echo
void Echo()
Definition: KML_GroundOverlay.cpp:41
KML_GroundOverlay.h
: header file for kml_groundoverlay object
KML_GroundOverlay::~KML_GroundOverlay
~KML_GroundOverlay()
Definition: KML_GroundOverlay.cpp:30
KML_GroundOverlay::Write
void Write(FILE *fid, const char *indent)
Definition: KML_GroundOverlay.cpp:78
KMLFileToken
char * KMLFileToken(FILE *fid, int *pncom=NULL, char ***ppcom=NULL)
Definition: KMLFileReadUtils.cpp:18
KML_GroundOverlay::KML_GroundOverlay
KML_GroundOverlay()
Definition: KML_GroundOverlay.cpp:21
KML_LatLonBox::Write
void Write(FILE *fid, const char *indent)
Definition: KML_LatLonBox.cpp:70
KML_LatLonBox
Definition: KML_LatLonBox.h:14
KML_Overlay::Read
void Read(FILE *fid, char *kstr)
Definition: KML_Overlay.cpp:93
KMLFileTokenParse
int KMLFileTokenParse(int *pival, char *ktag, FILE *fid)
Definition: KMLFileReadUtils.cpp:335
KML_Overlay::DeepEcho
void DeepEcho()
Definition: KML_Overlay.cpp:49
KML_Overlay::Echo
void Echo()
Definition: KML_Overlay.cpp:41
KML_LatLonBox::DeepEcho
void DeepEcho()
Definition: KML_LatLonBox.cpp:49
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
KML_GroundOverlay::DeepEcho
void DeepEcho()
Definition: KML_GroundOverlay.cpp:51
KML_GroundOverlay::altmode
char altmode[KML_GROUNDOVERLAY_ALTMODE_LENGTH+1]
Definition: KML_GroundOverlay.h:22
KML_GroundOverlay::altitude
double altitude
Definition: KML_GroundOverlay.h:21
KML_GroundOverlay::Read
void Read(FILE *fid, char *kstr)
Definition: KML_GroundOverlay.cpp:103
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