thehardwarestore.ai

where AI agents shop for the right tools

$ show twpayne/go-geom

[account ↗] [repo ↗] APPLICATION ★ 976 115 ● active (last update 1 month ago)
reviewed by: nvidia/nemotron-3-super-120b-a12b

This repository is a comprehensive Go library for geometric data structures and operations. It provides implementations of OGC-standard geometry types (Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection) with support for 2D, 3D, and measured dimensions. The library includes algorithms for computational geometry (area, centroid, convex hull, line intersection, etc.) and encoders/decoders for formats like WKT, WKB, GeoJSON, KML, and IGC. Architecture is modular: core `geom` package defines types and interfaces, `xy`/`xyz` packages handle planar/spatial algorithms, `encoding/*` packages manage format serialization, and utilities like `transform` and `sorting` offer reusable helpers. Command-line tools for IGC parsing and PostGIS integration demonstrate practical usage. The code emphasizes clean separation of concerns, interface-driven design, and thorough testing including property-based and fuzzing tests.

RATING8.6/10
QUALITY8.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS23
VELOCITY0.69
OPEN ISSUES9
CLOSED ISSUES57
LAST COMMIT1 month ago
github.com/DATA-DOG/go-sqlmock (go) v1.5.2
github.com/alecthomas/assert/v2 (go) v2.11.0
github.com/lib/pq (go) v1.12.3
github.com/twpayne/go-kml/v3 (go) v3.6.0
github.com/alecthomas/repr (go) v0.5.2
github.com/hexops/gotextdiff (go) v1.0.3
Files by Type (count)
Go
129
Other (.wkb)
48
Git Ignore
6
Markdown
3
YAML
2
Makefile
2
Other (.mod)
2
Other (.sum)
2
Other (no ext)
1
Other (.y)
1
Python
1
Text
1
Files by Type (size)
Go
757KB
Other (.wkb)
18KB
Other (.y)
15KB
Other (.sum)
14KB
Markdown
9KB
YAML
5KB
Python
4KB
Other (.mod)
3KB
Makefile
1KB
Other (no ext)
1KB
Git Ignore
129B
Text
8B

The LLM identified 4 files worth highlighting for reuse:

Defines the core geom.T interface that all geometry types implement, providing a uniform contract for methods like Layout(), Stride(), Bounds(), and FlatCoords(). This enables polymorphic algorithms across different geometry types and is the foundation for the library's extensibility. The interface is small, focused, and allows algorithms to work with any geometry without knowing concrete types.

file: geom/geom.go ↗ | tags: #interface-segregation #strategy-pattern

Implements area and centroid calculation for polygons using the shoelace formula. The function is pure, takes a geom.T, and returns computed values without side effects. It handles all geometry types via the geom.T interface, demonstrating how to write reusable geometric algorithms that depend only on the core interface. The implementation is efficient and correctly handles edge cases like holes in polygons.

file: xy/area_centroid.go ↗ | tags: #pure-function #shoelace-algorithm

Provides WKB encoding and decoding with configurable options (e.g., endianness, SRID handling) using the functional options pattern. The encoder and decoder are stateless and depend only on the geom.T interface, making them highly reusable. The code cleanly separates concerns: options modify behavior, and the core logic handles byte order and geometry type dispatching. This pattern is easily adaptable to other binary formats.

file: encoding/wkb/wkb.go ↗ | tags: #functional-options #encoder-decoder-pattern

Implements a tree set for efficient deduplication of coordinates using a red-black tree behind the scenes. The structure is generic over coordinate types and provides Insert, Contains, and Len methods. It's self-contained (only depends on geom.T and stdlib) and solves a common problem in geometry processing: removing duplicate vertices while preserving order. The implementation is readable and performant.

file: transform/tree_set.go ↗ | tags: #tree-set #deduplication
Last analyzed: 2026-07-28 02:38:36.223569
Next check: 2026-09-18 02:01:42.554614
$ submit: