ランキングに戻る

google/s2geometry

C++s2geometry.io

Computational geometry and spatial indexing on the sphere

geometryspherical-geometrys2spatial-indexing
スター成長
スター
2.7k
フォーク
358
週間成長
Issue
56
1k2k
2015年11月2019年5月2022年12月2026年7月
README

S2 Geometry Library

Overview

This is a package 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. This makes it especially suitable for working with geographic data.

If you want to learn more about the library, start by reading the overview and quick start document, then read the introduction to the basic types.

S2 documentation can be found on s2geometry.io.

API/ABI Stability

Note that all releases are version 0.x, so there are no API or ABI stability guarantees. Starting with 1.0 we will adhere to SemVer and follow the Google OSS breaking change policy

The Python API is particularly unstable, and it is planned that the SWIGged API will be replaced by a pybind11 version with more Pythonic names and more complete functionality.

Requirements for End Users using Bazel

Build

This bazel build requires Bazel 8 or newer. Builds were tested using C++20 as set in .bazelrc. This setup relies on abseil-cpp and googletest from the bazel central repository as set in MODULE.bazel.

To build and test using bazel, from within s2geometry/src, run:

bazel test "//:*"

To build the libary without testing, from within s2geometry/src, run:

bazel build //:s2

Status

All tests enumerated in the BUILD.bazel file pass on x86 machines. On Apple M1, s2loop_measures_test fails due to a 6% excess accumlated error. This issue may require revision of boringssl or exactfloat.

Requirements for End Users using CMake

On Ubuntu, all of these other than abseil can be installed via apt-get:

sudo apt-get install cmake libssl-dev

abseil-cpp may need to be installed from source if an LTS release is not packaged for the platform. See the use of -DCMAKE_PREFIX_PATH in the build instructions below.

On macOS, use MacPorts or Homebrew. For MacPorts:

sudo port install cmake abseil gtest openssl

Build and Install

You may either download the source as a ZIP archive, or clone the git repository.

Via ZIP archive

Download ZIP file

cd [parent of directory where you want to put S2]
unzip [path to ZIP file]/s2geometry-master.zip
cd s2geometry-master

Via git clone

cd [parent of directory where you want to put S2]
git clone https://github.com/google/s2geometry.git
cd s2geometry

Building

First, install Abseil. It must be configured with -DCMAKE_POSITION_INDEPENDENT_CODE=ON. s2geometry must be configured to use the same C++ version that abseil uses. The easiest way to achieve this is to pass -DCMAKE_CXX_STANDARD=17 to cmake when compiling both abseil and s2geometry.

From the appropriate directory depending on how you got the source:

mkdir build
cd build
# You can use -DBUILD_TESTS=no to skip tests.
# Use the same CMAKE_CXX_STANDARD value that was used with absl.
cmake -DBUILD_TESTS=yes -DCMAKE_PREFIX_PATH=/path/to/absl/install -DCMAKE_CXX_STANDARD=17 ..
make -j $(nproc)
make test ARGS="-j$(nproc)"  # If -DBUILD_TESTS=yes was used above.
sudo make install

On macOS, sysctl -n hw.logicalcpu is the equivalent of nproc.

Disable building of shared libraries with -DBUILD_SHARED_LIBS=OFF.

Enable the python interface with -DWITH_PYTHON=ON.

For Testing

If BUILD_TESTS is 'on' (the default), then OpenSSL must be available to build some tests:

If OpenSSL is installed in a non-standard location set OPENSSL_ROOT_DIR before running configure, for example on macOS:

OPENSSL_ROOT_DIR=/opt/homebrew/Cellar/openssl@3/3.1.0 cmake -DCMAKE_PREFIX_PATH=/opt/homebrew -DCMAKE_CXX_STANDARD=17

Installing

From build subdirectory:

make install

Prefix it with sudo if needed:

sudo make install

