I've got a weird behavior of SQL-Server regarding spatial objects here. The code from below defines a postal code area in Frankfurt, Germany as a linestring. I want to transform this to a polygon, to check if some points are liying within this area. But the resulting polygon is way bigger, than the original area of the linestring. Even stranger is, that this code works as soon as I change the datatype from geography to geometry. All the other German postal code areas can be converted to geography using this method. Is there an explanation why this one area can not?
DECLARE @geo geography;
SET @geo = geography::STGeomFromText('LINESTRING (8.6720136 50.110756800000004, 8.6730391 50.1111221, 8.6736415 50.110477100000004, 8.6735392 50.110440800000006, 8.6733426 50.110371400000005, 8.673323 50.110364800000006, 8.6732403 50.110337, 8.6731607 50.1103083, 8.6729404 50.1102288, 8.6726428 50.1101158, 8.6723155 50.110397500000005, 8.6720136 50.110756800000004)', 4326);
SELECT @geo AS geo
,@geo.STAsText() AS WKText
,replace(@geo.STAsText(), 'LINESTRING ', 'POLYGON (') + ')' AS PolyText
,geography::STGeomFromText(replace(@geo.STAsText(), 'LINESTRING ', 'POLYGON (') + ')', @geo.STSrid) AS newGeography
,geometry::STGeomFromText(replace(@geo.STAsText(), 'LINESTRING ', 'POLYGON (') + ')', @geo.STSrid) AS newGeometry;
Thanks in advance!