Changeset 20122


Ignore:
Timestamp:
02/11/16 19:25:06 (9 years ago)
Author:
Eric.Larour
Message:

CHG: improve by returning within a radius, and a certain tolerance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/geometry/locationtonode.m

    r20076 r20122  
    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 TracChangeset for help on using the changeset viewer.