1 | /*!\file KML_Icon.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 <stdio.h>
|
---|
14 | #include <string.h>
|
---|
15 | #include "../objects.h"
|
---|
16 | #include "../../shared/shared.h"
|
---|
17 | #include "../../io/io.h"
|
---|
18 | #include "../../Container/Container.h"
|
---|
19 | #include "../../include/include.h"
|
---|
20 | /*}}}*/
|
---|
21 |
|
---|
22 | /*Constructors/destructor/copy*/
|
---|
23 | /*FUNCTION KML_Icon::KML_Icon(){{{*/
|
---|
24 | KML_Icon::KML_Icon(){
|
---|
25 |
|
---|
26 | strcpy(href ,"");
|
---|
27 | strcpy(refmode ,"onChange");
|
---|
28 | refint = 4.;
|
---|
29 | strcpy(vrefmode ,"never");
|
---|
30 | vreftime = 4.;
|
---|
31 | vboundsc = 1.;
|
---|
32 | strcpy(vformat ,"");
|
---|
33 | strcpy(hquery ,"");
|
---|
34 |
|
---|
35 | }
|
---|
36 | /*}}}*/
|
---|
37 | /*FUNCTION KML_Icon::~KML_Icon(){{{*/
|
---|
38 | KML_Icon::~KML_Icon(){
|
---|
39 |
|
---|
40 | ;
|
---|
41 |
|
---|
42 | }
|
---|
43 | /*}}}*/
|
---|
44 |
|
---|
45 | /*Other*/
|
---|
46 | /*FUNCTION KML_Icon::Echo {{{*/
|
---|
47 | void KML_Icon::Echo(){
|
---|
48 |
|
---|
49 | bool flag=true;
|
---|
50 |
|
---|
51 | _printf_(flag,"KML_Icon:\n");
|
---|
52 | KML_Object::Echo();
|
---|
53 |
|
---|
54 | _printf_(flag," href: \"%s\"\n" ,href);
|
---|
55 | _printf_(flag," refmode: \"%s\"\n" ,refmode);
|
---|
56 | _printf_(flag," refint: %g\n" ,refint);
|
---|
57 | _printf_(flag," vrefmode: \"%s\"\n" ,vrefmode);
|
---|
58 | _printf_(flag," vreftime: %g\n" ,vreftime);
|
---|
59 | _printf_(flag," vboundsc: %g\n" ,vboundsc);
|
---|
60 | _printf_(flag," vformat: \"%s\"\n" ,vformat);
|
---|
61 | _printf_(flag," hquery: \"%s\"\n" ,hquery);
|
---|
62 |
|
---|
63 | return;
|
---|
64 | }
|
---|
65 | /*}}}*/
|
---|
66 |
|
---|
67 | /*FUNCTION KML_Icon::DeepEcho {{{*/
|
---|
68 | void KML_Icon::DeepEcho(){
|
---|
69 |
|
---|
70 | char indent[81]="";
|
---|
71 |
|
---|
72 | KML_Icon::DeepEcho(indent);
|
---|
73 |
|
---|
74 | return;
|
---|
75 | }
|
---|
76 | /*}}}*/
|
---|
77 |
|
---|
78 | /*FUNCTION KML_Icon::DeepEcho {{{*/
|
---|
79 | void KML_Icon::DeepEcho(const char* indent){
|
---|
80 |
|
---|
81 | bool flag=true;
|
---|
82 |
|
---|
83 | _printf_(flag,"%sKML_Icon:\n",indent);
|
---|
84 | KML_Object::DeepEcho(indent);
|
---|
85 |
|
---|
86 | _printf_(flag,"%s href: \"%s\"\n" ,indent,href);
|
---|
87 | _printf_(flag,"%s refmode: \"%s\"\n" ,indent,refmode);
|
---|
88 | _printf_(flag,"%s refint: %g\n" ,indent,refint);
|
---|
89 | _printf_(flag,"%s vrefmode: \"%s\"\n" ,indent,vrefmode);
|
---|
90 | _printf_(flag,"%s vreftime: %g\n" ,indent,vreftime);
|
---|
91 | _printf_(flag,"%s vboundsc: %g\n" ,indent,vboundsc);
|
---|
92 | _printf_(flag,"%s vformat: \"%s\"\n" ,indent,vformat);
|
---|
93 | _printf_(flag,"%s hquery: \"%s\"\n" ,indent,hquery);
|
---|
94 |
|
---|
95 | return;
|
---|
96 | }
|
---|
97 | /*}}}*/
|
---|
98 |
|
---|
99 | /*FUNCTION KML_Icon::Write {{{*/
|
---|
100 | void KML_Icon::Write(FILE* filout,const char* indent){
|
---|
101 |
|
---|
102 | fprintf(filout,"%s<Icon",indent);
|
---|
103 | WriteAttrib(filout," ");
|
---|
104 | fprintf(filout,">\n");
|
---|
105 | WriteCommnt(filout,indent);
|
---|
106 |
|
---|
107 | KML_Object::Write(filout,indent);
|
---|
108 |
|
---|
109 | if (href && strlen(href))
|
---|
110 | fprintf(filout,"%s <href>%s</href>\n",indent,href);
|
---|
111 | if (refmode && strlen(refmode))
|
---|
112 | fprintf(filout,"%s <refreshMode>%s</refreshMode>\n",indent,refmode);
|
---|
113 | fprintf(filout,"%s <refreshInterval>%g</refreshInterval>\n",indent,refint);
|
---|
114 | if (vrefmode && strlen(vrefmode))
|
---|
115 | fprintf(filout,"%s <viewRefreshMode>%s</viewRefreshMode>\n",indent,vrefmode);
|
---|
116 | fprintf(filout,"%s <viewRefreshTime>%g</viewRefreshTime>\n",indent,vreftime);
|
---|
117 | fprintf(filout,"%s <viewBoundScale>%g</viewBoundScale>\n",indent,vboundsc);
|
---|
118 | if (vformat && strlen(vformat))
|
---|
119 | fprintf(filout,"%s <viewFormat>%s</viewFormat>\n",indent,vformat);
|
---|
120 | if (hquery && strlen(hquery))
|
---|
121 | fprintf(filout,"%s <httpQuery>%s</httpQuery>\n",indent,hquery);
|
---|
122 |
|
---|
123 | fprintf(filout,"%s</Icon>\n",indent);
|
---|
124 |
|
---|
125 | return;
|
---|
126 | }
|
---|
127 | /*}}}*/
|
---|
128 |
|
---|
129 | /*FUNCTION KML_Icon::Read {{{*/
|
---|
130 | void KML_Icon::Read(FILE* fid,char* kstr){
|
---|
131 |
|
---|
132 | char* kstri;
|
---|
133 | int ncom=0;
|
---|
134 | char** pcom=NULL;
|
---|
135 |
|
---|
136 | /* get object attributes and check for solo tag */
|
---|
137 |
|
---|
138 | if (KMLFileTagAttrib(this,
|
---|
139 | kstr))
|
---|
140 | return;
|
---|
141 |
|
---|
142 | /* loop over and process fields within opening and closing tags */
|
---|
143 |
|
---|
144 | while (kstri=KMLFileToken(fid,
|
---|
145 | &ncom,&pcom)) {
|
---|
146 | if (!strncmp(kstri,"</Icon", 6)) {
|
---|
147 | xfree((void**)&kstri);
|
---|
148 | break;
|
---|
149 | }
|
---|
150 | else if (!strncmp(kstri,"</",2))
|
---|
151 | {_error2_("KML_Icon::Read -- Unexpected closing tag " << kstri << ".\n");}
|
---|
152 | else if (strncmp(kstri,"<",1))
|
---|
153 | {_error2_("KML_Icon::Read -- Unexpected field \"" << kstri << "\".\n");}
|
---|
154 |
|
---|
155 | else if (!strcmp(kstri,"<href>"))
|
---|
156 | KMLFileTokenParse( href ,NULL,KML_ICON_HREF_LENGTH, kstri, fid);
|
---|
157 | else if (!strcmp(kstri,"<refreshMode>"))
|
---|
158 | KMLFileTokenParse( refmode ,NULL,KML_ICON_REFMODE_LENGTH, kstri, fid);
|
---|
159 | else if (!strcmp(kstri,"<refreshInterval>"))
|
---|
160 | KMLFileTokenParse(&refint , kstri, fid);
|
---|
161 | else if (!strcmp(kstri,"<viewRefreshMode>"))
|
---|
162 | KMLFileTokenParse( vrefmode ,NULL,KML_ICON_VREFMODE_LENGTH, kstri, fid);
|
---|
163 | else if (!strcmp(kstri,"<viewRefreshTime>"))
|
---|
164 | KMLFileTokenParse(&vreftime , kstri, fid);
|
---|
165 | else if (!strcmp(kstri,"<viewBoundScale>"))
|
---|
166 | KMLFileTokenParse(&vboundsc , kstri, fid);
|
---|
167 | else if (!strcmp(kstri,"<viewFormat>"))
|
---|
168 | KMLFileTokenParse( vformat ,NULL,KML_ICON_VFORMAT_LENGTH, kstri, fid);
|
---|
169 | else if (!strcmp(kstri,"<httpQuery>"))
|
---|
170 | KMLFileTokenParse( hquery ,NULL,KML_ICON_HQUERY_LENGTH, kstri, fid);
|
---|
171 |
|
---|
172 | else if (!strncmp(kstri,"<",1))
|
---|
173 | KML_Object::Read(fid,kstri);
|
---|
174 |
|
---|
175 | xfree((void**)&kstri);
|
---|
176 | }
|
---|
177 |
|
---|
178 | this->AddCommnt(ncom,pcom);
|
---|
179 |
|
---|
180 | for (ncom; ncom>0; ncom--)
|
---|
181 | xfree((void**)&(pcom[ncom-1]));
|
---|
182 | xfree((void**)&pcom);
|
---|
183 |
|
---|
184 | return;
|
---|
185 | }
|
---|
186 | /*}}}*/
|
---|
187 |
|
---|