这些文件指出:
返回一个对象,该对象表示一个地理实例或另一个地理实例中的所有点,但不表示位于两个实例中的那些点。
给予@g3
LINESTRING (-122.348 47.649, -119.119263 46.18363401)@g2
POINT (-119.119263 46.18363401)为什么@g3.STSymDifference()是.STAsText()
LINESTRING (-122.348 47.649, -119.119263 46.18363401)一个点都没有(-122.348 47.649)?
点-119.119263 46.18363401在@g2和@g3中,不排除。
发布于 2018-12-24 14:09:29
点-119.119263 46.18363401在@g2和@g3中,不排除。
四舍五入。坐标系具有有限的精度,所以当您从一条线中移除端点时,新的端点应该是什么?
没有很好的答案。这条线的长度不会改变。
如果你试图确定一个点是否在一条线上,你就会得到类似的精确性和四舍五入的奇异性。
例如
declare @g3 geography = geography::Parse('LINESTRING (-122.348 47.649, -119.119263 46.18363401)')
declare @g2 geography = @g3.STIntersection(geography::Parse('LINESTRING (-120.5 48, -120.5 46)'))
select @g3.STIntersection(@g2).STAsText()输出
GEOMETRYCOLLECTION EMPTY发布于 2018-12-24 14:32:40
通过将行字符串转换为一系列点并将点与该系列进行比较,我找到了示例的解决方案。我希望这能帮上忙。
DECLARE @LinestringGeometry GEOMETRY;
DECLARE @PointGeometry GEOMETRY;
SET @LinestringGeometry = GEOMETRY::STGeomFromText('LINESTRING (-122.348 47.649, -119.119263 46.18363401)', 4269);
SET @PointGeometry = GEOMETRY::STGeomFromText('POINT (-119.119263 46.18363401)', 4269);
--Get series of points within the linestring
WITH GeometryPoints(N, Point) AS
(
SELECT 1, @LinestringGeometry.STPointN(1)
UNION ALL
SELECT N + 1, @LinestringGeometry.STPointN(N + 1)
FROM GeometryPoints GP
WHERE N < @LinestringGeometry.STNumPoints()
)
--Compare the points
SELECT Point.STAsText() AS 'UniquePoint'
FROM GeometryPoints
WHERE Point.STEquals(@PointGeometry) = 0https://stackoverflow.com/questions/53912469
复制相似问题