aboutsummaryrefslogtreecommitdiff
path: root/noao/onedspec/ecidentify/ecnearest.x
blob: 7b061472afb1e84660af6175abe76c9e66c5e7a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
include	<mach.h>
include	"ecidentify.h"

# EC_NEAREST -- Find the nearest feature to a given coordinate.

procedure ec_nearest (ec, fitnear)

pointer	ec			# ID pointer
double	fitnear			# Coordinate to find nearest feature

int	i, ec_next()
double	delta, delta1

begin
	EC_CURRENT(ec) = 0

	i = 0
	delta = MAX_REAL
	while (ec_next (ec, i) != EOF) {
	    delta1 = abs (FIT(ec,i) - fitnear)
	    if (delta1 < delta) {
		EC_CURRENT(ec) = i
		delta = delta1
	    }
	}
end