Shopping Cart

Search:

Signup

Contact

FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

# FileMaker Pro Custom Functions

Rate this function:

Discuss this Custom Function

Steve Murray, Steve Murray
http://www.nurse.tv

Calculates latitude and longitude boundaries at radius of a location.

Sample Input:
 GeoBox (35.0846 ; 106.6516 ; 20 )
Sample Output:
 34.7955 35.3737 106.2983 107.0049

Then copy & paste into FileMaker Advanced's Edit Custom Function window.

## Description:

Use with your database of locations or addresses, each record having latitude and longitude geo data.
Given a longitude and latitude (ie. from a zip code db or geocode lookup) for your centerpoint and a radius in miles. This function will calculate boundary latitudes and longitudes, creating a box area for finding locations within the radius of the box's centerpoint. The result is delivered in a four member value list. (lat1¶lat2¶long1¶long2). Use FileMaker's GetValue function to retreive the values.

Typical Use:
You can use the values for a Find:
criteria: Latitude= lat1 ... lat2 AND Longitude = long1 ... long2.
Or you can create a multipredicate relationship to define the range and pull in related records.

Things to consider:
Due to the fact that we are using a box instead of a circle, there is margin of error here but acceptable for most applications, such as retail locations, delivery information, etc.

These calculations are generally accepted formulas for approximate (close enough) results. There are other, albeit more complex formulas if pinpoint accuracy is required.

If your DB containing geo location data contains negative values (ie. negative longitudes for western hemisphere), it is best to just remove the negative signs and make sure that all data represents absolute values. This is easier than adjusting calculation results or find requests for occurances of negative values in your fields. This is valid as long as your radius calcs do not involve more than one quadrant. For example, the North American quadrant is all north latitudes and west longitudes.

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

This is my Custom Function and I want to edit it

## Discuss:

ddd

vvv, GeoBox (35.0846 ; 106.6516 ; 20 )
December 26, 2014 10:12am

Steve,

hello.
just added two more variables to your CF in order to adapt it to deal with negative values as well as miles and kilometers.

best regards,

/*
GeoBox( latitude ; longitude ; radius ; KmOrMiles ; roundVal )
"Km" for kilometers; any other value for miles
any numeric value (best if between 1~6) for roundVal
based on a CF written by Steve Murray

Steve Murray
http://www.nurse.tv
*/

Let (
[

Case (

KmOrMiles = "Km";
);

signLati =
Case (
Left ( latitude ; 1 ) = "-";
"-"
);

signLong =
Case (
Left ( longitude ; 1 ) = "-";
"-"
);

stripLati = Filter ( latitude ; ".0123456789" );
stripLong = Filter ( longitude ; ".0123456789" );

lati01 = Round( stripLati - ( convRadius / 69.172 ) ; roundVal );
lati02 = Round( stripLati + ( convRadius / 69.172 ) ; roundVal );
long01 = Round( stripLong - ( convRadius / ( Cos( Radians( latitude ) ) * 69.172) ) ; roundVal );
long02 = Round( stripLong + ( convRadius / ( Cos( Radians( latitude ) ) * 69.172) ) ; roundVal )
];

signLati & lati01 & ¶ &
signLati & lati02 & ¶ &
signLong & long01 & ¶ &
signLong & long02
)

Edward, Victoria, BC, CA — Sao Paulo, SP, BR
December 07, 2015 2:30am

Best way to deal with this would be to change the middle section of the longer custom function to look like this:

signLati =
Case (
Latitude < 0;
"-"
);

signLong =
Case (
Longitude < 0;
"-"
);

Scott, Austin
August 30, 2017 12:12pm