| [7654] | 1 | /*!\file KMLMeshWritex | 
|---|
|  | 2 | */ | 
|---|
|  | 3 |  | 
|---|
|  | 4 | #include "./KMLMeshWritex.h" | 
|---|
|  | 5 | #include "../../shared/shared.h" | 
|---|
| [9761] | 6 | #include "../../io/io.h" | 
|---|
| [7654] | 7 | #include "../../toolkits/toolkits.h" | 
|---|
|  | 8 | #include "../../EnumDefinitions/EnumDefinitions.h" | 
|---|
|  | 9 |  | 
|---|
| [12442] | 10 | void KMLMeshWritex(int* ierror,char* name,char* notes,int* elem,int melem,int nelem,int* nodecon,int mncon,int nncon,double* lat, double* lng,int* part,double* data, int mdata, int ndata,double* cmap, int mcmap, int ncmap,FILE* fid){ | 
|---|
| [7654] | 11 |  | 
|---|
| [12442] | 12 | int                 i,j,k,ipt=0,jpt=0,nnodes; | 
|---|
|  | 13 | int                 mxepg      = 25; | 
|---|
|  | 14 | int                 lwidth     = 1; | 
|---|
|  | 15 | double              popac      = 0.50; | 
|---|
|  | 16 | char                indent[81] = " "; | 
|---|
|  | 17 | char                cstr[81]; | 
|---|
|  | 18 | double             *edata = NULL; | 
|---|
|  | 19 | bool ncfree=false, edfree=false; | 
|---|
|  | 20 | KML_Document       *kdoc = NULL; | 
|---|
|  | 21 | KML_Style          *kstyle; | 
|---|
|  | 22 | KML_LineStyle      *klsty; | 
|---|
|  | 23 | KML_PolyStyle      *kpsty; | 
|---|
| [7654] | 24 |  | 
|---|
|  | 25 | clock_t clock0,clock1,clock0a,clock0b,clock0c; | 
|---|
|  | 26 | time_t  time0, time1, time0a, time0b, time0c; | 
|---|
|  | 27 |  | 
|---|
|  | 28 | clock0=clock(); | 
|---|
|  | 29 | time0 =time(NULL); | 
|---|
| [12519] | 30 | _pprintString_("\nKMLMeshWritex Module -- " << ctime(&time0)); | 
|---|
| [7654] | 31 |  | 
|---|
|  | 32 | /*  construct kml document  */ | 
|---|
|  | 33 |  | 
|---|
|  | 34 | kdoc=new KML_Document(); | 
|---|
|  | 35 | sprintf(kdoc->name      ,"ISSM Mesh: %s",name); | 
|---|
|  | 36 | kdoc->open      =1; | 
|---|
|  | 37 | sprintf(kdoc->descript  ,"%s",notes); | 
|---|
|  | 38 |  | 
|---|
|  | 39 | /*  write style templates for defaults and for each color of the matlab | 
|---|
|  | 40 | colormap (note that matlab colormap format is rgb, where each varies | 
|---|
|  | 41 | from 0 to 1, whereas the kml color format is aabbggrr, where each | 
|---|
|  | 42 | varies from 00 to ff.)  */ | 
|---|
|  | 43 |  | 
|---|
|  | 44 | klsty=new KML_LineStyle(); | 
|---|
|  | 45 | sprintf(klsty->color     ,"ff000000"); | 
|---|
|  | 46 | sprintf(klsty->colormode ,"normal"); | 
|---|
|  | 47 | klsty->width     =lwidth; | 
|---|
|  | 48 | kpsty=new KML_PolyStyle(); | 
|---|
|  | 49 | sprintf(kpsty->color     ,"%02xffffff",(int)floor(popac*255+0.5)); | 
|---|
|  | 50 | sprintf(kpsty->colormode ,"random"); | 
|---|
|  | 51 | kstyle=new KML_Style(); | 
|---|
| [8461] | 52 | kstyle->AddAttrib("id","BlackLineRandomPoly"); | 
|---|
| [7654] | 53 | kstyle->line      =klsty; | 
|---|
|  | 54 | kstyle->poly      =kpsty; | 
|---|
|  | 55 | (kdoc->style     )->AddObject((Object*)kstyle); | 
|---|
|  | 56 |  | 
|---|
|  | 57 | klsty=new KML_LineStyle(); | 
|---|
|  | 58 | sprintf(klsty->color     ,"ff000000"); | 
|---|
|  | 59 | sprintf(klsty->colormode ,"normal"); | 
|---|
|  | 60 | klsty->width     ,lwidth; | 
|---|
|  | 61 | kpsty=new KML_PolyStyle(); | 
|---|
|  | 62 | sprintf(kpsty->color     ,"00ffffff"); | 
|---|
|  | 63 | sprintf(kpsty->colormode ,"random"); | 
|---|
|  | 64 | kstyle=new KML_Style(); | 
|---|
| [8461] | 65 | kstyle->AddAttrib("id","BlackLineEmptyPoly"); | 
|---|
| [7654] | 66 | kstyle->line      =klsty; | 
|---|
|  | 67 | kstyle->poly      =kpsty; | 
|---|
|  | 68 | (kdoc->style     )->AddObject((Object*)kstyle); | 
|---|
|  | 69 |  | 
|---|
|  | 70 | klsty=new KML_LineStyle(); | 
|---|
|  | 71 | sprintf(klsty->color     ,"ff0000ff"); | 
|---|
|  | 72 | sprintf(klsty->colormode ,"normal"); | 
|---|
|  | 73 | klsty->width     =lwidth; | 
|---|
|  | 74 | kpsty=new KML_PolyStyle(); | 
|---|
|  | 75 | sprintf(kpsty->color     ,"%02x0000ff",(int)floor(popac*255+0.5)); | 
|---|
|  | 76 | sprintf(kpsty->colormode ,"random"); | 
|---|
|  | 77 | kstyle=new KML_Style(); | 
|---|
| [8461] | 78 | kstyle->AddAttrib("id","RedLineRedPoly"); | 
|---|
| [7654] | 79 | kstyle->line      =klsty; | 
|---|
|  | 80 | kstyle->poly      =kpsty; | 
|---|
|  | 81 | (kdoc->style     )->AddObject((Object*)kstyle); | 
|---|
|  | 82 |  | 
|---|
|  | 83 | if (cmap) { | 
|---|
| [12519] | 84 | _pprintLine_("Writing " << mcmap << " Matlab colors as KML style templates."); | 
|---|
| [7658] | 85 | ipt=0; | 
|---|
| [7654] | 86 | for (i=0; i<mcmap; i++) { | 
|---|
|  | 87 | klsty=new KML_LineStyle(); | 
|---|
| [9259] | 88 | //                      sprintf(klsty->color     ,"ff000000"); | 
|---|
|  | 89 | sprintf(klsty->color     ,"%02x%02x%02x%02x", | 
|---|
|  | 90 | (int)255, | 
|---|
|  | 91 | (int)floor(cmap[ipt+2]*255+0.5), | 
|---|
|  | 92 | (int)floor(cmap[ipt+1]*255+0.5), | 
|---|
|  | 93 | (int)floor(cmap[ipt  ]*255+0.5)); | 
|---|
| [7654] | 94 | sprintf(klsty->colormode ,"normal"); | 
|---|
|  | 95 | klsty->width     =lwidth; | 
|---|
|  | 96 | kpsty=new KML_PolyStyle(); | 
|---|
|  | 97 | sprintf(kpsty->color     ,"%02x%02x%02x%02x", | 
|---|
|  | 98 | (int)floor(popac*255+0.5), | 
|---|
|  | 99 | (int)floor(cmap[ipt+2]*255+0.5), | 
|---|
|  | 100 | (int)floor(cmap[ipt+1]*255+0.5), | 
|---|
|  | 101 | (int)floor(cmap[ipt  ]*255+0.5)); | 
|---|
|  | 102 | sprintf(kpsty->colormode ,"normal"); | 
|---|
|  | 103 | kstyle=new KML_Style(); | 
|---|
| [8461] | 104 | sprintf(cstr,"MatlabColor%d",i+1); | 
|---|
|  | 105 | kstyle->AddAttrib("id",cstr); | 
|---|
| [7654] | 106 | kstyle->line      =klsty; | 
|---|
|  | 107 | kstyle->poly      =kpsty; | 
|---|
|  | 108 | (kdoc->style     )->AddObject((Object*)kstyle); | 
|---|
| [7658] | 109 | ipt+=ncmap; | 
|---|
| [7654] | 110 | } | 
|---|
|  | 111 | } | 
|---|
|  | 112 | //      kdoc->DeepEcho(); | 
|---|
|  | 113 |  | 
|---|
| [7660] | 114 | /*  create the node connectivity table, if necessary | 
|---|
|  | 115 | (noting that rows do not need to be sorted, since the elements | 
|---|
|  | 116 | are consecutively numbered)  */ | 
|---|
| [7658] | 117 |  | 
|---|
| [7660] | 118 | if (!nodecon) { | 
|---|
| [12519] | 119 | _pprintLine_("Creating the node connectivity table."); | 
|---|
| [7660] | 120 | nncon=mxepg+1; | 
|---|
| [12446] | 121 | nodecon=xNewZeroInit<int>(mncon*nncon); | 
|---|
| [7660] | 122 | ncfree=true; | 
|---|
|  | 123 |  | 
|---|
|  | 124 | jpt=0; | 
|---|
|  | 125 | for (i=0; i<melem; i++) { | 
|---|
|  | 126 | for (j=0; j<nelem; j++) { | 
|---|
|  | 127 | if (elem[jpt]) { | 
|---|
|  | 128 | ipt=(elem[jpt]-1)*nncon; | 
|---|
|  | 129 | if (nodecon[ipt+(nncon-1)] < mxepg) { | 
|---|
|  | 130 | nodecon[ipt+nodecon[ipt+(nncon-1)]]=i+1; | 
|---|
|  | 131 | nodecon[ipt+(nncon-1)]++; | 
|---|
|  | 132 | } | 
|---|
|  | 133 | else | 
|---|
| [13056] | 134 | _error_("Nodal connectivity table needs more than specified " << mxepg << " columns.\n"); | 
|---|
| [7660] | 135 | } | 
|---|
|  | 136 | jpt++; | 
|---|
|  | 137 | } | 
|---|
|  | 138 | } | 
|---|
|  | 139 | } | 
|---|
|  | 140 |  | 
|---|
|  | 141 | /*  average nodal data to element data, if necessary | 
|---|
|  | 142 | (noting that multiple columns of data are handled here, but not | 
|---|
|  | 143 | yet below)  */ | 
|---|
|  | 144 |  | 
|---|
| [7658] | 145 | if (data) { | 
|---|
|  | 146 | if      (mdata == melem) | 
|---|
|  | 147 | edata=data; | 
|---|
| [7660] | 148 |  | 
|---|
| [7658] | 149 | else if (mdata == mncon) { | 
|---|
| [12519] | 150 | _pprintLine_("Averaging nodal data to element data."); | 
|---|
| [12446] | 151 | edata=xNewZeroInit<double>(melem*ndata); | 
|---|
| [7660] | 152 | edfree=true; | 
|---|
|  | 153 |  | 
|---|
| [7658] | 154 | ipt=0; | 
|---|
|  | 155 | jpt=0; | 
|---|
|  | 156 | for (i=0; i<melem; i++) { | 
|---|
| [7660] | 157 | nnodes=0; | 
|---|
| [7658] | 158 | for (j=0; j<nelem; j++) { | 
|---|
| [7660] | 159 | if (elem[jpt]) { | 
|---|
|  | 160 | for (k=0; k<ndata; k++) | 
|---|
|  | 161 | edata[ipt+k]+=data[(elem[jpt]-1)*ndata+k]; | 
|---|
|  | 162 | nnodes++; | 
|---|
|  | 163 | } | 
|---|
| [7658] | 164 | jpt++; | 
|---|
|  | 165 | } | 
|---|
| [7660] | 166 | if (nnodes) | 
|---|
|  | 167 | for (k=0; k<ndata; k++) | 
|---|
|  | 168 | edata[ipt+k]/=(double)nnodes; | 
|---|
| [7658] | 169 | ipt+=ndata; | 
|---|
|  | 170 | } | 
|---|
|  | 171 | } | 
|---|
| [7660] | 172 |  | 
|---|
| [7658] | 173 | else | 
|---|
| [13056] | 174 | _error_("Data matrix has incorrect number of " << mdata << " rows.\n"); | 
|---|
| [7658] | 175 | } | 
|---|
|  | 176 |  | 
|---|
| [7654] | 177 | /*  write folder for mesh  */ | 
|---|
|  | 178 |  | 
|---|
|  | 179 | (kdoc ->feature   )->AddObject((Object*)KMLMeshElem(elem,melem,nelem, | 
|---|
|  | 180 | nodecon,mncon,nncon, | 
|---|
|  | 181 | lat,lng, | 
|---|
| [7658] | 182 | edata, | 
|---|
| [7654] | 183 | cmap,mcmap,ncmap)); | 
|---|
|  | 184 |  | 
|---|
| [12450] | 185 | if(edfree) xDelete<double>(edata); | 
|---|
|  | 186 | if(ncfree) xDelete<int>(nodecon); | 
|---|
| [7654] | 187 | clock0a=clock(); | 
|---|
|  | 188 | time0a =time(NULL); | 
|---|
|  | 189 | _printf_(true,"  Constructed kml document -- %f CPU seconds; %f elapsed seconds.\n\n", | 
|---|
|  | 190 | ((double)(clock0a-clock0))/CLOCKS_PER_SEC,difftime(time0a,time0)); | 
|---|
|  | 191 |  | 
|---|
|  | 192 | /*  write kml file  */ | 
|---|
|  | 193 |  | 
|---|
| [12519] | 194 | _pprintLine_("Writing kml document to file."); | 
|---|
| [7654] | 195 | fprintf(fid,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); | 
|---|
|  | 196 | fprintf(fid,"<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n"); | 
|---|
|  | 197 | kdoc->Write(fid,indent); | 
|---|
|  | 198 | fprintf(fid,"</kml>\n"); | 
|---|
|  | 199 | clock0b=clock(); | 
|---|
|  | 200 | time0b =time(NULL); | 
|---|
|  | 201 | _printf_(true,"  Wrote kml file -- %f CPU seconds; %f elapsed seconds.\n\n", | 
|---|
|  | 202 | ((double)(clock0b-clock0a))/CLOCKS_PER_SEC,difftime(time0b,time0a)); | 
|---|
|  | 203 |  | 
|---|
| [12519] | 204 | _pprintLine_("Deleting kml document."); | 
|---|
| [7654] | 205 | delete kdoc; | 
|---|
|  | 206 | clock0c=clock(); | 
|---|
|  | 207 | time0c =time(NULL); | 
|---|
|  | 208 | _printf_(true,"  Deleted kml document -- %f CPU seconds; %f elapsed seconds.\n\n", | 
|---|
|  | 209 | ((double)(clock0c-clock0b))/CLOCKS_PER_SEC,difftime(time0c,time0b)); | 
|---|
|  | 210 |  | 
|---|
|  | 211 | clock1=clock(); | 
|---|
|  | 212 | time1 =time(NULL); | 
|---|
|  | 213 | _printf_(true,"KMLMeshWritex Module -- %f CPU seconds; %f elapsed seconds.\n\n", | 
|---|
|  | 214 | ((double)(clock1-clock0))/CLOCKS_PER_SEC,difftime(time1,time0)); | 
|---|
|  | 215 |  | 
|---|
|  | 216 | return; | 
|---|
|  | 217 | } | 
|---|
|  | 218 |  | 
|---|
|  | 219 | KML_Folder* KMLMeshElem(int* elem,int melem,int nelem, | 
|---|
|  | 220 | int* nodecon,int mncon,int nncon, | 
|---|
|  | 221 | double* lat, double* lng, | 
|---|
|  | 222 | double* edata, | 
|---|
|  | 223 | double* cmap, int mcmap, int ncmap){ | 
|---|
|  | 224 |  | 
|---|
| [7658] | 225 | int     i,j,ipt=0; | 
|---|
| [7669] | 226 | double  alt=0; | 
|---|
| [7658] | 227 | double  cmin= DBL_MAX, | 
|---|
| [7660] | 228 | cmax=-DBL_MAX; | 
|---|
| [7658] | 229 | int     imap; | 
|---|
| [7654] | 230 | KML_Folder*     kfold =NULL; | 
|---|
|  | 231 | KML_Placemark*  kplace=NULL; | 
|---|
|  | 232 | KML_Polygon*    kpoly =NULL; | 
|---|
|  | 233 | KML_LinearRing* kring =NULL; | 
|---|
|  | 234 |  | 
|---|
|  | 235 | /*  write folder for mesh  */ | 
|---|
|  | 236 |  | 
|---|
|  | 237 | kfold=new KML_Folder(); | 
|---|
| [7685] | 238 | //      sprintf(kfold->name      ,"Mesh"); | 
|---|
|  | 239 | sprintf(kfold->name      ,"ISSM Targets"); | 
|---|
| [7654] | 240 | kfold->visibility=1; | 
|---|
| [8303] | 241 | //      sprintf(kfold->descript  ,"Elements=%d, Nodes=%d",melem,mncon); | 
|---|
| [7685] | 242 | sprintf(kfold->descript  ,"campaign{\n"); | 
|---|
|  | 243 | strcat(kfold->descript  ,"  evaluator ClaspTargetEvaluator;\n"); | 
|---|
| [8046] | 244 | strcat(kfold->descript  ,"  solver IssmSolver;\n"); | 
|---|
| [7685] | 245 | strcat(kfold->descript  ,"  spacecraft airplane ClaspSpacecraft(\n"); | 
|---|
|  | 246 | strcat(kfold->descript  ,"    dutyCycleDuration=0,\n"); | 
|---|
|  | 247 | strcat(kfold->descript  ,"    dutyCycleOnDuration=0,\n"); | 
|---|
|  | 248 | strcat(kfold->descript  ,"    memoryInit=15000,\n"); | 
|---|
|  | 249 | strcat(kfold->descript  ,"    memoryLimit=40000000,\n"); | 
|---|
|  | 250 | strcat(kfold->descript  ,"    maxDataCollectionRate=27,\n"); | 
|---|
|  | 251 | strcat(kfold->descript  ,"    maxDataDownlinkRate=10);\n"); | 
|---|
|  | 252 | strcat(kfold->descript  ,"\n"); | 
|---|
|  | 253 | strcat(kfold->descript  ,"  //sensor names\n"); | 
|---|
|  | 254 | strcat(kfold->descript  ,"  sensor qqp_swath = 2,102,1002,1102;\n"); | 
|---|
|  | 255 | strcat(kfold->descript  ,"\n"); | 
|---|
|  | 256 | strcat(kfold->descript  ,"  //sensor ids to modes\n"); | 
|---|
|  | 257 | strcat(kfold->descript  ,"  low_bandwidth_single_pol = 2,102,1002,1102;\n"); | 
|---|
|  | 258 | strcat(kfold->descript  ,"  single_pol = 2,102,1002,1102;\n"); | 
|---|
|  | 259 | strcat(kfold->descript  ,"  dual_pol = 2,102,1002,1102;\n"); | 
|---|
|  | 260 | strcat(kfold->descript  ,"  quad_pol = 2,102,1002,1102;\n"); | 
|---|
|  | 261 | strcat(kfold->descript  ,"\n"); | 
|---|
|  | 262 | strcat(kfold->descript  ,"  //LRAD\n"); | 
|---|
|  | 263 | strcat(kfold->descript  ,"  //Note all targets are \"ascending right\"-- i.e. mode=2\n"); | 
|---|
|  | 264 | strcat(kfold->descript  ,"  left = 1002,1102;\n"); | 
|---|
|  | 265 | strcat(kfold->descript  ,"  right = 2,102;\n"); | 
|---|
|  | 266 | strcat(kfold->descript  ,"  ascending = 2,1002;\n"); | 
|---|
|  | 267 | strcat(kfold->descript  ,"  descending = 102,1102;\n"); | 
|---|
|  | 268 | strcat(kfold->descript  ,"\n"); | 
|---|
|  | 269 | strcat(kfold->descript  ,"  //data rates\n"); | 
|---|
|  | 270 | strcat(kfold->descript  ,"  low_bandwidth_single_pol datarate = 0.896;\n"); | 
|---|
|  | 271 | strcat(kfold->descript  ,"  single_pol datarate = 4.214;\n"); | 
|---|
|  | 272 | strcat(kfold->descript  ,"  dual_pol datarate = 8.428;\n"); | 
|---|
|  | 273 | strcat(kfold->descript  ,"  quad_pol datarate = 16.856;\n"); | 
|---|
|  | 274 | strcat(kfold->descript  ,"\n"); | 
|---|
|  | 275 | strcat(kfold->descript  ,"  //mode domination relationships\n"); | 
|---|
|  | 276 | strcat(kfold->descript  ,"  quad_pol dominates low_bandwidth_single_pol;\n"); | 
|---|
|  | 277 | strcat(kfold->descript  ,"  quad_pol dominates single_pol;\n"); | 
|---|
|  | 278 | strcat(kfold->descript  ,"  quad_pol dominates dual_pol;\n"); | 
|---|
|  | 279 | strcat(kfold->descript  ,"  dual_pol dominates low_bandwidth_single_pol;\n"); | 
|---|
|  | 280 | strcat(kfold->descript  ,"  dual_pol dominates single_pol;\n"); | 
|---|
|  | 281 | strcat(kfold->descript  ,"  single_pol dominates low_bandwidth_single_pol;\n"); | 
|---|
|  | 282 | strcat(kfold->descript  ,"\n"); | 
|---|
|  | 283 | strcat(kfold->descript  ,"  //sensor styles\n"); | 
|---|
|  | 284 | strcat(kfold->descript  ,"  2 0xff00ffff 0xff000000;\n"); | 
|---|
|  | 285 | strcat(kfold->descript  ,"  102 0x7f00ffff 0xff00ffff;\n"); | 
|---|
|  | 286 | strcat(kfold->descript  ,"  1002 0xffffff00 0xffffff00;\n"); | 
|---|
|  | 287 | strcat(kfold->descript  ,"  1102 0x7fffff00 0xffffff00;\n"); | 
|---|
|  | 288 | strcat(kfold->descript  ,"\n"); | 
|---|
|  | 289 | strcat(kfold->descript  ,"  //discipline styles\n"); | 
|---|
|  | 290 | strcat(kfold->descript  ,"  deformation 0xff006090 0xff006090 0xff0000ff 0xff1010ff;\n"); | 
|---|
|  | 291 | strcat(kfold->descript  ,"  vegetation  0xff00ff00 0xff00ff00 0xff0000ff 0xff0020ff;\n"); | 
|---|
|  | 292 | strcat(kfold->descript  ,"  ice         0xffff0000 0xffff0000 0xff0000ff 0xff2000ff;\n"); | 
|---|
|  | 293 | strcat(kfold->descript  ,"}"); | 
|---|
| [7654] | 294 |  | 
|---|
|  | 295 | if (edata) | 
|---|
|  | 296 | for (i=0; i<melem; i++) { | 
|---|
|  | 297 | if (edata[i] < cmin) | 
|---|
|  | 298 | cmin=edata[i]; | 
|---|
|  | 299 | if (edata[i] > cmax) | 
|---|
|  | 300 | cmax=edata[i]; | 
|---|
|  | 301 | } | 
|---|
|  | 302 |  | 
|---|
|  | 303 | /*  write each element as a polygon placemark  */ | 
|---|
|  | 304 |  | 
|---|
| [12519] | 305 | _pprintLine_("Writing " << melem << " tria elements as KML polygons."); | 
|---|
| [7654] | 306 |  | 
|---|
|  | 307 | for (i=0; i<melem; i++) { | 
|---|
|  | 308 | kplace=new KML_Placemark(); | 
|---|
|  | 309 | sprintf(kplace->name      ,"Element %d",(i+1)); | 
|---|
|  | 310 | kplace->visibility=1; | 
|---|
|  | 311 | if (edata) { | 
|---|
|  | 312 | //                      sprintf(kplace->descript  ,"Element data: %g",edata[i]); | 
|---|
|  | 313 | sprintf(kplace->descript  ,"campaign{\n  deformation 1 %g quad_pol ascending right asap;\n}",edata[i]); | 
|---|
|  | 314 | imap = (int)floor((edata[i]-cmin)/(cmax-cmin)*mcmap+0.5)+1; | 
|---|
|  | 315 | if      ((imap >= 1) && (imap <= mcmap)) | 
|---|
|  | 316 | sprintf(kplace->styleurl  ,"#MatlabColor%d",imap); | 
|---|
|  | 317 | else if (edata[i] == cmax) | 
|---|
|  | 318 | sprintf(kplace->styleurl  ,"#MatlabColor%d",mcmap); | 
|---|
|  | 319 | else | 
|---|
|  | 320 | sprintf(kplace->styleurl  ,"#BlackLineEmptyPoly"); | 
|---|
|  | 321 | } | 
|---|
|  | 322 | else { | 
|---|
|  | 323 | sprintf(kplace->descript  ,""); | 
|---|
|  | 324 | sprintf(kplace->styleurl  ,"#BlackLineRandomPoly"); | 
|---|
|  | 325 | } | 
|---|
|  | 326 | //              kplace->DeepEcho(); | 
|---|
|  | 327 |  | 
|---|
|  | 328 | kpoly=new KML_Polygon(); | 
|---|
|  | 329 | kpoly->extrude   =1; | 
|---|
| [7669] | 330 | sprintf(kpoly->altmode   ,"clampToGround"); | 
|---|
| [7654] | 331 | //              kpoly->DeepEcho(); | 
|---|
|  | 332 |  | 
|---|
|  | 333 | kring=new KML_LinearRing(); | 
|---|
|  | 334 | kring->ncoord    =nelem+1; | 
|---|
| [12442] | 335 | kring->coords =xNew<double>((nelem+1)*3); | 
|---|
| [7654] | 336 |  | 
|---|
|  | 337 | /*  write the nodal coordinates as a linear ring  */ | 
|---|
|  | 338 |  | 
|---|
|  | 339 | for (j=0; j<nelem; j++) { | 
|---|
| [12442] | 340 | kring->coords[3*j+0]=lng[elem[ipt]-1]; | 
|---|
|  | 341 | kring->coords[3*j+1]=lat[elem[ipt]-1]; | 
|---|
|  | 342 | kring->coords[3*j+2]=alt; | 
|---|
| [7654] | 343 | ipt++; | 
|---|
|  | 344 | } | 
|---|
| [12442] | 345 | kring->coords[3*nelem+0]=kring->coords[3*0+0]; | 
|---|
|  | 346 | kring->coords[3*nelem+1]=kring->coords[3*0+1]; | 
|---|
|  | 347 | kring->coords[3*nelem+2]=kring->coords[3*0+2]; | 
|---|
| [7654] | 348 | //              kring->DeepEcho(); | 
|---|
|  | 349 |  | 
|---|
|  | 350 | /*  assemble the linear ring into polygon into placemark into folder  */ | 
|---|
|  | 351 |  | 
|---|
| [12442] | 352 | (kpoly ->outer   )->AddObject((Object*)kring); | 
|---|
|  | 353 | (kplace->geometry)->AddObject((Object*)kpoly); | 
|---|
|  | 354 | (kfold ->feature )->AddObject((Object*)kplace); | 
|---|
| [7654] | 355 |  | 
|---|
| [7658] | 356 | //              if (!(int)fmod((double)(i+1),1000)) | 
|---|
| [12519] | 357 | //                      _pprintLine_("  " << (i+1) << " tria elements written."); | 
|---|
| [7654] | 358 | } | 
|---|
| [12519] | 359 | _pprintLine_("  " << melem << " tria elements written."); | 
|---|
| [7654] | 360 |  | 
|---|
|  | 361 | return(kfold); | 
|---|
|  | 362 | } | 
|---|