Changeset 14279


Ignore:
Timestamp:
01/22/13 11:44:31 (12 years ago)
Author:
jschierm
Message:

NEW: Prototype of Shp2Exp matlab modules.

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  
    627627                             ./modules/Kml2Expx/Kml2Expx.h\
    628628                             ./modules/Kml2Expx/Kml2Expx.cpp\
     629                             ./modules/Shp2Expx/Shp2Expx.h\
     630                             ./modules/Shp2Expx/Shp2Expx.cpp\
    629631                             ./modules/Shp2Kmlx/Shp2Kmlx.h\
    630632                             ./modules/Shp2Kmlx/Shp2Kmlx.cpp\
  • TabularUnified issm/trunk-jpl/src/c/modules/Shp2Expx/Shp2Expx.cpp

    r14016 r14279  
    1 /*!\file Shp2Kmlx
    2  * \brief shp to kml conversion routines.
     1/*!\file Shp2Expx
     2 * \brief shp to exp conversion routines.
    33 */
    44
    5 #include "./Shp2Kmlx.h"
     5#include "./Shp2Expx.h"
    66#include "../../shared/shared.h"
    77#include "../../include/include.h"
     
    1111#include "../modules.h"
    1212
    13 int Shp2Kmlx(char* filshp,char* filkml,
     13int Shp2Expx(char* filshp,char* filexp,
    1414                         int sgn){
    1515
     
    2121                Xy2lldef(&cm,&sp,sgn);
    2222
    23         return(Shp2Kmlx(filshp,filkml,
     23        return(Shp2Expx(filshp,filexp,
    2424                                        sgn,cm,sp));
    2525
     
    2929}
    3030
    31 int Shp2Kmlx(char* filshp,char* filkml,
     31int Shp2Expx(char* filshp,char* filexp,
    3232                         int sgn,double cm,double sp){
    3333
     
    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;
    5651        KML_Folder        *kfold  = NULL;
    5752        KML_Placemark     *kplace = NULL;
     
    6863        clock0=clock();
    6964        time0 =time(NULL);
    70         _pprintString_("\nShp2Kmlx Module -- " << ctime(&time0));
     65        _pprintString_("\nShp2Expx Module -- " << ctime(&time0));
    7166
    7267/*  note that much of the following code is taken from shpdump.c in shapelib.  */
     
    204199
    205200        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);
    258201
    259202/*  construct kml folder for shapes  */
     
    564507        }
    565508
    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;
    582523        for (i=nshape-1; i>=0; i--) {
    583524                xDelete<double>((pshapm[i]));
     
    602543        clock1=clock();
    603544        time1 =time(NULL);
    604         _printf_(true,"Shp2Kmlx Module -- %f CPU seconds; %f elapsed seconds.\n\n",
     545        _printf_(true,"Shp2Expx Module -- %f CPU seconds; %f elapsed seconds.\n\n",
    605546                         ((double)(clock1-clock0))/CLOCKS_PER_SEC,difftime(time1,time0));
    606547
  • TabularUnified issm/trunk-jpl/src/c/modules/Shp2Expx/Shp2Expx.h

    r14016 r14279  
    1 /*!\file:  Shp2Kmlx.h
    2  * \brief header file for shp to kml conversion routines.
     1/*!\file:  Shp2Expx.h
     2 * \brief header file for shp to exp conversion routines.
    33 */
    44
    5 #ifndef _SHP2KMLX_H
    6 #define _SHP2KMLX_H
     5#ifndef _SHP2EXPX_H
     6#define _SHP2EXPX_H
    77
    88#ifdef HAVE_CONFIG_H
     
    2222
    2323/* local prototypes: */
    24 int Shp2Kmlx(char* filshp,char* filkml, int sgn);
    25 int Shp2Kmlx(char* filshp,char* filkml, int sgn,double cm,double sp);
     24int Shp2Expx(char* filshp,char* filexp, int sgn);
     25int Shp2Expx(char* filshp,char* filexp, int sgn,double cm,double sp);
    2626
    27 #endif  /* _SHP2KMLX_H */
     27#endif  /* _SHP2EXPX_H */
  • TabularUnified issm/trunk-jpl/src/c/modules/modules.h

    r13939 r14279  
    6060#include "./Kml2Expx/Kml2Expx.h"
    6161#include "./Krigingx/Krigingx.h"
    62 #include "./Shp2Kmlx/Shp2Kmlx.h"
    6362#include "./Mergesolutionfromftogx/Mergesolutionfromftogx.h"
    6463#include "./MeshPartitionx/MeshPartitionx.h"
     
    8786#include "./RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.h"
    8887#include "./Scotchx/Scotchx.h"
     88#include "./Shp2Expx/Shp2Expx.h"
     89#include "./Shp2Kmlx/Shp2Kmlx.h"
    8990#include "./SmbGradientsx/SmbGradientsx.h"
    9091#include "./Solverx/Solverx.h"
  • TabularUnified issm/trunk-jpl/src/wrappers/Shp2Exp/Shp2Exp.cpp

    r14016 r14279  
    1 /*\file Shp2Kml.c
    2  *\brief: shp to kml file conversion mex module.
     1/*\file Shp2Exp.c
     2 *\brief: shp to exp file conversion mex module.
    33 */
    44
     
    99#endif
    1010
    11 #include "./Shp2Kml.h"
     11#include "./Shp2Exp.h"
    1212
    13 void Shp2KmlUsage(void){/*{{{*/
    14         _pprintLine_("Shp2Kml - shp to kml file conversion module:");
     13void Shp2ExpUsage(void){/*{{{*/
     14        _pprintLine_("Shp2Exp - shp to exp file conversion module:");
    1515        _pprintLine_("");
    16         _pprintLine_("   This module converts a file from shp to kml format.");
     16        _pprintLine_("   This module converts a file from shp to exp format.");
    1717        _pprintLine_("");
    1818        _pprintLine_("   Usage:");
    19         _pprintLine_("      [ret]=Shp2Kml(filshp,filkml,sgn,'param name',param,...);");
     19        _pprintLine_("      [ret]=Shp2Exp(filshp,filexp,sgn,'param name',param,...);");
    2020        _pprintLine_("");
    2121        _pprintLine_("      filshp      file name of shp file to be read (char, extension optional)");
    22         _pprintLine_("      filkml      file name of kml file to be written (char)");
     22        _pprintLine_("      filexp      file name of exp file to be written (char)");
    2323        _pprintLine_("      sgn         sign for hemisphere (double, +1 (north); -1 (south); or 0 (no translation))");
    2424        _pprintLine_("");
     
    2929        _pprintLine_("");
    3030        _pprintLine_("   Examples:");
    31         _pprintLine_("      [ret]=Shp2Kml('file.shp','file.kml', 0);");
    32         _pprintLine_("      [ret]=Shp2Kml('file.shp','file.kml', 1,'central_meridian',45,'standard_parallel',70);");
    33         _pprintLine_("      [ret]=Shp2Kml('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);");
    3434        _pprintLine_("");
    3535}/*}}}*/
    36 WRAPPER(Shp2Kml){
     36WRAPPER(Shp2Exp){
    3737
    3838        int i,verbose=1;
    3939
    4040        /*input: */
    41         char    *filshp=NULL,*filkml=NULL;
     41        char    *filshp=NULL,*filexp=NULL;
    4242        int     sgn;
    4343        Options* options=NULL;
     
    5656        /*checks on arguments on the matlab side: */
    5757        if (nlhs > NLHS) {
    58                 Shp2KmlUsage(); _error_("Shp2Kml usage error");
     58                Shp2ExpUsage(); _error_("Shp2Exp usage error");
    5959        }
    6060        if (nrhs < NRHS) {
    61                 Shp2KmlUsage(); _error_("Shp2Kml usage error");
     61                Shp2ExpUsage(); _error_("Shp2Exp usage error");
    6262        }
    6363
    6464        /*Input datasets: */
    6565        FetchData(&filshp,SHP_IN);
    66         FetchData(&filkml,KML_IN);
     66        FetchData(&filexp,EXP_IN);
    6767        FetchData(&sgn,SGN_IN);
    6868        FetchData(&options,NRHS,nrhs,prhs);
     
    8383        /* Run core computations: */
    8484        if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
    85                 iret=Shp2Kmlx(filshp,filkml,sgn,cm,sp);
     85                iret=Shp2Expx(filshp,filexp,sgn,cm,sp);
    8686        else
    87                 iret=Shp2Kmlx(filshp,filkml,sgn);
     87                iret=Shp2Expx(filshp,filexp,sgn);
    8888
    8989        /*Write data: */
     
    9292        /*Clean-up*/
    9393        delete options;
    94         xDelete<char>(filkml);
     94        xDelete<char>(filexp);
    9595        xDelete<char>(filshp);
    9696
  • TabularUnified issm/trunk-jpl/src/wrappers/Shp2Exp/Shp2Exp.h

    r14016 r14279  
    1 /*!\file Shp2Kml.h
    2  * \brief: prototype for shp to kml file conversion mex module.
     1/*!\file Shp2Exp.h
     2 * \brief: prototype for shp to exp file conversion mex module.
    33 */
    44
    5 #ifndef _SHP2KML_H
    6 #define _SHP2KML_H
     5#ifndef _SHP2EXP_H
     6#define _SHP2EXP_H
    77
    88#ifdef HAVE_CONFIG_H
     
    2424
    2525#undef __FUNCT__
    26 #define __FUNCT__  "Shp2Kml"
     26#define __FUNCT__  "Shp2Exp"
    2727
    2828#ifdef _HAVE_MATLAB_MODULES_
    2929/* serial input macros: */
    3030#define SHP_IN  prhs[0]
    31 #define KML_IN  prhs[1]
     31#define EXP_IN  prhs[1]
    3232#define SGN_IN  prhs[2]
    3333/* serial output macros: */
     
    3838/* serial input macros: */
    3939#define SHP_IN PyTuple_GetItem(args,0)
    40 #define KML_IN PyTuple_GetItem(args,1)
     40#define EXP_IN PyTuple_GetItem(args,1)
    4141#define SGN_IN PyTuple_GetItem(args,2)
    4242/* serial output macros: */
  • TabularUnified issm/trunk-jpl/src/wrappers/matlab/Makefile.am

    r13831 r14279  
    7676                                   KMLMeshWrite.la\
    7777                                   KMLOverlay.la\
    78                                    Shp2Kml.la\
    7978                                   Exp2Kml.la\
    80                                    Kml2Exp.la
     79                                   Kml2Exp.la\
     80                                   Shp2Exp.la\
     81                                   Shp2Kml.la
    8182endif
    8283endif
     
    246247Scotch_la_LIBADD = ${deps} $(SCOTCHLIB) $(MPILIB)
    247248
     249Shp2Exp_la_SOURCES = ../Shp2Exp/Shp2Exp.cpp\
     250                                                        ../Shp2Exp/Shp2Exp.h
     251Shp2Exp_la_LIBADD = ${deps} $(SHAPELIBLIB) $(MPILIB) $(PETSCLIB)
     252
    248253Shp2Kml_la_SOURCES = ../Shp2Kml/Shp2Kml.cpp\
    249254                                                        ../Shp2Kml/Shp2Kml.h
Note: See TracChangeset for help on using the changeset viewer.