Changeset 10629


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

KML: Handle solo tags in KML files.

Location:
issm/trunk/src/c/objects/KML
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/KML/KMLFileReadUtils.cpp

    r10627 r10629  
    4040        while ((c=getc(fid)) != EOF) {
    4141                /*  ignore leading blanks  */
    42 //              printf("point 0 c=%c\n",c);
    4342                if (inew && isspace(c))
    4443                        continue;
     
    4948                        /*  distinguish between tag or comment  */
    5049                        if (c == '<') {
    51 //                              printf("point 1 c=%c\n",c);
    5250                                ungetc(c,fid);
    5351                                if (!(bufferc=KMLFileTokenComment(fid))) {
    5452                                        c=getc(fid);
    55 //                                      printf("point 2 c=%c\n",c);
    5653                                        itag=1;
    5754                                }
    5855                                else {
    59 //                                      printf("point 3 buffer=%s\n",buffer);
    6056                                        xfree((void**)&bufferc);
    6157                                        inew=1;
     
    117113                }
    118114
    119         if      (itag)
    120                 _printf_(true,"tag buffer (length=%d):\n",ibuf);
    121         else if (ifield)
    122                 _printf_(true,"field buffer (length=%d):\n",ibuf);
    123         _printf_(true,"%s\n",buffer);
     115//      if      (itag)
     116//              _printf_(true,"tag buffer (length=%d):\n",ibuf);
     117//      else if (ifield)
     118//              _printf_(true,"field buffer (length=%d):\n",ibuf);
     119//      _printf_(true,"%s\n",buffer);
    124120
    125121        if (!ibuf)
     
    147143
    148144        while ((c=getc(fid)) != EOF) {
    149 //              printf("point 10 c=%c\n",c);
    150145                /*  ignore leading blanks  */
    151146                if (inew && isspace(c))
     
    165160                                for (i=ibuf-1; i>=0; i--)
    166161                                        ungetc(buffer[i],fid);
    167 //                              printf("point 11 buffer=%p\n",buffer);
    168162                                xfree((void**)&buffer);
    169 //                              printf("point 12 buffer=%p\n",buffer);
    170163                                return(buffer);
    171164                        }
     
    188181                }
    189182
    190         _printf_(true,"comment buffer (length=%d):\n",ibuf);
    191         _printf_(true,"%s\n",buffer);
     183//      _printf_(true,"comment buffer (length=%d):\n",ibuf);
     184//      _printf_(true,"%s\n",buffer);
    192185
    193186        if (!ibuf)
     
    224217
    225218/*FUNCTION  KMLFileTagAttrib {{{1*/
    226 void KMLFileTagAttrib(KML_Object* kobj,
    227                                           char* ktag){
     219int KMLFileTagAttrib(KML_Object* kobj,
     220                                         char* ktag){
    228221
    229222/*  for the given tag buffer, read and store the attributes  */
     
    233226        char*   ktokv;
    234227        char    quote[]={'\"','\0'};
     228        int     isolo=0;
    235229
    236230/*  strtok modifies ktag, so work on copy  */
     
    241235/*  loop through tag to find all attributes  */
    242236
     237        /*  return first non blank and move past subsequent blank  */
    243238        ktokn=strtok(ktagi," ");
    244         while (ktokn=strtok(NULL," =?>")) {
    245 
     239//      _printf_(true,"KMLFileTagAttrib -- initial token=\"%s\".\n",ktokn);
     240
     241        /*  return next non " =?/>" and move past subsequent " =?/>"  */
     242        while (ktokn=strtok(NULL," =?/>")) {
     243
     244                /*  return next non quote and move past subsequent quote  */
    246245                ktokv=strtok(NULL,quote);
    247246//              _printf_(true,"KMLFileTagAttrib -- attribute %s=\"%s\".\n",ktokn,ktokv);
     
    255254        xfree((void**)&ktagi);
    256255
    257         return;
     256/*  check for xml declaration, dtd declaration, or solo tag  */
     257
     258        if ((!strncmp(&ktag[0],"<?"       ,2) && !strncmp(&ktag[strlen(ktag)-2],"?>",2)) ||
     259                (!strncmp(&ktag[0],"<!DOCTYPE",9) && !strncmp(&ktag[strlen(ktag)-1], ">",1)) ||
     260                (!strncmp(&ktag[0],"<"        ,1) && !strncmp(&ktag[strlen(ktag)-2],"/>",2)))
     261                isolo=1;
     262//      _printf_(true,"KMLFileTagAttrib -- isolo=%d.\n",isolo);
     263
     264        return(isolo);
    258265}
    259266/*}}}*/
  • issm/trunk/src/c/objects/KML/KMLFileReadUtils.h

    r10627 r10629  
    2020                                                int c,
    2121                                                int bufblk);
    22 void KMLFileTagAttrib(KML_Object* kobj,
    23                                           char* ktag);
     22int KMLFileTagAttrib(KML_Object* kobj,
     23                                         char* ktag);
    2424int KMLFileTokenParse(int* pival,
    2525                                          char* ktag,
  • issm/trunk/src/c/objects/KML/KML_Document.cpp

    r9761 r10629  
    9292        char*        kstri;
    9393
    94 /*  get object attributes */
     94/*  get object attributes and check for solo tag */
    9595
    96         KMLFileTagAttrib(this,
    97                                          kstr);
     96        if (KMLFileTagAttrib(this,
     97                                                 kstr))
     98                return;
    9899
    99100/*  loop over and process fields within opening and closing tags  */
  • issm/trunk/src/c/objects/KML/KML_File.cpp

    r10257 r10629  
    127127        KML_Object*  kobj;
    128128
    129 /*  get object attributes  */
    130 
    131         KMLFileTagAttrib(this,
    132                                          kstr);
     129/*  get object attributes and check for solo tag  */
     130
     131        if (KMLFileTagAttrib(this,
     132                                                 kstr))
     133                return;
    133134
    134135/*  loop over and process fields within opening and closing tags  */
  • issm/trunk/src/c/objects/KML/KML_Folder.cpp

    r9761 r10629  
    9292        char*        kstri;
    9393
    94 /*  get object attributes */
     94/*  get object attributes and check for solo tag */
    9595
    96         KMLFileTagAttrib(this,
    97                                          kstr);
     96        if (KMLFileTagAttrib(this,
     97                                                 kstr))
     98                return;
    9899
    99100/*  loop over and process fields within opening and closing tags  */
  • issm/trunk/src/c/objects/KML/KML_GroundOverlay.cpp

    r9761 r10629  
    125125        char*        kstri;
    126126
    127 /*  get object attributes */
     127/*  get object attributes and check for solo tag */
    128128
    129         KMLFileTagAttrib(this,
    130                                          kstr);
     129        if (KMLFileTagAttrib(this,
     130                                                 kstr))
     131                return;
    131132
    132133/*  loop over and process fields within opening and closing tags  */
  • issm/trunk/src/c/objects/KML/KML_Icon.cpp

    r9761 r10629  
    131131        char*        kstri;
    132132
    133 /*  get object attributes */
     133/*  get object attributes and check for solo tag */
    134134
    135         KMLFileTagAttrib(this,
    136                                          kstr);
     135        if (KMLFileTagAttrib(this,
     136                                                 kstr))
     137                return;
    137138
    138139/*  loop over and process fields within opening and closing tags  */
  • issm/trunk/src/c/objects/KML/KML_LatLonBox.cpp

    r9761 r10629  
    114114        char*        kstri;
    115115
    116 /*  get object attributes */
     116/*  get object attributes and check for solo tag */
    117117
    118         KMLFileTagAttrib(this,
    119                                          kstr);
     118        if (KMLFileTagAttrib(this,
     119                                                 kstr))
     120                return;
    120121
    121122/*  loop over and process fields within opening and closing tags  */
  • issm/trunk/src/c/objects/KML/KML_LineString.cpp

    r10255 r10629  
    129129        char*        kstri;
    130130
    131 /*  get object attributes  */
    132 
    133         KMLFileTagAttrib(this,
    134                                          kstr);
     131/*  get object attributes and check for solo tag  */
     132
     133        if (KMLFileTagAttrib(this,
     134                                                 kstr))
     135                return;
    135136
    136137/*  loop over and process fields within opening and closing tags  */
  • issm/trunk/src/c/objects/KML/KML_LineStyle.cpp

    r9761 r10629  
    9999        char*        kstri;
    100100
    101 /*  get object attributes */
     101/*  get object attributes and check for solo tag */
    102102
    103         KMLFileTagAttrib(this,
    104                                          kstr);
     103        if (KMLFileTagAttrib(this,
     104                                                 kstr))
     105                return;
    105106
    106107/*  loop over and process fields within opening and closing tags  */
  • issm/trunk/src/c/objects/KML/KML_LinearRing.cpp

    r9761 r10629  
    129129        char*        kstri;
    130130
    131 /*  get object attributes  */
    132 
    133         KMLFileTagAttrib(this,
    134                                          kstr);
     131/*  get object attributes and check for solo tag  */
     132
     133        if (KMLFileTagAttrib(this,
     134                                                 kstr))
     135                return;
    135136
    136137/*  loop over and process fields within opening and closing tags  */
  • issm/trunk/src/c/objects/KML/KML_MultiGeometry.cpp

    r10257 r10629  
    127127        KML_Object*  kobj;
    128128
    129 /*  get object attributes  */
    130 
    131         KMLFileTagAttrib(this,
    132                                          kstr);
     129/*  get object attributes and check for solo tag  */
     130
     131        if (KMLFileTagAttrib(this,
     132                                                 kstr))
     133                return;
    133134
    134135/*  loop over and process fields within opening and closing tags  */
  • issm/trunk/src/c/objects/KML/KML_Overlay.cpp

    r9761 r10629  
    11/*!\file KML_Overlay.cpp
    2  * \brief: implementation of the kml_container abstract object
     2 * \brief: implementation of the kml_overlay abstract object
    33 */
    44
  • issm/trunk/src/c/objects/KML/KML_Placemark.cpp

    r10257 r10629  
    127127        KML_Object*  kobj;
    128128
    129 /*  get object attributes  */
    130 
    131         KMLFileTagAttrib(this,
    132                                          kstr);
     129/*  get object attributes and check for solo tag  */
     130
     131        if (KMLFileTagAttrib(this,
     132                                                 kstr))
     133                return;
    133134
    134135/*  loop over and process fields within opening and closing tags  */
  • issm/trunk/src/c/objects/KML/KML_Point.cpp

    r10274 r10629  
    112112        char*        kstri;
    113113
    114 /*  get object attributes */
     114/*  get object attributes and check for solo tag */
    115115
    116         KMLFileTagAttrib(this,
    117                                          kstr);
     116        if (KMLFileTagAttrib(this,
     117                                                 kstr))
     118                return;
    118119
    119120/*  loop over and process fields within opening and closing tags  */
  • issm/trunk/src/c/objects/KML/KML_PolyStyle.cpp

    r9761 r10629  
    103103        char*        kstri;
    104104
    105 /*  get object attributes */
     105/*  get object attributes and check for solo tag */
    106106
    107         KMLFileTagAttrib(this,
    108                                          kstr);
     107        if (KMLFileTagAttrib(this,
     108                                                 kstr))
     109                return;
    109110
    110111/*  loop over and process fields within opening and closing tags  */
  • issm/trunk/src/c/objects/KML/KML_Polygon.cpp

    r9761 r10629  
    167167        KML_Object*  kobj;
    168168
    169 /*  get object attributes  */
    170 
    171         KMLFileTagAttrib(this,
    172                                          kstr);
     169/*  get object attributes and check for solo tag  */
     170
     171        if (KMLFileTagAttrib(this,
     172                                                 kstr))
     173                return;
    173174
    174175/*  loop over and process fields within opening and closing tags  */
  • issm/trunk/src/c/objects/KML/KML_Style.cpp

    r9761 r10629  
    180180        char*        kstri;
    181181
    182 /*  get object attributes  */
    183 
    184         KMLFileTagAttrib(this,
    185                                          kstr);
     182/*  get object attributes and check for solo tag  */
     183
     184        if (KMLFileTagAttrib(this,
     185                                                 kstr))
     186                return;
    186187
    187188/*  loop over and process fields within opening and closing tags  */
Note: See TracChangeset for help on using the changeset viewer.