add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE FUNCTION LatToMercatorProjectedLat(@Lat FLOAT)
RETURNS FLOAT
AS BEGIN
-- Degenerate case @Lat ~ +/- 90 degrees
IF ABS(@Lat) > 89.9999999999
RETURN 9999 * SIGN(@Lat)

-- https://en.wikipedia.org/wiki/Mercator_projection#Derivation
-- Modified to include degrees/radians conversion
RETURN LOG(TAN((45 + 0.5 * @Lat) * PI() / 180)) / PI() * 180
END
CREATE FUNCTION MercatorProjectedToDegreesLat(@Projected FLOAT)
RETURNS FLOAT
AS BEGIN
-- Degenerate case @Lat ~ +/- 90 degrees (round trip)
IF ABS(@Projected) >= 9999
RETURN 90 * SIGN(@Projected)

-- https://en.wikipedia.org/wiki/Mercator_projection#Derivation
-- Modified to include degrees/radians conversion
RETURN (ATAN(EXP(@Projected * PI() / 180)) / PI() * 180 - 45) * 2
END
CREATE FUNCTION InterpolateLatitude(
@Latitude1 FLOAT, -- Start
@Latitude2 FLOAT, -- End
@I FLOAT, -- Interpolation factor 0 (start) to N (end)
@N FLOAT, -- Number of steps
@Mercator BIT -- If 1, adjust for Mercator projection
)
RETURNS FLOAT -- Interpolated resultS
BEGIN
IF @Mercator = 1
BEGIN
SET @Latitude1 = dbo.LatToMercatorProjectedLat(@Latitude1)
SET @Latitude2 = dbo.LatToMercatorProjectedLat(@Latitude2)
END

DECLARE @Fraction FLOAT = @I / NULLIF(@N, 0)
DECLARE @Result FLOAT = @Latitude1 * (1 - @Fraction) + @Latitude2 * @Fraction

IF @Mercator = 1
BEGIN
SET @Result = dbo.MercatorProjectedToDegreesLat(@Result)
END

RETURN @Result
END

CREATE FUNCTION InterpolateLongitude(
@Longitude1 FLOAT, -- Start longitude in degrees
@Longitude2 FLOAT, -- End longitude in degrees
@I FLOAT, -- Interpolation factor 0 (start) to N (end)
@N FLOAT -- Number of steps
)
RETURNS FLOAT -- Interpolated result, adjusted to be in +/- 180 range.
AS
BEGIN
-- For longitudes that cross the +/-180 mark, adjust
-- @LatOrLong2 to be within +/- 180 degrees from @LatOrLong1.
DECLARE @AdjustedLongitude2 FLOAT = CASE
WHEN @Longitude2 < @Longitude1 - 180 THEN @Longitude2 + 360
WHEN @Longitude2 > @Longitude1 + 180 THEN @Longitude2 - 360
ELSE @Longitude2
END
-- Calculate interpolated latitude or longitude and adjust to be in +/- 180 range.
DECLARE @Fraction FLOAT = @I / NULLIF(@N, 0)
DECLARE @Temp FLOAT =
@Longitude1 * (1 - @Fraction)
+ @AdjustedLongitude2 * @Fraction
+ 180
DECLARE @NormalizedResult FLOAT =
@Temp
- 360 * FLOOR(@Temp / 360)
- 180
RETURN @NormalizedResult
END
CREATE FUNCTION AdjustPolygonEdgesForMercadorProjection(
@Polygon Geography,
@Tolerance FLOAT)
RETURNS Geography
AS
BEGIN
DECLARE @Result Geography
DECLARE @Fudge FLOAT = 1.1 -- Allowance for approximations
DECLARE @Mercator BIT = 1 -- If 1, calc using Mercator projected latitude

DECLARE @SRID INT = @Polygon.STSrid -- Typically 4326 for WGS84

