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