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