...

Text file src/github.com/golang/geo/README.md

Documentation: github.com/golang/geo

     1# Overview
     2
     3S2 is a library for spherical geometry that aims to have the same robustness,
     4flexibility, and performance as the best planar geometry libraries.
     5
     6This is a library for manipulating geometric shapes. Unlike many geometry
     7libraries, S2 is primarily designed to work with *spherical geometry*, i.e.,
     8shapes drawn on a sphere rather than on a planar 2D map. (In fact, the name S2
     9is derived from the mathematical notation for the unit sphere *Sยฒ*.) This makes
    10it especially suitable for working with geographic data.
    11
    12More details about S2 in general are available on the S2 Geometry Website
    13[s2geometry.io](https://s2geometry.io/).
    14
    15## Scope
    16
    17The library provides the following:
    18
    19*   Representations of angles, intervals, latitude-longitude points, unit
    20    vectors, and so on, and various operations on these types.
    21
    22*   Geometric shapes over the unit sphere, such as spherical caps ("discs"),
    23    latitude-longitude rectangles, polylines, and polygons. These are
    24    collectively known as "regions".
    25
    26*   A hierarchical decomposition of the sphere into regions called "cells". The
    27    hierarchy starts with the six faces of a projected cube and recursively
    28    subdivides them in a quadtree-like fashion.
    29
    30*   Robust constructive operations (e.g., union) and boolean predicates (e.g.,
    31    containment) for arbitrary collections of points, polylines, and polygons.
    32
    33*   Fast in-memory indexing of collections of points, polylines, and polygons.
    34
    35*   Algorithms for measuring distances and finding nearby objects.
    36
    37*   Robust algorithms for snapping and simplifying geometry (with accuracy and
    38    topology guarantees).
    39
    40*   A collection of efficient yet exact mathematical predicates for testing
    41    relationships among geometric objects.
    42
    43*   Support for spatial indexing, including the ability to approximate regions
    44    as collections of discrete "S2 cells". This feature makes it easy to build
    45    large distributed spatial indexes.
    46
    47On the other hand, the following are outside the scope of S2:
    48
    49*   Planar geometry.
    50
    51*   Conversions to/from common GIS formats.
    52
    53### Robustness
    54
    55What do we mean by "robust"?
    56
    57In the S2 library, the core operations are designed to be 100% robust. This
    58means that each operation makes strict mathematical guarantees about its output,
    59and is implemented in such a way that it meets those guarantees for all possible
    60valid inputs. For example, if you compute the intersection of two polygons, not
    61only is the output guaranteed to be topologically correct (up to the creation of
    62degeneracies), but it is also guaranteed that the boundary of the output stays
    63within a user-specified tolerance of true, mathematically exact result.
    64
    65Robustness is very important when building higher-level algorithms, since
    66unexpected results from low-level operations can be very difficult to handle. S2
    67achieves this goal using a combination of techniques from computational
    68geometry, including *conservative error bounds*, *exact geometric predicates*,
    69and *snap rounding*.
    70
    71The implementation attempts to be precise both in terms of mathematical
    72definitions (e.g. whether regions include their boundaries, and how degeneracies
    73are handled) and numerical accuracy (e.g. minimizing cancellation error).
    74
    75Note that the intent of this library is to represent geometry as a mathematical
    76abstraction. For example, although the unit sphere is obviously a useful
    77approximation for the Earth's surface, functions that are specifically related
    78to geography are not part of the core library (e.g. easting/northing
    79conversions, ellipsoid approximations, geodetic vs. geocentric coordinates,
    80etc).
    81
    82See http://godoc.org/github.com/golang/geo for specific package documentation.
    83
    84For an analogous library in C++, see https://github.com/google/s2geometry, in
    85Java, see https://github.com/google/s2-geometry-library-java, and Python, see
    86https://github.com/google/s2geometry/tree/master/src/python
    87
    88# Status of the Go Library
    89
    90This library is principally a port of the
    91[C++ S2 library](https://github.com/google/s2geometry), adapting to Go idioms
    92where it makes sense. We detail the progress of this port below relative to that
    93C++ library.
    94
    95Legend:
    96
    97*   โœ… - Feature Complete
    98*   ๐ŸŸก - Mostly Complete
    99*   โŒ - Not available
   100
   101## [โ„ยน](https://godoc.org/github.com/golang/geo/r1) - One-dimensional Cartesian coordinates
   102
   103C++ Type   | Go
   104:--------- | ---
   105R1Interval | โœ…
   106
   107## [โ„ยฒ](https://godoc.org/github.com/golang/geo/r2) - Two-dimensional Cartesian coordinates
   108
   109C++ Type | Go
   110:------- | ---
   111R2Point  | โœ…
   112R2Rect   | โœ…
   113
   114## [โ„ยณ](https://godoc.org/github.com/golang/geo/r3) - Three-dimensional Cartesian coordinates
   115
   116C++ Type      | Go
   117:------------ | ---
   118R3Vector      | โœ…
   119R3ExactVector | โœ…
   120Matrix3x3     | โœ…
   121
   122## [Sยน](https://godoc.org/github.com/golang/geo/s1) - Circular Geometry
   123
   124C++ Type     | Go
   125:----------- | ---
   126S1Angle      | โœ…
   127S1ChordAngle | โœ…
   128S1Interval   | โœ…
   129
   130## [Sยฒ](https://godoc.org/github.com/golang/geo/s2) - Spherical Geometry
   131
   132### Basic Types
   133
   134C++ Type             | Go
   135:------------------- | ---
   136S2Cap                | โœ…
   137S2Cell               | โœ…
   138S2CellId             | โœ…
   139S2CellIdVector       | โŒ
   140S2CellIndex          | ๐ŸŸก
   141S2CellUnion          | โœ…
   142S2Coords             | โœ…
   143S2DensityTree        | โŒ
   144S2DistanceTarget     | โœ…
   145S2EdgeVector         | โœ…
   146S2LatLng             | โœ…
   147S2LatLngRect         | โœ…
   148S2LaxLoop            | ๐ŸŸก
   149S2LaxPolygon         | ๐ŸŸก
   150S2LaxPolyline        | ๐ŸŸก
   151S2Loop               | โœ…
   152S2PaddedCell         | โœ…
   153S2Point              | โœ…
   154S2PointIndex         | โŒ
   155S2PointSpan          | โŒ
   156S2PointRegion        | โŒ
   157S2PointVector        | โœ…
   158S2Polygon            | ๐ŸŸก
   159S2Polyline           | โœ…
   160S2R2Rect             | โŒ
   161S2Region             | โœ…
   162S2RegionCoverer      | โœ…
   163S2RegionIntersection | โŒ
   164S2RegionUnion        | โœ…
   165S2Shape              | โœ…
   166S2ShapeIndex         | โœ…
   167S2ShapeIndexRegion   | โŒ
   168EncodedLaxPolygon    | โŒ
   169EncodedLaxPolyline   | โŒ
   170EncodedShapeIndex    | โŒ
   171EncodedStringVector  | โŒ
   172EncodedUintVector    | โŒ
   173IdSetLexicon         | โŒ
   174ValueSetLexicon      | โŒ
   175SequenceLexicon      | โŒ
   176LaxClosedPolyline    | โŒ
   177VertexIDLaxLoop      | โŒ
   178
   179### Query Types
   180
   181C++ Type             | Go
   182:------------------- | ---
   183S2ChainInterpolation | โŒ
   184S2ClosestCell        | โŒ
   185S2FurthestCell       | โŒ
   186S2ClosestEdge        | โœ…
   187S2FurthestEdge       | โœ…
   188S2ClosestPoint       | โŒ
   189S2FurthestPoint      | โŒ
   190S2ContainsPoint      | โœ…
   191S2ContainsVertex     | โœ…
   192S2ConvexHull         | โœ…
   193S2CrossingEdge       | โœ…
   194S2HausdorffDistance  | โŒ
   195S2ShapeNesting       | โŒ
   196
   197### Supporting Types
   198
   199C++ Type                         | Go
   200:------------------------------- | ---
   201S2BooleanOperation               | โŒ
   202S2BufferOperation                | โŒ
   203S2Builder                        | โŒ
   204S2BuilderClosedSetNormalizer     | โŒ
   205S2BuilderFindPolygonDegeneracies | โŒ
   206S2BuilderGraph                   | โŒ
   207S2BuilderLayers                  | โŒ
   208S2BuilderSnapFunctions           | โŒ
   209S2BuilderTesting                 | โŒ
   210S2Builderutil\*                  | โŒ
   211S2Coder                          | โŒ
   212S2EdgeClipping                   | โœ…
   213S2EdgeCrosser                    | โœ…
   214S2EdgeCrossings                  | โœ…
   215S2EdgeDistances                  | โœ…
   216S2EdgeTessellator                | โœ…
   217S2LoopMeasures                   | โŒ
   218S2Measures                       | โœ…
   219S2MemoryTracker                  | โŒ
   220S2Metrics                        | โŒ
   221S2PointUtil                      | ๐ŸŸก
   222S2PolygonBuilder                 | โŒ
   223S2PolylineAlignment              | โŒ
   224S2PolylineMeasures               | โœ…
   225S2PolylineSimplifier             | โŒ
   226S2Predicates                     | โœ…
   227S2Projections                    | โŒ
   228S2rectBounder                    | โŒ
   229S2RegionTermIndexer              | โŒ
   230S2ShapeIndexMeasures             | โŒ
   231S2ShapeIndexUtil\*               | ๐ŸŸก
   232S2ShapeMeasures                  | โŒ
   233S2ShapeUtil\*                    | ๐ŸŸก
   234S2Stats                          | โŒ
   235S2Testing                        | โœ…
   236S2TextFormat                     | โœ…
   237S2WedgeRelations                 | โœ…
   238S2WindingOperation               | โŒ
   239
   240### Encode/Decode
   241
   242Encoding and decoding of S2 types is fully implemented and interoperable with
   243C++ and Java.

View as plain text