Answer the question
In order to leave comments, you need to log in
Determining a point inside the Moscow Ring Road Yandex API?
Good afternoon, I ask for help with one function inPoly (x, y)
it incorrectly determines whether the address is inside the Moscow Ring Road, all addresses are determined as outside the Moscow Ring Road
function inPoly( x, y ){
let j = mkad_points.length - 1,
c = false; // true/false - внутри или вне полигона
for (i = 0; i < mkad_points.length; i++){
if ((((mkad_points[i][1]<=y) && (y<mkad_points[j][1])) || ((mkad_points[j][1]<=y) && (y<mkad_points[i][1]))) && (x > (mkad_points[j][0] - mkad_points[i][0]) * (y - mkad_points[i][1]) / (mkad_points[j][1] - mkad_points[i][1]) + mkad_points[i][0])) {
c = !c
}
j = i;
}
return c;
}
let mkad_points = [
[55.78000432402266,37.84172564285271],
[55.775874525970494,37.8381207618713],
[55.775626746008065,37.83979446823122],
[55.77446586811748,37.84243326983639],
..........
[55.79131399999368,37.840581150787344],
[55.78000432402266,37.84172564285271]
];
Answer the question
In order to leave comments, you need to log in
Ops, remove the question, incorrectly transmitted the coordinates of the point))
inPoly (55.718872, 37.499893) - correct
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question