Changeset 8461
- Timestamp:
- 06/01/11 09:13:35 (14 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 4 added
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Makefile.am
r8429 r8461 77 77 ./objects/Bamg/Mesh.cpp\ 78 78 ./objects/Bamg/Mesh.h\ 79 ./objects/KML/KML_Attribute.cpp\ 80 ./objects/KML/KML_Attribute.h\ 79 81 ./objects/KML/KML_ColorStyle.cpp\ 80 82 ./objects/KML/KML_ColorStyle.h\ … … 508 510 ./modules/MinVzx/MinVzx.h\ 509 511 ./modules/MinVzx/MinVzx.cpp\ 512 ./modules/KMLMeshWritex/KMLFileReadx.h\ 513 ./modules/KMLMeshWritex/KMLFileReadx.cpp\ 510 514 ./modules/KMLMeshWritex/KMLMeshWritex.h\ 511 515 ./modules/KMLMeshWritex/KMLMeshWritex.cpp\ … … 730 734 ./objects/Gauss/GaussPenta.h\ 731 735 ./objects/Gauss/GaussPenta.cpp\ 736 ./objects/KML/KML_Attribute.cpp\ 737 ./objects/KML/KML_Attribute.h\ 732 738 ./objects/KML/KML_ColorStyle.cpp\ 733 739 ./objects/KML/KML_ColorStyle.h\ … … 1149 1155 ./modules/MinVzx/MinVzx.h\ 1150 1156 ./modules/MinVzx/MinVzx.cpp\ 1157 ./modules/KMLMeshWritex/KMLFileReadx.h\ 1158 ./modules/KMLMeshWritex/KMLFileReadx.cpp\ 1151 1159 ./modules/KMLMeshWritex/KMLMeshWritex.h\ 1152 1160 ./modules/KMLMeshWritex/KMLMeshWritex.cpp\ -
issm/trunk/src/c/modules/KMLMeshWritex/KMLMeshWritex.cpp
r8303 r8461 24 24 double popac=0.50; 25 25 char indent[81]=" "; 26 char cstr[81]; 26 27 double* edata=NULL; 27 28 bool ncfree=false, … … 59 60 sprintf(kpsty->colormode ,"random"); 60 61 kstyle=new KML_Style(); 61 sprintf(kstyle->id,"BlackLineRandomPoly");62 kstyle->AddAttrib("id","BlackLineRandomPoly"); 62 63 kstyle->line =klsty; 63 64 kstyle->poly =kpsty; … … 72 73 sprintf(kpsty->colormode ,"random"); 73 74 kstyle=new KML_Style(); 74 sprintf(kstyle->id,"BlackLineEmptyPoly");75 kstyle->AddAttrib("id","BlackLineEmptyPoly"); 75 76 kstyle->line =klsty; 76 77 kstyle->poly =kpsty; … … 85 86 sprintf(kpsty->colormode ,"random"); 86 87 kstyle=new KML_Style(); 87 sprintf(kstyle->id,"RedLineRedPoly");88 kstyle->AddAttrib("id","RedLineRedPoly"); 88 89 kstyle->line =klsty; 89 90 kstyle->poly =kpsty; … … 106 107 sprintf(kpsty->colormode ,"normal"); 107 108 kstyle=new KML_Style(); 108 sprintf(kstyle->id ,"MatlabColor%d",i+1); 109 sprintf(cstr,"MatlabColor%d",i+1); 110 kstyle->AddAttrib("id",cstr); 109 111 kstyle->line =klsty; 110 112 kstyle->poly =kpsty; -
issm/trunk/src/c/modules/KMLMeshWritex/KMLMeshWritex.h
r7670 r8461 3 3 */ 4 4 5 #ifndef _KMLM eshWriteX_H6 #define _KMLM eshWriteX_H5 #ifndef _KMLMESHWRITEX_H 6 #define _KMLMESHWRITEX_H 7 7 8 8 #include <float.h> /* DBL_MAX */ … … 28 28 double* cmap, int mcmap, int ncmap); 29 29 30 #endif /* _KMLM eshWriteX_H */30 #endif /* _KMLMESHWRITEX_H */ -
issm/trunk/src/c/modules/modules.h
r8404 r8461 49 49 #include "./InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.h" 50 50 #include "./InputArtificialNoisex/InputArtificialNoisex.h" 51 #include "./KMLMeshWritex/KMLFileReadx.h" 51 52 #include "./KMLMeshWritex/KMLMeshWritex.h" 52 53 #include "./MassFluxx/MassFluxx.h" -
issm/trunk/src/c/objects/KML/KMLFileReadUtils.cpp
r8206 r8461 94 94 } 95 95 96 if (itag)97 _printf_(true,"tag buffer (length=%d):\n",ibuf);98 else if (ifield)99 _printf_(true,"field buffer (length=%d):\n",ibuf);100 _printf_(true,"%s\n",buffer);96 // if (itag) 97 // _printf_(true,"tag buffer (length=%d):\n",ibuf); 98 // else if (ifield) 99 // _printf_(true,"field buffer (length=%d):\n",ibuf); 100 // _printf_(true,"%s\n",buffer); 101 101 102 102 if (!ibuf) … … 131 131 132 132 /*FUNCTION KMLFileTagAttrib {{{1*/ 133 char* KMLFileTagAttrib(char* pstr,int *m,int maxlen, 134 char* ktag, 135 char* att){ 133 void KMLFileTagAttrib(KML_Object* kobj, 134 char* ktag){ 136 135 137 136 char* ktagi; 138 char* ktok; 137 char* ktokn; 138 char* ktokv; 139 139 char quote[]={'\"','\0'}; 140 char* pstro=NULL; 141 142 if (pstr) 143 (pstr)[0]='\0'; 144 145 /* ktok modifies ktag, so work on copy */ 140 141 /* strtok modifies ktag, so work on copy */ 146 142 147 143 ktagi=(char *) xmalloc((strlen(ktag)+1)*sizeof(char)); … … 150 146 /* loop through tag to find all attributes */ 151 147 152 ktok=strtok(ktagi," "); 153 while (ktok=strtok(NULL," =?>")) { 154 _printf_(true,"KMLFileTagAttrib -- attribute %s",ktok); 155 156 /* check if it's the specified attribute */ 157 158 if (!strcmp(ktok,att)) { 159 ktok=strtok(NULL,quote); 160 _printf_(true,"=\"%s\" found.\n",ktok); 161 162 if (!pstr) { 163 pstr=(char *) xmalloc((strlen(ktok)+1)*sizeof(char)); 164 pstro=pstr; 165 } 166 167 if (maxlen && (maxlen < strlen(ktok))) { 168 _printf_(true,"KMLFileTagAttrib -- string field too short for attribute \"%s\".\n",att); 169 _printf_(true,"KMLFileTagAttrib -- \"%s\" truncated to %d characters.\n",ktok,maxlen); 170 strncpy(pstr,ktok,maxlen); 171 } 172 else 173 strcpy(pstr,ktok); 174 } 175 else { 176 ktok=strtok(NULL,quote); 177 _printf_(true,"=\"%s\" skipped.\n",ktok); 178 } 148 ktokn=strtok(ktagi," "); 149 while (ktokn=strtok(NULL," =?>")) { 150 151 ktokv=strtok(NULL,quote); 152 _printf_(true,"KMLFileTagAttrib -- attribute %s=\"%s\".\n",ktokn,ktokv); 153 154 /* add the attribute to the dataset */ 155 156 if (kobj) 157 kobj->AddAttrib(ktokn,ktokv); 179 158 } 180 159 181 160 xfree((void**)&ktagi); 182 161 183 if (pstr && m) 184 *m=strlen(pstr); 185 186 if (pstr) 187 _printf_(true,"KMLFileTagAttrib -- attribute %s=\"%s\".\n",att,pstr); 188 else 189 _printf_(true,"KMLFileTagAttrib -- attribute \"%s\" not found.\n",att); 190 191 return(pstro); 162 return; 192 163 } 193 164 /*}}}*/ … … 220 191 xfree((void**)&kstr); 221 192 222 _printf_(true,"KMLFileTokenParse -- %s=%d.\n",ktag,*pival);193 // _printf_(true,"KMLFileTokenParse -- %s=%d.\n",ktag,*pival); 223 194 224 195 return(0); … … 255 226 xfree((void**)&kstr); 256 227 257 _printf_(true,"KMLFileTokenParse -- %s=%s.\n",ktag,(*pbval ? "true" : "false"));228 // _printf_(true,"KMLFileTokenParse -- %s=%s.\n",ktag,(*pbval ? "true" : "false")); 258 229 259 230 return(0); … … 306 277 xfree((void**)&kstr); 307 278 308 _printf_(true,"KMLFileTokenParse -- %s=\"%s\".\n",ktag,pstr);279 // _printf_(true,"KMLFileTokenParse -- %s=\"%s\".\n",ktag,pstr); 309 280 310 281 return(pstro); 282 } 283 /*}}}*/ 284 285 /*FUNCTION KMLFileTokenParse {{{1*/ 286 int KMLFileTokenParse(float* pfval, 287 char* ktag, 288 FILE* fid){ 289 290 char* kstr; 291 292 /* get next token and convert to appropriate format */ 293 294 if (!(kstr=KMLFileToken(fid)) || 295 (kstr[0] == '<')) 296 _error_("KMLFileTokenParse -- Missing integer field for %s.\n",ktag); 297 298 sscanf(kstr,"%g",pfval); 299 xfree((void**)&kstr); 300 301 /* get additional token and compare to closing tag */ 302 303 if (ktag) 304 if (!(kstr=KMLFileToken(fid)) || 305 (kstr[0] != '<') || 306 (kstr[1] != '/') || 307 (strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1))) 308 _error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag); 309 else 310 xfree((void**)&kstr); 311 312 // _printf_(true,"KMLFileTokenParse -- %s=%g.\n",ktag,*pfval); 313 314 return(0); 311 315 } 312 316 /*}}}*/ … … 370 374 xfree((void**)&kstr); 371 375 372 _printf_(true,"KMLFileTokenParse -- %s=...\n",ktag);373 for (j=0; j<=i; j++)374 _printf_(true," [%d][0-2]: %g,%g,%g\n",j,(*pdval3)[j][0],(*pdval3)[j][1],(*pdval3)[j][2]);376 // _printf_(true,"KMLFileTokenParse -- %s=...\n",ktag); 377 // for (j=0; j<=i; j++) 378 // _printf_(true," [%d][0-2]: %g,%g,%g\n",j,(*pdval3)[j][0],(*pdval3)[j][1],(*pdval3)[j][2]); 375 379 376 380 return(0); -
issm/trunk/src/c/objects/KML/KMLFileReadUtils.h
r8206 r8461 19 19 int c, 20 20 int bufblk); 21 char* KMLFileTagAttrib(char* pstr,int *m,int maxlen, 22 char* ktag, 23 char* att); 21 void KMLFileTagAttrib(KML_Object* kobj, 22 char* ktag); 24 23 int KMLFileTokenParse(int* pint, 25 24 char* ktag, … … 29 28 FILE* fid); 30 29 char* KMLFileTokenParse(char* pstr,int *m,int maxlen, 30 char* ktag, 31 FILE* fid); 32 int KMLFileTokenParse(float* pfl, 31 33 char* ktag, 32 34 FILE* fid); -
issm/trunk/src/c/objects/KML/KML_ColorStyle.cpp
r8293 r8461 95 95 /* process field within opening and closing tags */ 96 96 97 if (!strncmp(kstr,"</ColorStyle",1 1))97 if (!strncmp(kstr,"</ColorStyle",12)) 98 98 return; 99 99 else if (!strncmp(kstr,"</",2)) -
issm/trunk/src/c/objects/KML/KML_Container.cpp
r8293 r8461 79 79 if (feature->Size()) 80 80 for (i=0; i<feature->Size(); i++) { 81 _printf_(flag,"%s feature: [%d] begin\n" ,indent,i);81 _printf_(flag,"%s feature: -------- begin [%d] --------\n" ,indent,i); 82 82 ((KML_Feature *)feature->GetObjectByOffset(i))->DeepEcho(indent2); 83 _printf_(flag,"%s feature: [%d] end\n",indent,i);83 _printf_(flag,"%s feature: -------- end [%d] --------\n" ,indent,i); 84 84 } 85 85 else -
issm/trunk/src/c/objects/KML/KML_Container.h
r8293 r8461 13 13 14 14 #include "./KML_Feature.h" 15 class DataSet; 15 16 /*}}}*/ 16 17 -
issm/trunk/src/c/objects/KML/KML_Document.cpp
r8293 r8461 74 74 void KML_Document::Write(FILE* filout,char* indent){ 75 75 76 if (this->id && strlen(this->id)) 77 fprintf(filout,"%s<Document id=\"%s\">\n",indent,this->id); 78 else 79 fprintf(filout,"%s<Document>\n",indent); 76 fprintf(filout,"%s<Document",indent); 77 WriteAttrib(filout," "); 78 fprintf(filout,">\n"); 80 79 81 80 KML_Container::Write(filout,indent); … … 92 91 char* kstri; 93 92 94 /* check for id attribute*/93 /* get object attributes */ 95 94 96 // KML_Object::Read(fid,kstr); 97 KMLFileTagAttrib( id ,NULL,KML_OBJECT_ID_LENGTH, 98 kstr, 99 "id"); 95 KMLFileTagAttrib(this, 96 kstr); 100 97 101 98 /* loop over and process fields within opening and closing tags */ -
issm/trunk/src/c/objects/KML/KML_Document.h
r8293 r8461 14 14 #include "./KML_Container.h" 15 15 class KML_Feature; 16 class DataSet;17 16 /*}}}*/ 18 17 -
issm/trunk/src/c/objects/KML/KML_Feature.cpp
r8293 r8461 98 98 if (style->Size()) 99 99 for (i=0; i<style->Size(); i++) { 100 _printf_(flag,"%s style: [%d] begin\n" ,indent,i);100 _printf_(flag,"%s style: -------- begin [%d] --------\n" ,indent,i); 101 101 ((KML_Style *)style->GetObjectByOffset(i))->DeepEcho(indent2); 102 _printf_(flag,"%s style: [%d] end\n",indent,i);102 _printf_(flag,"%s style: -------- end [%d] --------\n" ,indent,i); 103 103 } 104 104 else -
issm/trunk/src/c/objects/KML/KML_Folder.cpp
r8293 r8461 74 74 void KML_Folder::Write(FILE* filout,char* indent){ 75 75 76 int i; 77 78 if (this->id && strlen(this->id)) 79 fprintf(filout,"%s<Folder id=\"%s\">\n",indent,this->id); 80 else 81 fprintf(filout,"%s<Folder>\n",indent); 76 fprintf(filout,"%s<Folder",indent); 77 WriteAttrib(filout," "); 78 fprintf(filout,">\n"); 82 79 83 80 KML_Container::Write(filout,indent); … … 94 91 char* kstri; 95 92 96 /* check for id attribute*/93 /* get object attributes */ 97 94 98 // KML_Object::Read(fid,kstr); 99 KMLFileTagAttrib( id ,NULL,KML_OBJECT_ID_LENGTH, 100 kstr, 101 "id"); 95 KMLFileTagAttrib(this, 96 kstr); 102 97 103 98 /* loop over and process fields within opening and closing tags */ -
issm/trunk/src/c/objects/KML/KML_Folder.h
r8293 r8461 14 14 #include "./KML_Container.h" 15 15 class KML_Feature; 16 class DataSet;17 16 /*}}}*/ 18 17 -
issm/trunk/src/c/objects/KML/KML_Geometry.cpp
r8293 r8461 77 77 void KML_Geometry::Read(FILE* fid,char* kstr){ 78 78 79 KML_Object::Read(fid,kstr); 79 /* process field within opening and closing tags */ 80 81 if (!strncmp(kstr,"</Geometry",10)) 82 return; 83 else if (!strncmp(kstr,"</",2)) 84 _error_("KML_Geometry::Read -- Unexpected closing tag %s.\n",kstr); 85 else if (strncmp(kstr,"<",1)) 86 _error_("KML_Geometry::Read -- Unexpected field \"%s\".\n",kstr); 87 88 else if (!strncmp(kstr,"<",1)) 89 KML_Object::Read(fid,kstr); 80 90 81 91 return; -
issm/trunk/src/c/objects/KML/KML_LineString.cpp
r8293 r8461 97 97 int i; 98 98 99 if (this->id && strlen(this->id)) 100 fprintf(filout,"%s<LineString id=\"%s\">\n",indent,this->id); 101 else 102 fprintf(filout,"%s<LineString>\n",indent); 99 fprintf(filout,"%s<LineString",indent); 100 WriteAttrib(filout," "); 101 fprintf(filout,">\n"); 103 102 104 103 KML_Geometry::Write(filout,indent); … … 125 124 void KML_LineString::Read(FILE* fid,char* kstr){ 126 125 126 char* kstri; 127 128 /* get object attributes */ 129 130 KMLFileTagAttrib(this, 131 kstr); 132 133 /* loop over and process fields within opening and closing tags */ 134 135 while (kstri=KMLFileToken(fid)) { 136 if (!strncmp(kstri,"</LineString",12)) { 137 xfree((void**)&kstri); 138 break; 139 } 140 else if (!strncmp(kstri,"</",2)) 141 _error_("KML_LineString::Read -- Unexpected closing tag %s.\n",kstri); 142 else if (strncmp(kstri,"<",1)) 143 _error_("KML_LineString::Read -- Unexpected field \"%s\".\n",kstri); 144 145 else if (!strcmp(kstri,"<extrude>")) 146 KMLFileTokenParse(&extrude , 147 kstri, 148 fid); 149 else if (!strcmp(kstri,"<tessellate>")) 150 KMLFileTokenParse(&tessellate, 151 kstri, 152 fid); 153 else if (!strcmp(kstri,"<altitudeMode>")) 154 KMLFileTokenParse( altmode ,NULL,KML_LINESTRING_ALTMODE_LENGTH, 155 kstri, 156 fid); 157 else if (!strcmp(kstri,"<coordinates>")) 158 KMLFileTokenParse(&coords ,&ncoord ,0, 159 kstri, 160 fid); 161 162 else if (!strncmp(kstri,"<",1)) 163 KML_Geometry::Read(fid,kstri); 164 165 xfree((void**)&kstri); 166 } 127 167 128 168 return; -
issm/trunk/src/c/objects/KML/KML_LineStyle.cpp
r8293 r8461 23 23 KML_LineStyle::KML_LineStyle(){ 24 24 25 width =1 ;25 width =1.; 26 26 27 27 } … … 44 44 KML_ColorStyle::Echo(); 45 45 46 _printf_(flag," width: % d\n" ,width);46 _printf_(flag," width: %g\n" ,width); 47 47 48 48 return; … … 70 70 KML_ColorStyle::DeepEcho(indent); 71 71 72 _printf_(flag,"%s width: % d\n" ,indent,width);72 _printf_(flag,"%s width: %g\n" ,indent,width); 73 73 74 74 return; … … 79 79 void KML_LineStyle::Write(FILE* filout,char* indent){ 80 80 81 int i; 82 83 if (this->id && strlen(this->id)) 84 fprintf(filout,"%s<LineStyle id=\"%s\">\n",indent,this->id); 85 else 86 fprintf(filout,"%s<LineStyle>\n",indent); 81 fprintf(filout,"%s<LineStyle",indent); 82 WriteAttrib(filout," "); 83 fprintf(filout,">\n"); 87 84 88 85 KML_ColorStyle::Write(filout,indent); 89 86 90 fprintf(filout,"%s <width>% d</width>\n",indent,width);87 fprintf(filout,"%s <width>%g</width>\n",indent,width); 91 88 92 89 fprintf(filout,"%s</LineStyle>\n",indent); … … 99 96 void KML_LineStyle::Read(FILE* fid,char* kstr){ 100 97 98 char* kstri; 99 100 /* get object attributes */ 101 102 KMLFileTagAttrib(this, 103 kstr); 104 105 /* loop over and process fields within opening and closing tags */ 106 107 while (kstri=KMLFileToken(fid)) { 108 if (!strncmp(kstri,"</LineStyle",11)) { 109 xfree((void**)&kstri); 110 break; 111 } 112 else if (!strncmp(kstri,"</",2)) 113 _error_("KML_LineStyle::Read -- Unexpected closing tag %s.\n",kstri); 114 else if (strncmp(kstri,"<",1)) 115 _error_("KML_LineStyle::Read -- Unexpected field \"%s\".\n",kstri); 116 117 else if (!strcmp(kstri,"<width>")) 118 KMLFileTokenParse(&width , 119 kstri, 120 fid); 121 122 else if (!strncmp(kstri,"<",1)) 123 KML_ColorStyle::Read(fid,kstri); 124 125 xfree((void**)&kstri); 126 } 101 127 102 128 return; -
issm/trunk/src/c/objects/KML/KML_LineStyle.h
r8293 r8461 19 19 public: 20 20 21 intwidth;21 float width; 22 22 23 23 /*KML_LineStyle constructors, destructors {{{1*/ -
issm/trunk/src/c/objects/KML/KML_LinearRing.cpp
r8293 r8461 97 97 int i; 98 98 99 if (this->id && strlen(this->id)) 100 fprintf(filout,"%s<LinearRing id=\"%s\">\n",indent,this->id); 101 else 102 fprintf(filout,"%s<LinearRing>\n",indent); 99 fprintf(filout,"%s<LinearRing",indent); 100 WriteAttrib(filout," "); 101 fprintf(filout,">\n"); 103 102 104 103 KML_Geometry::Write(filout,indent); … … 125 124 void KML_LinearRing::Read(FILE* fid,char* kstr){ 126 125 126 char* kstri; 127 128 /* get object attributes */ 129 130 KMLFileTagAttrib(this, 131 kstr); 132 133 /* loop over and process fields within opening and closing tags */ 134 135 while (kstri=KMLFileToken(fid)) { 136 if (!strncmp(kstri,"</LinearRing",12)) { 137 xfree((void**)&kstri); 138 break; 139 } 140 else if (!strncmp(kstri,"</",2)) 141 _error_("KML_LinearRing::Read -- Unexpected closing tag %s.\n",kstri); 142 else if (strncmp(kstri,"<",1)) 143 _error_("KML_LinearRing::Read -- Unexpected field \"%s\".\n",kstri); 144 145 else if (!strcmp(kstri,"<extrude>")) 146 KMLFileTokenParse(&extrude , 147 kstri, 148 fid); 149 else if (!strcmp(kstri,"<tessellate>")) 150 KMLFileTokenParse(&tessellate, 151 kstri, 152 fid); 153 else if (!strcmp(kstri,"<altitudeMode>")) 154 KMLFileTokenParse( altmode ,NULL,KML_LINEARRING_ALTMODE_LENGTH, 155 kstri, 156 fid); 157 else if (!strcmp(kstri,"<coordinates>")) 158 KMLFileTokenParse(&coords ,&ncoord ,0, 159 kstri, 160 fid); 161 162 else if (!strncmp(kstri,"<",1)) 163 KML_Geometry::Read(fid,kstri); 164 165 xfree((void**)&kstri); 166 } 127 167 128 168 return; -
issm/trunk/src/c/objects/KML/KML_MultiGeometry.cpp
r8293 r8461 81 81 if (geometry->Size()) 82 82 for (i=0; i<geometry->Size(); i++) { 83 _printf_(flag,"%s geometry: [%d] begin\n" ,indent,i);83 _printf_(flag,"%s geometry: -------- begin [%d] --------\n" ,indent,i); 84 84 ((KML_Geometry *)geometry->GetObjectByOffset(i))->DeepEcho(indent2); 85 _printf_(flag,"%s geometry: [%d] end\n",indent,i);85 _printf_(flag,"%s geometry: -------- end [%d] --------\n" ,indent,i); 86 86 } 87 87 else … … 98 98 char indent2[81]; 99 99 100 if (this->id && strlen(this->id)) 101 fprintf(filout,"%s<MultiGeometry id=\"%s\">\n",indent,this->id); 102 else 103 fprintf(filout,"%s<MultiGeometry>\n",indent); 100 fprintf(filout,"%s<MultiGeometry",indent); 101 WriteAttrib(filout," "); 102 fprintf(filout,">\n"); 104 103 105 104 KML_Geometry::Write(filout,indent); … … 122 121 void KML_MultiGeometry::Read(FILE* fid,char* kstr){ 123 122 123 char* kstri; 124 KML_Object* kobj; 125 126 /* get object attributes */ 127 128 KMLFileTagAttrib(this, 129 kstr); 130 131 /* loop over and process fields within opening and closing tags */ 132 133 while (kstri=KMLFileToken(fid)) { 134 if (!strncmp(kstri,"</MultiGeometry",15)) { 135 xfree((void**)&kstri); 136 break; 137 } 138 else if (!strncmp(kstri,"</",2)) 139 _error_("KML_MultiGeometry::Read -- Unexpected closing tag %s.\n",kstri); 140 else if (strncmp(kstri,"<",1)) 141 _error_("KML_MultiGeometry::Read -- Unexpected field \"%s\".\n",kstri); 142 143 // else if (!strncmp(kstri,"<Point", 6)) { 144 // kobj=(KML_Object*)new KML_Point(); 145 // kobj->Read(fid,kstri); 146 // geometry ->AddObject((Object*)kobj); 147 // } 148 149 else if (!strncmp(kstri,"<LineString",11)) { 150 kobj=(KML_Object*)new KML_LineString(); 151 kobj->Read(fid,kstri); 152 geometry ->AddObject((Object*)kobj); 153 } 154 155 else if (!strncmp(kstri,"<LinearRing",11)) { 156 kobj=(KML_Object*)new KML_LinearRing(); 157 kobj->Read(fid,kstri); 158 geometry ->AddObject((Object*)kobj); 159 } 160 161 else if (!strncmp(kstri,"<Polygon", 8)) { 162 kobj=(KML_Object*)new KML_Polygon(); 163 kobj->Read(fid,kstri); 164 geometry ->AddObject((Object*)kobj); 165 } 166 167 else if (!strncmp(kstri,"<MultiGeometry",14)) { 168 kobj=(KML_Object*)new KML_MultiGeometry(); 169 kobj->Read(fid,kstri); 170 geometry ->AddObject((Object*)kobj); 171 } 172 173 else if (!strncmp(kstri,"<",1)) 174 KML_Geometry::Read(fid,kstri); 175 176 xfree((void**)&kstri); 177 } 124 178 125 179 return; -
issm/trunk/src/c/objects/KML/KML_Object.cpp
r8293 r8461 23 23 KML_Object::KML_Object(){ 24 24 25 strcpy(id ,"");25 attrib =new DataSet; 26 26 27 27 } … … 30 30 KML_Object::~KML_Object(){ 31 31 32 ; 32 if (attrib) { 33 delete attrib; 34 attrib =NULL; 35 } 33 36 34 37 } … … 41 44 bool flag=true; 42 45 43 _printf_(flag," id: \"%s\"\n" ,id);46 _printf_(flag," attrib: (size=%d)\n" ,attrib->Size()); 44 47 45 48 return; … … 61 64 void KML_Object::DeepEcho(char* indent){ 62 65 66 int i; 63 67 bool flag=true; 64 68 65 _printf_(flag,"%s id: \"%s\"\n" ,indent,id); 69 /* loop over the attributes for the object */ 70 71 if (attrib->Size()) 72 for (i=0; i<attrib->Size(); i++) { 73 ((KML_Attribute *)attrib->GetObjectByOffset(i))->DeepEcho(indent); 74 } 75 else 76 _printf_(flag,"%s attrib: [empty]\n" ,indent); 66 77 67 78 return; … … 72 83 void KML_Object::Write(FILE* filout,char* indent){ 73 84 74 // id is always written in keyword line of derived classes85 // attributes always written in keyword line of derived classes 75 86 76 87 ; … … 102 113 /*}}}*/ 103 114 115 /*FUNCTION KML_Object::AddAttrib {{{1*/ 116 void KML_Object::AddAttrib(char* name,char* value){ 117 118 KML_Attribute* katt=NULL; 119 120 katt=new KML_Attribute(); 121 katt->Alloc(name,value); 122 katt->Add(attrib); 123 124 return; 125 } 126 /*}}}*/ 127 128 /*FUNCTION KML_Object::FindAttrib {{{1*/ 129 void KML_Object::FindAttrib(char** pvalue,char* name,char* deflt){ 130 131 int i; 132 KML_Attribute* katt=NULL; 133 134 /* loop over any attributes for the object */ 135 136 if (attrib->Size()) 137 for (i=0; i<attrib->Size(); i++) 138 if (!strcmp(((KML_Attribute *)attrib->GetObjectByOffset(i))->name,name)) { 139 katt=(KML_Attribute *)attrib->GetObjectByOffset(i); 140 break; 141 } 142 143 if (katt) 144 katt->Get(pvalue,deflt); 145 else { 146 *pvalue=(char *) xmalloc((strlen(deflt)+1)*sizeof(char)); 147 strcpy(*pvalue,deflt); 148 } 149 150 return; 151 } 152 /*}}}*/ 153 154 /*FUNCTION KML_Object::WriteAttrib {{{1*/ 155 void KML_Object::WriteAttrib(FILE* filout,char* indent){ 156 157 int i; 158 159 // attributes always written in keyword line of kml_object 160 161 /* loop over any attributes for the object */ 162 163 if (attrib->Size()) 164 for (i=0; i<attrib->Size(); i++) 165 ((KML_Attribute *)attrib->GetObjectByOffset(i))->Write(filout,indent); 166 167 return; 168 } 169 /*}}}*/ 170 -
issm/trunk/src/c/objects/KML/KML_Object.h
r8293 r8461 6 6 #define _KML_OBJECT_H_ 7 7 8 #define KML_OBJECT_ID_LENGTH 809 10 8 /*Headers:{{{1*/ 11 9 #include "../../include/include.h" … … 14 12 15 13 #include "../Object.h" 14 class DataSet; 16 15 /*}}}*/ 17 16 … … 20 19 public: 21 20 22 char id[KML_OBJECT_ID_LENGTH+1];21 DataSet* attrib; 23 22 24 23 /*KML_Object constructors, destructors {{{1*/ … … 42 41 virtual void Write(FILE* fid,char* indent)=0; 43 42 virtual void Read(FILE* fid,char* kstr)=0; 44 43 virtual void AddAttrib(char* name,char* value); 44 virtual void FindAttrib(char** pvalue,char* name,char* deflt); 45 virtual void WriteAttrib(FILE* fid,char* indent); 45 46 46 47 }; -
issm/trunk/src/c/objects/KML/KML_Placemark.cpp
r8293 r8461 81 81 if (geometry->Size()) 82 82 for (i=0; i<geometry->Size(); i++) { 83 _printf_(flag,"%s geometry: [%d] begin\n" ,indent,i);83 _printf_(flag,"%s geometry: -------- begin [%d] --------\n" ,indent,i); 84 84 ((KML_Geometry *)geometry->GetObjectByOffset(i))->DeepEcho(indent2); 85 _printf_(flag,"%s geometry: [%d] end\n",indent,i);85 _printf_(flag,"%s geometry: -------- end [%d] --------\n" ,indent,i); 86 86 } 87 87 else … … 98 98 char indent2[81]; 99 99 100 if (this->id && strlen(this->id)) 101 fprintf(filout,"%s<Placemark id=\"%s\">\n",indent,this->id); 102 else 103 fprintf(filout,"%s<Placemark>\n",indent); 100 fprintf(filout,"%s<Placemark",indent); 101 WriteAttrib(filout," "); 102 fprintf(filout,">\n"); 104 103 105 104 KML_Feature::Write(filout,indent); … … 125 124 KML_Object* kobj; 126 125 127 /* check for id attribute*/126 /* get object attributes */ 128 127 129 // KML_Object::Read(fid,kstr); 130 KMLFileTagAttrib( id ,NULL,KML_OBJECT_ID_LENGTH, 131 kstr, 132 "id"); 128 KMLFileTagAttrib(this, 129 kstr); 133 130 134 131 /* loop over and process fields within opening and closing tags */ … … 144 141 _error_("KML_Placemark::Read -- Unexpected field \"%s\".\n",kstri); 145 142 143 // else if (!strncmp(kstri,"<Point", 6)) { 144 // kobj=(KML_Object*)new KML_Point(); 145 // kobj->Read(fid,kstri); 146 // geometry ->AddObject((Object*)kobj); 147 // } 148 146 149 else if (!strncmp(kstri,"<LineString",11)) { 147 150 kobj=(KML_Object*)new KML_LineString(); 148 kobj->Read(fid,kstr );151 kobj->Read(fid,kstri); 149 152 geometry ->AddObject((Object*)kobj); 150 153 } … … 152 155 else if (!strncmp(kstri,"<LinearRing",11)) { 153 156 kobj=(KML_Object*)new KML_LinearRing(); 154 kobj->Read(fid,kstr );157 kobj->Read(fid,kstri); 155 158 geometry ->AddObject((Object*)kobj); 156 159 } … … 158 161 else if (!strncmp(kstri,"<Polygon", 8)) { 159 162 kobj=(KML_Object*)new KML_Polygon(); 160 kobj->Read(fid,kstr );163 kobj->Read(fid,kstri); 161 164 geometry ->AddObject((Object*)kobj); 162 165 } … … 164 167 else if (!strncmp(kstri,"<MultiGeometry",14)) { 165 168 kobj=(KML_Object*)new KML_MultiGeometry(); 166 kobj->Read(fid,kstr );169 kobj->Read(fid,kstri); 167 170 geometry ->AddObject((Object*)kobj); 168 171 } -
issm/trunk/src/c/objects/KML/KML_PolyStyle.cpp
r8293 r8461 82 82 void KML_PolyStyle::Write(FILE* filout,char* indent){ 83 83 84 int i; 85 86 if (this->id && strlen(this->id)) 87 fprintf(filout,"%s<PolyStyle id=\"%s\">\n",indent,this->id); 88 else 89 fprintf(filout,"%s<PolyStyle>\n",indent); 84 fprintf(filout,"%s<PolyStyle",indent); 85 WriteAttrib(filout," "); 86 fprintf(filout,">\n"); 90 87 91 88 KML_ColorStyle::Write(filout,indent); … … 103 100 void KML_PolyStyle::Read(FILE* fid,char* kstr){ 104 101 102 char* kstri; 103 104 /* get object attributes */ 105 106 KMLFileTagAttrib(this, 107 kstr); 108 109 /* loop over and process fields within opening and closing tags */ 110 111 while (kstri=KMLFileToken(fid)) { 112 if (!strncmp(kstri,"</PolyStyle",11)) { 113 xfree((void**)&kstri); 114 break; 115 } 116 else if (!strncmp(kstri,"</",2)) 117 _error_("KML_PolyStyle::Read -- Unexpected closing tag %s.\n",kstri); 118 else if (strncmp(kstri,"<",1)) 119 _error_("KML_PolyStyle::Read -- Unexpected field \"%s\".\n",kstri); 120 121 else if (!strcmp(kstri,"<fill>")) 122 KMLFileTokenParse(&fill , 123 kstri, 124 fid); 125 else if (!strcmp(kstri,"<outline>")) 126 KMLFileTokenParse(&outline , 127 kstri, 128 fid); 129 130 else if (!strncmp(kstri,"<",1)) 131 KML_ColorStyle::Read(fid,kstri); 132 133 xfree((void**)&kstri); 134 } 105 135 106 136 return; -
issm/trunk/src/c/objects/KML/KML_Polygon.cpp
r8293 r8461 96 96 if (outer->Size()) 97 97 for (i=0; i<outer->Size(); i++) { 98 _printf_(flag,"%s outer: [%d] begin\n" ,indent,i);98 _printf_(flag,"%s outer: -------- begin [%d] --------\n" ,indent,i); 99 99 ((KML_LinearRing *)outer->GetObjectByOffset(i))->DeepEcho(indent2); 100 _printf_(flag,"%s outer: [%d] end\n",indent,i);100 _printf_(flag,"%s outer: -------- end [%d] --------\n" ,indent,i); 101 101 } 102 102 else … … 105 105 if (inner->Size()) 106 106 for (i=0; i<inner->Size(); i++) { 107 _printf_(flag,"%s inner: [%d] begin\n" ,indent,i);107 _printf_(flag,"%s inner: -------- begin [%d] --------\n" ,indent,i); 108 108 ((KML_LinearRing *)inner->GetObjectByOffset(i))->DeepEcho(indent2); 109 _printf_(flag,"%s inner: [%d] end\n",indent,i);109 _printf_(flag,"%s inner: -------- end [%d] --------\n" ,indent,i); 110 110 } 111 111 else … … 122 122 char indent4[81]; 123 123 124 if (this->id && strlen(this->id)) 125 fprintf(filout,"%s<Polygon id=\"%s\">\n",indent,this->id); 126 else 127 fprintf(filout,"%s<Polygon>\n",indent); 124 fprintf(filout,"%s<Polygon",indent); 125 WriteAttrib(filout," "); 126 fprintf(filout,">\n"); 128 127 129 128 KML_Geometry::Write(filout,indent); … … 158 157 void KML_Polygon::Read(FILE* fid,char* kstr){ 159 158 160 161 return; 162 } 163 /*}}}*/ 164 159 char* kstri; 160 char* kstrj; 161 KML_Object* kobj; 162 163 /* get object attributes */ 164 165 KMLFileTagAttrib(this, 166 kstr); 167 168 /* loop over and process fields within opening and closing tags */ 169 170 while (kstri=KMLFileToken(fid)) { 171 if (!strncmp(kstri,"</Polygon", 9)) { 172 xfree((void**)&kstri); 173 break; 174 } 175 else if (!strncmp(kstri,"</",2)) 176 _error_("KML_Polygon::Read -- Unexpected closing tag %s.\n",kstri); 177 else if (strncmp(kstri,"<",1)) 178 _error_("KML_Polygon::Read -- Unexpected field \"%s\".\n",kstri); 179 180 else if (!strcmp(kstri,"<extrude>")) 181 KMLFileTokenParse(&extrude , 182 kstri, 183 fid); 184 else if (!strcmp(kstri,"<tessellate>")) 185 KMLFileTokenParse(&tessellate, 186 kstri, 187 fid); 188 else if (!strcmp(kstri,"<altitudeMode>")) 189 KMLFileTokenParse( altmode ,NULL,KML_POLYGON_ALTMODE_LENGTH, 190 kstri, 191 fid); 192 193 else if (!strcmp(kstri,"<outerBoundaryIs>")) 194 195 /* loop over and process fields within outer boundary */ 196 197 while (kstrj=KMLFileToken(fid)) { 198 if (!strncmp(kstrj,"</outerBoundaryIs",17)) { 199 xfree((void**)&kstrj); 200 break; 201 } 202 else if (!strncmp(kstrj,"</",2)) 203 _error_("KML_Polygon::Read -- Unexpected closing tag %s.\n",kstrj); 204 else if (strncmp(kstrj,"<",1)) 205 _error_("KML_Polygon::Read -- Unexpected field \"%s\".\n",kstrj); 206 207 else if (!strncmp(kstrj,"<LinearRing",11)) { 208 kobj=(KML_Object*)new KML_LinearRing(); 209 kobj->Read(fid,kstrj); 210 outer ->AddObject((Object*)kobj); 211 } 212 213 else if (!strncmp(kstrj,"<",1)) 214 KML_Geometry::Read(fid,kstrj); 215 216 xfree((void**)&kstrj); 217 } 218 219 else if (!strcmp(kstri,"<innerBoundaryIs>")) 220 221 /* loop over and process fields within inner boundaries */ 222 223 while (kstrj=KMLFileToken(fid)) { 224 if (!strncmp(kstrj,"</innerBoundaryIs",17)) { 225 xfree((void**)&kstrj); 226 break; 227 } 228 else if (!strncmp(kstrj,"</",2)) 229 _error_("KML_Polygon::Read -- Unexpected closing tag %s.\n",kstrj); 230 else if (strncmp(kstrj,"<",1)) 231 _error_("KML_Polygon::Read -- Unexpected field \"%s\".\n",kstrj); 232 233 else if (!strncmp(kstrj,"<LinearRing",11)) { 234 kobj=(KML_Object*)new KML_LinearRing(); 235 kobj->Read(fid,kstrj); 236 inner ->AddObject((Object*)kobj); 237 } 238 239 else if (!strncmp(kstrj,"<",1)) 240 KML_Geometry::Read(fid,kstrj); 241 242 xfree((void**)&kstrj); 243 } 244 245 246 else if (!strncmp(kstri,"<",1)) 247 KML_Geometry::Read(fid,kstri); 248 249 xfree((void**)&kstri); 250 } 251 252 return; 253 } 254 /*}}}*/ 255 -
issm/trunk/src/c/objects/KML/KML_Style.cpp
r8293 r8461 101 101 void KML_Style::DeepEcho(char* indent){ 102 102 103 int i;104 103 char indent2[81]; 105 104 bool flag=true; … … 143 142 void KML_Style::Write(FILE* filout,char* indent){ 144 143 145 int i;146 144 char indent2[81]; 147 145 148 if (this->id && strlen(this->id)) 149 fprintf(filout,"%s<Style id=\"%s\">\n",indent,this->id); 150 else 151 fprintf(filout,"%s<Style>\n",indent); 146 fprintf(filout,"%s<Style",indent); 147 WriteAttrib(filout," "); 148 fprintf(filout,">\n"); 152 149 153 150 KML_StyleSelector::Write(filout,indent); … … 178 175 void KML_Style::Read(FILE* fid,char* kstr){ 179 176 180 181 return; 182 } 183 /*}}}*/ 184 177 char* kstri; 178 179 /* get object attributes */ 180 181 KMLFileTagAttrib(this, 182 kstr); 183 184 /* loop over and process fields within opening and closing tags */ 185 186 while (kstri=KMLFileToken(fid)) { 187 if (!strncmp(kstri,"</Style", 7)) { 188 xfree((void**)&kstri); 189 break; 190 } 191 else if (!strncmp(kstri,"</",2)) 192 _error_("KML_Style::Read -- Unexpected closing tag %s.\n",kstri); 193 else if (strncmp(kstri,"<",1)) 194 _error_("KML_Style::Read -- Unexpected field \"%s\".\n",kstri); 195 196 // else if (!strncmp(kstri,"<IconStyle",10)) { 197 // icon =new KML_IconStyle(); 198 // icon ->Read(fid,kstri); 199 // } 200 201 // else if (!strncmp(kstri,"<LabelStyle",11)) { 202 // label =new KML_LabelStyle(); 203 // label ->Read(fid,kstri); 204 // } 205 206 else if (!strncmp(kstri,"<LineStyle",10)) { 207 line =new KML_LineStyle(); 208 line ->Read(fid,kstri); 209 } 210 211 else if (!strncmp(kstri,"<PolyStyle",10)) { 212 poly =new KML_PolyStyle(); 213 poly ->Read(fid,kstri); 214 } 215 216 // else if (!strncmp(kstri,"<BalloonStyle",13)) { 217 // balloon =new KML_BalloonStyle(); 218 // balloon ->Read(fid,kstri); 219 // } 220 221 // else if (!strncmp(kstri,"<ListStyle",10)) { 222 // list =new KML_ListStyle(); 223 // list ->Read(fid,kstri); 224 // } 225 226 else if (!strncmp(kstri,"<",1)) 227 KML_StyleSelector::Read(fid,kstri); 228 229 xfree((void**)&kstri); 230 } 231 232 return; 233 } 234 /*}}}*/ 235 -
issm/trunk/src/c/objects/KML/KML_StyleSelector.cpp
r8293 r8461 77 77 void KML_StyleSelector::Read(FILE* fid,char* kstr){ 78 78 79 KML_Object::Read(fid,kstr); 79 /* process field within opening and closing tags */ 80 81 if (!strncmp(kstr,"</StyleSelector",15)) 82 return; 83 else if (!strncmp(kstr,"</",2)) 84 _error_("KML_StyleSelector::Read -- Unexpected closing tag %s.\n",kstr); 85 else if (strncmp(kstr,"<",1)) 86 _error_("KML_StyleSelector::Read -- Unexpected field \"%s\".\n",kstr); 87 88 else if (!strncmp(kstr,"<",1)) 89 KML_Object::Read(fid,kstr); 80 90 81 91 return; -
issm/trunk/src/c/objects/KML/KML_SubStyle.cpp
r8293 r8461 77 77 void KML_SubStyle::Read(FILE* fid,char* kstr){ 78 78 79 KML_Object::Read(fid,kstr); 79 /* process field within opening and closing tags */ 80 81 if (!strncmp(kstr,"</SubStyle",10)) 82 return; 83 else if (!strncmp(kstr,"</",2)) 84 _error_("KML_SubStyle::Read -- Unexpected closing tag %s.\n",kstr); 85 else if (strncmp(kstr,"<",1)) 86 _error_("KML_SubStyle::Read -- Unexpected field \"%s\".\n",kstr); 87 88 else if (!strncmp(kstr,"<",1)) 89 KML_Object::Read(fid,kstr); 80 90 81 91 return; -
issm/trunk/src/c/objects/objects.h
r8376 r8461 45 45 46 46 /*KML parsing objects: */ 47 #include "./KML/KML_Attribute.h" 47 48 #include "./KML/KML_ColorStyle.h" 48 49 #include "./KML/KML_Container.h"
Note:
See TracChangeset
for help on using the changeset viewer.