1 | /*!\file KML_LatLonBox.cpp
|
---|
2 | * \brief: implementation of the kml_feature abstract object
|
---|
3 | */
|
---|
4 |
|
---|
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*/
|
---|
19 | /*FUNCTION KML_LatLonBox::KML_LatLonBox(){{{*/
|
---|
20 | KML_LatLonBox::KML_LatLonBox(){
|
---|
21 |
|
---|
22 | north = 0.;
|
---|
23 | south = 0.;
|
---|
24 | east = 0.;
|
---|
25 | west = 0.;
|
---|
26 | rotation = 0.;
|
---|
27 |
|
---|
28 | }
|
---|
29 | /*}}}*/
|
---|
30 | /*FUNCTION KML_LatLonBox::~KML_LatLonBox(){{{*/
|
---|
31 | KML_LatLonBox::~KML_LatLonBox(){
|
---|
32 |
|
---|
33 | ;
|
---|
34 |
|
---|
35 | }
|
---|
36 | /*}}}*/
|
---|
37 |
|
---|
38 | /*Other*/
|
---|
39 | /*FUNCTION KML_LatLonBox::Echo {{{*/
|
---|
40 | void KML_LatLonBox::Echo(){
|
---|
41 |
|
---|
42 | _printf_("KML_LatLonBox:\n");
|
---|
43 | KML_Object::Echo();
|
---|
44 |
|
---|
45 | _printf_(" north: " << north << "\n");
|
---|
46 | _printf_(" south: " << south << "\n");
|
---|
47 | _printf_(" east: " << east << "\n");
|
---|
48 | _printf_(" west: " << west << "\n");
|
---|
49 | _printf_(" rotation: " << rotation << "\n");
|
---|
50 | }
|
---|
51 | /*}}}*/
|
---|
52 | /*FUNCTION KML_LatLonBox::DeepEcho {{{*/
|
---|
53 | void KML_LatLonBox::DeepEcho(){
|
---|
54 |
|
---|
55 | char indent[81]="";
|
---|
56 |
|
---|
57 | KML_LatLonBox::DeepEcho(indent);
|
---|
58 |
|
---|
59 | return;
|
---|
60 | }
|
---|
61 | /*}}}*/
|
---|
62 | /*FUNCTION KML_LatLonBox::DeepEcho {{{*/
|
---|
63 | void KML_LatLonBox::DeepEcho(const char* indent){
|
---|
64 |
|
---|
65 | _printf_(indent << "KML_LatLonBox:\n");
|
---|
66 | KML_Object::DeepEcho(indent);
|
---|
67 |
|
---|
68 | _printf_(" north: " << north << "\n");
|
---|
69 | _printf_(" south: " << south << "\n");
|
---|
70 | _printf_(" east: " << east << "\n");
|
---|
71 | _printf_(" west: " << west << "\n");
|
---|
72 | _printf_(" rotation: " << rotation << "\n");
|
---|
73 | }
|
---|
74 | /*}}}*/
|
---|
75 | /*FUNCTION KML_LatLonBox::Write {{{*/
|
---|
76 | void KML_LatLonBox::Write(FILE* filout,const char* indent){
|
---|
77 |
|
---|
78 | fprintf(filout,"%s<LatLonBox",indent);
|
---|
79 | WriteAttrib(filout," ");
|
---|
80 | fprintf(filout,">\n");
|
---|
81 | WriteCommnt(filout,indent);
|
---|
82 |
|
---|
83 | KML_Object::Write(filout,indent);
|
---|
84 |
|
---|
85 | fprintf(filout,"%s <north>%0.16g</north>\n",indent,north);
|
---|
86 | fprintf(filout,"%s <south>%0.16g</south>\n",indent,south);
|
---|
87 | fprintf(filout,"%s <east>%0.16g</east>\n",indent,east);
|
---|
88 | fprintf(filout,"%s <west>%0.16g</west>\n",indent,west);
|
---|
89 | fprintf(filout,"%s <rotation>%0.16g</rotation>\n",indent,rotation);
|
---|
90 |
|
---|
91 | fprintf(filout,"%s</LatLonBox>\n",indent);
|
---|
92 |
|
---|
93 | return;
|
---|
94 | }
|
---|
95 | /*}}}*/
|
---|
96 | /*FUNCTION KML_LatLonBox::Read {{{*/
|
---|
97 | void KML_LatLonBox::Read(FILE* fid,char* kstr){
|
---|
98 |
|
---|
99 | char* kstri;
|
---|
100 | int ncom=0;
|
---|
101 | char** pcom=NULL;
|
---|
102 |
|
---|
103 | /* get object attributes and check for solo tag */
|
---|
104 |
|
---|
105 | if (KMLFileTagAttrib(this,
|
---|
106 | kstr))
|
---|
107 | return;
|
---|
108 |
|
---|
109 | /* loop over and process fields within opening and closing tags */
|
---|
110 |
|
---|
111 | while((kstri=KMLFileToken(fid, &ncom,&pcom))){
|
---|
112 | if (!strncmp(kstri,"</LatLonBox",11)) {
|
---|
113 | xDelete<char>(kstri);
|
---|
114 | break;
|
---|
115 | }
|
---|
116 | else if (!strncmp(kstri,"</",2))
|
---|
117 | {_error_("KML_LatLonBox::Read -- Unexpected closing tag " << kstri << ".\n");}
|
---|
118 | else if (strncmp(kstri,"<",1))
|
---|
119 | {_error_("KML_LatLonBox::Read -- Unexpected field \"" << kstri << "\".\n");}
|
---|
120 |
|
---|
121 | else if (!strcmp(kstri,"<north>"))
|
---|
122 | KMLFileTokenParse(&north ,
|
---|
123 | kstri,
|
---|
124 | fid);
|
---|
125 | else if (!strcmp(kstri,"<south>"))
|
---|
126 | KMLFileTokenParse(&south ,
|
---|
127 | kstri,
|
---|
128 | fid);
|
---|
129 | else if (!strcmp(kstri,"<east>"))
|
---|
130 | KMLFileTokenParse(&east ,
|
---|
131 | kstri,
|
---|
132 | fid);
|
---|
133 | else if (!strcmp(kstri,"<west>"))
|
---|
134 | KMLFileTokenParse(&west ,
|
---|
135 | kstri,
|
---|
136 | fid);
|
---|
137 | else if (!strcmp(kstri,"<rotation>"))
|
---|
138 | KMLFileTokenParse(&rotation ,
|
---|
139 | kstri,
|
---|
140 | fid);
|
---|
141 |
|
---|
142 | else if (!strncmp(kstri,"<",1))
|
---|
143 | KML_Object::Read(fid,kstri);
|
---|
144 |
|
---|
145 | xDelete<char>(kstri);
|
---|
146 | }
|
---|
147 |
|
---|
148 | this->AddCommnt(ncom,pcom);
|
---|
149 |
|
---|
150 | for (ncom=ncom; ncom>0; ncom--)
|
---|
151 | xDelete<char>(pcom[ncom-1]);
|
---|
152 | xDelete<char*>(pcom);
|
---|
153 |
|
---|
154 | return;
|
---|
155 | }
|
---|
156 | /*}}}*/
|
---|