Ice Sheet System Model  4.18
Code documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Data Fields
KML_LinearRing Class Reference

#include <KML_LinearRing.h>

Inheritance diagram for KML_LinearRing:
KML_Geometry KML_Object Object

Public Member Functions

 KML_LinearRing ()
 
 ~KML_LinearRing ()
 
void Echo ()
 
void DeepEcho ()
 
void DeepEcho (const char *indent)
 
void Write (FILE *fid, const char *indent)
 
void Read (FILE *fid, char *kstr)
 
void WriteExp (FILE *fid, const char *nstr, int sgn, double cm, double sp)
 
int Id ()
 
int ObjectEnum ()
 
Objectcopy ()
 
void Marshall (char **pmarshalled_data, int *pmarshalled_data_size, int marshall_direction)
 
- Public Member Functions inherited from KML_Geometry
 KML_Geometry ()
 
 ~KML_Geometry ()
 
- Public Member Functions inherited from KML_Object
 KML_Object ()
 
 ~KML_Object ()
 
int Id ()
 
int ObjectEnum ()
 
Objectcopy ()
 
void Marshall (char **pmarshalled_data, int *pmarshalled_data_size, int marshall_direction)
 
virtual void AddAttrib (const char *name, const char *value)
 
virtual void WriteAttrib (FILE *fid, const char *indent)
 
virtual void AddCommnt (int ncom, char **pcom)
 
virtual void AddCommnt (char *value)
 
virtual void WriteCommnt (FILE *fid, const char *indent)
 
- Public Member Functions inherited from Object
virtual ~Object ()
 

Data Fields

bool extrude
 
bool tessellate
 
char altmode [KML_LINEARRING_ALTMODE_LENGTH+1]
 
int ncoord
 
double * coords
 
- Data Fields inherited from KML_Object
DataSetattrib
 
DataSetcommnt
 
DataSetkmlobj
 

Detailed Description

Definition at line 16 of file KML_LinearRing.h.

Constructor & Destructor Documentation

◆ KML_LinearRing()

KML_LinearRing::KML_LinearRing ( )

Definition at line 19 of file KML_LinearRing.cpp.

19  {/*{{{*/
20 
21  extrude =false;
22  tessellate=false;
23  memcpy(altmode,"clampToGround",(strlen("clampToGround")+1)*sizeof(char));
24 
25  ncoord =0;
26  coords =NULL;
27 
28 }

◆ ~KML_LinearRing()

KML_LinearRing::~KML_LinearRing ( )

Definition at line 30 of file KML_LinearRing.cpp.

30  {/*{{{*/
31 
32  if (coords) xDelete<double>(coords);
33 
34  coords =NULL;
35  ncoord =0;
36 
37 }

Member Function Documentation

◆ Echo()

void KML_LinearRing::Echo ( void  )
virtual

Reimplemented from KML_Geometry.

Definition at line 41 of file KML_LinearRing.cpp.

41  {/*{{{*/
42 
43  bool flag=true;
44 
45  if(flag) _printf0_("KML_LinearRing:\n");
47 
48  if(flag) _printf0_(" extrude: " << (extrude ? "true" : "false") << "\n");
49  if(flag) _printf0_(" tessellate: " << (tessellate ? "true" : "false") << "\n");
50  if(flag) _printf0_(" altmode: \"" << altmode << "\"\n");
51  if(flag) _printf0_(" coords: (ncoord=" << ncoord << ")\n");
52 
53  return;
54 }

◆ DeepEcho() [1/2]

void KML_LinearRing::DeepEcho ( void  )
virtual

Reimplemented from KML_Geometry.

Definition at line 56 of file KML_LinearRing.cpp.

56  {/*{{{*/
57 
58  char indent[81]="";
59 
61 
62  return;
63 }

◆ DeepEcho() [2/2]

void KML_LinearRing::DeepEcho ( const char *  indent)
virtual

Reimplemented from KML_Geometry.

Definition at line 65 of file KML_LinearRing.cpp.

65  {/*{{{*/
66 
67  int i;
68  bool flag=true;
69 
70  if(flag) _printf0_(indent << "KML_LinearRing:\n");
71  KML_Geometry::DeepEcho(indent);
72 
73  if(flag) _printf0_(indent << " extrude: " << (extrude ? "true" : "false") << "\n");
74  if(flag) _printf0_(indent << " tessellate: " << (tessellate ? "true" : "false") << "\n");
75  if(flag) _printf0_(indent << " altmode: \"" << altmode << "\"\n");
76  if(flag) _printf0_(indent << " coords: (ncoord=" << ncoord << ")\n");
77  for (i=0; i<ncoord; i++)
78  if(flag)_printf_(indent << " (" <<coords[3*i+0] << "," <<coords[3*i+1] << "," <<coords[3*i+2] << ")\n\n");
79 
80  return;
81 }