;WITH Curves AS (
-- A polygon will have one outer boundary curve plus zero or more
-- inner boundary curves (holes)
SELECT
S.value AS CurveNum,
@Polygon.RingN(S.value) AS Curve
FROM GENERATE_SERIES(1, @Polygon.NumRings()) S
),
Vertices AS (
-- Each curve (outer and inner boundary) should have 4 or more vertices
-- (last = first) representing 3 or more edges.
SELECT
C.CurveNum,
S.value AS PointNum,
C.Curve.STPointN(S.value).Long AS Lng,
C.Curve.STPointN(S.value).Lat AS Lat
FROM Curves C
CROSS APPLY GENERATE_SERIES(1, C.Curve.STNumPoints()) S
),
Edges AS (
-- Extract edges.
SELECT
V1.CurveNum,
V1.PointNum AS EdgeNum,
-- Demo using an adaptation of the original posted code
create table #gtest ([Lat] [float], [Lng] [float], [GeoPoint] AS ([geography]::Point([Lat],[Lng],(4326))))
insert #gtest(Lat, Lng) values (36.3893, -102.796)

declare @swLng float, @swLat float, @neLng float, @neLat float

-- Selectively comment/uncomment the following to pick a test case
select @swLng=-147.45514585847684, @swLat=28.841195680455485, @neLng=-59.86599816500535, @neLat=56.14838208179307
--select @swLng=-134.35054327724572, @swLat=31.64106010841097, @neLng=-71.77427705012154, @neLat=51.66708602548192
--select @swLng=170, @swLat=28, @neLng=-59, @neLat=56

declare @g geography, @poly varchar(max)
set @poly = 'POLYGON((' + cast(@swLng as varchar) + ' ' + cast(@swLat as varchar) + ',' + cast(@neLng as varchar) + ' ' + cast(@swLat as varchar) + ',' + cast(@neLng as varchar) + ' ' + cast(@neLat as varchar) + ',' + cast(@swLng as varchar) + ' ' + cast(@neLat as varchar) + ',' + cast(@swLng as varchar) + ' ' + cast(@swLat as varchar) + '))'
set @g = geography::STGeomFromText(@poly, 4326);

-- Original results
select @g
select * from #gtest where GeoPoint.STWithin(@g) = 1 -- no results
select * from #gtest where GeoPoint.STIntersects(@g) = 1 -- no results either

-- Bring out the big guns and try to fix things up
declare @tolerance float = 100.0 -- 100 meters tolerance
set @g = dbo.AdjustPolygonEdgesForMercadorProjection(@g, @tolerance)
-- Improved results
select @g
select * from #gtest where GeoPoint.STWithin(@g) = 1 -- Match!
select * from #gtest where GeoPoint.STIntersects(@g) = 1 -- Also a match!

(No column name)
POLYGON ((-147.455 28.8412, -59.866 28.8412, -59.866 56.1484, -147.455 56.1484, -147.455 28.8412))
Lat Lng GeoPoint
Lat Lng GeoPoint
(No column name)
POLYGON ((-147.455 28.8412, -146.5962843137255 28.8412, -145.73756862745097 28.8412, -144.87885294117649 28.8412, -144.02013725490198 28.8412, -143.16142156862745 28.8412, -142.30270588235294 28.8412, -141.44399019607843 28.8412, -140.58527450980392 28.8412, -139.72655882352944 28.8412, -138.86784313725491 28.8412, -138.0091274509804 28.8412, -137.15041176470589 28.8412, -136.29169607843139 28.8412, -135.43298039215688 28.8412, -134.57426470588237 28.8412, -133.71554901960786 28.8412, -132.85683333333336 28.8412, -131.99811764705882 28.8412, -131.13940196078431 28.8412, -130.28068627450983 28.8412, -129.42197058823533 28.8412, -128.56325490196079 28.8412, -127.70453921568628 28.8412, -126.84582352941177 28.8412, -125.98710784313727 28.8412, -125.12839215686274 28.8412, -124.26967647058825 28.8412, -123.41096078431373 28.8412, -122.55224509803924 28.8412, -121.6935294117647 28.8412, -120.83481372549019 28.8412, -119.97609803921569 28.8412, -119.11738235294119 28.8412, -118.25866666666668 28.8412, -117.39995098039216 28.8412, -116.54123529411764 28.8412, -115.68251960784313 28.8412, -114.82380392156864 28.8412, -113.96508823529413 28.8412, -113.10637254901962 28.8412, -112.2476568627451 28.8412, -111.3889411764706 28.8412, -110.53022549019607 28.8412, -109.67150980392157 28.8412, -108.81279411764706 28.8412, -107.95407843137257 28.8412, -107.09536274509806 28.8412, -106.23664705882354 28.8412, -105.37793137254901 28.8412, -104.51921568627451 28.8412, -103.66050000000001 28.8412, -102.80178431372551 28.8412, -101.943068627451 28.8412, -101.08435294117646 28.8412, -100.22563725490197 28.8412, -99.366921568627447 28.8412, -98.508205882352939 28.8412, -97.649490196078432 28.8412, -96.790774509803924 28.8412, -95.932058823529417 28.8412, -95.073343137254909 28.8412, -94.2146274509804 28.8412, -93.3559117647059 28.8412, -92.497196078431372 28.8412, -91.638480392156879 28.8412, -90.779764705882343 28.8412, -89.92104901960785 28.8412, -89.062333333333342 28.8412, -88.20361764705882 28.8412, -87.344901960784313 28.8412, -86.4861862745098 28.8412, -85.6274705882353 28.8412, -84.76875490196079 28.8412, -83.910039215686282 28.8412, -83.051323529411775 28.8412, -82.192607843137253 28.8412, -81.33389215686276 28.8412, -80.475176470588238 28.8412, -79.61646078431373 28.8412, -78.757745098039223 28.8412, -77.8990294117647 28.8412, -77.0403137254902 28.8412, -76.181598039215686 28.8412, -75.322882352941178 28.8412, -74.464166666666671 28.8412, -73.605450980392163 28.8412, -72.746735294117656 28.8412, -71.888019607843134 28.8412, -71.029303921568626 28.8412, -70.170588235294119 28.8412, -69.3118725490196 28.8412, -68.4531568627451 28.8412, -67.594441176470582 28.8412, -66.735725490196089 28.8412, -65.877009803921567 28.8412, -65.018294117647059 28.8412, -64.159578431372552 28.8412, -63.300862745098044 28.8412, -62.442147058823537 28.8412, -61.583431372549029 28.8412, -60.724715686274507 28.8412, -59.866 28.8412, -59.866 56.1484, -60.74189 56.148399999999981, -61.61778000000001 56.148399999999981, -62.493670000000009 56.148399999999981, -63.369560000000007 56.148399999999981, -64.245449999999991 56.148399999999981, -65.12134 56.148399999999981, -65.99723 56.148399999999981, -66.87312 56.148399999999981, -67.74901 56.148399999999981, -68.624900000000011 56.148399999999981, -69.50079 56.148399999999981, -70.37668 56.148399999999981, -71.252569999999992 56.148399999999981, -72.12846 56.148399999999981, -73.00435 56.148399999999981, -73.88024 56.148399999999981, -74.75613 56.148399999999981, -75.632020000000011 56.148399999999981, -76.50791000000001 56.148399999999981, -77.383800000000008 56.148399999999981, -78.25969 56.148399999999981, -79.13558 56.148399999999981, -80.01147 56.148399999999981, -80.88736 56.148399999999981, -81.76325 56.148399999999981, -82.63914 56.148399999999981, -83.51503 56.148399999999981, -84.39092 56.148399999999981, -85.266809999999992 56.148399999999981, -86.142699999999991 56.148399999999981, -87.018589999999989 56.148399999999981, -87.89448 56.148399999999981, -88.770370000000014 56.148399999999981, -89.646260000000012 56.148399999999981, -90.522150000000011 56.148399999999981, -91.398040000000009 56.148399999999981, -92.27393 56.148399999999981, -93.14982 56.148399999999981, -94.02571 56.148399999999981, -94.9016 56.148399999999981, -95.77749 56.148399999999981, -96.65338 56.148399999999981, -97.52927 56.148399999999981, -98.40516 56.148399999999981, -99.281050000000022 56.148399999999981, -100.15694 56.148399999999981, -101.03282999999999 56.148399999999981, -101.90872 56.148399999999981, -102.78461 56.148399999999981, -103.66050000000001 56.148399999999981, -104.53639000000001 56.148399999999981, -105.41228000000001 56.148399999999981, -106.28817000000001 56.148399999999981, -107.16406 56.148399999999981, -108.03995000000002 56.148399999999981, -108.91584 56.148399999999981, -109.79173 56.148399999999981, -110.66762 56.148399999999981, -111.54351000000001 56.148399999999981, -112.4194 56.148399999999981, -113.29529000000001 56.148399999999981, -114.17117999999999 56.148399999999981, -115.04707 56.148399999999981, -115.92296000000002 56.148399999999981, -116.79885000000002 56.148399999999981, -117.67474000000001 56.148399999999981, -118.55063000000001 56.148399999999981, -119.42652000000001 56.148399999999981, -120.30241000000001 56.148399999999981, -121.17830000000001 56.148399999999981, -122.05419 56.148399999999981, -122.93008 56.148399999999981, -123.80597 56.148399999999981, -124.68186000000001 56.148399999999981, -125.55775 56.148399999999981, -126.43364000000001 56.148399999999981, -127.30953000000002 56.148399999999981, -128.18542000000002 56.148399999999981, -129.06131000000002 56.148399999999981, -129.93720000000002 56.148399999999981, -130.81309000000002 56.148399999999981, -131.68898000000002 56.148399999999981, -132.56487 56.148399999999981, -133.44076 56.148399999999981, -134.31665 56.148399999999981, -135.19254 56.148399999999981, -136.06843 56.148399999999981, -136.94432 56.148399999999981, -137.82021000000003 56.148399999999981, -138.69610000000003 56.148399999999981, -139.57199 56.148399999999981, -140.44788 56.148399999999981, -141.32377000000002 56.148399999999981, -142.19966 56.148399999999981, -143.07555000000002 56.148399999999981, -143.95144000000002 56.148399999999981, -144.82733000000002 56.148399999999981, -145.70322 56.148399999999981, -146.57911 56.148399999999981, -147.455 56.1484, -147.455 28.8412))
Lat Lng GeoPoint
36.3893 -102.796 POINT (-102.796 36.3893)
Lat Lng GeoPoint
36.3893 -102.796 POINT (-102.796 36.3893)
-- Mercator Latitude projection test
SELECT
L.Lat,
dbo.LatToMercatorProjectedLat(L.Lat) AS MercatorProjected,
dbo.MercatorProjectedToDegreesLat(
dbo.LatToMercatorProjectedLat(L.Lat)
) AS Inverse
FROM (
SELECT S.value AS Lat
FROM GENERATE_SERIES(-100, 100, 10) S -- Includes some out-of range values
) L
ORDER BY L.Lat DESC

-- Edge cases
SELECT
Lat,
dbo.LatToMercatorProjectedLat(Lat) AS MercatorProjected,
dbo.MercatorProjectedToDegreesLat(
dbo.LatToMercatorProjectedLat(Lat)
) AS Inverse
FROM (
VALUES
(89), (89.99), (89.9999), (89.999999), (89.99999999), (89.9999999999),
(90)
) V(Val)
CROSS APPLY (VALUES (V.Val), (-V.Val)) L(Lat)
ORDER BY Lat DESC


Lat MercatorProjected Inverse
100 9999 90
90 9999 90
80 139.586616733322 80
70 99.4319645239368 70
60 75.4561292902169 60
50 57.9078811363613 50
40 43.7115032132109 40
30 31.4729237309454 30
20 20.4189842298941 20
10 10.0511596566301 10
0 -6.36110936292703E-15 0
-10 -10.0511596566301 -10
-20 -20.4189842298941 -20
-30 -31.4729237309454 -30
-40 -43.7115032132109 -40
-50 -57.9078811363614 -50
-60 -75.4561292902169 -60
-70 -99.4319645239369 -70
-80 -139.586616733322 -80
-90 -9999 -90
-100 -9999 -90
Lat MercatorProjected Inverse
90.0000000000 9999 90
89.9999999999 1590.95729089409 89.9999999999
89.9999999900 1327.08783442178 89.99999999
89.9999990000 1063.23117525444 89.999999
89.9999000000 799.374358831233 89.9999
89.9900000000 535.517543086629 89.99
89.0000000000 271.659273168482 89
-89.0000000000 -271.659273168482 -89
-89.9900000000 -535.51754308649 -89.99
-89.9999000000 -799.374358826641 -89.9999
-89.9999990000 -1063.23117456981 -89.999999
-89.9999999900 -1327.08802599218 -89.99999999
-89.9999999999 -1590.94378310929 -89.9999999999
-90.0000000000 -9999 -90
-- Interpolation test
SELECT
*,
MercatorProjectedLat - LAG(MercatorProjectedLat)
OVER(PARTITION BY TestCaseId ORDER BY I)
AS MercatorProjectedDiff
FROM (
VALUES
(1, 60, 75, 0),
(2, -60, -75, 1),
(3, 60, 75, 2),
(4, -60, -75, 3),
(5, -10, 80, 4), -- 0 degree crossover
(6, -120, 150, 5) -- 180 longitude crossover (latititude is part out of range)
) V(TestCaseId, L1, L2, N)
OUTER APPLY (
SELECT
S.value AS I,
dbo.InterpolateLongitude(L1, L2, S.value, N) Long,
dbo.InterpolateLatitude(L1, L2, S.value, N, 0) EuclideanLat,
dbo.InterpolateLatitude(L1, L2, S.value, N, 1) MercatorLat
FROM GENERATE_SERIES(0, N) S
) Calc
OUTER APPLY (
SELECT
dbo.LatToMercatorProjectedLat(MercatorLat) MercatorProjectedLat
) Calc2

TestCaseId L1 L2 N I Long EuclideanLat MercatorLat MercatorProjectedLat MercatorProjectedDiff
1 60 75 0 0 null null null null null
2 -60 -75 1 0 -60 -60 -60 -75.4561292902169 null
2 -60 -75 1 1 -75 -75 -75 -116.172316454518 -40.7161871643016
3 60 75 2 0 60 60 60 75.4561292902169 null
3 60 75 2 1 67.5 67.5 68.7253182544787 95.8142228723676 20.3580935821507
3 60 75 2 2 75 75 75 116.172316454518 20.3580935821507
4 -60 -75 3 0 -60 -60 -60 -75.4561292902169 null
4 -60 -75 3 1 -65 -65 -66.1229339346435 -89.0281916783174 -13.5720623881005
4 -60 -75 3 2 -70 -70 -71.0558860215307 -102.600254066418 -13.5720623881005
4 -60 -75 3 3 -75 -75 -75 -116.172316454518 -13.5720623881006
5 -10 80 4 0 -10 -10 -10 -10.0511596566301 null
5 -10 80 4 1 12.5 12.5 26.3742706131667 27.3582844408579 37.409444097488
5 -10 80 4 2 35 35 54.2093802647503 64.7677285383459 37.409444097488
5 -10 80 4 3 57.5 57.5 70.9180538033006 102.177172635834 37.4094440974879
5 -10 80 4 4 80 80 80 139.586616733322 37.4094440974882
6 -120 150 5 0 -120 -120 -90 -9999 null
6 -120 150 5 1 -138 -66 -90 -9999 0
6 -120 150 5 2 -156 -12 -89.9999999999999 -9999 0
6 -120 150 5 3 -174 42 89.9999999999999 9999 19998
6 -120 150 5 4 168 96 90 9999 0
6 -120 150 5 5 150 150 90 9999 0
-- Mapping tolerance test
--
DECLARE @Tolerance FLOAT = 1000 -- 1000 meters (1km)
DECLARE @SRID INT = 4326 -- WGS84
DECLARE @N INT = 1000 -- Points to test per edge

SELECT
G.Polygon.STNumPoints() AS NPoints,
G2.Polygon2.STNumPoints() AS NPoints2,
G3.Polygon3.STNumPoints() AS NPoints3,
--G.Polygon.STArea() * 1e-6 AS SqKm1,
--G2.Polygon2.STArea() * 1e-6 AS SqKm2,
MD.*,
G2.Polygon2
FROM (
VALUES
(-147.45514585847684, 28.841195680455485, -59.86599816500535, 56.14838208179307),
(-134.35054327724572, 31.64106010841097, -71.77427705012154, 51.66708602548192),
(170, 28, -59, 56)
) V(Lng1, Lat1, Lng2, Lat2)
CROSS APPLY (
SELECT
CONVERT(VARCHAR, Lng1, 3) AS Lng1Text,
CONVERT(VARCHAR, Lat1, 3) AS Lat1Text,
CONVERT(VARCHAR, Lng2, 3) AS Lng2Text,
CONVERT(VARCHAR, Lat2, 3) AS Lat2Text
) T
CROSS APPLY (
SELECT CONCAT(
'POLYGON((',
Lng1Text, ' ', Lat1Text, ',',
Lng2Text, ' ', Lat1Text, ',',
Lng2Text, ' ', Lat2Text, ',',
Lng1Text, ' ', Lat2Text, ',',
Lng1Text, ' ', Lat1Text,
'))'
NPoints NPoints2 NPoints3 MaxDistance MaxDistance2 Polygon2
5 68 68 942635.398 719.908 POLYGON ((-147.45514585847684 28.841195680455485, -144.800929261705 28.841195680455471, -142.14671266493312 28.841195680455471, -139.49249606816124 28.841195680455471, -136.83827947138937 28.841195680455471, -134.18406287461752 28.841195680455471, -131.52984627784565 28.841195680455471, -128.8756296810738 28.841195680455471, -126.22141308430193 28.841195680455471, -123.56719648753008 28.841195680455471, -120.91297989075822 28.841195680455471, -118.25876329398636 28.841195680455471, -115.60454669721449 28.841195680455471, -112.95033010044263 28.841195680455471, -110.29611350367074 28.841195680455471, -107.64189690689888 28.841195680455471, -104.98768031012702 28.841195680455471, -102.33346371335517 28.841195680455471, -99.679247116583312 28.841195680455471, -97.025030519811438 28.841195680455471, -94.370813923039577 28.841195680455471, -91.7165973262677 28.841195680455471, -89.062380729495857 28.841195680455471, -86.408164132723982 28.841195680455471, -83.753947535952108 28.841195680455471, -81.099730939180262 28.841195680455471, -78.4455143424084 28.841195680455471, -75.791297745636527 28.841195680455471, -73.137081148864667 28.841195680455471, -70.4828645520928 28.841195680455471, -67.828647955320946 28.841195680455471, -65.174431358549072 28.841195680455471, -62.520214761777211 28.841195680455471, -59.865998165005351 28.841195680455485, -59.865998165005351 56.148382081793073, -62.60315903042634 56.1483820817931, -65.34031989584733 56.1483820817931, -68.0774807612683 56.1483820817931, -70.81464162668928 56.1483820817931, -73.551802492110269 56.1483820817931, -76.288963357531259 56.1483820817931, -79.026124222952234 56.1483820817931, -81.763285088373223 56.1483820817931, -84.500445953794213 56.1483820817931, -87.237606819215188 56.1483820817931, -89.974767684636163 56.1483820817931, -92.711928550057166 56.1483820817931, -95.449089415478142 56.1483820817931, -98.186250280899117 56.1483820817931, -100.92341114632011 56.1483820817931, -103.6605720117411 56.1483820817931, -106.39773287716208 56.1483820817931, -109.13489374258307 56.1483820817931, -111.87205460800405 56.1483820817931, -114.60921547342502 56.1483820817931, -117.34637633884603 56.1483820817931, -120.08353720426699 56.1483820817931, -122.82069806968798 56.1483820817931, -125.55785893510897 56.1483820817931, -128.29501980052996 56.1483820817931, -131.03218066595093 56.1483820817931, -133.76934153137191 56.1483820817931, -136.50650239679288 56.1483820817931, -139.24366326221389 56.1483820817931, -141.98082412763486 56.1483820817931, -144.71798499305586 56.1483820817931, -147.45514585847684 56.148382081793073, -147.45514585847684 28.841195680455485))
5 49 49 460612.591 799.850 POLYGON ((-134.35054327724572 31.641060108410969, -131.62983604997945 31.641060108410983, -128.9091288227132 31.641060108410983, -126.18842159544691 31.641060108410983, -123.46771436818065 31.641060108410983, -120.74700714091438 31.641060108410983, -118.0262999136481 31.641060108410983, -115.30559268638184 31.641060108410983, -112.58488545911558 31.641060108410983, -109.86417823184931 31.641060108410983, -107.14347100458305 31.641060108410983, -104.42276377731676 31.641060108410983, -101.70205655005049 31.641060108410983, -98.98134932278424 31.641060108410983, -96.260642095517966 31.641060108410983, -93.539934868251692 31.641060108410983, -90.819227640985417 31.641060108410983, -88.098520413719157 31.641060108410983, -85.377813186452883 31.641060108410983, -82.657105959186609 31.641060108410983, -79.936398731920349 31.641060108410983, -77.215691504654075 31.641060108410983, -74.4949842773878 31.641060108410983, -71.77427705012154 31.641060108410969, -71.77427705012154 51.667086025481922, -74.4949842773878 51.667086025481922, -77.215691504654089 51.667086025481922, -79.936398731920349 51.667086025481922, -82.657105959186609 51.667086025481922, -85.377813186452883 51.667086025481922, -88.098520413719143 51.667086025481922, -90.819227640985417 51.667086025481922, -93.539934868251692 51.667086025481922, -96.260642095517966 51.667086025481922, -98.98134932278424 51.667086025481922, -101.70205655005049 51.667086025481922, -104.42276377731676 51.667086025481922, -107.14347100458303 51.667086025481922, -109.86417823184931 51.667086025481922, -112.58488545911558 51.667086025481922, -115.30559268638184 51.667086025481922, -118.0262999136481 51.667086025481922, -120.74700714091438 51.667086025481922, -123.46771436818065 51.667086025481922, -126.18842159544691 51.667086025481922, -128.90912882271317 51.667086025481922, -131.62983604997945 51.667086025481922, -134.35054327724572 51.667086025481922, -134.35054327724572 31.641060108410969))
5 106 106 2670293.478 568.620 POLYGON ((170 28, 172.38181818181818 27.999999999999986, 174.76363636363635 27.999999999999986, 177.14545454545453 27.999999999999986, 179.5272727272727 27.999999999999986, -178.09090909090912 27.999999999999986, -175.70909090909095 27.999999999999986, -173.32727272727271 27.999999999999986, -170.9454545454546 27.999999999999986, -168.56363636363636 27.999999999999986, -166.18181818181819 27.999999999999986, -163.8 27.999999999999986, -161.41818181818184 27.999999999999986, -159.03636363636366 27.999999999999986, -156.65454545454543 27.999999999999986, -154.27272727272725 27.999999999999986, -151.89090909090908 27.999999999999986, -149.5090909090909 27.999999999999986, -147.12727272727273 27.999999999999986, -144.74545454545455 27.999999999999986, -142.36363636363637 27.999999999999986, -139.9818181818182 27.999999999999986, -137.60000000000002 27.999999999999986, -135.21818181818185 27.999999999999986, -132.83636363636361 27.999999999999986, -130.4545454545455 27.999999999999986, -128.07272727272726 27.999999999999986, -125.69090909090914 27.999999999999986, -123.30909090909091 27.999999999999986, -120.92727272727274 27.999999999999986, -118.54545454545456 27.999999999999986, -116.16363636363633 27.999999999999986, -113.78181818181815 27.999999999999986, -111.39999999999998 27.999999999999986, -109.0181818181818 27.999999999999986, -106.63636363636363 27.999999999999986, -104.25454545454545 27.999999999999986, -101.87272727272727 27.999999999999986, -99.4909090909091 27.999999999999986, -97.109090909090924 27.999999999999986, -94.727272727272748 27.999999999999986, -92.345454545454572 27.999999999999986, -89.96363636363634 27.999999999999986, -87.581818181818164 27.999999999999986, -85.199999999999989 27.999999999999986, -82.818181818181813 27.999999999999986, -80.436363636363637 27.999999999999986, -78.054545454545462 27.999999999999986, -75.672727272727286 27.999999999999986, -73.290909090909111 27.999999999999986, -70.909090909090935 27.999999999999986, -68.5272727272727 27.999999999999986, -66.145454545454584 27.999999999999986, -63.763636363636351 27.999999999999986, -61.381818181818232 27.999999999999986, -59 28, -59 56, -61.729166666666657 55.999999999999972, -64.458333333333343 55.999999999999972, -67.1875 55.999999999999972, -69.916666666666657 55.999999999999972, -72.645833333333343 55.999999999999972, -75.375 55.999999999999972, -78.104166666666657 55.999999999999972, -80.833333333333343 55.999999999999972, -83.5625 55.999999999999972, -86.291666666666657 55.999999999999972, -89.020833333333343 55.999999999999972, -91.75 55.999999999999972, -94.479166666666657 55.999999999999972, -97.208333333333343 55.999999999999972, -99.9375 55.999999999999972, -102.66666666666666 55.999999999999972, -105.39583333333334 55.999999999999972, -108.125 55.999999999999972, -110.85416666666666 55.999999999999972, -113.58333333333334 55.999999999999972, -116.3125 55.999999999999972, -119.04166666666667 55.999999999999972, -121.77083333333333 55.999999999999972, -124.5 55.999999999999972, -127.22916666666667 55.999999999999972, -129.95833333333331 55.999999999999972, -132.6875 55.999999999999972, -135.41666666666669 55.999999999999972, -138.14583333333331 55.999999999999972, -140.875 55.999999999999972, -143.60416666666669 55.999999999999972, -146.33333333333331 55.999999999999972, -149.0625 55.999999999999972, -151.79166666666669 55.999999999999972, -154.52083333333331 55.999999999999972, -157.25 55.999999999999972, -159.97916666666669 55.999999999999972, -162.70833333333331 55.999999999999972, -165.4375 55.999999999999972, -168.16666666666669 55.999999999999972, -170.89583333333331 55.999999999999972, -173.625 55.999999999999972, -176.35416666666669 55.999999999999972, -179.08333333333331 55.999999999999972, 178.1875 55.999999999999972, 175.45833333333331 55.999999999999972, 172.72916666666669 55.999999999999972, 170 56, 170 28))