I need to convert/display leaflet coordinates from decimal to integer values in multiple objects in order to use it in turfjs mehod:
https://www.npmjs.com/package/@turf/boolean-point-in-polygon
coord = geojsonFeature.geometry.coordinates:
{type: "D", designator: "EPD53A", availabilities: Array(1), info: Array(2), geometry: {…}}
{type: "TRA", designator: "EPTR105", availabilities: Array(1), info: Array(2), geometry: {…}}
{type: "D", designator: "UMD192", availabilities: Array(1), info: Array(2), geometry: {…}}
(...)
geometry:
type: "Polygon"
coordinates: Array(1)
0: Array(8):
0: (2) [16.845, 54.587777778]
1: (2) [16.647777778, 54.515]
2: (2) [16.545277778, 54.543611111]
(...)
Is there any simple way to do it? (angular/typescript)
I'm trying to check if clicked point is laying on two or more layer polygons. Do I really need to convert this values to integer?
var pt2 = turf.point([22.65380859375, 49.710272582105695]);
var multiPoly = turf.multiPolygon([[[
[22.828611111111112, 49.68472222222222],
[23.065833333333334, 49.9],
[23.20861111111111, 49.843333333333334],
[22.98611111111111, 49.650555555555556],
[22.828611111111112, 49.68472222222222],
[22.828611111111112, 49.68472222222222],
[22.828611111111112, 49.68472222222222]
]]]);
console.log("test-turf",turf.booleanPointInPolygon(pt2, multiPoly));
It returns false
All TurfJS methods accept (well-formed) GeoJSON as input. There is no need to use integer values for the coordinates.
It returns false
Your call to boolanPointInPolygon
returns false because that point is outside that polygon: