1

I am trying to create a polygon, with inside cut out, and I have created a dozen of them no problem.
However, I cannot get the following point list to verify.

POLYGON(
(53.890253 -114.150550, 53.890810 -113.124401, 53.832739 -113.124487, 53.832533 -112.975801, 53.716218 -112.975681, 53.716245 -112.950733, 53.367006 -112.951374, 53.367022 -112.926510, 53.249564 -112.927986, 53.250591 -112.969270, 53.250594 -113.074241, 53.192440 -113.074356, 53.192351 -114.001744, 53.248514 -114.001862, 53.279625 -114.002033, 53.279612 -114.026280, 53.279612 -114.147860, 53.294027 -114.148203, 53.890253 -114.150550)
,
(53.773877 -114.001813, 53.774105 -113.998508, 53.774105 -113.917720, 53.803400 -113.917398, 53.803575 -113.661065, 53.812242 -113.660379, 53.818221 -113.652482, 53.818221 -113.620124, 53.803575 -113.620124, 53.803499 -113.347294, 53.818120 -113.347380, 53.818145 -113.345062, 53.830178 -113.334934, 53.835015 -113.335750, 53.842232 -113.324506, 53.840485 -113.321759, 53.845245 -113.314550, 53.845448 -113.309958, 53.847321 -113.309271, 53.847296 -113.305537, 53.845827 -113.306310, 53.845827 -113.304164, 53.844030 -113.306267, 53.842283 -113.310601, 53.825365 -113.310601, 53.825340 -113.322317, 53.803524 -113.322961, 53.803244 -113.124330, 53.774265 -113.124223, 53.715852 -113.124309, 53.715846 -113.098581, 53.571181 -113.098811, 53.366714 -113.098865, 53.366702 -113.074291, 53.279625 -113.074530, 53.279664 -113.098670, 53.279606 -113.220582, 53.250595 -113.220603, 53.250582 -113.488503, 53.250531 -113.499918, 53.235790 -113.499918, 53.235892 -113.561716, 53.250531 -113.561716, 53.250556 -113.598323, 53.257720 -113.598452, 53.257771 -113.610425, 53.265139 -113.610468, 53.265062 -113.927419, 53.366600 -113.927333, 53.366715 -114.001904, 53.497785 -114.001980, 53.497785 -113.959151, 53.504837 -113.959151, 53.504837 -113.945397, 53.520338 -113.945397, 53.519726 -113.885364, 53.541153 -113.885364, 53.541101 -113.845993, 53.571438 -113.846851, 53.570012 -113.885364, 53.571082 -113.916435, 53.569349 -113.959007, 53.555451 -113.959383, 53.555985 -114.002024), (53.497785 -114.001980, 53.497785 -113.959151, 53.504837 -113.959151, 53.504837 -113.945397, 53.520338 -113.945397, 53.519726 -113.885364, 53.541153 -113.885364, 53.541101 -113.845993, 53.571438 -113.846851, 53.570012 -113.885364, 53.571082 -113.916435, 53.569349 -113.959007, 53.555451 -113.959383, 53.555985 -114.002024, 53.555804 -114.038727, 53.541397 -114.038512, 53.541372 -114.050958, 53.512009 -114.050958, 53.512111 -114.026410, 53.505169 -114.026410, 53.504320 -114.001980, 53.773877 -114.001813)
)

I get the following error in SQL server

Msg 6522, Level 16, State 1, Line 22 A .NET Framework error occurred during execution of user-defined routine or aggregate "geometry": System.FormatException: 24121: The Polygon input is not valid because the start and end points of the interior ring number 1 are not the same. Each ring of a polygon must have the same start and end points. System.FormatException: at Microsoft.SqlServer.Types.GeometryValidator.ValidatePolygonRing(Int32 iRing, Int32 cPoints, Double firstX, Double firstY, Double lastX, Double lastY) at

I can verify that it is the second polygon list in the object that is the problem. But you can see that 53.773877 -114.001813 is both the starting and ending points for that list.

For reference, these are lat long points.

Can someone help me figure out why this polygon object won't verify

