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

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

CHG: done with Archive/19101-20495

File size: 1.2 KB
RevLine 
[20498]1Index: ../trunk-jpl/src/m/geometry/locationtonode.m
2===================================================================
3--- ../trunk-jpl/src/m/geometry/locationtonode.m (revision 20121)
4+++ ../trunk-jpl/src/m/geometry/locationtonode.m (revision 20122)
5@@ -1,11 +1,26 @@
6-function node=locationtonode(md,location)
7+function nodes=locationtonode(md,location,varargin)
8 %LOCATIONTONODE - find, given a string location (ex: 'LA', 'new york', the nearest node on a mesh3dsurface.
9 %
10 % Usage:
11 % node=locationnode(md,'LA');
12+% nodes=locationnode(md,'LA',100); %option, specify a distance (km) around the location that will return nodes
13 %
14 % See also: geoCode (in externalpackages), find_point
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+ if nargin==3,
20+ radius=varargin{1};
21+ else
22+ radius=0;
23+ end
24+
25+ coords=geoCode(location,'osm');
26+ latny=coords(1); longny=coords(2);
27+ node=find_point(md.mesh.lat,md.mesh.long,latny,longny);
28+
29+ if radius>0,
30+ 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);
31+ nodes=find(distance<radius*1000);
32+ else
33+ nodes=node;
34+ end
35+end
Note: See TracBrowser for help on using the repository browser.