This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create function dbo.udf_OrdnanceSurvey_WGS84 (@east int, @north int) | |
returns geography | |
as | |
begin | |
if @east is null | |
or @north is null | |
or (@east = 0 and @north = 0) -- 0,0 is a legitmate co-ordinate, but in our DB it's used instead of missing locations | |
return null | |
-- Adapted from https://stackoverflow.com/a/12317217/905 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create function dbo.udf_OSGrid_WGS84 (@east int, @north int) | |
returns geography | |
as | |
begin | |
-- reference implementation: http://www.movable-type.co.uk/scripts/latlong-os-gridref.html | |
if @east is null | |
or @north is null | |
return null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create function dbo.searchToXml(@input varchar(max)) returns xml | |
as | |
begin | |
set @input = ltrim(rtrim(@input)) | |
-- Mismatched ( and ) means we can't parse with this method | |
if len(replace(@input, '(', '')) <> len(replace(@input, ')', '')) | |
return null; | |
set @input = replace(replace(replace(replace(replace(replace(replace( |