简体   繁体   中英

How to extend the polygon to a certain distance?

How to extend the polygon to a certain distance? I create a convex hull around the multipoint. But I need to extend the range to several kilometers. At least in theory.

http://img.radiokot.ru/files/21274/1oykzc5pez.png

Build outer bisector vector in every vertex (as sum of normalized normals na and nb of two neighbor edges) and normalize it

在此处输入图片说明

bis = na + nb
bis = bis / Length(bis)

Make length of bisector to provide needed distance as

 l = d / Cos(fi/2)

where d is offset, and fi is angle between vectors na and nb .

 fi = atan2(crossproduct(na,nb), dotproduct(na,nb))

or without trigonometric functions:

l = d / Sqrt(1 + dotproduct(na,nb))

And find offset polygon vertex:

 P' = P + l * bis

Assuming that you're able to get a convex hull (which maybe you're using ConvexHullAggregate !), STBuffer() should do what you want.

declare @hull geography = «your value here»;
select @hull.STBuffer(10000); -- 10 km buffer

NB: the 10000 may need to change based on the SRID that you're using since SRIDs have units of distance baked into them inherently. But SRID 4326 is what's used in the docs most often and the native unit for that SRID is meters. So 10 km → 10000 m.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM