PatrickHaston
IS-IT--Management
We've developed a little function that others may find useful - no warrenty is supplied with this code, use it at your own risk.
It converts a UK Grid Reference to Eastings and Northings data and calls MultiMap.com to display a map at 1:50,000 of the area around the point (highlighted with a red circle). It can be used for addresses too but we work mainly with Grid References.
It's a very easy function to add to a form and makes you look good. The users here like it.
Patrick.
The first function is added to the WHEN-BUTTON-PRESSED trigger on a button on the form, the other two functions convert the Grid Reference into a format that MultiMap likes better.
declare
V_COMMAND VARCHAR2(2000);
V_NORTHINGS NUMBER;
V_EASTINGS NUMBER;
begin
-- Convert the Grid Reference to Eastings and Northings
V_NORTHINGS := UNF_GRIDREF_NORTH( :GRID_REFERENCE);
V_EASTINGS := UNF_GRIDREF_EAST( :GRID_REFERENCE);
-- Build the command to call Multimap
V_COMMAND := '"c:\program files\internet explorer\IEXPLORE.EXE" || to_char(V_EASTINGS) || '&GridN=' || to_char(V_NORTHINGS) || '&scale=50000'
|| '&title=SNH+Casework+Recording+Location&cat=h';
-- Display the map
host(V_COMMAND);
end;
FUNCTION UNF_GRIDREF_NORTH (P_GRIDREF VARCHAR2) RETURN NUMBER IS
THE_RESULT NUMBER;
TEMP1 INTEGER;
VAR_A INTEGER;
VAR_B INTEGER;
BEGIN
THE_RESULT := 0;
VAR_A := ASCII(UPPER(SUBSTR(P_GRIDREF,1,1))) - 65;
VAR_B := ASCII(UPPER(SUBSTR(P_GRIDREF,2,1))) - 65;
IF VAR_A > 8 THEN
VAR_A := VAR_A - 1;
END IF;
IF VAR_B > 8 THEN
VAR_B := VAR_B - 1;
END IF;
VAR_A := 3 - round(VAR_A / 5);
VAR_B := 4 - round(VAR_B / 5);
TEMP1 := (LENGTH(P_GRIDREF) - 2) / 2;
THE_RESULT := VAR_A * 500000 + VAR_B * 100000 + ((SUBSTR(P_GRIDREF,TEMP1+3,TEMP1)) * 10 ** (5 - TEMP1));
RETURN THE_RESULT;
END;
FUNCTION UNF_GRIDREF_EAST (P_GRIDREF VARCHAR2) RETURN NUMBER IS
THE_RESULT NUMBER;
TEMP1 INTEGER;
VAR_A INTEGER;
VAR_B INTEGER;
BEGIN
THE_RESULT := 0;
VAR_A := ASCII(UPPER(SUBSTR(P_GRIDREF,1,1))) - 65;
VAR_B := ASCII(UPPER(SUBSTR(P_GRIDREF,2,1))) - 65;
IF VAR_A > 8 THEN
VAR_A := VAR_A - 1;
END IF;
IF VAR_B > 8 THEN
VAR_B := VAR_B - 1;
END IF;
VAR_A := MOD(VAR_A, 5) - 2;
VAR_B := MOD(VAR_B, 5);
TEMP1 := (LENGTH(P_GRIDREF) - 2) / 2;
THE_RESULT := VAR_A * 500000 + VAR_B * 100000 + ((SUBSTR(P_GRIDREF,3,TEMP1)) * 10 ** (5 - TEMP1));
RETURN THE_RESULT;
END;
It converts a UK Grid Reference to Eastings and Northings data and calls MultiMap.com to display a map at 1:50,000 of the area around the point (highlighted with a red circle). It can be used for addresses too but we work mainly with Grid References.
It's a very easy function to add to a form and makes you look good. The users here like it.
Patrick.
The first function is added to the WHEN-BUTTON-PRESSED trigger on a button on the form, the other two functions convert the Grid Reference into a format that MultiMap likes better.
declare
V_COMMAND VARCHAR2(2000);
V_NORTHINGS NUMBER;
V_EASTINGS NUMBER;
begin
-- Convert the Grid Reference to Eastings and Northings
V_NORTHINGS := UNF_GRIDREF_NORTH( :GRID_REFERENCE);
V_EASTINGS := UNF_GRIDREF_EAST( :GRID_REFERENCE);
-- Build the command to call Multimap
V_COMMAND := '"c:\program files\internet explorer\IEXPLORE.EXE" || to_char(V_EASTINGS) || '&GridN=' || to_char(V_NORTHINGS) || '&scale=50000'
|| '&title=SNH+Casework+Recording+Location&cat=h';
-- Display the map
host(V_COMMAND);
end;
FUNCTION UNF_GRIDREF_NORTH (P_GRIDREF VARCHAR2) RETURN NUMBER IS
THE_RESULT NUMBER;
TEMP1 INTEGER;
VAR_A INTEGER;
VAR_B INTEGER;
BEGIN
THE_RESULT := 0;
VAR_A := ASCII(UPPER(SUBSTR(P_GRIDREF,1,1))) - 65;
VAR_B := ASCII(UPPER(SUBSTR(P_GRIDREF,2,1))) - 65;
IF VAR_A > 8 THEN
VAR_A := VAR_A - 1;
END IF;
IF VAR_B > 8 THEN
VAR_B := VAR_B - 1;
END IF;
VAR_A := 3 - round(VAR_A / 5);
VAR_B := 4 - round(VAR_B / 5);
TEMP1 := (LENGTH(P_GRIDREF) - 2) / 2;
THE_RESULT := VAR_A * 500000 + VAR_B * 100000 + ((SUBSTR(P_GRIDREF,TEMP1+3,TEMP1)) * 10 ** (5 - TEMP1));
RETURN THE_RESULT;
END;
FUNCTION UNF_GRIDREF_EAST (P_GRIDREF VARCHAR2) RETURN NUMBER IS
THE_RESULT NUMBER;
TEMP1 INTEGER;
VAR_A INTEGER;
VAR_B INTEGER;
BEGIN
THE_RESULT := 0;
VAR_A := ASCII(UPPER(SUBSTR(P_GRIDREF,1,1))) - 65;
VAR_B := ASCII(UPPER(SUBSTR(P_GRIDREF,2,1))) - 65;
IF VAR_A > 8 THEN
VAR_A := VAR_A - 1;
END IF;
IF VAR_B > 8 THEN
VAR_B := VAR_B - 1;
END IF;
VAR_A := MOD(VAR_A, 5) - 2;
VAR_B := MOD(VAR_B, 5);
TEMP1 := (LENGTH(P_GRIDREF) - 2) / 2;
THE_RESULT := VAR_A * 500000 + VAR_B * 100000 + ((SUBSTR(P_GRIDREF,3,TEMP1)) * 10 ** (5 - TEMP1));
RETURN THE_RESULT;
END;