Changeset 14281


Ignore:
Timestamp:
01/23/13 10:18:17 (12 years ago)
Author:
jschierm
Message:

FIX: Working version of Shp2Exp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/modules/Shp2Expx/Shp2Expx.cpp

    r14279 r14281  
    4949
    5050        char    indent[81]="";
     51        KML_File          *kfile  = NULL;
     52        KML_Document      *kdoc   = NULL;
     53        KML_Style         *kstyle = NULL;
     54        KML_LineStyle     *klsty  = NULL;
     55        KML_PolyStyle     *kpsty  = NULL;
    5156        KML_Folder        *kfold  = NULL;
    5257        KML_Placemark     *kplace = NULL;
     
    199204
    200205        SHPClose( hSHP );
     206
     207/*  construct kml file  */
     208
     209        kfile =new KML_File();
     210        kfile->AddAttrib("xmlns","http://www.opengis.net/kml/2.2");
     211
     212/*  construct kml document  */
     213
     214        kdoc  =new KML_Document();
     215        sprintf(kdoc->name      ,"Shp2Kmlx Module -- %s",ctime(&time0));
     216        kdoc->open      =1;
     217
     218/*  construct style templates for defaults  */
     219
     220        klsty =new KML_LineStyle();
     221        sprintf(klsty->color     ,"ff000000");
     222        sprintf(klsty->colormode ,"normal");
     223        klsty->width     =lwidth;
     224        kpsty =new KML_PolyStyle();
     225        sprintf(kpsty->color     ,"%02xffffff",(int)floor(popac*255+0.5));
     226        sprintf(kpsty->colormode ,"random");
     227        kstyle=new KML_Style();
     228        kstyle->AddAttrib("id","BlackLineRandomPoly");
     229        kstyle->line      =klsty;
     230        kstyle->poly      =kpsty;
     231        (kdoc->style     )->AddObject((Object*)kstyle);
     232
     233        klsty =new KML_LineStyle();
     234        sprintf(klsty->color     ,"ff000000");
     235        sprintf(klsty->colormode ,"normal");
     236        klsty->width     ,lwidth;
     237        kpsty =new KML_PolyStyle();
     238        sprintf(kpsty->color     ,"00ffffff");
     239        sprintf(kpsty->colormode ,"random");
     240        kstyle=new KML_Style();
     241        kstyle->AddAttrib("id","BlackLineEmptyPoly");
     242        kstyle->line      =klsty;
     243        kstyle->poly      =kpsty;
     244        (kdoc->style     )->AddObject((Object*)kstyle);
     245
     246        klsty =new KML_LineStyle();
     247        sprintf(klsty->color     ,"%02xffffff",(int)floor(popac*255+0.5));
     248        sprintf(klsty->colormode ,"random");
     249        klsty->width     =lwidth*2;
     250        kpsty =new KML_PolyStyle();
     251        sprintf(kpsty->color     ,"00ffffff");
     252        sprintf(kpsty->colormode ,"random");
     253        kstyle=new KML_Style();
     254        kstyle->AddAttrib("id","RandomLineEmptyPoly");
     255        kstyle->line      =klsty;
     256        kstyle->poly      =kpsty;
     257        (kdoc->style     )->AddObject((Object*)kstyle);
    201258
    202259/*  construct kml folder for shapes  */
     
    507564        }
    508565
     566/*  assemble the rest of the kml hierarchy  */
     567
     568        (kdoc ->feature   )->AddObject((Object*)kfold);
     569        kfold=NULL;
     570        (kfile->kmlobj    )->AddObject((Object*)kdoc);
     571        kdoc =NULL;
     572
    509573/*  open exp file  */
    510574
    511     _pprintLine_("Writing exp profiles to file.");
    512     fid=fopen(filexp,"w");
     575        _pprintLine_("Writing exp profiles to file.");
     576        fid=fopen(filexp,"w");
    513577
    514578/*  write the polygons and linestrings  */
    515579
    516     kfold->WriteExp(fid,"",sgn,cm,sp);
     580        kfile->WriteExp(fid,"",sgn,cm,sp);
    517581
    518582/*  close exp file  */
    519583
    520     fclose(fid);
    521 
    522         delete kfold;
     584        fclose(fid);
     585
     586        delete kfile;
    523587        for (i=nshape-1; i>=0; i--) {
    524588                xDelete<double>((pshapm[i]));
Note: See TracChangeset for help on using the changeset viewer.