Commit 31fe224
Add 9 offline geospatial tools using Turf.js (#96)
* Add distance_tool for offline geospatial calculations
Implements the first offline geospatial tool using Turf.js for calculating
great-circle distance between two geographic coordinates.
Features:
- Calculate distance between any two points on Earth
- Support for multiple units: km, miles, meters, feet, nautical miles
- Haversine formula for accurate great-circle distance
- Completely offline - no API calls required
- Fast local calculations with OpenTelemetry tracing
Technical details:
- Uses Turf.js distance function
- Follows project patterns (BaseTool, proper annotations)
- Coordinate format: { longitude, latitude } objects (not tuples)
- Read-only, idempotent, closed-world tool
- Full test coverage with 8 test cases
Dependencies added:
- @turf/turf: Comprehensive geospatial analysis library
All 433 tests passing ✅
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
* Add 8 offline geospatial tools using Turf.js
Implement fundamental geospatial calculation tools that work completely
offline without requiring Mapbox API calls:
- point_in_polygon_tool: Test if a point is inside a polygon
- bearing_tool: Calculate compass direction between coordinates
- midpoint_tool: Find geographic midpoint between two points
- centroid_tool: Calculate center point of polygons
- area_tool: Calculate polygon area in various units (meters, km, acres, etc)
- bbox_tool: Calculate bounding box of any geometry
- buffer_tool: Create buffer zones around geometries
- simplify_tool: Reduce vertex count while preserving shape
All tools:
- Extend BaseTool (not MapboxApiBasedTool) for offline operation
- Use Turf.js (@turf/turf) for geospatial calculations
- Include OpenTelemetry tracing
- Have proper annotations (openWorldHint: false)
- Use coordinate objects for inputs to avoid JSON schema issues
Updated test annotations to include all offline tools in exclusion list.
All 457 tests passing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
* Update README with offline geospatial tools documentation
- Add new "Offline Geospatial Tools" section documenting all 9 tools
- Update intro to mention offline calculations capability
- Add example prompts for offline geospatial calculations
- Document features and use cases for each offline tool
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
* Add comprehensive test coverage for offline geospatial tools
Add test suites for 8 offline tools that were missing coverage:
1. **Point in Polygon Tool** (10 tests)
- Simple polygons (inside/outside)
- Complex polygons
- Polygons with holes
- Edge cases (boundaries, extreme coordinates)
- Large polygons with many vertices
2. **Bearing Tool** (15 tests)
- Cardinal directions (N, S, E, W)
- Ordinal directions (NE, SE, SW, NW)
- Real world locations
- Antimeridian crossing
- Near poles
- Reverse bearing validation
3. **Midpoint Tool** (15 tests)
- Points on equator and meridians
- Real world city pairs
- Same point edge case
- Antimeridian crossing
- Hemispheres (N/S, E/W)
- Precision and rounding
4. **Centroid Tool** (15 tests)
- Simple shapes (square, rectangle, triangle)
- Polygons with holes
- Multipolygons
- Complex irregular shapes
- Extreme coordinates
- Precision validation
5. **Area Tool** (16 tests)
- All supported units (meters, km, feet, miles, acres, hectares)
- Simple and complex polygons
- Polygons with holes
- Multipolygons
- Different latitudes (equator, poles)
- Precision rounding
6. **Bounding Box Tool** (18 tests)
- All geometry types (point, line, polygon, multipolygon)
- Complex shapes
- Extreme coordinates
- Precision validation
- Format verification
7. **Buffer Tool** (19 tests)
- All geometry types (point, line, polygon)
- All supported units
- Various distances (small to large)
- Real world locations
- Different hemispheres
- Validation of output format
8. **Simplify Tool** (16 tests)
- Linestrings and polygons
- Various tolerance levels
- High quality mode
- Straight lines and curves
- Polygons with holes
- Reduction percentage calculation
All 556 tests now passing (124 new tests added).
Addresses PR feedback: #96
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
---------
Co-authored-by: Claude Sonnet 4.5 <[email protected]>1 parent c4b357d commit 31fe224
File tree
46 files changed
+6447
-6
lines changed- src
- tools
- area-tool
- bearing-tool
- bounding-box-tool
- buffer-tool
- centroid-tool
- distance-tool
- midpoint-tool
- point-in-polygon-tool
- simplify-tool
- utils
- test/tools
- area-tool
- bearing-tool
- bounding-box-tool
- buffer-tool
- centroid-tool
- distance-tool
- midpoint-tool
- point-in-polygon-tool
- simplify-tool
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
46 files changed
+6447
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
80 | 93 | | |
81 | 94 | | |
82 | 95 | | |
| |||
178 | 191 | | |
179 | 192 | | |
180 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
181 | 307 | | |
182 | 308 | | |
183 | 309 | | |
| |||
0 commit comments