◆ Write()

void KML_LinearRing::Write ( FILE *  fid,
const char *  indent 
)
virtual

Reimplemented from KML_Geometry.

Definition at line 83 of file KML_LinearRing.cpp.

83  {/*{{{*/
84 
85  int i;
86 
87  fprintf(filout,"%s<LinearRing",indent);
88  WriteAttrib(filout," ");
89  fprintf(filout,">\n");
90  WriteCommnt(filout,indent);
91 
92  KML_Geometry::Write(filout,indent);
93 
94  fprintf(filout,"%s <extrude>%d</extrude>\n",indent,(extrude ? 1 : 0));
95  fprintf(filout,"%s <tessellate>%d</tessellate>\n",indent,(tessellate ? 1 : 0));
96  fprintf(filout,"%s <altitudeMode>%s</altitudeMode>\n",indent,altmode);
97  fprintf(filout,"%s <coordinates>\n",indent);
98 
99 /* loop over the coordinates for the linearring */
100 
101  for (i=0; i<ncoord; i++)
102  fprintf(filout,"%s %0.16g,%0.16g,%0.16g\n",indent,coords[3*i+0],coords[3*i+1],coords[3*i+2]);
103 
104  fprintf(filout,"%s </coordinates>\n",indent);
105  fprintf(filout,"%s</LinearRing>\n",indent);
106 
107  return;
108 }

◆ Read()

void KML_LinearRing::Read ( FILE *  fid,
char *  kstr 
)
virtual

Reimplemented from KML_Geometry.

Definition at line 110 of file KML_LinearRing.cpp.

