halfrost / S2

S2 geometry library in Go | experiment version
Apache License 2.0
21 stars 5 forks source link

Update

S2/regioncoverer.go
S2/cellid.go
S2/cellunion.go

Overview

This is a library for manipulating geometric shapes. Unlike many geometry libraries, S2 is primarily designed to work with spherical geometry, i.e., shapes drawn on a sphere rather than on a planar 2D map. (In fact, the name S2 is derived from the mathematical notation for the unit sphere.) This makes it especially suitable for working with geographic data.

The library consists of:

The implementations attempt to be precise both in terms of mathematical definitions (e.g. whether regions include their boundaries, representations of empty and full regions) and numerical accuracy (e.g. avoiding cancellation error).

Note that the intent of this library is to represent geometry as a mathematical abstraction. For example, although the unit sphere is obviously a useful approximation for the Earth's surface, functions that are specifically related to geography are not part of the core library (e.g. easting/northing conversions, ellipsoid approximations, geodetic vs. geocentric coordinates, etc).

See http://godoc.org/github.com/golang/geo for specific package documentation.

For an analogous library in C++, see https://code.google.com/archive/p/s2-geometry-library/, and in Java, see https://github.com/google/s2-geometry-library-java

Status of the Go Library

This library is principally a port of the C++ S2 library, adapting to Go idioms where it makes sense. We detail the progress of this port below relative to that C++ library.

Note: The C++ code on code.google.com is an out-of-date snapshot of the Google-internal version, and isn't the basis of this Go library. When the C++ library is re-released, we will update this document.

ℝ¹ - One-dimensional Cartesian coordinates

Full parity with C++.

ℝ² - Two-dimensional Cartesian coordinates

Full parity with C++.

ℝ³ - Three-dimensional Cartesian coordinates

Full parity with C++.

- Circular Geometry

Complete

Mostly complete

- Spherical Geometry

Approximately ~40% complete.

Complete These files have full parity with the C++ implementation.

Mostly Complete Files that have almost all of the features of the original C++ code, and are reasonably complete enough to use in live code. Up to date listing of the incomplete methods are documented at the end of each file.

In Progress Files that have some work done, but are probably not complete enough for general use in production code.

Not Started Yet. These files (and their associated unit tests) have dependencies on most of the In Progress files before they can begin to be started.

Encode/Decode

Encoding of S2 Go types is committed and is interoperable with C++ and Java. Decoding for Loops, Polygons, Polylines, and Rects is now completed. The remaining types will be worked on in the future.