NOTE: There is not uninstall target but install_manifest.txt may be helpful.

All files will be installed at location specified in CMAKE_INSTALL_PREFIX variable.

Several suffix variables used for some file groups:

Variable Default Description
CMAKE_INSTALL_INCLUDEDIR include For header files
CMAKE_INSTALL_BINDIR bin For executables and *.dll files on DLL-based platforms
CMAKE_INSTALL_LIBDIR lib For library files (*.so, *.a, *.lib etc)

If needed set this variables on command line as cmake arguments with -D prefix or edit from build subdirectory:

make edit_cache

For more info read: The CMake Cache.

Python

If you want the Python interface, you need to run cmake using -DWITH_PYTHON=ON. You will also need to install the following dependencies:

  • SWIG 4 (for Python support, optional)
  • python3-dev (for Python support, optional)

which can be installed via

sudo apt-get install swig python3-dev

or on macOS:

sudo port install swig

SWIG version 4.0 is required.

Python 3.10 is required.

Creating wheels

First, make a virtual environment and install build into it:

python3 -m venv venv
source venv/bin/activate
pip install build

Then build the wheel:

python -m build

The resulting wheel will be in the dist directory.

If OpenSSL is in a non-standard location make sure to set OPENSSL_ROOT_DIR; see above for more information.

Other S2 implementations

  • Go (Approximately 40% complete.)
  • Java

Disclaimer

This is not an official Google product.

関連リポジトリ
williamfiset/algorithms

A collection of algorithms and data structures

JavaMavenMIT Licensealgorithmslinear-algebra
18.7k4.5k
williamfiset/Algorithms

A collection of algorithms and data structures

JavaMavenMIT Licensealgorithmslinear-algebra
17.7k4.4k
colmap/colmap

COLMAP - Structure-from-Motion and Multi-View Stereo

C++Otherstructure-from-motionmulti-view-stereo
colmap.github.io
12.3k2.1k
openMVG/openMVG

open Multiple View Geometry library. Basis for 3D computer vision and Structure from Motion.

C++Mozilla Public License 2.0geometrycomputer-vision
6.5k1.7k
LibreCAD/LibreCAD

LibreCAD is a cross-platform 2D CAD program. It can read DXF/DWG, and write DXF/DWG/PDF/SVG files. It supports point/line/circle/ellipse/parabola/hyperbola/spline primitives. The GUI is highly customizable, and has dozens of translations.

C++Othercadqt
librecad.org
6.1k1.3k
CGAL/cgal

The public CGAL repository, see the README below

C++Othercgalc-plus-plus
github.com/CGAL/cgal
6k1.6k
patriciogonzalezvivo/glslViewer

Console-based GLSL Sandbox for 2D/3D shaders

C++BSD 3-Clause "New" or "Revised" Licenseshadersfragment-shader
patriciogonzalezvivo.github.io/glslViewer/
5.3k371
xiangechen/chili3d

A browser-based 3D CAD application for online model design and editing

TypeScriptnpmGNU Affero General Public License v3.0cadopencascade
chili3d.com
4.7k451
thi-ng/umbrella

⛱ Broadly scoped ecosystem & mono-repository of 215 TypeScript projects (and ~185 examples) for general purpose, functional, data driven development

TypeScriptnpmApache License 2.0colordata-structures
thi.ng
3.8k168
mikedh/trimesh

Python library for loading and using triangular meshes.

PythonPyPIMIT Licensemeshtriangular-meshes
trimesh.org
3.6k655
gkjohnson/three-mesh-bvh

A BVH implementation to speed up raycasting and enable spatial queries against three.js meshes.

JavaScriptnpmMIT Licensegraphicsraycast
gkjohnson.github.io/three-mesh-bvh/example/bundle/raycast.html
3.4k331
hlorus/CAD_Sketcher

Constraint-based geometry sketcher for blender

PythonPyPIGNU General Public License v3.0blender3d
3.4k172