| 1 | /*!\file KML_File.cpp
|
|---|
| 2 | * \brief: implementation of the kml_file 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_File::KML_File(){{{*/
|
|---|
| 24 | KML_File::KML_File(){
|
|---|
| 25 |
|
|---|
| 26 | ;
|
|---|
| 27 |
|
|---|
| 28 | }
|
|---|
| 29 | /*}}}*/
|
|---|
| 30 | /*FUNCTION KML_File::~KML_File(){{{*/
|
|---|
| 31 | KML_File::~KML_File(){
|
|---|
| 32 |
|
|---|
| 33 | ;
|
|---|
| 34 |
|
|---|
| 35 | }
|
|---|
| 36 | /*}}}*/
|
|---|
| 37 |
|
|---|
| 38 | /*Other*/
|
|---|
| 39 | /*FUNCTION KML_File::Echo {{{*/
|
|---|
| 40 | void KML_File::Echo(){
|
|---|
| 41 |
|
|---|
| 42 | bool flag=true;
|
|---|
| 43 |
|
|---|
| 44 | if(flag) _pprintLine_("KML_File:");
|
|---|
| 45 | KML_Object::Echo();
|
|---|
| 46 |
|
|---|
| 47 | return;
|
|---|
| 48 | }
|
|---|
| 49 | /*}}}*/
|
|---|
| 50 | /*FUNCTION KML_File::DeepEcho {{{*/
|
|---|
| 51 | void KML_File::DeepEcho(){
|
|---|
| 52 |
|
|---|
| 53 | char indent[81]="";
|
|---|
| 54 |
|
|---|
| 55 | KML_File::DeepEcho(indent);
|
|---|
| 56 |
|
|---|
| 57 | return;
|
|---|
| 58 | }
|
|---|
| 59 | /*}}}*/
|
|---|
| 60 | /*FUNCTION KML_File::DeepEcho {{{*/
|
|---|
| 61 | void KML_File::DeepEcho(const char* indent){
|
|---|
| 62 |
|
|---|
| 63 | bool flag=true;
|
|---|
| 64 |
|
|---|
| 65 | if(flag) _pprintLine_("" << indent << "KML_File:");
|
|---|
| 66 | KML_Object::DeepEcho(indent);
|
|---|
| 67 |
|
|---|
| 68 | return;
|
|---|
| 69 | }
|
|---|
| 70 | /*}}}*/
|
|---|
| 71 | /*FUNCTION KML_File::Write {{{*/
|
|---|
| 72 | void KML_File::Write(FILE* filout,const char* indent){
|
|---|
| 73 |
|
|---|
| 74 | fprintf(filout,"%s<kml",indent);
|
|---|
| 75 | WriteAttrib(filout," ");
|
|---|
| 76 | fprintf(filout,">\n");
|
|---|
| 77 | WriteCommnt(filout,indent);
|
|---|
| 78 |
|
|---|
| 79 | KML_Object::Write(filout,indent);
|
|---|
| 80 |
|
|---|
| 81 | fprintf(filout,"%s</kml>\n",indent);
|
|---|
| 82 |
|
|---|
| 83 | return;
|
|---|
| 84 | }
|
|---|
| 85 | /*}}}*/
|
|---|
| 86 | /*FUNCTION KML_File::Read {{{*/
|
|---|
| 87 | void KML_File::Read(FILE* fid,char* kstr){
|
|---|
| 88 |
|
|---|
| 89 | char* kstri;
|
|---|
| 90 | int ncom=0;
|
|---|
| 91 | char** pcom=NULL;
|
|---|
| 92 | KML_Object* kobj;
|
|---|
| 93 |
|
|---|
| 94 | /* get object attributes and check for solo tag */
|
|---|
| 95 |
|
|---|
| 96 | if (KMLFileTagAttrib(this,
|
|---|
| 97 | kstr))
|
|---|
| 98 | return;
|
|---|
| 99 |
|
|---|
| 100 | /* loop over and process fields within opening and closing tags */
|
|---|
| 101 |
|
|---|
| 102 | while (kstri=KMLFileToken(fid,
|
|---|
| 103 | &ncom,&pcom)) {
|
|---|
| 104 | if (!strncmp(kstri,"</kml", 5)) {
|
|---|
| 105 | xfree((void**)&kstri);
|
|---|
| 106 | break;
|
|---|
| 107 | }
|
|---|
| 108 | else if (!strncmp(kstri,"</",2))
|
|---|
| 109 | {_error2_("KML_File::Read -- Unexpected closing tag " << kstri << ".");}
|
|---|
| 110 | else if (strncmp(kstri,"<",1))
|
|---|
| 111 | {_error2_("KML_File::Read -- Unexpected field \"" << kstri << "\"");}
|
|---|
| 112 |
|
|---|
| 113 | else if (!strncmp(kstri,"<",1))
|
|---|
| 114 | KML_Object::Read(fid,kstri);
|
|---|
| 115 |
|
|---|
| 116 | xfree((void**)&kstri);
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | this->AddCommnt(ncom,pcom);
|
|---|
| 120 |
|
|---|
| 121 | for (ncom; ncom>0; ncom--)
|
|---|
| 122 | xfree((void**)&(pcom[ncom-1]));
|
|---|
| 123 | xfree((void**)&pcom);
|
|---|
| 124 |
|
|---|
| 125 | return;
|
|---|
| 126 | }
|
|---|
| 127 | /*}}}*/
|
|---|
| 128 | /*FUNCTION KML_File::WriteExp {{{*/
|
|---|
| 129 | void KML_File::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
|
|---|
| 130 |
|
|---|
| 131 | int i;
|
|---|
| 132 |
|
|---|
| 133 | /* loop over the kml objects for the file */
|
|---|
| 134 |
|
|---|
| 135 | for (i=0; i<kmlobj->Size(); i++)
|
|---|
| 136 | ((KML_Object *)kmlobj->GetObjectByOffset(i))->WriteExp(fid,nstr,sgn,cm,sp);
|
|---|
| 137 |
|
|---|
| 138 | return;
|
|---|
| 139 | }
|
|---|
| 140 | /*}}}*/
|
|---|