.net - How can I interpolate a point along a line string using DbGeography? -


i have linestring dbgeography object , want find point along linestring given fractional value of total distance. example, if give 0.5, should midpoint of line dbgeography object point wkt (well known text).

i've tried digging through dbgeography documentation, no apparent "easy" method seems exist.

i think method similar google maps js api spherical geometry interpolate method. suggestions?

i've done before using following approach:

  1. iterate through linestring's points until find pair of adjacent points between target point must lie (the target distance either given or can computed distance fraction mention); then

  2. use dbgeography.buffer on each of 2 points, providing "remaining distance target" + "small distance padding"* first , "distance between 2 points" - "remaining distance target" + "small distance padding" second; then

  3. use dbgeography.intersection on 2 points, obtaining small polygon, not point; then

  4. convert polygon dbgeometry object , take centroid; then

  5. convert result point dbgeography object if desired.

note won't technically precise, because geometric centroid not identical geographic center. however, it's enough in case because polygon centroid taken can darn small (e.g. using 1 meter buffer distance padding).

*: distance padding provided try avoid "near misses" due rounding errors floating-point. if had infinite precision, you'd take buffers no padding , intersection give exact point you're looking for.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -