{"id":13413002,"url":"https://github.com/golang/geo","last_synced_at":"2025-05-14T12:00:16.012Z","repository":{"id":24123598,"uuid":"27512134","full_name":"golang/geo","owner":"golang","description":"S2 geometry library in Go","archived":false,"fork":false,"pushed_at":"2025-05-05T20:15:51.000Z","size":1155,"stargazers_count":1744,"open_issues_count":26,"forks_count":188,"subscribers_count":72,"default_branch":"master","last_synced_at":"2025-05-07T11:41:40.255Z","etag":null,"topics":["geometry","geometry-library","go","sphere"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/golang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-12-03T23:02:15.000Z","updated_at":"2025-05-05T20:15:47.000Z","dependencies_parsed_at":"2023-02-12T21:30:36.861Z","dependency_job_id":"0ca48b8c-6ab4-4a9d-9e94-c5e554c552ae","html_url":"https://github.com/golang/geo","commit_stats":{"total_commits":388,"total_committers":17,"mean_commits":"22.823529411764707","dds":"0.24742268041237114","last_synced_commit":"6adc5660321723185f04b66d66a5563b29228236"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golang%2Fgeo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golang%2Fgeo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golang%2Fgeo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golang%2Fgeo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/golang","download_url":"https://codeload.github.com/golang/geo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254140738,"owners_count":22021218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geometry","geometry-library","go","sphere"],"created_at":"2024-07-30T20:01:32.186Z","updated_at":"2025-05-14T12:00:15.890Z","avatar_url":"https://github.com/golang.png","language":"Go","funding_links":[],"categories":["Geographic","Go","地理","Geospatial Library","位置信息与地理GEO处理库","Relational Databases"],"sub_categories":["Search and Analytic Databases","Advanced Console UIs","检索及分析资料库","Go","Tools","[Tools](#tools-1)","SQL 查询语句构建库"],"readme":"# S2 geometry library in Go\n\n[![Go Build and Test](https://github.com/golang/geo/actions/workflows/go.yml/badge.svg)](https://github.com/golang/geo/actions/workflows/go.yml) [![CodeQL](https://github.com/golang/geo/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/golang/geo/actions/workflows/github-code-scanning/codeql) [![golangci-lint](https://github.com/golang/geo/actions/workflows/golangci-lint.yml/badge.svg)](https://github.com/golang/geo/actions/workflows/golangci-lint.yml) [![OpenSSF Scorecard](https://img.shields.io/ossf-scorecard/github.com/golang/geo?label=OpenSSF%20Scorecard\u0026style=flat)](https://scorecard.dev/viewer/?uri=github.com/golang/geo)\n\nS2 is a library for spherical geometry that aims to have the same robustness,\nflexibility, and performance as the best planar geometry libraries.\n\nThis is a library for manipulating geometric shapes. Unlike many geometry\nlibraries, S2 is primarily designed to work with *spherical geometry*, i.e.,\nshapes drawn on a sphere rather than on a planar 2D map. (In fact, the name S2\nis derived from the mathematical notation for the unit sphere *S²*.) This makes\nit especially suitable for working with geographic data.\n\nMore details about S2 in general are available on the S2 Geometry Website\n[s2geometry.io](https://s2geometry.io/).\n\n## Scope\n\nThe library provides the following:\n\n*   Representations of angles, intervals, latitude-longitude points, unit\n    vectors, and so on, and various operations on these types.\n\n*   Geometric shapes over the unit sphere, such as spherical caps (\"discs\"),\n    latitude-longitude rectangles, polylines, and polygons. These are\n    collectively known as \"regions\".\n\n*   A hierarchical decomposition of the sphere into regions called \"cells\". The\n    hierarchy starts with the six faces of a projected cube and recursively\n    subdivides them in a quadtree-like fashion.\n\n*   Robust constructive operations (e.g., union) and boolean predicates (e.g.,\n    containment) for arbitrary collections of points, polylines, and polygons.\n\n*   Fast in-memory indexing of collections of points, polylines, and polygons.\n\n*   Algorithms for measuring distances and finding nearby objects.\n\n*   Robust algorithms for snapping and simplifying geometry (with accuracy and\n    topology guarantees).\n\n*   A collection of efficient yet exact mathematical predicates for testing\n    relationships among geometric objects.\n\n*   Support for spatial indexing, including the ability to approximate regions\n    as collections of discrete \"S2 cells\". This feature makes it easy to build\n    large distributed spatial indexes.\n\nOn the other hand, the following are outside the scope of S2:\n\n*   Planar geometry.\n\n*   Conversions to/from common GIS formats.\n\n### Robustness\n\nWhat do we mean by \"robust\"?\n\nIn the S2 library, the core operations are designed to be 100% robust. This\nmeans that each operation makes strict mathematical guarantees about its output,\nand is implemented in such a way that it meets those guarantees for all possible\nvalid inputs. For example, if you compute the intersection of two polygons, not\nonly is the output guaranteed to be topologically correct (up to the creation of\ndegeneracies), but it is also guaranteed that the boundary of the output stays\nwithin a user-specified tolerance of true, mathematically exact result.\n\nRobustness is very important when building higher-level algorithms, since\nunexpected results from low-level operations can be very difficult to handle. S2\nachieves this goal using a combination of techniques from computational\ngeometry, including *conservative error bounds*, *exact geometric predicates*,\nand *snap rounding*.\n\nThe implementation attempts to be precise both in terms of mathematical\ndefinitions (e.g. whether regions include their boundaries, and how degeneracies\nare handled) and numerical accuracy (e.g. minimizing cancellation error).\n\nNote that the intent of this library is to represent geometry as a mathematical\nabstraction. For example, although the unit sphere is obviously a useful\napproximation for the Earth's surface, functions that are specifically related\nto geography are not part of the core library (e.g. easting/northing\nconversions, ellipsoid approximations, geodetic vs. geocentric coordinates,\netc).\n\nSee https://pkg.go.dev/github.com/golang/geo for specific package documentation.\n\nFor an analogous library in C++, see https://github.com/google/s2geometry, in\nJava, see https://github.com/google/s2-geometry-library-java, and Python, see\nhttps://github.com/google/s2geometry/tree/master/src/python\n\n# Status of the Go Library\n\nThis library is principally a port of the\n[C++ S2 library](https://github.com/google/s2geometry), adapting to Go idioms\nwhere it makes sense. We detail the progress of this port below relative to that\nC++ library.\n\nLegend:\n\n*   ✅ - Feature Complete\n*   🟡 - Mostly Complete\n*   ❌ - Not available\n\n## [ℝ¹](https://pkg.go.dev/github.com/golang/geo/r1) - One-dimensional Cartesian coordinates\n\nC++ Type   | Go\n:--------- | ---\nR1Interval | ✅\n\n## [ℝ²](https://pkg.go.dev/github.com/golang/geo/r2) - Two-dimensional Cartesian coordinates\n\nC++ Type | Go\n:------- | ---\nR2Point  | ✅\nR2Rect   | ✅\n\n## [ℝ³](https://pkg.go.dev/github.com/golang/geo/r3) - Three-dimensional Cartesian coordinates\n\nC++ Type      | Go\n:------------ | ---\nR3Vector      | ✅\nR3ExactVector | ✅\nMatrix3x3     | ✅\n\n## [S¹](https://pkg.go.dev/github.com/golang/geo/s1) - Circular Geometry\n\nC++ Type     | Go\n:----------- | ---\nS1Angle      | ✅\nS1ChordAngle | ✅\nS1Interval   | ✅\n\n## [S²](https://pkg.go.dev/github.com/golang/geo/s2) - Spherical Geometry\n\n### Basic Types\n\nC++ Type             | Go\n:------------------- | ---\nS2Cap                | ✅\nS2Cell               | ✅\nS2CellId             | ✅\nS2CellIdVector       | ❌\nS2CellIndex          | 🟡\nS2CellUnion          | ✅\nS2Coords             | ✅\nS2DensityTree        | ❌\nS2DistanceTarget     | ✅\nS2EdgeVector         | ✅\nS2LatLng             | ✅\nS2LatLngRect         | ✅\nS2LaxLoop            | 🟡\nS2LaxPolygon         | 🟡\nS2LaxPolyline        | 🟡\nS2Loop               | ✅\nS2PaddedCell         | ✅\nS2Point              | ✅\nS2PointIndex         | ❌\nS2PointSpan          | ❌\nS2PointRegion        | ❌\nS2PointVector        | ✅\nS2Polygon            | 🟡\nS2Polyline           | ✅\nS2R2Rect             | ❌\nS2Region             | ✅\nS2RegionCoverer      | ✅\nS2RegionIntersection | ❌\nS2RegionUnion        | ✅\nS2Shape              | ✅\nS2ShapeIndex         | ✅\nS2ShapeIndexRegion   | ❌\nEncodedLaxPolygon    | ❌\nEncodedLaxPolyline   | ❌\nEncodedShapeIndex    | ❌\nEncodedStringVector  | ❌\nEncodedUintVector    | ❌\nIdSetLexicon         | ❌\nValueSetLexicon      | ❌\nSequenceLexicon      | ❌\nLaxClosedPolyline    | ❌\nVertexIDLaxLoop      | ❌\n\n### Query Types\n\nC++ Type             | Go\n:------------------- | ---\nS2ChainInterpolation | ❌\nS2ClosestCell        | ❌\nS2FurthestCell       | ❌\nS2ClosestEdge        | ✅\nS2FurthestEdge       | ✅\nS2ClosestPoint       | ❌\nS2FurthestPoint      | ❌\nS2ContainsPoint      | ✅\nS2ContainsVertex     | ✅\nS2ConvexHull         | ✅\nS2CrossingEdge       | ✅\nS2HausdorffDistance  | ❌\nS2ShapeNesting       | ❌\nS2ValidationQuery    | ❌\n\n### Supporting Types\n\nC++ Type                         | Go\n:------------------------------- | ---\nS2BooleanOperation               | ❌\nS2BufferOperation                | ❌\nS2Builder                        | ❌\nS2BuilderGraph                   | ❌\nS2BuilderLayer                   | ❌\nS2BuilderUtil_\\*                 | ❌\nS2CellIterator                   | ❌\nS2CellIteratorJoin               | ❌\nS2CellRangeIterator              | ❌\nS2Coder                          | ❌\nS2Earth                          | ❌\nS2EdgeClipping                   | ✅\nS2EdgeCrosser                    | ✅\nS2EdgeCrossings                  | ✅\nS2EdgeDistances                  | ✅\nS2EdgeTessellator                | ✅\nS2Fractal                        | ❌\nS2LoopMeasures                   | ❌\nS2Measures                       | ✅\nS2MemoryTracker                  | ❌\nS2Metrics                        | ❌\nS2PointUtil                      | 🟡\nS2PointCompression               | 🟡\nS2PolygonBuilder                 | ❌\nS2PolylineAlignment              | ❌\nS2PolylineMeasures               | ✅\nS2PolylineSimplifier             | ❌\nS2Predicates                     | ✅\nS2Projections                    | ❌\nS2Random                         | ❌\nS2RectBounder                    | ❌\nS2RegionSharder                  | ❌\nS2RegionTermIndexer              | ❌\nS2ShapeIndexBufferedRegion       | ❌\nS2ShapeIndexMeasures             | ❌\nS2ShapeIndexUtil\\*               | 🟡\nS2ShapeMeasures                  | ❌\nS2ShapeUtil\\*                    | 🟡\nS2Stats                          | ❌\nS2Testing                        | ✅\nS2TextFormat                     | ✅\nS2WedgeRelations                 | ✅\nS2WindingOperation               | ❌\n\n\n### Encode/Decode\n\nEncoding and decoding of S2 types is fully implemented and interoperable with\nC++ and Java.\n\n\n## Disclaimer\n\nThis is not an official Google product.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolang%2Fgeo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgolang%2Fgeo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolang%2Fgeo/lists"}