mapbox / mapbox/mapbox-java

TurfsJoins pointsWithinPolygon => Need more informations

未关闭
#1,311 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Java
星标
438
派生
117
PR 合并指标
30 天内没有已合并 PR

描述

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)
    }
}

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 TurfJoins.pointsWithinPolygon 入手,将提供的 FeatureCollection 构造与该方法所期望的多边形坐标进行比较;检查所示的 Kotlin 服务代码,尤其是过滤和坐标顺序。使用相同的点和多边形重现空结果,并在确定原因且该方法返回预期的点,或记录所需的输入修正后,视为该 issue 已完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
java, kotlin
领域
backend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。