Changeset 14279
- Timestamp:
- 01/22/13 11:44:31 (12 years ago)
- Location:
- issm/trunk-jpl/src
- Files:
-
- 2 added
- 3 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/c/Makefile.am ¶
r14218 r14279 627 627 ./modules/Kml2Expx/Kml2Expx.h\ 628 628 ./modules/Kml2Expx/Kml2Expx.cpp\ 629 ./modules/Shp2Expx/Shp2Expx.h\ 630 ./modules/Shp2Expx/Shp2Expx.cpp\ 629 631 ./modules/Shp2Kmlx/Shp2Kmlx.h\ 630 632 ./modules/Shp2Kmlx/Shp2Kmlx.cpp\ -
TabularUnified issm/trunk-jpl/src/c/modules/Shp2Expx/Shp2Expx.cpp ¶
r14016 r14279 1 /*!\file Shp2 Kmlx2 * \brief shp to kmlconversion routines.1 /*!\file Shp2Expx 2 * \brief shp to exp conversion routines. 3 3 */ 4 4 5 #include "./Shp2 Kmlx.h"5 #include "./Shp2Expx.h" 6 6 #include "../../shared/shared.h" 7 7 #include "../../include/include.h" … … 11 11 #include "../modules.h" 12 12 13 int Shp2 Kmlx(char* filshp,char* filkml,13 int Shp2Expx(char* filshp,char* filexp, 14 14 int sgn){ 15 15 … … 21 21 Xy2lldef(&cm,&sp,sgn); 22 22 23 return(Shp2 Kmlx(filshp,filkml,23 return(Shp2Expx(filshp,filexp, 24 24 sgn,cm,sp)); 25 25 … … 29 29 } 30 30 31 int Shp2 Kmlx(char* filshp,char* filkml,31 int Shp2Expx(char* filshp,char* filexp, 32 32 int sgn,double cm,double sp){ 33 33 … … 49 49 50 50 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;56 51 KML_Folder *kfold = NULL; 57 52 KML_Placemark *kplace = NULL; … … 68 63 clock0=clock(); 69 64 time0 =time(NULL); 70 _pprintString_("\nShp2 Kmlx Module -- " << ctime(&time0));65 _pprintString_("\nShp2Expx Module -- " << ctime(&time0)); 71 66 72 67 /* note that much of the following code is taken from shpdump.c in shapelib. */ … … 204 199 205 200 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);258 201 259 202 /* construct kml folder for shapes */ … … 564 507 } 565 508 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 573 /* write kml file */ 574 575 _pprintLine_("Writing kml document to file."); 576 fid=fopen(filkml,"w"); 577 fprintf(fid,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); 578 kfile->Write(fid,indent); 579 fclose(fid); 580 581 delete kfile; 509 /* open exp file */ 510 511 _pprintLine_("Writing exp profiles to file."); 512 fid=fopen(filexp,"w"); 513 514 /* write the polygons and linestrings */ 515 516 kfold->WriteExp(fid,"",sgn,cm,sp); 517 518 /* close exp file */ 519 520 fclose(fid); 521 522 delete kfold; 582 523 for (i=nshape-1; i>=0; i--) { 583 524 xDelete<double>((pshapm[i])); … … 602 543 clock1=clock(); 603 544 time1 =time(NULL); 604 _printf_(true,"Shp2 Kmlx Module -- %f CPU seconds; %f elapsed seconds.\n\n",545 _printf_(true,"Shp2Expx Module -- %f CPU seconds; %f elapsed seconds.\n\n", 605 546 ((double)(clock1-clock0))/CLOCKS_PER_SEC,difftime(time1,time0)); 606 547 -
TabularUnified issm/trunk-jpl/src/c/modules/Shp2Expx/Shp2Expx.h ¶
r14016 r14279 1 /*!\file: Shp2 Kmlx.h2 * \brief header file for shp to kmlconversion routines.1 /*!\file: Shp2Expx.h 2 * \brief header file for shp to exp conversion routines. 3 3 */ 4 4 5 #ifndef _SHP2 KMLX_H6 #define _SHP2 KMLX_H5 #ifndef _SHP2EXPX_H 6 #define _SHP2EXPX_H 7 7 8 8 #ifdef HAVE_CONFIG_H … … 22 22 23 23 /* local prototypes: */ 24 int Shp2 Kmlx(char* filshp,char* filkml, int sgn);25 int Shp2 Kmlx(char* filshp,char* filkml, int sgn,double cm,double sp);24 int Shp2Expx(char* filshp,char* filexp, int sgn); 25 int Shp2Expx(char* filshp,char* filexp, int sgn,double cm,double sp); 26 26 27 #endif /* _SHP2 KMLX_H */27 #endif /* _SHP2EXPX_H */ -
TabularUnified issm/trunk-jpl/src/c/modules/modules.h ¶
r13939 r14279 60 60 #include "./Kml2Expx/Kml2Expx.h" 61 61 #include "./Krigingx/Krigingx.h" 62 #include "./Shp2Kmlx/Shp2Kmlx.h"63 62 #include "./Mergesolutionfromftogx/Mergesolutionfromftogx.h" 64 63 #include "./MeshPartitionx/MeshPartitionx.h" … … 87 86 #include "./RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.h" 88 87 #include "./Scotchx/Scotchx.h" 88 #include "./Shp2Expx/Shp2Expx.h" 89 #include "./Shp2Kmlx/Shp2Kmlx.h" 89 90 #include "./SmbGradientsx/SmbGradientsx.h" 90 91 #include "./Solverx/Solverx.h" -
TabularUnified issm/trunk-jpl/src/wrappers/Shp2Exp/Shp2Exp.cpp ¶
r14016 r14279 1 /*\file Shp2 Kml.c2 *\brief: shp to kmlfile conversion mex module.1 /*\file Shp2Exp.c 2 *\brief: shp to exp file conversion mex module. 3 3 */ 4 4 … … 9 9 #endif 10 10 11 #include "./Shp2 Kml.h"11 #include "./Shp2Exp.h" 12 12 13 void Shp2 KmlUsage(void){/*{{{*/14 _pprintLine_("Shp2 Kml - shp to kmlfile conversion module:");13 void Shp2ExpUsage(void){/*{{{*/ 14 _pprintLine_("Shp2Exp - shp to exp file conversion module:"); 15 15 _pprintLine_(""); 16 _pprintLine_(" This module converts a file from shp to kmlformat.");16 _pprintLine_(" This module converts a file from shp to exp format."); 17 17 _pprintLine_(""); 18 18 _pprintLine_(" Usage:"); 19 _pprintLine_(" [ret]=Shp2 Kml(filshp,filkml,sgn,'param name',param,...);");19 _pprintLine_(" [ret]=Shp2Exp(filshp,filexp,sgn,'param name',param,...);"); 20 20 _pprintLine_(""); 21 21 _pprintLine_(" filshp file name of shp file to be read (char, extension optional)"); 22 _pprintLine_(" fil kml file name of kmlfile to be written (char)");22 _pprintLine_(" filexp file name of exp file to be written (char)"); 23 23 _pprintLine_(" sgn sign for hemisphere (double, +1 (north); -1 (south); or 0 (no translation))"); 24 24 _pprintLine_(""); … … 29 29 _pprintLine_(""); 30 30 _pprintLine_(" Examples:"); 31 _pprintLine_(" [ret]=Shp2 Kml('file.shp','file.kml', 0);");32 _pprintLine_(" [ret]=Shp2 Kml('file.shp','file.kml', 1,'central_meridian',45,'standard_parallel',70);");33 _pprintLine_(" [ret]=Shp2 Kml('file.shp','file.kml',-1,'central_meridian', 0,'standard_parallel',71);");31 _pprintLine_(" [ret]=Shp2Exp('file.shp','file.exp', 0);"); 32 _pprintLine_(" [ret]=Shp2Exp('file.shp','file.exp', 1,'central_meridian',45,'standard_parallel',70);"); 33 _pprintLine_(" [ret]=Shp2Exp('file.shp','file.exp',-1,'central_meridian', 0,'standard_parallel',71);"); 34 34 _pprintLine_(""); 35 35 }/*}}}*/ 36 WRAPPER(Shp2 Kml){36 WRAPPER(Shp2Exp){ 37 37 38 38 int i,verbose=1; 39 39 40 40 /*input: */ 41 char *filshp=NULL,*fil kml=NULL;41 char *filshp=NULL,*filexp=NULL; 42 42 int sgn; 43 43 Options* options=NULL; … … 56 56 /*checks on arguments on the matlab side: */ 57 57 if (nlhs > NLHS) { 58 Shp2 KmlUsage(); _error_("Shp2Kmlusage error");58 Shp2ExpUsage(); _error_("Shp2Exp usage error"); 59 59 } 60 60 if (nrhs < NRHS) { 61 Shp2 KmlUsage(); _error_("Shp2Kmlusage error");61 Shp2ExpUsage(); _error_("Shp2Exp usage error"); 62 62 } 63 63 64 64 /*Input datasets: */ 65 65 FetchData(&filshp,SHP_IN); 66 FetchData(&fil kml,KML_IN);66 FetchData(&filexp,EXP_IN); 67 67 FetchData(&sgn,SGN_IN); 68 68 FetchData(&options,NRHS,nrhs,prhs); … … 83 83 /* Run core computations: */ 84 84 if (options->GetOption("central_meridian") && options->GetOption("standard_parallel")) 85 iret=Shp2 Kmlx(filshp,filkml,sgn,cm,sp);85 iret=Shp2Expx(filshp,filexp,sgn,cm,sp); 86 86 else 87 iret=Shp2 Kmlx(filshp,filkml,sgn);87 iret=Shp2Expx(filshp,filexp,sgn); 88 88 89 89 /*Write data: */ … … 92 92 /*Clean-up*/ 93 93 delete options; 94 xDelete<char>(fil kml);94 xDelete<char>(filexp); 95 95 xDelete<char>(filshp); 96 96 -
TabularUnified issm/trunk-jpl/src/wrappers/Shp2Exp/Shp2Exp.h ¶
r14016 r14279 1 /*!\file Shp2 Kml.h2 * \brief: prototype for shp to kmlfile conversion mex module.1 /*!\file Shp2Exp.h 2 * \brief: prototype for shp to exp file conversion mex module. 3 3 */ 4 4 5 #ifndef _SHP2 KML_H6 #define _SHP2 KML_H5 #ifndef _SHP2EXP_H 6 #define _SHP2EXP_H 7 7 8 8 #ifdef HAVE_CONFIG_H … … 24 24 25 25 #undef __FUNCT__ 26 #define __FUNCT__ "Shp2 Kml"26 #define __FUNCT__ "Shp2Exp" 27 27 28 28 #ifdef _HAVE_MATLAB_MODULES_ 29 29 /* serial input macros: */ 30 30 #define SHP_IN prhs[0] 31 #define KML_IN prhs[1]31 #define EXP_IN prhs[1] 32 32 #define SGN_IN prhs[2] 33 33 /* serial output macros: */ … … 38 38 /* serial input macros: */ 39 39 #define SHP_IN PyTuple_GetItem(args,0) 40 #define KML_IN PyTuple_GetItem(args,1)40 #define EXP_IN PyTuple_GetItem(args,1) 41 41 #define SGN_IN PyTuple_GetItem(args,2) 42 42 /* serial output macros: */ -
TabularUnified issm/trunk-jpl/src/wrappers/matlab/Makefile.am ¶
r13831 r14279 76 76 KMLMeshWrite.la\ 77 77 KMLOverlay.la\ 78 Shp2Kml.la\79 78 Exp2Kml.la\ 80 Kml2Exp.la 79 Kml2Exp.la\ 80 Shp2Exp.la\ 81 Shp2Kml.la 81 82 endif 82 83 endif … … 246 247 Scotch_la_LIBADD = ${deps} $(SCOTCHLIB) $(MPILIB) 247 248 249 Shp2Exp_la_SOURCES = ../Shp2Exp/Shp2Exp.cpp\ 250 ../Shp2Exp/Shp2Exp.h 251 Shp2Exp_la_LIBADD = ${deps} $(SHAPELIBLIB) $(MPILIB) $(PETSCLIB) 252 248 253 Shp2Kml_la_SOURCES = ../Shp2Kml/Shp2Kml.cpp\ 249 254 ../Shp2Kml/Shp2Kml.h
Note:
See TracChangeset
for help on using the changeset viewer.