Page 1 of 1

Distance and Angle Function

PostPosted: Mon Jul 24, 2006 1:06 pm
by glhein
I have a data base with UTM coordinates (Easting, Northing) for rock art panels we are documenting. I need to compute the distance and angle from one set of coordinates to the next. I have a function that works in Excel but it is a shame to export the data to do this.

The problems I haven't solved in FileMarker are

1. Starting on the second record of a found set
2. Getting the Easting and Northing of the previous record so I can calculate the differnce between the current record and previous record.

What didn't I find in the help that makes this function possible?

PostPosted: Mon Jul 24, 2006 1:57 pm
by Ender
What version of FileMaker do you have?

Can you share what your current function is, or give us the specs for how it should work?

PostPosted: Mon Jul 24, 2006 7:27 pm
by glhein
I am using Version 7.

The function is

ec, ep Easting current record, previous record
nc, np Nothing current record, previous record

de = ec - ep
dn = nc - np
dist = sqrt( de*de + dn*dn)
ang = 57.29578*ATAN(dn/((de)+0.000001))
If( de > 0 and dn > 0 )gridnorth = 90 - ang
If( de > 0 and dn < 0 )gridnorth = 90 - ang
If( de < 0 and dn < 0 )gridnorth = 270 - ang
If( de < 0 and dn > 0 )gridnorth = 270 - ang


Note:
This is all basic trig and the if statements convert the angles to what you get on a compass. The coordinate system uses a grid north that will be adjusted to be magnectic north. The idea is a person can use a distance in meters and a compass bearing to locate the next panel of rock art.

If these data are sorted by Photo Number then it is distance/bearing are to next recorded panel. If these data are sorted by Easting then Northing then it is to the next closest panel.

We have about 2,600 panels over a 5 mile long dike and the adjacent slopes.

PostPosted: Mon Jul 24, 2006 8:24 pm
by John Sindelar
You can use the following to get the value from a previous record, where the value you want is in a field called "FieldName":

GetNthRecord ( FieldName ; Get ( RecordNumber ) - 1 )

If using this in a field definition calculation, be sure the calculation is unstored (click storage options in the lower right of the calculation definition window, then "Do not store..."). When the calc is unstored it will get the previous record in the found set, according to your current record sort order.

PostPosted: Tue Jul 25, 2006 5:01 am
by Ender
Since GetNthRecord() is only available in version 8 and later, you'll need some other technique to grab or see the previous record's value. How to do this depends on what you mean by "previous record". If you mean the previously created record, then you can define the ep and np fields to use the values of the ec & nc fields from the record with the next lower serial# (via a self-join relationship). If you mean the previous record in the found set, then you'll need a script to loop through them, setting all the ep & np fields based on the previous record's values.

PostPosted: Tue Jul 25, 2006 5:54 am
by John Sindelar
Ender wrote:Since GetNthRecord() is only available in version 8


Thanks Ender. I completely forgot that wasn't in 7.

PostPosted: Tue Jul 25, 2006 3:53 pm
by Ender
Ah, how quickly we become dependant on the new features!

Do you remember back when the dialog windows couldn't be resized (FM3 and below, I think). I remember complaining about having to work in a tiny window and scroll through every ten fields or so. Then we finally got to resize some windows, but not all (like that pesky Layout Order dialog), but it was still worth upgrading. Of course then we complained about the lightning-fast scroll speed in the Import dialog and the Layout Order dialog, so they gave us a new version that fixed that. The release of FileMaker 7 (Developer) gave us all kinds of great new developer features, but we complained about not being able to import tables from other files. Finally we got 8 Advanced, and were delighted to be able to not only import tables, but copy and paste tables, fields, and script steps. Oh, what a great application we get to work with! :D

PostPosted: Tue Jul 25, 2006 5:19 pm
by John Sindelar
Ender wrote:Oh, what a great application we get to work with! :D


Well said!

PostPosted: Sat Jul 29, 2006 10:49 am
by glhein
Well it looks like an upgrade is in order or I do this in Excel.

What do I read to get up to speed on Filemaker scripting. I assume that I have to use ScriptMaker to get at the commands until I pound the usefull one into the head.

I do like FileMaker much better that Access. It is much more capable.

I have to confess that my programing growth was stunted in the 70s after getting good a real time assembly language, Fortran, and even a bit of machine language through the console.