LINESTRING を受け取り、それを POINTS の結果セットに変換するクエリがあります。
私が理解できないのは、この結果セットの 2 つの特定の行ポイント間の距離を見つける方法です。
これは私がこれまでに持っているものです:
DECLARE @GeographyToConvert geography
SET @GeographyToConvert = geography::STGeomFromText('LINESTRING (26.6434033 -81.7097817, 26.6435367 -81.709785, 26.6435783 -81.7098033, 26.6436067 -81.709825, 26.6435883 -81.709875, 26.64356 -81.7100417, 26.6434417 -81.710125, 26.6433167 -81.7101467, 26.643195 -81.7101033, 26.6431533 -81.7099517, 26.643175 -81.7097867, 26.643165 -81.7097917, 26.6431633 -81.7097367, 26.6431583 -81.7097083)',4326);
WITH GeographyPoints(N, Point) AS
(
SELECT 1, @GeographyToConvert.STPointN(1)
UNION ALL
SELECT N + 1, @GeographyToConvert.STPointN(N + 1)
FROM GeographyPoints GP
WHERE N < @GeographyToConvert.STNumPoints()
)
SELECT N,Point.STBuffer(0.25) as point, Point.STAsText() FROM GeographyPoints
たとえば、N=10 と N=11 の距離を比較するにはどうすればよいですか?
これは私が試していたものですが、うまくいきません:
Declare @Point1 geography;
Declare @Point2 geography;
DECLARE @GeographyToConvert geography
--SET @GeometryToConvert = (select top 1 geotrack from dbo.SYNCTESTING2 where geotrack is not null);
SET @GeographyToConvert = geography::STGeomFromText('LINESTRING (26.6434033 -81.7097817, 26.6435367 -81.709785, 26.6435783 -81.7098033, 26.6436067 -81.709825, 26.6435883 -81.709875, 26.64356 -81.7100417, 26.6434417 -81.710125, 26.6433167 -81.7101467, 26.643195 -81.7101033, 26.6431533 -81.7099517, 26.643175 -81.7097867, 26.643165 -81.7097917, 26.6431633 -81.7097367, 26.6431583 -81.7097083)',4326);
WITH GeographyPoints(N, Point) AS
(
SELECT 1, @GeographyToConvert.STPointN(1)
UNION ALL
SELECT N + 1, @GeographyToConvert.STPointN(N + 1)
FROM GeographyPoints GP
WHERE N < @GeographyToConvert.STNumPoints()
)
SELECT N,Point.STBuffer(0.25) as point, Point.STAsText() FROM GeographyPoints
select @Point1 = Point FROM GeometryPoints where N = 10;
select @Point2 = Point FROM GeometryPoints where N = 11
select @Point1.STDistance(@Point2) as [Distance in Meters]