TurfsJoins pointsWithinPolygon => Need more informations
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 438
- Forks
- 117
- PR merge metrics
- No merged PRs in 30d
Description
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
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)
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at TurfJoins.pointsWithinPolygon and compare the supplied FeatureCollection construction with the method's expected polygon coordinates; inspect the Kotlin service code shown, especially filtering and coordinate order. Reproduce the empty result with the same points and polygons, and consider the issue done when the cause is identified and the method returns the expected points or the required input correction is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100