Changeset 12912
- Timestamp:
- 08/06/12 11:30:55 (13 years ago)
- Location:
- issm/trunk-jpl/src/c/classes/objects/KML
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/objects/KML/KMLFileReadUtils.cpp
r12835 r12912 586 586 /*}}}*/ 587 587 /*FUNCTION KMLFileTokenParse {{{*/ 588 int KMLFileTokenParse(double (**pdval3)[3],int* m,int maxlen,588 int KMLFileTokenParse(double **pdval,int* m,int n,int maxlen, 589 589 char* ktag, 590 590 FILE* fid){ 591 591 592 int i= 0,j=-1;592 int i=-1,j=-1; 593 593 char* kstr; 594 594 char* ktok; … … 600 600 NULL,NULL)) || 601 601 (kstr[0] == '<')) 602 _error2_("KMLFileTokenParse -- Missing double [m x 3] field for " << ktag << ".\n");603 604 if (!*pdval 3)602 _error2_("KMLFileTokenParse -- Missing double [m x n] field for " << ktag << ".\n"); 603 604 if (!*pdval) 605 605 if (maxlen) 606 *pdval 3=(double (*)[3]) xmalloc((maxlen*3) *sizeof(double));607 else 608 *pdval 3=(double (*)[3]) xmalloc(((strlen(kstr)+1)/2)*sizeof(double));606 *pdval=(double *) xmalloc((maxlen*n) *sizeof(double)); 607 else 608 *pdval=(double *) xmalloc(((strlen(kstr)+1)/2)*sizeof(double)); 609 609 610 610 /* loop through string to get all values */ … … 612 612 ktok=strtok(kstr,delim); 613 613 while (ktok) { 614 j++; 615 if (j == 3) { 616 i++; 617 j=0; 618 if (maxlen && (maxlen < i+1)) 619 _error2_("KMLFileTokenParse -- Double [m x 3] field too short for " << ktag << ".\n"); 620 } 621 sscanf(ktok,"%lg",&((*pdval3)[i][j])); 614 i++; 615 if (maxlen && (maxlen*n < i+1)) 616 _error2_("KMLFileTokenParse -- Double [m x n] field too short for " << ktag << ".\n"); 617 j=(j+1) % n; 618 sscanf(ktok,"%lg",&((*pdval)[i])); 622 619 ktok=strtok(NULL,delim); 623 620 } … … 625 622 626 623 if (!maxlen) 627 *pdval 3=(double (*)[3]) xrealloc(*pdval3,((i+1)*3)*sizeof(double));624 *pdval=(double *) xrealloc(*pdval,((i+1)*n)*sizeof(double)); 628 625 629 626 if (m) 630 *m= i+1;631 632 if ( j != 2)633 _pprintLine_("KMLFileTokenParse -- Double [m x 3] field for " << ktag << " does not have multiple of 3values.");627 *m=((i+1)+(n-1))/n; 628 629 if ((i+1) % n) 630 _pprintLine_("KMLFileTokenParse -- Double [m x n] field for " << ktag << " does not have multiple of n values."); 634 631 635 632 /* get additional token and compare to closing tag */ … … 647 644 // _pprintLine_("KMLFileTokenParse -- " << ktag << "=..."); 648 645 // for (j=0; j<=i; j++) 649 // _pprintLine_(" [" << j << "] [0-2]: " << (*pdval3)[j][0] << "g," << (*pdval3)[j][1] << "g," << (*pdval3)[j][2] << "g");646 // _pprintLine_(" [" << j << "]: " << (*pdval)[j] << "g"); 650 647 651 648 return(0); -
issm/trunk-jpl/src/c/classes/objects/KML/KMLFileReadUtils.h
r12832 r12912 48 48 char* ktag, 49 49 FILE* fid); 50 int KMLFileTokenParse(double (**pdval3)[3],int* m,int maxlen,50 int KMLFileTokenParse(double **pdval,int* m,int n,int maxlen, 51 51 char* ktag, 52 52 FILE* fid); -
issm/trunk-jpl/src/c/classes/objects/KML/KML_LinearRing.cpp
r12835 r12912 150 150 KMLFileTokenParse(altmode,NULL,KML_LINEARRING_ALTMODE_LENGTH,kstri,fid); 151 151 else if (!strcmp(kstri,"<coordinates>")) 152 KMLFileTokenParse(&coords,&ncoord, 0,kstri,fid);152 KMLFileTokenParse(&coords,&ncoord,3,0,kstri,fid); 153 153 else if (!strncmp(kstri,"<",1)) 154 154 KML_Geometry::Read(fid,kstri);
Note:
See TracChangeset
for help on using the changeset viewer.