4
  • sounds like a ring orientation issue stackoverflow.com/questions/48305408/…
    – Mapperz
    Apr 28, 2021 at 21:02
  • Geometry stores coordinates {X,Y}, so flip your vertex order ({lon,lat}).
    – Vince
    Apr 28, 2021 at 21:03
  • thanks, I cannot flip co-ordinates, it comes from another source that way and may change so it can't be manually done each time.
    – J King
    Apr 28, 2021 at 21:10
  • @Mapperz - I can see the link you sent, but because the object won't verify, I cant even tell if that case is relevant
    – J King
    Apr 28, 2021 at 21:11

2 Answers 2

3

Reindenting, the issue is obvious e.g

POLYGON(
(53.890253 -114.150550, 53.890810 -113.124401, 53.832739 -113.124487, 53.832533 -112.975801, 53.716218 -112.975681, 53.716245 -112.950733, 53.367006 -112.951374, 53.367022 -112.926510, 53.249564 -112.927986, 53.250591 -112.969270, 53.250594 -113.074241, 53.192440 -113.074356, 53.192351 -114.001744, 53.248514 -114.001862, 53.279625 -114.002033, 53.279612 -114.026280, 53.279612 -114.147860, 53.294027 -114.148203, 53.890253 -114.150550)
,
(53.773877 -114.001813, 53.774105 -113.998508, 53.774105 -113.917720, 53.803400 -113.917398, 53.803575 -113.661065, 53.812242 -113.660379, 53.818221 -113.652482, 53.818221 -113.620124, 53.803575 -113.620124, 53.803499 -113.347294, 53.818120 -113.347380, 53.818145 -113.345062, 53.830178 -113.334934, 53.835015 -113.335750, 53.842232 -113.324506, 53.840485 -113.321759, 53.845245 -113.314550, 53.845448 -113.309958, 53.847321 -113.309271, 53.847296 -113.305537, 53.845827 -113.306310, 53.845827 -113.304164, 53.844030 -113.306267, 53.842283 -113.310601, 53.825365 -113.310601, 53.825340 -113.322317, 53.803524 -113.322961, 53.803244 -113.124330, 53.774265 -113.124223, 53.715852 -113.124309, 53.715846 -113.098581, 53.571181 -113.098811, 53.366714 -113.098865, 53.366702 -113.074291, 53.279625 -113.074530, 53.279664 -113.098670, 53.279606 -113.220582, 53.250595 -113.220603, 53.250582 -113.488503, 53.250531 -113.499918, 53.235790 -113.499918, 53.235892 -113.561716, 53.250531 -113.561716, 53.250556 -113.598323, 53.257720 -113.598452, 53.257771 -113.610425, 53.265139 -113.610468, 53.265062 -113.927419, 53.366600 -113.927333, 53.366715 -114.001904, 53.497785 -114.001980, 53.497785 -113.959151, 53.504837 -113.959151, 53.504837 -113.945397, 53.520338 -113.945397, 53.519726 -113.885364, 53.541153 -113.885364, 53.541101 -113.845993, 53.571438 -113.846851, 53.570012 -113.885364, 53.571082 -113.916435, 53.569349 -113.959007, 53.555451 -113.959383, 53.555985 -114.002024)
,
(53.497785 -114.001980, 53.497785 -113.959151, 53.504837 -113.959151, 53.504837 -113.945397, 53.520338 -113.945397, 53.519726 -113.885364, 53.541153 -113.885364, 53.541101 -113.845993, 53.571438 -113.846851, 53.570012 -113.885364, 53.571082 -113.916435, 53.569349 -113.959007, 53.555451 -113.959383, 53.555985 -114.002024, 53.555804 -114.038727, 53.541397 -114.038512, 53.541372 -114.050958, 53.512009 -114.050958, 53.512111 -114.026410, 53.505169 -114.026410, 53.504320 -114.001980, 53.773877 -114.001813)
)

Start and end coordinates are fine for element 1 but wrong for the 2 other elements: 53.773877 -114.001813 different from 53.555985 -114.002024 and 53.497785 -114.001980 different from 53.773877 -114.001813

1
  • nice catch, this data was generated from a JavaScript front end, I didn't catch that there were three polygons, I falsely assumed only two.
    – J King
    Apr 29, 2021 at 0:49
2

You can visualize the geometry despite the error by editing the WKT. Just change POLYGON into MULTILINESTRING.

Part 1 enter image description here

Part 2 enter image description here

Part 3 enter image description here

Not-closing rings are not the only problem. It is impossible to express this geometry as a single polygon or multipolygon. It could be geometry collection where rings 1 and 2 make a polygon with a hole and ring 3 is a separate polygon.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.