110  {/*{{{*/
111 
112  char *kstri = NULL;
113  int ncom = 0;
114  char **pcom = NULL;
115 
116 /* get object attributes and check for solo tag */
117 
118  if (KMLFileTagAttrib(this,kstr)) return;
119 
120 /* loop over and process fields within opening and closing tags */
121 
122  while((kstri=KMLFileToken(fid,&ncom,&pcom))){
123  if (!strncmp(kstri,"</LinearRing",12)){
124  xDelete<char>(kstri);
125  break;
126  }
127  else if (!strncmp(kstri,"</",2))
128  {_error_("KML_LinearRing::Read -- Unexpected closing tag " << kstri << ".\n");}
129  else if (strncmp(kstri,"<",1))
130  {_error_("KML_LinearRing::Read -- Unexpected field \"" << kstri << "\".\n");}
131 
132  else if (!strcmp(kstri,"<extrude>"))
133  KMLFileTokenParse(&extrude,kstri,fid);
134  else if (!strcmp(kstri,"<tessellate>"))
135  KMLFileTokenParse(&tessellate,kstri,fid);
136  else if (!strcmp(kstri,"<altitudeMode>"))
138  else if (!strcmp(kstri,"<coordinates>"))
139  KMLFileTokenParse(&coords,&ncoord,3,0,kstri,fid);
140  else if (!strncmp(kstri,"<",1))
141  KML_Geometry::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 }

◆ WriteExp()

void KML_LinearRing::WriteExp ( FILE *  fid,
const char *  nstr,
int  sgn,
double  cm,
double  sp 
)
virtual

Reimplemented from KML_Object.

Definition at line 155 of file KML_LinearRing.cpp.

155  {/*{{{*/
156 
157  int i;
158  double *lat,*lon,*x,*y;
159  char nstr2[81];
160 
161 /* extract latitude and longitude into vectors */
162 
163  lat=xNew<IssmPDouble>(ncoord);
164  lon=xNew<IssmPDouble>(ncoord);
165  for (i=0; i<ncoord; i++) {
166  lon[i]=coords[3*i+0];
167  lat[i]=coords[3*i+1];
168  }
169 
170 /* convert latitude and longitude to x and y */
171 
172  x =xNew<IssmPDouble>(ncoord);
173  y =xNew<IssmPDouble>(ncoord);
174  if (sgn) {
175  Ll2xyx(x,y,lat,lon,ncoord,sgn,cm,sp);
176  }
177  else {
178  memcpy(x,lon,ncoord*sizeof(IssmDouble));
179  memcpy(y,lat,ncoord*sizeof(IssmDouble));
180  }
181 
182 /* write header */
183 
184  memcpy(nstr2,nstr,(strlen(nstr)+1)*sizeof(char));
185 
186  for (i=0; i<strlen(nstr2); i++)
187  if ((nstr2[i] == ' ') || (nstr2[i] == '\t'))
188  nstr2[i]='_';
189  fprintf(fid,"## Name:%s\n",nstr2);
190  fprintf(fid,"## Icon:0\n");
191  fprintf(fid,"# Points Count Value\n");
192  if ((lat[ncoord-1] != lat[0]) || (lon[ncoord-1] != lon[0]))
193  fprintf(fid,"%u %s\n",ncoord+1,"1.");
194  else
195  fprintf(fid,"%u %s\n",ncoord ,"1.");
196  fprintf(fid,"# X pos Y pos\n");
197 
198 /* write vertices, making sure ring is closed */
199 
200  for (i=0; i<ncoord; i++)
201  fprintf(fid,"%lf\t%lf\n",x[i],y[i]);
202  if ((lat[ncoord-1] != lat[0]) || (lon[ncoord-1] != lon[0]))
203  fprintf(fid,"%lf\t%lf\n",x[0],y[0]);
204 
205 /* write blank line */
206 
207  fprintf(fid,"\n");
208 
209  xDelete<double>(y);
210  xDelete<double>(x);
211  xDelete<double>(lon);
212  xDelete<double>(lat);
213 
214  return;
215 }

◆ Id()

int KML_LinearRing::Id ( void  )
inlinevirtual

Reimplemented from KML_Geometry.

Definition at line 37 of file KML_LinearRing.h.

37 {_error_("Not implemented yet.");};

◆ ObjectEnum()

int KML_LinearRing::ObjectEnum ( void  )
inlinevirtual

Reimplemented from KML_Geometry.

Definition at line 38 of file KML_LinearRing.h.

38 {_error_("Not implemented yet.");};

◆ copy()

Object* KML_LinearRing::copy ( void  )
inlinevirtual

Reimplemented from KML_Geometry.

Definition at line 39 of file KML_LinearRing.h.

39 {_error_("Not implemented yet.");};

◆ Marshall()

void KML_LinearRing::Marshall ( char **  pmarshalled_data,
int *  pmarshalled_data_size,
int  marshall_direction 
)
inlinevirtual

Reimplemented from KML_Geometry.

Definition at line 40 of file KML_LinearRing.h.

40 { _error_("not implemented yet!");};

Field Documentation

◆ extrude

bool KML_LinearRing::extrude

Definition at line 20 of file KML_LinearRing.h.

◆ tessellate

bool KML_LinearRing::tessellate

Definition at line 21 of file KML_LinearRing.h.

◆ altmode

char KML_LinearRing::altmode[KML_LINEARRING_ALTMODE_LENGTH+1]

Definition at line 22 of file KML_LinearRing.h.

◆ ncoord

int KML_LinearRing::ncoord

Definition at line 23 of file KML_LinearRing.h.

◆ coords

double* KML_LinearRing::coords

Definition at line 24 of file KML_LinearRing.h.


The documentation for this class was generated from the following files:
Ll2xyx
int Ll2xyx(double *x, double *y, double *lat, double *lon, int ncoord, int sgn)
Definition: Ll2xyx.cpp:8
IssmDouble
double IssmDouble
Definition: types.h:37
_printf0_
#define _printf0_(StreamArgs)
Definition: Print.h:29
KML_Object::WriteAttrib
virtual void WriteAttrib(FILE *fid, const char *indent)
Definition: KML_Object.cpp:288
KML_Geometry::Write
void Write(FILE *fid, const char *indent)
Definition: KML_Geometry.cpp:56
KML_LinearRing::coords
double * coords
Definition: KML_LinearRing.h:24
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
KML_LinearRing::altmode
char altmode[KML_LINEARRING_ALTMODE_LENGTH+1]
Definition: KML_LinearRing.h:22
KMLFileTagAttrib
int KMLFileTagAttrib(KML_Object *kobj, char *ktag)
Definition: KMLFileReadUtils.cpp:287
KMLFileToken
char * KMLFileToken(FILE *fid, int *pncom=NULL, char ***ppcom=NULL)
Definition: KMLFileReadUtils.cpp:18
KML_LinearRing::tessellate
bool tessellate
Definition: KML_LinearRing.h:21
KML_Geometry::DeepEcho
void DeepEcho()
Definition: KML_Geometry.cpp:40
KML_LinearRing::extrude
bool extrude
Definition: KML_LinearRing.h:20
KML_LinearRing::ncoord
int ncoord
Definition: KML_LinearRing.h:23
KMLFileTokenParse
int KMLFileTokenParse(int *pival, char *ktag, FILE *fid)
Definition: KMLFileReadUtils.cpp:335
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
KML_LinearRing::DeepEcho
void DeepEcho()
Definition: KML_LinearRing.cpp:56
KML_LINEARRING_ALTMODE_LENGTH
#define KML_LINEARRING_ALTMODE_LENGTH
Definition: KML_LinearRing.h:8
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_Geometry::Echo
void Echo()
Definition: KML_Geometry.cpp:33
KML_Geometry::Read
void Read(FILE *fid, char *kstr)
Definition: KML_Geometry.cpp:63