Answer the question
In order to leave comments, you need to log in
How to take points on a polyline through equal segments?
There is a polyline, I need to draw n objects on it (for example, markers). It is not known in advance how many markers, but it is known that it is necessary to fit them on the line through equal segments. I have no idea, who can help?
Answer the question
In order to leave comments, you need to log in
postgis has a special feature. But if you need a browser without a database, you will have to look for ready-made analogues or implement it yourself.
In general, the task is not difficult. Each polyline segment has a certain length.
Your task is to measure a certain distance from the beginning of the polyline and find a point at this distance on the desired segment.
Subtract entire segments of the polyline one by one from the distance, while there is such an opportunity. So you will find the segment on which the desired point will be. Further, this segment needs to be divided into proportions:
(x2-x)/(x2-x1)=(y2-y)/(y2-y1)
d^2=x^2+y^2
Here is a system of equations, where
x1, x2 , y1, y2 - ordinates of polyline segment ends.
d is the remainder of the distance from which all whole segments have been subtracted,
x, y - coordinates of the desired point
it is necessary to calculate the length from summing the distance between the points (segments), if the sum is greater than then we find the point in the last segment. Simple math. I didn’t find such solutions in the documentation for the geometry module, so I write with pens (I’m too lazy to write code here, I did something similar for an electric grid company).
swap means could not create, and why, it remains to be guessed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question