You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a service that transforms data into geojson.
I have points and polygons. I want to check if the points are in the polygons. For this, I use "TurfJoins.pointsWithinPolygon()".
But when I pass my two FeatureCollections as parameters, it returns an empty list. Maybe I forgot something?
After several hours of searching, I decide to turn to you. I thank you in advance for your help. I code in Kotlin
class PointWithinPolygonService @Autowired constructor (val tblPolygonRepository: TblPolygonRepository, val pointsService: PointsService) {
fun withinPolygon(): FeatureCollection {
val polygons = tblPolygonRepository.findAll()
val points = pointsService.getPoints()
val pointsFeatureCollection = FeatureCollection
.fromFeatures(points
.filter { it.gpsLongitude != null }
.map { Feature.fromGeometry(Point.fromLngLat(BigDecimal(it.gpsLongitude!!).setScale(4, RoundingMode.CEILING).toDouble(), BigDecimal(it.gpsLatitude!!).setScale(4, RoundingMode.CEILING).toDouble()))
})
val polygonsFeatureCollection = FeatureCollection
.fromFeature(Feature
.fromGeometry(Polygon
.fromLngLats(polygons
.map {it.getListCoordinates()?.map { it -> Point.fromLngLat(it.longitude, it.latitude) } }))
)
return TurfJoins.pointsWithinPolygon(pointsFeatureCollection, polygonsFeatureCollection)
}
}
The text was updated successfully, but these errors were encountered:
Hello !
First of all, thank you for your work!
I have a service that transforms data into geojson.
I have points and polygons. I want to check if the points are in the polygons. For this, I use "TurfJoins.pointsWithinPolygon()".
But when I pass my two FeatureCollections as parameters, it returns an empty list. Maybe I forgot something?
After several hours of searching, I decide to turn to you. I thank you in advance for your help. I code in Kotlin
The text was updated successfully, but these errors were encountered: