Changeset 10633


Ignore:
Timestamp:
11/14/11 14:49:25 (13 years ago)
Author:
jschierm
Message:

KML: Clean up KMLFileReadx.cpp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/modules/KMLMeshWritex/KMLFileReadx.cpp

    r9761 r10633  
    1111KML_Object* KMLFileReadx(FILE* fid){
    1212
    13         int     c;
    1413        char*   kstr;
    15         int     ival;
    16         bool    bval;
    17         char*   pstr=NULL;
    18         double  (*pdval3)[3]=NULL;
    19         KML_Object*    kobj=NULL;
    20         KML_Document*  kdoc=NULL;
     14        KML_File*      kxml=NULL;
     15        KML_File*      kdtd=NULL;
    2116        KML_File*      kfil=NULL;
    2217
     
    3025/*  read kml file  */
    3126
    32 //      while ((c=getc(fid)) != EOF)
    33 //              _printf_(true,"%c",c);
    3427        while (kstr=KMLFileToken(fid)) {
    35                 if (!strncmp(kstr,"<?xml"      ,5) ||
    36 //                      !strncmp(kstr,"<kml"       ,4) ||
    37                         !strncmp(kstr,"<LineString",11) ||
    38                         !strncmp(kstr,"<LinearRing",11))
    39                         KMLFileTagAttrib(NULL,
     28                if      (!strncmp(kstr,"<?xml"    ,5)) {
     29                        kxml=new KML_File();
     30                        KMLFileTagAttrib(kxml,
    4031                                                         kstr);
    41                 if (!strcmp(kstr,"<extrude>"))
    42                         KMLFileTokenParse(&ival,
    43                                                           kstr,
    44                                                           fid);
    45                 if (!strcmp(kstr,"<tessellate>"))
    46                         KMLFileTokenParse(&bval,
    47                                                           kstr,
    48                                                           fid);
    49                 if (!strcmp(kstr,"<altitudeMode>"))
    50                         pstr=KMLFileTokenParse((char *)NULL,NULL,0,
    51                                                           kstr,
    52                                                           fid);
    53                 if (!strcmp(kstr,"<coordinates>"))
    54                         KMLFileTokenParse(&pdval3,NULL,0,
    55                                                           kstr,
    56                                                           fid);
    57                 if (!strncmp(kstr,"<LinearRing",11))
    58                         KMLFileTagSkip(kstr,
    59                                                    fid);
    60                 if (!strncmp(kstr,"<Document",9)) {
    61                         kdoc=new KML_Document();
    62                         kdoc->Read(fid,kstr);
    63 //                      kdoc->DeepEcho();
    64                         kobj=kdoc;
    6532                }
    66                 if (!strncmp(kstr,"<kml",4)) {
     33                else if (!strncmp(kstr,"<!DOCTYPE",9)) {
     34                        kdtd=new KML_File();
     35                        KMLFileTagAttrib(kdtd,
     36                                                         kstr);
     37                }
     38                else if (!strncmp(kstr,"<kml"     ,4)) {
    6739                        kfil=new KML_File();
    6840                        kfil->Read(fid,kstr);
    6941//                      kfil->DeepEcho();
    70                         kobj=kfil;
    7142                }
    7243
    7344//              _printf_(true,"%s\n",kstr);
    7445                xfree((void**)&kstr);
     46        }
     47
     48        if (kxml) {
     49                _printf_(true,"XML declaration:\n");
     50                kxml->DeepEcho("  ");
     51                delete kxml;
     52        }
     53        if (kdtd) {
     54                _printf_(true,"DTD declaration (not yet implemented):\n");
     55                kdtd->DeepEcho("  ");
     56                delete kdtd;
    7557        }
    7658
     
    8062                         ((double)(clock1-clock0))/CLOCKS_PER_SEC,difftime(time1,time0));
    8163
    82         return(kobj);
     64        return(kfil);
    8365}
    8466
Note: See TracChangeset for help on using the changeset viewer.