当我有一个基本形状时,几何和地理形成相同的形状:
DECLARE @shapegeo geography = geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326);
DECLARE @shapegeom geometry = geometry::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326);
SELECT @shapegeo;
SELECT @shapegeom;
当我有一个更复杂的形状,它是从多边形工具生成的:https://arthur-e.github.io/Wicket/sandbox-gmaps3.html
几何图形是正确的形状,但地理位置是FULLGLOBE - 形状:
DECLARE @ovalgeo geography = geography::STGeomFromText('POLYGON((-83.221435546875 40.119237128467624,-83.1280517578125 40.253525039452626,-82.9302978515625 40.29543548046365,-82.7490234375 40.257717252394976,-82.6776123046875 40.19900263907047,-82.5897216796875 40.08982621705029,-82.5732421875 39.9383693235635,-82.63916015625 39.828774835536194,-82.935791015625 39.74435221539322,-83.21044921875 39.80767889257094,-83.287353515625 39.87516311271822,-83.3148193359375 39.98468347687377,-83.221435546875 40.119237128467624))', 4326).MakeValid();
DECLARE @ovalgeom geometry = geometry::STGeomFromText('POLYGON((-83.221435546875 40.119237128467624,-83.1280517578125 40.253525039452626,-82.9302978515625 40.29543548046365,-82.7490234375 40.257717252394976,-82.6776123046875 40.19900263907047,-82.5897216796875 40.08982621705029,-82.5732421875 39.9383693235635,-82.63916015625 39.828774835536194,-82.935791015625 39.74435221539322,-83.21044921875 39.80767889257094,-83.287353515625 39.87516311271822,-83.3148193359375 39.98468347687377,-83.221435546875 40.119237128467624))', 4326).MakeValid();
SELECT @ovalgeo;
SELECT @ovalgeom;
DECLARE @squaregeo geography = geography::STGeomFromText('POLYGON((-121.025390625 48.73717255965176,-94.04296875 48.73717255965176,-94.04296875 28.9060038852843,-121.025390625 28.9060038852843,-121.025390625 48.73717255965176))', 4326).MakeValid();
DECLARE @squaregeom geometry = geometry::STGeomFromText('POLYGON((-121.025390625 48.73717255965176,-94.04296875 48.73717255965176,-94.04296875 28.9060038852843,-121.025390625 28.9060038852843,-121.025390625 48.73717255965176))', 4326).MakeValid();
SELECT @squaregeo;
SELECT @squaregeom;
答案 0 :(得分:1)
你有一个响铃问题。对于地理多边形,指定点的顺序很重要。也就是说,给定A,B,C和D点,POLYGON(A, B, C, D, A)
与POLYGON(A, D, C, B, A)
不同。它们的关联在于它们两者的结合将成为全球。换句话说,如果这两个多边形中的一个是中央公园,那么另一个将是整个地球上都有一个中央公园形状的洞。
那么你能做些什么呢?如果你发现你有一个"全球大部分地区"大小的形状,你可以调用ReorientObject()
方法。我用来确定是否需要这样做的启发式方法是在对象上调用EnvelopeAngle()
。如果那个太大(我的门槛是90度),我会重新调整对象的方向,这可能是正确的。