| 1 | /*!\file KML_Icon.cpp | 
|---|
| 2 | * \brief: implementation of the kml_feature abstract object | 
|---|
| 3 | */ | 
|---|
| 4 |  | 
|---|
| 5 | /*Headers:*/ | 
|---|
| 6 | /*{{{1*/ | 
|---|
| 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(){{{1*/ | 
|---|
| 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(){{{1*/ | 
|---|
| 38 | KML_Icon::~KML_Icon(){ | 
|---|
| 39 |  | 
|---|
| 40 | ; | 
|---|
| 41 |  | 
|---|
| 42 | } | 
|---|
| 43 | /*}}}*/ | 
|---|
| 44 |  | 
|---|
| 45 | /*Other*/ | 
|---|
| 46 | /*FUNCTION KML_Icon::Echo {{{1*/ | 
|---|
| 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 {{{1*/ | 
|---|
| 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 {{{1*/ | 
|---|
| 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 {{{1*/ | 
|---|
| 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 {{{1*/ | 
|---|
| 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 | _error_("KML_Icon::Read -- Unexpected closing tag %s.\n",kstri); | 
|---|
| 152 | else if (strncmp(kstri,"<",1)) | 
|---|
| 153 | _error_("KML_Icon::Read -- Unexpected field \"%s\".\n",kstri); | 
|---|
| 154 |  | 
|---|
| 155 | else if (!strcmp(kstri,"<href>")) | 
|---|
| 156 | KMLFileTokenParse( href      ,NULL,KML_ICON_HREF_LENGTH, | 
|---|
| 157 | kstri, | 
|---|
| 158 | fid); | 
|---|
| 159 | else if (!strcmp(kstri,"<refreshMode>")) | 
|---|
| 160 | KMLFileTokenParse( refmode   ,NULL,KML_ICON_REFMODE_LENGTH, | 
|---|
| 161 | kstri, | 
|---|
| 162 | fid); | 
|---|
| 163 | else if (!strcmp(kstri,"<refreshInterval>")) | 
|---|
| 164 | KMLFileTokenParse(&refint    , | 
|---|
| 165 | kstri, | 
|---|
| 166 | fid); | 
|---|
| 167 | else if (!strcmp(kstri,"<viewRefreshMode>")) | 
|---|
| 168 | KMLFileTokenParse( vrefmode  ,NULL,KML_ICON_VREFMODE_LENGTH, | 
|---|
| 169 | kstri, | 
|---|
| 170 | fid); | 
|---|
| 171 | else if (!strcmp(kstri,"<viewRefreshTime>")) | 
|---|
| 172 | KMLFileTokenParse(&vreftime  , | 
|---|
| 173 | kstri, | 
|---|
| 174 | fid); | 
|---|
| 175 | else if (!strcmp(kstri,"<viewBoundScale>")) | 
|---|
| 176 | KMLFileTokenParse(&vboundsc  , | 
|---|
| 177 | kstri, | 
|---|
| 178 | fid); | 
|---|
| 179 | else if (!strcmp(kstri,"<viewFormat>")) | 
|---|
| 180 | KMLFileTokenParse( vformat   ,NULL,KML_ICON_VFORMAT_LENGTH, | 
|---|
| 181 | kstri, | 
|---|
| 182 | fid); | 
|---|
| 183 | else if (!strcmp(kstri,"<httpQuery>")) | 
|---|
| 184 | KMLFileTokenParse( hquery    ,NULL,KML_ICON_HQUERY_LENGTH, | 
|---|
| 185 | kstri, | 
|---|
| 186 | fid); | 
|---|
| 187 |  | 
|---|
| 188 | else if (!strncmp(kstri,"<",1)) | 
|---|
| 189 | KML_Object::Read(fid,kstri); | 
|---|
| 190 |  | 
|---|
| 191 | xfree((void**)&kstri); | 
|---|
| 192 | } | 
|---|
| 193 |  | 
|---|
| 194 | this->AddCommnt(ncom,pcom); | 
|---|
| 195 |  | 
|---|
| 196 | for (ncom; ncom>0; ncom--) | 
|---|
| 197 | xfree((void**)&(pcom[ncom-1])); | 
|---|
| 198 | xfree((void**)&pcom); | 
|---|
| 199 |  | 
|---|
| 200 | return; | 
|---|
| 201 | } | 
|---|
| 202 | /*}}}*/ | 
|---|
| 203 |  | 
|---|