source: issm/oecreview/Archive/19101-20495/ISSM-20121-20122.diff@ 20498

Last change on this file since 20498 was 20498, checked in by Mathieu Morlighem, 9 years ago

CHG: done with Archive/19101-20495

File size: 1.2 KB
  • ../trunk-jpl/src/m/geometry/locationtonode.m

     
    1 function node=locationtonode(md,location)
     1function nodes=locationtonode(md,location,varargin)
    22%LOCATIONTONODE - find, given a string location (ex: 'LA', 'new york', the nearest node on a mesh3dsurface.
    33%
    44%   Usage:
    55%      node=locationnode(md,'LA');
     6%      nodes=locationnode(md,'LA',100); %option, specify a distance (km) around the location that will return nodes
    67%
    78%   See also: geoCode (in externalpackages), find_point
    89
    9 coords=geoCode(location,'osm'); 
    10 latny=coords(1); longny=coords(2);
    11 node=find_point(md.mesh.lat,md.mesh.long,latny,longny);
     10        if nargin==3,
     11                radius=varargin{1};
     12        else
     13                radius=0;
     14        end
     15
     16        coords=geoCode(location,'osm'); 
     17        latny=coords(1); longny=coords(2);
     18        node=find_point(md.mesh.lat,md.mesh.long,latny,longny);
     19
     20        if radius>0,
     21                distance=sqrt( (md.mesh.x-md.mesh.x(node)).^2 + (md.mesh.y-md.mesh.y(node)).^2 + (md.mesh.z-md.mesh.z(node)).^2);
     22                nodes=find(distance<radius*1000);
     23        else
     24                nodes=node;
     25        end
     26end
Note: See TracBrowser for help on using the repository browser.