Skip to content

Comments

Feature: Improve geospatial api surface and add additional bedrock models#42

Open
Zettersten wants to merge 3 commits intoElement84:mainfrom
Zettersten:feature/improve-geospatial-api-surface-and-add-additional-bedrock-models
Open

Feature: Improve geospatial api surface and add additional bedrock models#42
Zettersten wants to merge 3 commits intoElement84:mainfrom
Zettersten:feature/improve-geospatial-api-surface-and-add-additional-bedrock-models

Conversation

@Zettersten
Copy link

Summary

This branch adds geometry validation/area calculation utilities and expands LLM model support with Amazon Titan, Mistral AI, and Cohere models.

Total Changes: 5 files modified, +293 insertions, -2 deletions

Changes by Category

1. Geometry Module Enhancements

File: src/e84_geoai_common/geometry.py (+73 lines)

New Functions

validate_and_fix_geometry(geom: BaseGeometry) -> BaseGeometry
  • Validates and automatically fixes invalid geometries
  • Handles common geospatial issues:
    • Self-intersections
    • Duplicate vertices
    • Topological errors
  • Uses buffer(0) technique for automatic repair
  • Returns input unchanged if already valid
approximate_area_km2(g: BaseGeometry) -> float
  • Calculates approximate area in square kilometers for WGS84 geometries
  • Uses latitude-based approximation for conversion from square degrees
  • More accurate than raw degree calculations, suitable for most GeoAI use cases
  • Accuracy decreases near poles and for very large geometries

Minor Fixes

  • Fixed typo: "spead" → "sped" in performance comment

2. LLM Model Expansion

Files:

  • src/e84_geoai_common/llm/models/converse/converse.py (+30 lines)
  • src/e84_geoai_common/llm/models/converse/__init__.py (+24 lines)
  • src/e84_geoai_common/llm/models/__init__.py (+24 lines)

New Model Constants

Amazon Titan Models
TITAN_TEXT_EXPRESS = "amazon.titan-text-express-v1"
TITAN_TEXT_LITE = "amazon.titan-text-lite-v1"
TITAN_TEXT_PREMIER = "amazon.titan-text-premier-v1:0"
Mistral AI Models
MISTRAL_7B_INSTRUCT = "mistral.mistral-7b-instruct-v0:2"
MISTRAL_8X7B_INSTRUCT = "mistral.mixtral-8x7b-instruct-v0:1"
MISTRAL_LARGE = "mistral.mistral-large-2402-v1:0"
MISTRAL_LARGE_2407 = "mistral.mistral-large-2407-v1:0"
MISTRAL_SMALL = "mistral.mistral-small-2402-v1:0"
Cohere Models
COHERE_COMMAND_TEXT = "cohere.command-text-v14"
COHERE_COMMAND_LIGHT_TEXT = "cohere.command-light-text-v14"
COHERE_COMMAND_R = "cohere.command-r-v1:0"
COHERE_COMMAND_R_PLUS = "cohere.command-r-plus-v1:0"

All new models are:

  • Properly exported in __all__ declarations
  • Added to CONVERSE_BEDROCK_MODEL_IDS dictionary
  • Available through the Bedrock Converse API wrapper

3. Test Coverage

File: tests/test_geometry.py (+144 lines)

validate_and_fix_geometry() Tests

  • ✓ Valid geometries (Point, Polygon, LineString) returned unchanged
  • ✓ Self-intersecting polygons automatically fixed
  • ✓ Duplicate consecutive points handled
  • ✓ Fixed geometries are valid and maintain positive area

approximate_area_km2() Tests

  • ✓ Equator calculations (1° × 1° ≈ 12,392 km²)
  • ✓ Mid-latitude accuracy (45° latitude)
  • ✓ Small area precision (0.1° × 0.1°)
  • ✓ Irregular polygon support (triangles)
  • ✓ Northern hemisphere (-30° to +60° latitude range)
  • ✓ Southern hemisphere validation
  • ✓ All tests use 1% tolerance for floating-point accuracy

API Impact

New Public APIs

  • e84_geoai_common.geometry.validate_and_fix_geometry()
  • e84_geoai_common.geometry.approximate_area_km2()
  • 12 new LLM model constants (Titan, Mistral, Cohere families)

@element84-infra
Copy link

element84-infra commented Nov 4, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Licenses 0 0 0 0 0 issues
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@Zettersten Zettersten changed the title Feature/improve geospatial api surface and add additional bedrock models Feature: Improve geospatial api surface and add additional bedrock models Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants