Hi - just joined, so a big "Hi" first of all. Only just discovered this forum and it looks great! I hope to be here for many years helping and being helped.
I have a bit of a problem and need a nudge in the right direction. Any takers?
My database is managing multiple "Places" at different geographical locations. I would like to be able to automatically produce information on the "as the crow flies" distance between the co-ordinates captured for each record of a Place.
My "Place" table holds fields that capture "lat" and "long" aspects of geospherical co-ordinates and a calculated "distance" field that uses a custom function I created (well, the authors of "FileMaker 8 Functions and Scripts" created to be fair!) that can take these lat and long co-ordinates for two separate Place records (so, four pieces of data) and will calculate the distance using the Haversine forumala. (http://en.wikipedia.org/wiki/Haversine_formula) for anyone interested.
My inclination was to create a self-join relationship between my original "Place" table and a new table occurrence of Place that I have called "OtherPlace" and so have done so using a cross-product relationship.
I then embed a portal control for the "OtherPlace" table occurrence in one of my tabbed "Place" layouts and this dutifully shows a list of all of the "Place/OtherPlace" records in my database. It also correctly shows the lat and long values for every record in "OtherPlace" AND the lat and long values for the parent "Place" repeated identically as expected on every row of the portal.
So far so good! - so, what is my problem?
The problem I cannot quite figure out why my new portal won't make the calculation between every "pair" of Places according to the Haversine forumula in my custom function.
[if I create DUMMY fields for "another" place in just one record, the forumula works just fine, by the way - so the problem is not with the formula/ custom function.]
What it won't do is, via the portal of "OtherPlace" records, calculate the distance between each "OtherPlace" record in a row of the portal and the single 'parent' "Place" record shown in the main layout. It is as if the coordinates for the other side of the pairing of places are all set to zero, even though they show up in the portal row correctly.
I've tried changing the relationship between "Place" and "OtherPlace" to be a exclusionary type (where the "Place" primary key does NOT equal the "OtherPlace" primary key) and this does remove the parent record from the portal list as expected but still the Haversine calculations are wrong.
I know this has to be to do with how I am designing the relationship between an individual record in the "Place" table occurrence and all other records for Places in a "OtherPlace" table ocurrence but can't make my brain fire-up to puzzle it out.
Self-joins are always a head-nip for me! Where am I going wrong?
Perhaps there is some other way of building up some sort of data array to hold the distances between every pair of records in a single "Place" table but that's beyond me (using FileMaker) if I'm being honest - but if there is some way to do that I'd be grateful for a nudge in the right direction.
Thanks a million,
Paul