[postgis-devel] SQL Server Denali ShortestLineTo

Paragon Corporation lr at pcorp.us
Wed Dec 8 08:17:49 PST 2010


Nicklas,

Did you see this. 

SQL Server has released their own ShortestLine function  in their upcoming
2011 release except they put a To at the end.

The answers in PostGIS  are pretty close to theirs.  It's always nice when
the two systems I use most agree in output. Now I have another system to
cross compare to.

http://blogs.msdn.com/b/edkatibah/archive/2010/11/19/a-short-discussion-on-t
he-shortestlineto-method.aspx 

I see they also enjoy flaunting their new curved support.  I wonder if they
have an ST_LongestLine or any kind of 3D support.  I suspect they don't.
I'm hoping to install Denali sometime soon but  maybe not until the CTP2
So I can check it out.


-- PostGIS: 
SELECT 
	ST_AsText(ST_ShortestLine(ST_CurveToLine('CIRCULARSTRING(1.5 1, 1.6
1.1, 1.5 2)'::geometry,150),
			'POLYGON((2.2 1, 3.2 1, 3.2 2, 2.2 2, 2.2
1))'::geometry));
-- Result: LINESTRING(1.74030584077424 1.50290349279118,2.2
1.50290349279118)


-- SQL Server Denali: 
DECLARE @c GEOMETRY = 'CIRCULARSTRING(1.5 1, 1.6 1.1, 1.5 2)';
DECLARE @g GEOMETRY = 'POLYGON((2.2 1, 3.2 1, 3.2 2, 2.2 2, 2.2 1))';
SELECT @c.ShortestLineTo(@g).ToString(); 
--Result: LINESTRING (1.740312423743285 1.5, 2.2 1.5)


-- PostGIS:
SELECT ST_AsText(ST_ShortestLine('POINT(175346.325596772
202579.692494631)'::geometry,
'POLYGON((175373.37654079497 202663.47566268593, 175309.02370874584
202626.29556666315, 175328.32617276162 202595.99009463936,
175328.33046075702 202595.99284664169, 175335.22780476511 202600.4390546456,
175335.27100476623 202600.37697464228, 175335.33071676642
202600.29115064442, 175342.50012476742 202604.9433106482, 175343.06434877217
202605.3093906492, 175355.01686077565 202585.1888146326, 175355.22690878063
202584.8352146335, 175346.57487677038 202579.83649462834, 175350.90825277567
202572.54171062633, 175351.08706877381 202572.240654625, 175346.8919967711
202569.81697462127, 175345.81129277498 202569.19259062409,
175345.50646077097 202569.01646262407, 175352.43746877462
202558.13460661471, 175378.08418879658 202517.86843058839,
175378.47298879176 202517.2579985857, 175387.97513280064 202521.08609458804,
175392.46217280626 202523.75739059225, 175415.91702082008
202537.72103860229, 175429.48124483228 202545.79636660591,
175439.01698883623 202552.97799861059, 175438.9791008383 202553.04180661216,
175425.85634882748 202575.13236662746, 175373.37654079497
202663.47566268593), (175387.31574080139 202542.21063860506,
175387.92713280022 202542.56340660527,175385.82249280065 202546.25569460541,
175392.09526080638 202549.76961461082, 175391.75484480709
202550.37588660792, 175400.52566081286 202555.39905461296,
175402.95503681153 202551.16513460875, 175403.52956481278
202551.49115061015, 175408.33698881418 202543.07399860397, 175392.2850208059
202533.85300659761, 175387.31574080139 202542.21063860506))'::geometry))

-- Result: LINESTRING(175346.325596772 202579.692494631,175346.57487677
202579.836494628)

-- SQL Server Denali:
DECLARE @h GEOMETRY = 'POINT(175346.325596772 202579.692494631)';

DECLARE @g GEOMETRY = 'POLYGON((175373.37654079497 202663.47566268593,
175309.02370874584 202626.29556666315, 175328.32617276162
202595.99009463936, 175328.33046075702 202595.99284664169,
175335.22780476511 202600.4390546456, 175335.27100476623 202600.37697464228,
175335.33071676642 202600.29115064442, 175342.50012476742 202604.9433106482,
175343.06434877217 202605.3093906492, 175355.01686077565 202585.1888146326,
175355.22690878063 202584.8352146335, 175346.57487677038 202579.83649462834,
175350.90825277567 202572.54171062633, 175351.08706877381 202572.240654625,
175346.8919967711 202569.81697462127, 175345.81129277498 202569.19259062409,
175345.50646077097 202569.01646262407, 175352.43746877462
202558.13460661471, 175378.08418879658 202517.86843058839,
175378.47298879176 202517.2579985857, 175387.97513280064 202521.08609458804,
175392.46217280626 202523.75739059225, 175415.91702082008
202537.72103860229, 175429.48124483228 202545.79636660591,
175439.01698883623 202552.97799861059, 175438.9791008383 202553.04180661216,
175425.85634882748 202575.13236662746, 175373.37654079497
202663.47566268593), (175387.31574080139 202542.21063860506,
175387.92713280022 202542.56340660527,175385.82249280065 202546.25569460541,
175392.09526080638 202549.76961461082, 175391.75484480709
202550.37588660792, 175400.52566081286 202555.39905461296,
175402.95503681153 202551.16513460875, 175403.52956481278
202551.49115061015, 175408.33698881418 202543.07399860397, 175392.2850208059
202533.85300659761, 175387.31574080139 202542.21063860506))';

DECLARE @sl GEOMETRY = @h.ShortestLineTo(@g);

SELECT @sl.STAsText();
--Result: LINESTRING(175346.325596772 202579.692494631, 175346.57487677038
202579.83649462834) 

Thanks,
Regina





More information about the postgis-devel mailing list