Skip to content

Add geo suspect detection API, UI download flow, and tests#46

Merged
rad1092 merged 1 commit intomainfrom
codex/implement-geo-tools-and-api-for-suspect-detection
Feb 15, 2026
Merged

Add geo suspect detection API, UI download flow, and tests#46
rad1092 merged 1 commit intomainfrom
codex/implement-geo-tools-and-api-for-suspect-detection

Conversation

@rad1092
Copy link
Copy Markdown
Owner

@rad1092 rad1092 commented Feb 15, 2026

Motivation

  • Provide a lightweight, map-independent workflow to detect and extract suspicious geo records from CSV/Excel/document inputs.
  • Clearly separate suspect categories: missing/non-numeric coords, out-of-range coords, and large consecutive movement (distance threshold).
  • Produce stable tabular artifacts (CSV/JSON) and optional GeoJSON so downstream tooling or manual review can consume results without map/tile dependencies.

Description

  • Add bitnet_tools/geo.py implementing validate_lat_lon(lat, lon), haversine_km(...), and flag_geo_suspects(rows, lat_col, lon_col, threshold_km=25) and exposing reason constants (MISSING_OR_NON_NUMERIC, OUT_OF_RANGE, DISTANCE_THRESHOLD_EXCEEDED).
  • Extend bitnet_tools/web.py with helper functions (_rows_from_csv_text, _build_geojson_feature_collection, _write_geo_suspect_artifacts) and a new endpoint POST /api/geo/suspects that accepts column names and threshold and returns counts, inline rows (optional), and artifact paths (CSV/JSON, optional GeoJSON).
  • Ensure artifact outputs always include is_suspect, suspect_reason, and distance_km columns and persist artifacts under .bitnet_cache/geo_suspects/....
  • Add a minimal UI section in bitnet_tools/ui/index.html and wire frontend logic in bitnet_tools/ui/app.js to collect parameters and trigger the /api/geo/suspects call, showing a download/artifact summary without rendering any map tiles.
  • Add tests: tests/test_geo.py verifies range checks, Haversine scale, missing/non-numeric handling and distance-threshold behavior; tests/test_web.py extended with API success/error contract checks for /api/geo/suspects.

Testing

  • Ran unit/integration tests with pytest -q tests/test_geo.py tests/test_web.py tests/test_ui_contract.py and all tests passed (20 passed).
  • The new API and UI flow are covered by the added tests in tests/test_geo.py and the extended assertions in tests/test_web.py.

Codex Task

@rad1092 rad1092 merged commit 5b3c3ab into main Feb 15, 2026
4 checks passed
@rad1092 rad1092 deleted the codex/implement-geo-tools-and-api-for-suspect-detection branch February 15, 2026 05:19
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea72635bcb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bitnet_tools/web.py
if route == '/api/geo/suspects':
lat_col = str(payload.get('lat_col', '')).strip()
lon_col = str(payload.get('lon_col', '')).strip()
threshold_km = float(payload.get('threshold_km', 25) or 25)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve zero threshold values in geo suspects API

The threshold parsing uses float(payload.get('threshold_km', 25) or 25), which treats a valid numeric 0 as falsy and silently replaces it with 25. This changes user-requested behavior: when the client sends threshold_km: 0 (the UI allows this with min="0"), distances below 25 km are not flagged even though the request asked for a zero-distance cutoff.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant