| 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 | if(flag) _pprintLine_("KML_Icon:"); | 
|---|
| 52 | KML_Object::Echo(); | 
|---|
| 53 |  | 
|---|
| 54 | if(flag) _pprintLine_("          href: \"" << href << "\""); | 
|---|
| 55 | if(flag) _pprintLine_("       refmode: \"" << refmode << "\""); | 
|---|
| 56 | if(flag) _pprintLine_("        refint: " << refint); | 
|---|
| 57 | if(flag) _pprintLine_("      vrefmode: \"" << vrefmode << "\""); | 
|---|
| 58 | if(flag) _pprintLine_("      vreftime: " << vreftime); | 
|---|
| 59 | if(flag) _pprintLine_("      vboundsc: " << vboundsc); | 
|---|
| 60 | if(flag) _pprintLine_("       vformat: \"" << vformat << "\""); | 
|---|
| 61 | if(flag) _pprintLine_("        hquery: \"" << hquery << "\""); | 
|---|
| 62 |  | 
|---|
| 63 | return; | 
|---|
| 64 | } | 
|---|
| 65 | /*}}}*/ | 
|---|
| 66 | /*FUNCTION KML_Icon::DeepEcho {{{*/ | 
|---|
| 67 | void  KML_Icon::DeepEcho(){ | 
|---|
| 68 |  | 
|---|
| 69 | char  indent[81]=""; | 
|---|
| 70 |  | 
|---|
| 71 | KML_Icon::DeepEcho(indent); | 
|---|
| 72 |  | 
|---|
| 73 | return; | 
|---|
| 74 | } | 
|---|
| 75 | /*}}}*/ | 
|---|
| 76 | /*FUNCTION KML_Icon::DeepEcho {{{*/ | 
|---|
| 77 | void  KML_Icon::DeepEcho(const char* indent){ | 
|---|
| 78 |  | 
|---|
| 79 | bool  flag=true; | 
|---|
| 80 |  | 
|---|
| 81 | if(flag) _pprintLine_(indent << "KML_Icon:"); | 
|---|
| 82 | KML_Object::DeepEcho(indent); | 
|---|
| 83 |  | 
|---|
| 84 | if(flag) _pprintLine_(indent << "          href: \"" << href << "\""); | 
|---|
| 85 | if(flag) _pprintLine_(indent << "       refmode: \"" << refmode << "\""); | 
|---|
| 86 | if(flag) _pprintLine_(indent << "        refint: " << refint); | 
|---|
| 87 | if(flag) _pprintLine_(indent << "      vrefmode: \"" << vrefmode << "\""); | 
|---|
| 88 | if(flag) _pprintLine_(indent << "      vreftime: " << vreftime); | 
|---|
| 89 | if(flag) _pprintLine_(indent << "      vboundsc: " << vboundsc); | 
|---|
| 90 | if(flag) _pprintLine_(indent << "       vformat: \"" << vformat << "\""); | 
|---|
| 91 | if(flag) _pprintLine_(indent << "        hquery: \"" << hquery << "\""); | 
|---|
| 92 |  | 
|---|
| 93 | return; | 
|---|
| 94 | } | 
|---|
| 95 | /*}}}*/ | 
|---|
| 96 | /*FUNCTION KML_Icon::Write {{{*/ | 
|---|
| 97 | void  KML_Icon::Write(FILE* filout,const char* indent){ | 
|---|
| 98 |  | 
|---|
| 99 | fprintf(filout,"%s<Icon",indent); | 
|---|
| 100 | WriteAttrib(filout," "); | 
|---|
| 101 | fprintf(filout,">\n"); | 
|---|
| 102 | WriteCommnt(filout,indent); | 
|---|
| 103 |  | 
|---|
| 104 | KML_Object::Write(filout,indent); | 
|---|
| 105 |  | 
|---|
| 106 | if (href     && strlen(href)) | 
|---|
| 107 | fprintf(filout,"%s  <href>%s</href>\n",indent,href); | 
|---|
| 108 | if (refmode  && strlen(refmode)) | 
|---|
| 109 | fprintf(filout,"%s  <refreshMode>%s</refreshMode>\n",indent,refmode); | 
|---|
| 110 | fprintf(filout,"%s  <refreshInterval>%g</refreshInterval>\n",indent,refint); | 
|---|
| 111 | if (vrefmode && strlen(vrefmode)) | 
|---|
| 112 | fprintf(filout,"%s  <viewRefreshMode>%s</viewRefreshMode>\n",indent,vrefmode); | 
|---|
| 113 | fprintf(filout,"%s  <viewRefreshTime>%g</viewRefreshTime>\n",indent,vreftime); | 
|---|
| 114 | fprintf(filout,"%s  <viewBoundScale>%g</viewBoundScale>\n",indent,vboundsc); | 
|---|
| 115 | if (vformat  && strlen(vformat)) | 
|---|
| 116 | fprintf(filout,"%s  <viewFormat>%s</viewFormat>\n",indent,vformat); | 
|---|
| 117 | if (hquery   && strlen(hquery)) | 
|---|
| 118 | fprintf(filout,"%s  <httpQuery>%s</httpQuery>\n",indent,hquery); | 
|---|
| 119 |  | 
|---|
| 120 | fprintf(filout,"%s</Icon>\n",indent); | 
|---|
| 121 |  | 
|---|
| 122 | return; | 
|---|
| 123 | } | 
|---|
| 124 | /*}}}*/ | 
|---|
| 125 | /*FUNCTION KML_Icon::Read {{{*/ | 
|---|
| 126 | void  KML_Icon::Read(FILE* fid,char* kstr){ | 
|---|
| 127 |  | 
|---|
| 128 | char*        kstri; | 
|---|
| 129 | int          ncom=0; | 
|---|
| 130 | char**       pcom=NULL; | 
|---|
| 131 |  | 
|---|
| 132 | /*  get object attributes and check for solo tag  */ | 
|---|
| 133 |  | 
|---|
| 134 | if (KMLFileTagAttrib(this, | 
|---|
| 135 | kstr)) | 
|---|
| 136 | return; | 
|---|
| 137 |  | 
|---|
| 138 | /*  loop over and process fields within opening and closing tags  */ | 
|---|
| 139 |  | 
|---|
| 140 | while (kstri=KMLFileToken(fid, | 
|---|
| 141 | &ncom,&pcom)) { | 
|---|
| 142 | if      (!strncmp(kstri,"</Icon", 6)) { | 
|---|
| 143 | xDelete<char>(kstri); | 
|---|
| 144 | break; | 
|---|
| 145 | } | 
|---|
| 146 | else if (!strncmp(kstri,"</",2)) | 
|---|
| 147 | {_error2_("KML_Icon::Read -- Unexpected closing tag " << kstri << ".\n");} | 
|---|
| 148 | else if (strncmp(kstri,"<",1)) | 
|---|
| 149 | {_error2_("KML_Icon::Read -- Unexpected field \"" << kstri << "\".\n");} | 
|---|
| 150 |  | 
|---|
| 151 | else if (!strcmp(kstri,"<href>")) | 
|---|
| 152 | KMLFileTokenParse( href      ,NULL,KML_ICON_HREF_LENGTH, kstri, fid); | 
|---|
| 153 | else if (!strcmp(kstri,"<refreshMode>")) | 
|---|
| 154 | KMLFileTokenParse( refmode   ,NULL,KML_ICON_REFMODE_LENGTH, kstri, fid); | 
|---|
| 155 | else if (!strcmp(kstri,"<refreshInterval>")) | 
|---|
| 156 | KMLFileTokenParse(&refint    , kstri, fid); | 
|---|
| 157 | else if (!strcmp(kstri,"<viewRefreshMode>")) | 
|---|
| 158 | KMLFileTokenParse( vrefmode  ,NULL,KML_ICON_VREFMODE_LENGTH, kstri, fid); | 
|---|
| 159 | else if (!strcmp(kstri,"<viewRefreshTime>")) | 
|---|
| 160 | KMLFileTokenParse(&vreftime  , kstri, fid); | 
|---|
| 161 | else if (!strcmp(kstri,"<viewBoundScale>")) | 
|---|
| 162 | KMLFileTokenParse(&vboundsc  , kstri, fid); | 
|---|
| 163 | else if (!strcmp(kstri,"<viewFormat>")) | 
|---|
| 164 | KMLFileTokenParse( vformat   ,NULL,KML_ICON_VFORMAT_LENGTH, kstri, fid); | 
|---|
| 165 | else if (!strcmp(kstri,"<httpQuery>")) | 
|---|
| 166 | KMLFileTokenParse( hquery    ,NULL,KML_ICON_HQUERY_LENGTH, kstri, fid); | 
|---|
| 167 |  | 
|---|
| 168 | else if (!strncmp(kstri,"<",1)) | 
|---|
| 169 | KML_Object::Read(fid,kstri); | 
|---|
| 170 |  | 
|---|
| 171 | xDelete<char>(kstri); | 
|---|
| 172 | } | 
|---|
| 173 |  | 
|---|
| 174 | this->AddCommnt(ncom,pcom); | 
|---|
| 175 |  | 
|---|
| 176 | for (ncom; ncom>0; ncom--) | 
|---|
| 177 | xDelete<char>(pcom[ncom-1]); | 
|---|
| 178 | xDelete<char*>(pcom); | 
|---|
| 179 |  | 
|---|
| 180 | return; | 
|---|
| 181 | } | 
|---|
| 182 | /*}}}*/ | 
|---|