Add validate_geojson_tool for offline GeoJSON validation #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds a comprehensive offline GeoJSON validation tool that checks GeoJSON objects for correctness without requiring API access.
Features
✅ Validates all GeoJSON types:
✅ Comprehensive validation checks:
✅ Structured validation results:
validboolean flagerrorsarray (critical issues)warningsarray (non-critical issues)infoarray (informational messages)statisticsobject (type, feature count, geometry types, bbox)✅ Developer-friendly:
Implementation Details
BaseTool(offline, no HttpRequest dependency)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?
Expected: Valid, returns statistics (1 feature, Point geometry, bbox)
Test 2: Valid Polygon ✅
Validate this polygon:
Expected: Valid, polygon ring is properly closed (first and last coordinates match)
Test 3: Invalid Coordinates (Out of Range) ❌
Check if this GeoJSON is valid:
Expected:
Test 4: Unclosed Polygon ❌
Is this polygon valid?
Expected:
Test 5: Valid FeatureCollection ✅
Validate this collection:
Expected:
Test 6: Wrong Coordinate Order (Common Mistake)⚠️
Check this point:
Expected: