Skip to content

Conversation

@mattpodwysocki
Copy link
Contributor

@mattpodwysocki mattpodwysocki commented Jan 8, 2026

Summary

Adds a comprehensive offline GeoJSON validation tool that checks GeoJSON objects for correctness without requiring API access.

Features

  • ✅ Validates all GeoJSON types:

    • Feature, FeatureCollection
    • Point, MultiPoint
    • LineString, MultiLineString
    • Polygon, MultiPolygon
    • GeometryCollection
  • ✅ Comprehensive validation checks:

    • GeoJSON type validity
    • Required properties (type, coordinates, geometry, features)
    • Coordinate array structure
    • Position validity (lon/lat ranges)
    • Polygon ring closure
    • Minimum position requirements
  • ✅ Structured validation results:

    • valid boolean flag
    • errors array (critical issues)
    • warnings array (non-critical issues)
    • info array (informational messages)
    • statistics object (type, feature count, geometry types, bbox)
  • ✅ Developer-friendly:

    • Detailed error messages with JSON paths
    • Actionable suggestions for fixing issues
    • Accepts both JSON strings and objects as input

Implementation Details

  • Architecture: Extends BaseTool (offline, no HttpRequest dependency)
  • Testing: 28 comprehensive test cases covering:
    • Valid GeoJSON of all types
    • Invalid structure detection
    • Coordinate validation
    • Error handling
    • Statistics calculation
  • Documentation: Added to README with examples and usage patterns

Test Results

All 398 tests pass ✅

Example Usage

{
  "geojson": {
    "type": "Feature",
    "geometry": {
      "type": "Point",
      "coordinates": [102.0, 0.5]
    },
    "properties": {
      "name": "Test Point"
    }
  }
}

Returns:

{
  "valid": true,
  "errors": [],
  "warnings": [],
  "info": [],
  "statistics": {
    "type": "Feature",
    "featureCount": 1,
    "geometryTypes": ["Point"],
    "bbox": [102.0, 0.5, 102.0, 0.5]
  }
}

Related

Part of a series of offline validation tools being added to the server. This is the second tool after validate_style_tool (#49).

Test Plan

Test 1: Valid Point Feature ✅

Can you validate this GeoJSON?

  {
    "type": "Feature",
    "geometry": {
      "type": "Point",
      "coordinates": [-122.4194, 37.7749]
    },
    "properties": {
      "name": "San Francisco"
    }
  }

Expected: Valid, returns statistics (1 feature, Point geometry, bbox)

Screenshot 2026-01-09 at 12 28 41

Test 2: Valid Polygon ✅

Validate this polygon:

  {
    "type": "Polygon",
    "coordinates": [
      [
        [-122.4, 37.8],
        [-122.4, 37.7],
        [-122.3, 37.7],
        [-122.3, 37.8],
        [-122.4, 37.8]
      ]
    ]
  }

Expected: Valid, polygon ring is properly closed (first and last coordinates match)

Screenshot 2026-01-09 at 12 30 26

Test 3: Invalid Coordinates (Out of Range) ❌

Check if this GeoJSON is valid:

  {
    "type": "Point",
    "coordinates": [200.0, 100.0]
  }

Expected:

  • Invalid
  • Error: Longitude out of range (200.0 should be -180 to 180)
  • Error: Latitude out of range (100.0 should be -90 to 90)
Screenshot 2026-01-09 at 12 34 08

Test 4: Unclosed Polygon ❌

Is this polygon valid?

  {
    "type": "Polygon",
    "coordinates": [
      [
        [0, 0],
        [10, 0],
        [10, 10],
        [0, 10]
      ]
    ]
  }

Expected:

  • Invalid
  • Error: Polygon ring not closed (first and last coordinates must match)
  • Suggestion: Add closing coordinate [0, 0]
Screenshot 2026-01-09 at 12 35 04

Test 5: Valid FeatureCollection ✅

Validate this collection:

  {
    "type": "FeatureCollection",
    "features": [
      {
        "type": "Feature",
        "geometry": {
          "type": "Point",
          "coordinates": [-73.9857, 40.7484]
        },
        "properties": {"name": "NYC"}
      },
      {
        "type": "Feature",
        "geometry": {
          "type": "Point",
          "coordinates": [-118.2437, 34.0522]
        },
        "properties": {"name": "LA"}
      }
    ]
  }

Expected:

  • Valid
  • Statistics: 2 features, all Point geometries
  • Bounding box covering both NYC and LA
Screenshot 2026-01-09 at 12 40 28

Test 6: Wrong Coordinate Order (Common Mistake) ⚠️

Check this point:

  {
    "type": "Point",
    "coordinates": [37.7749, -122.4194]
  }

Expected:

  • Technically valid (coordinates are within range)
  • But this is lat,lon order (incorrect) instead of lon,lat
  • The tool validates ranges but can't detect coordinate order issues
  • Good test to see if Claude mentions this common mistake
Screenshot 2026-01-09 at 12 42 22

This commit adds a comprehensive GeoJSON validation tool that performs
offline validation of GeoJSON objects without requiring API access.

Features:
- Validates all GeoJSON types (Feature, FeatureCollection, Point, LineString,
  Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection)
- Checks required properties (type, coordinates, geometry, features)
- Validates coordinate array structure and position validity
- Warns about longitude/latitude out of range
- Detects unclosed polygon rings
- Calculates statistics (type, feature count, geometry types, bounding box)
- Returns structured errors, warnings, and info messages with suggestions
- Accepts both JSON strings and objects as input

The tool is implemented as a BaseTool (offline, no HttpRequest dependency)
and includes 28 comprehensive test cases covering valid and invalid GeoJSON,
coordinate validation, error handling, and statistics calculation.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@mattpodwysocki mattpodwysocki requested a review from a team as a code owner January 8, 2026 20:26
mattpodwysocki added a commit that referenced this pull request Jan 9, 2026
…roduction prompt

Adds comprehensive style quality validation capabilities:

Skill:
- Created mapbox-style-quality skill document (390+ lines)
- Pre-production checklist and validation best practices
- Guidance on expression validation, GeoJSON validation, and accessibility
- Optimization strategies and workflow recommendations
- Integration patterns for Git hooks, CI/CD, and code review

Prompt:
- Created prepare-style-for-production prompt
- Orchestrates validation workflow using 5 quality tools:
  * validate_expression_tool - Validate expressions in filters/paint/layout
  * validate_geojson_tool - Validate GeoJSON sources
  * check_color_contrast_tool - WCAG accessibility compliance
  * optimize_style_tool - Remove redundancies and optimize
  * compare_styles_tool - Compare versions (implicit in workflow)
- Configurable WCAG level (AA/AAA) and optional optimization skip
- Generates comprehensive quality report with deployment readiness assessment

Testing:
- 15 test cases for PrepareStyleForProductionPrompt
- All 386 tests passing
- Updated prompt registry tests

Documentation:
- Updated README with new skill listing
- Added prompt documentation with usage examples
- Cross-referenced skill and prompt

Related PRs:
- PR #50: validate_geojson_tool
- PR #51: validate_expression_tool
- PR #52: compare_styles_tool
- PR #53: check_color_contrast_tool
- PR #54: optimize_style_tool

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Valiunia
Valiunia previously approved these changes Jan 9, 2026
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.

2 participants