TS Error: `inside` does not accept multipolygon
charlieforward9 opened this issue · comments
As per the documentation of the inside
method
/**
* Takes a {<Point>} and a {<Polygon>} or {<MultiPolygon>} and determines if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.
*
* @name [inside](http://turfjs.org/docs/#inside)
* @param {Feature<Point>} point input point
* @param {Feature<(Polygon|MultiPolygon)>} polygon input polygon or multipolygon
* @return {Boolean} `true` if the Point is inside the Polygon; `false` if the Point is not inside the Polygon
* @example
* var pt = point([-77, 44])
* var poly = polygon([[[-81, 41], [-81, 47], [-72, 47], [-72, 41], [-81, 41]]])
*
* var isInside = turf.inside(pt, poly)
*
* //=isInside
*/
inside(
point: GeoJSON.Feature<GeoJSON.Point>,
polygon: GeoJSON.Feature<GeoJSON.Polygon>
): boolean;
It is clearly stated that the method takes a polygon OR multipolygon. However, in the definition of the method, it only includes polygon: GeoJSON.Feature<GeoJSON.Polygon>
.
This seems to be a quick fix, just including the Multipolygon type as so... polygon: GeoJSON.Feature<GeoJSON.Polygon> | GeoJSON.Feature<GeoJSON.MultiPolygon>
Is there a reason this is not included?
Additionally, the link in the doc snippet is no longer valid. It seems that the method replacing this is booleanPointInPolygon
, but I am still able to use the inside
method in my code.
I am depending on:
"@turf/turf": "^6.5.0",
"@types/turf": "^3.5.32",
turf-inside is deprecated. Use booleanPointInPolygon instead. Also pretty sure @types/turf is deprecated as well, I could be wrong but I think you are referencing an unimplemented function because of it.
Closing this for now @charlieforward9. Reopen or raise a new issue if removing @types/turf doesn't help.
Hi I am using React in TypeScript. But I am not able to access the booleanPointinPolygon method when I import @turf/turf. Is this is a current issue? I need to be able to put a Multipolygon as a parameter as well