Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Detect whether a coordinate or zone intersects with water layer

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

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
40/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
dart, flutter
领域
api, mobile-dev

调研方向

从 issue 正文中的 _zoneContainsWater 以及其中展示的 queryRenderedFeatures、pixelForCoordinate、RenderedQueryGeometry.fromScreenBox 和 RenderedQueryOptions 调用开始。验证返回的 layer 和 feature 如何表示水,以及 bounding-box 查询是否符合坐标或区域相交语义。完成的标准是水域返回 true,纯陆地区域返回 false,并按所示方式处理查询错误。

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

描述

Currently, I am trying to determine whether a coordinate lies on water by querying the rendered features of the water layer using queryRenderedFeatures.
` Future _zoneContainsWater(
double centerLat,
double centerLon,
double radiusNM,
) async {
if (mapboxMap == null) return false;

try {
  // Calculate Bounding Box coordinates for the zone (NW and SE corners)
  final dLat = radiusNM / 60.0;
  final latCos = cos(centerLat * pi / 180.0);
  final dLon = latCos.abs() < 0.0001 ? dLat : dLat / latCos;

  final nLat = centerLat + dLat;
  final sLat = centerLat - dLat;
  final wLon = centerLon - dLon;
  final eLon = centerLon + dLon;

  // Convert those geographic corners to screen pixels
  final nw = await mapboxMap!.pixelForCoordinate(mapBox.Point(coordinates: mapBox.Position(wLon, nLat)));
  final se = await mapboxMap!.pixelForCoordinate(mapBox.Point(coordinates: mapBox.Position(eLon, sLat)));

  // Perform a query across the entire zone's bounding box
  final result = await mapboxMap!.queryRenderedFeatures(
    mapBox.RenderedQueryGeometry.fromScreenBox(mapBox.ScreenBox(
      min: mapBox.ScreenCoordinate(x: min(nw.x, se.x), y: min(nw.y, se.y)),
      max: mapBox.ScreenCoordinate(x: max(nw.x, se.x), y: max(nw.y, se.y)),
    )),
    mapBox.RenderedQueryOptions(
      // Ensure we target our manually added 'water' layer + any style-detected ones
      layerIds: ["water", ..._waterLayerIds],
    ),
  );

  developer.log("Zone query found ${result.length} features in targeted water layers");

  for (var queried in result) {
    if (queried != null) {
      final layers = queried.layers;
      final featureMap = queried.queriedFeature.feature;
      final properties = featureMap["properties"] as Map?;

      print("Water Feature Match: $layers, properties: $properties");

      bool layerMatch = layers.any((layer) =>
          layer != null &&
          (layer.toLowerCase().contains("water") || layer.toLowerCase().contains("ocean") || layer.toLowerCase().contains("lake") || layer.toLowerCase().contains("sea")));

      bool propertyMatch = properties != null && (properties["class"] == "water" || properties["type"] == "water" || properties["water"] == "true");

      if (layerMatch || propertyMatch) {
        developer.log("WATER CONFIRMED inside Zone Box!");
        return true;
      }
    }
  }
} catch (e) {
  developer.log("Error querying zone box for water: $e");
}

return false; // No water features found within the 2*Radius area

}`

主要语言
Dart
星标
380
派生
204
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

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

mapbox/mapbox-maps-flutter 的其他 Issue

查看 mapbox/mapbox-maps-flutter 的全部 Issue

相似的 Issue

更多 Dart Issue

把新 issue 发到你的邮箱

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