Creating a Nearest Link
Creating a nearest link from one schema to another will allow you to find out which point in a schema is closest to a point in a second schema (in a straight line). For example, you could find out which competitors are the nearest to all your stores.
In this example we will create a nearest link to find which store is the nearest to each customer.
Setting up the link:
Go to Tools | Configure Catalog
Double click on the Schema Group (here User Data) that holds your first schema (here Branch customers)
Double click on the schema itself (e.g. Branch Customers)
Highlight Superior Links and select the New... button

Click on the down arrow next to Inferior Schema and select the schema you want to find the nearest from (eg. Branches)
Type in a Link Name and a Link Description
Note: A link name cannot contain spaces or non-alphanumeric characters
Change the Link Type to Exact_Within and the Link Method to Subquery
Click on the Inf.. button
In the Expression box, type Nearest(
Double click on the Master table (the red table icon with a small purple key)
Double click on the Location/Point column
Add a comma to the end of the expression so far

Select OK
Click on Sup..
Double click on the Master table and again, double click on the Location/Point column
Add ) to the end

Select OK
The expression should look like this:
Nearest(MASTER.POSTCODE_POINT, :MASTER.POSTCODE_POINT)

Click Apply
Add new record? Pick Yes then close the window
Using the link:
Open a browse on the schema that you created the link for, here Branch Customers
Right click and select Add Column…
You will see the link that you just created, (here Nearest Branch), double click on it
Note: If you don’t see it you may have to go through blue link called User Data first
Double click on the master table and select the Branch Name
Click on the > button to move it to Selected Expressions
Select OK

This will have added a new column to your browse listing the name of the nearest location. If you want to find the distance to this point, you will need to use a Distance expression which is covered in the tip ‘Distance between two points’.
Last updated