Changeset 20111


Ignore:
Timestamp:
02/10/16 12:35:12 (9 years ago)
Author:
Eric.Larour
Message:

CHG: new improved patchglobe that relies on gdaltransform instead of ll2xy. Also fixed large issue with connectivity
not being correctly handled when augmenting the mesh with patches.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/mesh/patchglobe.m

    r19954 r20111  
    55
    66        %recover basic options:
    7         hem=getfieldvalue(options,'hem');
    87        bandwidth=getfieldvalue(options,'bandwidth',100000);
    98
    109        %give ourselves a unique temporary directory:
    1110        temproot=tempname; mkdir(temproot);
     11
     12        %align external segments on 2d model:
     13        mh2d.segments=alignsegments(mh2d.segments);
    1214
    1315        %figure out domain outline:
     
    1820        expcontract([temproot '/PatchBroad.exp'],[temproot '/PatchBroad.exp'],-bandwidth);
    1921
    20         %now flag vertices that are within the contour:
    21         [x,y]=ll2xy(mh.lat,mh.long,hem);
    22         if hem==1,
    23                 flagsnods=ContourToNodes(x,y,[temproot '/PatchBroad.exp'],1) & mh.lat>=0;
    24         else
    25                 flagsnods=ContourToNodes(x,y,[temproot '/PatchBroad.exp'],1) & mh.lat<=0;
    26         end
     22        %now flag vertices (from mh2d's broad contour that are on the global mesh: do this in the local 2d mesh reference system.
     23        [x,y]=gdaltransform(mh.long,mh.lat,'EPSG:4326',['EPSG:' num2str(mh2d.epsg)]);
     24        flagsnods=ContourToNodes(x,y,[temproot '/PatchBroad.exp'],1);
    2725
    2826        %expand flags to any element that touches the contour:
     
    3735
    3836        %x,y for segments:
    39         [xsegs,ysegs]=ll2xy(mh.lat(mh.segments(:,1)),mh.long(mh.segments(:,1)),hem);
     37        [xsegs,ysegs]=gdaltransform(mh.long(mh.segments(:,1)),mh.lat(mh.segments(:,1)),'EPSG:4326',['EPSG:' num2str(mh2d.epsg)]);
    4038
    41         %create contour out of these segments:
     39        %create lat,long contour out of these segments:
    4240        meshtodomain(mh,[temproot '/PatchEnveloppe.exp'],'latlong','on');
    43         expll2xy([temproot '/PatchEnveloppe.exp'],hem);
     41               
     42        %get these lat,long transformed to local mesh referencial:
     43        env=expread([temproot '/PatchEnveloppe.exp']);
     44        [env.x,env.y]=gdaltransform(env.x,env.y,'EPSG:4326',['EPSG:' num2str(mh2d.epsg)]);
    4445
    4546        %now, create domain outine from broad enveloppe and initial mesh
    46         env=expread([temproot '/PatchEnveloppe.exp']);
    4747        dom=expread([temproot '/Patch.exp']);
    4848       
     
    6161        expwrite(domain,[temproot '/PatchBand.exp']);
    6262
     63        %plot mesh:
     64        if  getfieldvalue(options,'plot',0), expdisp([temproot '/PatchBand.exp']); end
     65
    6366        %mesh:
    6467        mdb=bamg(model(),'domain',[temproot '/PatchBand.exp'],'MaxCornerAngle',1e-15,'gradation',10000);
     
    7174
    7275        %augment patch with band
    73         [mhb.lat,mhb.long]=xy2ll(mhb.x,mhb.y,hem);
     76        [mhb.long,mhb.lat]=gdaltransform(mhb.x,mhb.y,['EPSG:' num2str(mh2d.epsg)],'EPSG:4326');
    7477        mh2db=augment2dmesh(mh2d,mhb);
    7578
Note: See TracChangeset for help on using the changeset viewer.