Skip to content

Clean up some minor stuff #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions GetOpenLocationCode.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ CREATE FUNCTION [dbo].[GetOpenLocationCode]
@longitude DECIMAL(9,6),
@codeLength INT = 10
)
RETURNS VARCHAR(MAX)
RETURNS VARCHAR(16)
AS
BEGIN
DECLARE @code VARCHAR(MAX) = '';
DECLARE @code VARCHAR(16) = '';
DECLARE @CodePrecisionNormal INT = 10; -- Provides a normal precision code, approximately 14x14 meters.
DECLARE @CodePrecisionExtra INT = 11; -- Provides an extra precision code, approximately 2x3 meters.
DECLARE @Separator CHAR(1) = '+'; -- A separator used to break the code into two parts to aid memorability.
Expand All @@ -44,9 +44,9 @@ BEGIN
IF (@latitude = @LatitudeMax)
BEGIN
DECLARE @latitudePrecission DECIMAL(9,6);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the improvements! And for pointing out the typo. Please change it also here on line 46 so I can merge your pull request. Thanks!

IF (@codeLength <= @CodePrecisionNormal) SET @latitudePrecission = POWER(@EncodingBase, @codeLength / -2 + 2);
ELSE SET @latitudePrecission = POWER(@EncodingBase, -3) / POWER(@GridRows, @codeLength - @PairCodeLength);
SET @latitude = @latitude - 0.9 * @latitudePrecission;
IF (@codeLength <= @CodePrecisionNormal) SET @latitudePrecision = POWER(@EncodingBase, (@codeLength / -2) + 2);
ELSE SET @latitudePrecision = POWER(@EncodingBase, -3) / POWER(@GridRows, @codeLength - @PairCodeLength);
SET @latitude = @latitude - 0.9 * @latitudePrecision;
END

-- Adjust latitude and longitude to be in positive number ranges.
Expand Down