s2geometry 0.2.1 copy "s2geometry: ^0.2.1" to clipboard
s2geometry: ^0.2.1 copied to clipboard

A Dart port of Google's S2 Geometry library for spherical geometry and spatial indexing.

0.2.1 #

New classes (48 source files) #

  • Geometry: S2Loop, S2Polygon, S2LaxPolygonShape, S2ConvexHullQuery
  • Builder: S2Builder, S2BuilderGraph, S2BuilderLayer, S2BuilderShapesLayer, S2BuilderSnapFunctions, S2BuilderUtil
  • Layers: S2PolygonLayer, S2PolylineLayer, S2LaxPolygonLayer, S2LaxPolylineLayer, S2PointVectorLayer
  • Boolean operations: S2BooleanOperation, S2WindingOperation, S2BufferOperation, S2ClosedSetNormalizer
  • Queries: S2ClosestEdgeQuery, S2FurthestEdgeQuery, S2HausdorffDistanceQuery, S2ContainsPointQuery, S2CrossingEdgeQuery, S2CrossingEdgesQuery
  • Shape utilities: S2ShapeMeasures, S2ShapeIndexMeasures, S2ShapeUtil, S2ShapeIndexRegion, S2ShapeIndexBufferedRegion, S2ShapeTracker, S2ReclippedShape
  • Index utilities: S2EdgeIterator, S2CellRangeIterator, S2CellIteratorJoin, S2IncidentEdgeTracker, S2IndexingHelper, S2IndexCellData, S2DensityTree
  • Distance collectors: MinChordAngleCollector, MaxChordAngleCollector
  • Other: IdSetLexicon, S2BestDistanceTarget, S2PolygonDegeneracyFinder, S2RobustCellClipper, S2ValidationQueries, S2ShapeIndexCoder, S2TaggedShapeCoder

Bug fixes #

  • S2EdgeUtil.vertexCrossing: Fixed reference direction to use S2.refDir() instead of robustCrossProd, matching the Java implementation. This was the root cause of incorrect containsPoint results for hemisphere and complex loops.
  • S2Loop._hasCrossingRelation: Fixed to only count proper edge crossings ( robustCrossing > 0), excluding shared vertices.
  • S2Loop.containsLoop / intersectsLoop: Fixed handling of shared boundary vertices and complementary loops (e.g., north/south hemisphere).
  • S2Loop.invert: Added _initBound() call and empty/full swap logic.
  • S2Loop.turningAngle: Returns correct ±2π for empty/full loops.
  • S2BooleanOperation.contains / intersects / equals: Rewritten with proper edge crossing detection and vertex containment checks, replacing broken vertex-only implementation.
  • S2Polygon._initNested: Fixed hole loop handling — all loops stay CCW (normalized), matching Java's XOR-based containsPoint model.

Tests #

  • Added 22 new test files with 89+ new tests
  • Total: 1,413 tests passing, 5 skipped, 0 failures (up from 1,324 in 0.2.0)
  • Overall code coverage: 79% across 102 source files

0.2.0 #

  • New port from Java Library, still a work in progress.

0.1.1 #

  • Original port from C++ library by Jan Boon @kaetemi
2
likes
150
points
181
downloads

Documentation

Documentation
API reference

Publisher

verified publisherslightfoot.dev

Weekly Downloads

A Dart port of Google's S2 Geometry library for spherical geometry and spatial indexing.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

collection, meta

More

Packages that depend on s2geometry