(point: [number, number], polygon: [number, number][])
| 1454 | function getMetersPerLng(latitude: number) { |
| 1455 | return 111320 * Math.cos((latitude * Math.PI) / 180); |
| 1456 | } |
| 1457 | |
| 1458 | function pointInPolygon(point: [number, number], polygon: [number, number][]) { |
| 1459 | let inside = false; |
| 1460 | for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) { |
| 1461 | const xi = polygon[i][0]; |
| 1462 | const yi = polygon[i][1]; |
| 1463 | const xj = polygon[j][0]; |
| 1464 | const yj = polygon[j][1]; |
| 1465 | const intersect = yi > point[1] !== yj > point[1] && point[0] < ((xj - xi) * (point[1] - yi)) / (yj - yi || 1e-9) + xi; |
| 1466 | if (intersect) inside = !inside; |
| 1467 | } |
| 1468 | return inside; |
| 1469 | } |
| 1470 |
no outgoing calls
no test coverage detected