Giter VIP home page Giter VIP logo

s2geometry's Introduction

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.

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

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

sudo apt-get install cmake googletest libssl-dev

Otherwise, you may need to install some from source.

Currently, Abseil must always be installed from source. See the use of -DCMAKE_PREFIX_PATH in the build instructions below. This is likely to change.

On macOS, use MacPorts or Homebrew. For MacPorts:

sudo port install cmake openssl

Do not install gtest from MacPorts; instead download release 1.10.0, unpack, and substitute

cmake -DGOOGLETEST_ROOT=/...absolute path to.../googletest-release-1.10.0 ..

in the build instructions below.

Thorough testing has only been done on Ubuntu 14.04.3 and macOS 10.12.

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=14 (or -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 omit -DGOOGLETEST_ROOT to skip tests; see above for macOS.
# Use the same CMAKE_CXX_STANDARD value that was used with absl.
cmake -DGOOGLETEST_ROOT=/usr/src/googletest -DCMAKE_PREFIX_PATH=/path/to/absl/install -DCMAKE_CXX_STANDARD=14 ..
make -j $(nproc)
make test ARGS="-j$(nproc)"  # If GOOGLETEST_ROOT specified 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.

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 helpfull.

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

Version 4.0 is required, but it should be easy to make it work 3.0 or probably even 2.0.

Python 3 is required.

Creating wheels

First, make a virtual environment and install cmake_build_extension and wheel into it:

python3 -m venv venv
source venv/bin/activate
pip install cmake_build_extension wheel

Then build the wheel:

python setup.py bdist_wheel

The resulting wheel will be in the dist directory.

If OpenSSL is in a non-standard location make sure to set OPENSSL_ROOT_DIR when calling setup.py, see above for more information.

Other S2 implementations

  • Go (Approximately 40% complete.)
  • Java
  • Kotlin (Complete except binary serialization)

Disclaimer

This is not an official Google product.

s2geometry's People

Contributors

acelyc111 avatar alas avatar bdon avatar bradhoov avatar danielhlarkin avatar daudrain avatar dhly-etc avatar eengle avatar goedderz avatar graetzer avatar gregcoombe avatar jbordeau avatar jherico avatar jmr avatar lafewessel avatar marklai0317 avatar mbkkt avatar micolous avatar mikeplayle avatar nlewycky avatar pateldeev avatar pelson avatar podsvirov avatar puretryout avatar rcoup avatar sammorris81 avatar selimnairb avatar smcallis avatar t-brito avatar wegylexy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

s2geometry's Issues

Building polygons in Python

Hi there,

I'm trying to build polygons from a list of vertices. However, there seems no S2Builder port to pywraps2. How can we build polygons effectively using the Python port?

I've actually tried to build it with S2Loop and S2Polygon,

loop = S2Loop()
points = [S2LatLng.FromDegrees(float(vertex[0]), float(vertex[1])).ToPoint() for vertex in hull[:-1]]
loop.Init(points)
loop.Normalize()
polygon = S2Polygon(loop)

The problem is that S2Loop requires a lot of checking, like edges not intersecting each other. And right now there are no easy ways for me to ensure the input (list of vertices) would not cross with each other (the input is from a concave hull calculation), so I often ran into errors like ERROR Edge 46 crosses edge 48.

Are there any effective ways to build polygons in Python given the circumstance above?

Thanks a lot,
Foxan

S2Cells for a "negative/inverse" polygon?!

Hi *

I would need the functionality/method to get all S2Cells for a given (very precise) polygon, lets say a country, that returns all S2Cells outside the polygon, i.e., the 5 faces plus all other S2Cells of the polygon surrounding the given area in face 6.

Is that somehow possible to calculate?

Kind regards + thx for any reply
Sebastian

S2 library not namespaced

First off, thanks for the great library! It has been a joy to use!

My issue is that it was difficult getting S2 to work with my project due to it not being namespaced. Most primitive classes, typedefs, and structs in the S2 library (e.g. S2Polygon, S2CellId, S2Point), as well as some classes with common names in //utils (e.g. Varint, Vector3_d) are declared in the global namespace. These can lead to conflicts, or even if they don't, should generally not be in a global namespace. Similarly for many of the macros and functions in //base (especially //base/port.h), or for //base/mutex.h which appears to collide with any target including its own absl/synchronization/mutex.h.

It would be nice if all code was wrapped in namespace s2 or similar, and all global macros had an S2_ prefix.

Node.js Interface?

Would there be interest in creating a node.js wrapper with SWIG? I know it would be helpful to me as I mostly work in node.js and node-s2 from mapbox is getting out-of-date.

PS. I'd be willing to help create this. However, since I'm unfamiliar with SWIG and building node.js C++ interfaces more generally, it's probably not best that I lead.

Error in function InitToDifference

I have two polygons:

  1. First (A) is a circle of radius R

  2. Second (B) is a circle of radius less than R (for example R/2)
    Both circles has same center. Now im trying to InitToDifference C = A - B, so the right answer, i guess, is polygon that consist of A and reverse B, but the result is {A, B}.
    There is code without generation of A and B. Is it a bag or am i wrong?

    S2Polygon* union_res = new S2Polygon;
    std::cout << "First:\n";
    for(int i = 0; i < a->num_loops(); i++) {
    std::cout << a->loop(i)->GetArea() << "\n";
    }

    std::cout << "Second:\n";
    for(int i = 0; i < b->num_loops(); i++) {
    std::cout << b->loop(i)->GetArea() << "\n";
    }
    union_res->InitToDifference(a, b);
    std::cout << "Out:\n";
    for(int i = 0; i < union_res->num_loops(); i++) {
    std::cout << union_res->loop(i)->GetArea() << "\n";
    }

Output:
First:
0.00829343
Second:
0.0022473
Out:
0.00829343
0.0022473

How to install pywraps2

Hi, about pywraps2_test.py, I try python pywraps2_test.py but genereted a error: "ImportError: No module named pywraps2".

How to install pywraps2 module? Perhaps the README.md need some clues for dummy users.

NOTES: I am using UBUNTU 16 LTS and followed the building instructions and the installation was fine, with make tests sucessess. SWIG installation also fine.

Is this library thread safe?

Is S2PointIndex thread safe? Should I use mutex when S2PointIndex.Add() and S2ClosestPointQuery.query() are called simultaneously in multithread?

Unable to create objects of S2Polyline and S2Polygon

Hi,

when trying to create objects of S2Polyline or S2Polgon I get the following error:

undefined reference to 'S2Polyline::S2Polyline()' undefined reference to 'S2Polyline::Init(std::vector<S2LatLng, std::allocator<S2LatLng> > const&)' undefined reference to 'S2Polyline::~S2Polyline()' undefined reference to 'S2Polyline::~S2Polyline()'

The code I am using is simply this:
std::vector<S2LatLng> vertices; S2Polyline polyline; polyline.Init(vertices);

The implementation of the declared functions in the header files (s2polyline.h and s2polygon.h) seems to be missing.

Thank you in advance
Best regards

when i run the example code in clion ,it shows undefined reference to `S2Testing::RandomPoint()' ; Ubuntu 18.04

here my Cmakelists is:
`project(test)

set(CMAKE_CXX_STANDARD 17)

set(INC_DIR /usr/local/include/s2)
set(LINK_DIR /usr/local/lib)

include_directories(${INC_DIR})
link_directories(${LINK_DIR})
link_libraries(libs2.so)
here is the error:
'add_executable(test main.cpp) undefined reference to S2Testing::RandomPoint()' undefined reference to S2Testing::RandomPoint()'`
I built this code yesterday. How can i do?Thanks!

Getting nearest neighbors with S2 geometry.

I am looking for a S2 geometry version of this SE answer - https://gis.stackexchange.com/questions/18330/using-geohash-for-proximity-searches/92331#92331

  1. I want to use S2 cells to do approximate nearest neighbor searches

  2. I have a bounding box on a 2D grid i.e. composed of latitudes and longitudes. For each latitude and longitude I want a S2 cell.These need to be "indexed" with a particular precision. That precision needs to be linked to a radius in kilometers or meters.

  3. Then I have a whole bunch of query coordinates completely unrelated to the above coordinates. So I can convert this coordinate to a index as well and maybe get's neighbors as well. These can be indexed at a lower precision.

  4. Then use this index to return nearest neighbors from the original bounding box. Here I am assuming some bit shifting will have to be done.

I have a highly optimized SkipList which does fast inserts and range queries. So the range query would return coordinates from the bounding box given the lower and upper range values from (3).

Is that possible with s2 geometry ?

advantage and disadavantage of s2

Who can tell me:
1.What's the advantage and disadavntage of s2? What scenes could s2 to be used?
2.Compare to R-Tree, what's the advantage and disadvantage of s2?
Thanks!

Is googletest optional or not?

The Readme says

Requirements for End Users

  • ...
  • googletest testing framework (to build tests and example programs, optional)

Despite this, the s2testing library is included in the build unconditionally, which in turn includes the file s2shapeutil_testing.cc, which includes gtest/gtest.h.

So it seems to me that googletest is required in practice. I'm not sure if the readme just needs to be updated to say that googletest is required or if the s2testing library should be included in the conditional test block.

Use a slightly more modern CMake

I find the CMake file is a bit out of date and I would like to rewrite it to make it easier to use. In preparation for that, I would like to bump the version to 3.5.
I think 3.5 is the lowest version it should be since Ubuntu 16.04 comes with 3.5. I don't think this should inconvenience people too much. Later versions of CMake are very easy to install and Ubuntu 18.04 comes with CMake 3.10.

Get cell ID for a given lat/lon

Given lat/lon, how do I get the cell ID at a certain level? I see a constructor for lat/lon only, which as far as I understand provides the cell ID at the maximum level only.

Cannot find S2MultiBooleanOperation class

Hello, friends,

I found in the s2boolean_operation.h file, the author mentioned S2MultiBooleanOperation which can do boolean operations on multiple objects. However I cannot find any where in the code that has this S2MultiBooleanOperation class. Any ideas why?

I need to union a set of S2Polygons and I find using S2BooleanOperation to do this union one by one to be very slow.

If anyone could give me some advise, that would be great! Thank you.

Best,

Support for python Encode / Decode

Hi,

I'm trying to encode and decode a polygon using as an example the C++ tests, and the Encoder() class doesn't seem to work the same, or maybe it isn't yet exposed in the SWIG files.

[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pywraps2 as s2
>>> london = s2.S2LatLng.FromDegrees(51.5001525, -0.1262355)
>>> src = s2.S2Polygon(s2.S2Cell(s2.S2CellId(london)))
>>> encoder = s2.Encoder()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Encoder'

Is there a different way to accomplish this in python?

How to build test programs?

I feel a little silly asking this, but is there some kind of magic required to build the test programs? I figured it was a simple way to check my installation of the library, but I cannot even get past the includes :)

$ cc -I/usr/local/include -I/opt/local/include -o term_index term_index.cc 
In file included from term_index.cc:21:
In file included from /usr/local/include/s2/s2earth.h:25:
In file included from /usr/local/include/s2/s1angle.h:28:
In file included from /usr/local/include/s2/s2point.h:22:
In file included from /usr/local/include/s2/util/math/vector.h:32:
In file included from /usr/local/include/s2/base/logging.h:54:
In file included from /usr/local/include/s2/base/log_severity.h:25:
/usr/local/include/s2/third_party/absl/base/log_severity.h:32:12: error: ISO C++ forbids forward references to 'enum' types
enum class LogSeverity : int {
           ^
/usr/local/include/s2/third_party/absl/base/log_severity.h:32:24: error: expected unqualified-id
enum class LogSeverity : int {
                       ^
/usr/local/include/s2/third_party/absl/base/log_severity.h:41:1: error: unknown type name 'constexpr'
constexpr std::array<absl::LogSeverity, 4> LogSeverities() {
^
/usr/local/include/s2/third_party/absl/base/log_severity.h:41:28: error: no member named 'LogSeverity' in namespace 'absl'
constexpr std::array<absl::LogSeverity, 4> LogSeverities() {
                     ~~~~~~^
/usr/local/include/s2/third_party/absl/base/log_severity.h:41:44: error: cannot define or redeclare 'LogSeverities' here
      because namespace 'absl' does not enclose namespace 'std'
constexpr std::array<absl::LogSeverity, 4> LogSeverities() {

Python API

Hi

Does the Python API support all native methods?

I would need set_min_level, set_max_level, and set_max_cells in S2RegionCoverer.

Or is it possible to access native methods from within python?

Kind regards

Why there are overlaps among adjacent google s2 cells.

Thank you for your contribution.I use S2RegionCoverer class to get specific region covering cells,and i get overlaps among adjacent google s2 cells.Here is my code.
` S2RegionCoverer::Options options;
options.set_min_level(level);
options.set_max_level(level);
S2RegionCoverer s2RegionCoverer(options);

// s2RegionCoverer.GetInteriorCovering(region,interior);
s2RegionCoverer->GetCovering(region,interior);I try three type ofregion,S2LatLngRect,S2Loop,S2Polygon,and the result is same.Could you give me some Suggest?

Missing files when installing

The file str_cat.h seems to be missing from installation in CMakelists.txt, causing failure when compiling with some of the s2 header files:

#include <s2/s2point_index.h>

int main() {
}  

Compiling this file gives an error:

$ g++ -std=c++11 test.cc 
In file included from /usr/local/include/s2/util/gtl/btree.h:74:0,
                 from /usr/local/include/s2/util/gtl/btree_map.h:34,
                 from /usr/local/include/s2/s2point_index.h:24,
                 from test.cc:1:
/usr/local/include/s2/util/gtl/layout.h:183:10: fatal error: s2/third_party/absl/strings/str_cat.h: No such file or directory
 #include "s2/third_party/absl/strings/str_cat.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
$ ls /usr/local/include/s2/third_party/absl/strings/
string_view.h
$

Effective overlap query

Does S2 support efficient overlap querying? I want to index polygons which can vary in size a lot (from room size to continent size), and efficiently check whether a point is within a region.
A nearby search would find me the nearby vertices only, but not those covering the point which could be far away.

S2Builder troubles

I'm trying to deal with feature to eliminate self-intersections. As written in s2builder.h

// - It can eliminate self-intersections by finding all edge pairs that cross
// and adding a new vertex at each intersection point.

and

// - Guaranteed minimum separation between edges and vertices other than
// their endpoints (similar to the goals of Iterated Snap Rounding). In
// other words, edges that do not intersect in the output are guaranteed
// to have a minimum separation between them."

Therefore when I use a builder I expect that output will meet the requrements to data for s2loop. But edges intersect point appears in output twice. That data is incorrect for s2loop.
I have checked a property of SnapFunction "min_edge_vertex_separation" and it is non zero.

// 5. A "min_edge_vertex_separation", the guaranteed minimum distance
// between edges and non-incident vertices in the output. This is
// generally a fraction of "snap_radius" where the fraction depends on
// the snap function.

In example below I'm trying to build s2loop from square with crossing diagonals. Here are many excess options, but i tried them all to be sure.

https://pastebin.com/WBpgn6Vj

This code crashs on S2loop::Init

/home/noscoper/s2geometry-master/src/s2/s2loop.cc:134 ERROR Edge 1 has duplicate vertex with edge 4
/home/noscoper/s2geometry-master/src/s2/s2loop.cc:287 FATAL Check failed: IsValid() Signal: SIGABRT (Aborted)

What is wrong? Is it my missunderstood or bug?

Support Intersects/Contains(polygon/loop) in S2Cap

I was looking at the code, and it'd be nice if I could check if S2Loop was in an S2Cap. Naively, it seems like you can take the existing code for S2Cap::Contains(const S2Cell& cell) and S2Cap::Intersects(const S2Cell& cell, ...) and just generalize it for an S2Loop, at a minimum, and maybe S2Rect and S2Poly as well. Would this be reasonable? Or is there a better way at handling this?

Obviously an arbitrary S2Region Intersects/Contains S2Region would be ideal, but I wasn't sure if that made sense to the other classes that extend S2Region.

Warnings with GCC 5.4

I noticed quite a lot of warnings in clang due to signed / unsigned integer comparison as well as structs that were forward declared as classes.

Would it be ok to submit a pull request which silences some of these ?

Compilation Error when using s2latlng

Hi,

I get the following error when compiling code that is using s2latlng:

In file included from /usr/local/include/s2/base/logging.h:54:0, from /usr/local/include/s2/util/math/vector.h:32, from /usr/local/include/s2/r2.h:22, from /usr/local/include/s2/s2latlng.h:28, ... (removed own files here) /usr/local/include/s2/base/log_severity.h:25:51: fatal error: s2/third_party/absl/base/log_severity.h: No such file or directory compilation terminated.

I think this has to to with the commit of March 5th (Make gflags and glog optional.). Maybe the cmake install configuration has to be adapted?
Using the commit of Feb 27 it worked fine.

If there is something that I am doing wrong pls let me know.

Thank you in advance
Best regards

CellUnion --> GeoJSON

Hi

What would be the easiest way to get from a S2CellUnion to MultiPolygons which can be used in GeoJSON or QGIS etc. to get a visual representation of the given S2CellUnion and overlay it with a city polygon for example?

Thx for any help

Could not call hidden method

Hi, I am fortunate to be able to use this S2 algorithm. I have to say that this is a great project. I admit I underestimated it. But when I use the swig python version, I can not use the method I want, pywraps2.S2RegionCoverer (), I can not use the set_min_level (), set_max_level (), set_max_cells () I was expecting because I found my project file Without these, I do not know where the problem is. If you can help me, I will be grateful.

Check failed: S2::IsUnitLength when creating CrossingEdgeQuery

Hello, first of all thanks for the great lib! I have been using the Go version successfully before but moving to C++ since I need S2ClosestEdgeQuery which is not ported yet.

However, I am having a strange issue when trying to create a S2CrossingEdgeQuery. I am using the following code:

int main(int argc, char* argv[]) {
    const auto& geo = readGeoJSON(argv[1], false);

    MutableS2ShapeIndex index;

    const auto& features = geo.get<feature_collection>();
    for (auto f : features) {
        std::vector<S2Point> pVector;
        const auto& p = f.geometry.get<polygon>();
        const auto& ring = p.at(0);
        for (auto coord: ring) {
            S2Point p = S2LatLng::FromDegrees(coord.y, coord.x).ToPoint().Normalize();
            pVector.push_back(p); 
        }
        pVector.pop_back();
        S2Loop loop(pVector);
        auto loopShape = absl::make_unique<S2Loop::Shape>(&loop);
        index.Add(absl::move(loopShape));
    }
    
    std::cout << "Create closest edge q" << std::endl;
    auto qtest = new S2ClosestEdgeQuery(&index);
    
    std::cout << "Create crossing edge q" << std::endl;
    auto query = new S2CrossingEdgeQuery(&index);
    std::cout << "Done!" << std::endl;
}

The readGeoJSON function will read the following GeoJSON:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              11.39007568359375,
              57.787696727659075
            ],
            [
              11.217041015625,
              57.676254483720356
            ],
            [
              11.483459472656248,
              57.66156546307091
            ],
            [
              11.53289794921875,
              57.81989228369527
            ],
            [
              11.39007568359375,
              57.787696727659075
            ]
          ]
        ]
      }
    }
  ]
}

To debug, I added the following to s2edge_crosser.h:257:

inline void S2EdgeCrosser::RestartAt(const S2Point* c) {
  S2_LOG(INFO) << *c;
  ...
}

What happens is that I see a bunch of logs like:

/s2geometry/src/s2/s2edge_crosser.h:258 INFO [0.52256, 0.105272, 0.846079]

however, when it gets to creating the S2CrossingEdgeQuery I see the following:

Create crossing edge q
/s2geometry/src/s2/s2edge_crosser.h:258 INFO [0, 0.105272, 0.846079]
/s2geometry/src/s2/s2edge_crosser.h:259 FATAL Check failed: S2::IsUnitLength(*c) Aborted

It seems like the first coordinate of the point is suddenly zero?
I'm sure this might be some issue on my part, but any help is greatly appreciated!

Export include directories

Adding the following line to CMakeLists.txt

target_include_directories(s2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)

would allow to seamlessly include S2 in a different CMake project like this:

list(APPEND CMAKE_MODULE_PATH "<path_to_s2geometry_folder>/third_party/cmake")
add_subdirectory(<path_to_s2geometry_folder> s2geometry)
target_link_libraries(<target_name> s2)

S2Polygon incorrectly covers the whole Earth

Hi, I am trying to initialize an S2Polygon from a bunch of loops by calling Normalize on each loop and then calling InitNested. The polygon is for San Jose, California. For some reason the polygon is coming out inverted, covering the whole Earth except San Jose, even though all of its constituent loops are normalized. Can you help?

Note: in all of my loops, the last vertex is the same as the first vertex. If I explicitly remove that identical last vertex, the issue goes away. I had thought that S2 would be OK with this imperfect data. Is there any functionality in S2 that I can use to not have to prune those vertices myself?

Here is a C++ program to replicate: https://paste.ee/p/7FAdB

compilation error because of deprecated BIGNUM functions in openssl 1.1

as of 8a8746c

compilation is failing on Arch because of openssl 1.1:

In file included from /home/akh/tmp/s2geometry/src/s2/s2predicates_internal.h:29:0,
                 from /home/akh/tmp/s2geometry/src/s2/s2edge_crossings.cc:28:
/home/akh/tmp/s2geometry/src/s2/util/math/exactfloat/exactfloat.h:516:10: error: field ‘bn_’ has incomplete type ‘BIGNUM {aka bignum_st}’
   BIGNUM bn_;
          ^~~
In file included from /usr/include/openssl/bn.h:32:0,
                 from /home/akh/tmp/s2geometry/src/s2/util/math/exactfloat/exactfloat.h:119,
                 from /home/akh/tmp/s2geometry/src/s2/s2predicates_internal.h:29,
                 from /home/akh/tmp/s2geometry/src/s2/s2edge_crossings.cc:28:
/usr/include/openssl/ossl_typ.h:80:16: note: forward declaration of ‘BIGNUM {aka struct bignum_st}’
 typedef struct bignum_st BIGNUM;
                ^~~~~~~~~
In file included from /home/akh/tmp/s2geometry/src/s2/s2predicates_internal.h:29:0,
                 from /home/akh/tmp/s2geometry/src/s2/s2edge_crossings.cc:28:
/home/akh/tmp/s2geometry/src/s2/util/math/exactfloat/exactfloat.h: In constructor ‘ExactFloat::ExactFloat()’:
/home/akh/tmp/s2geometry/src/s2/util/math/exactfloat/exactfloat.h:576:3: error: ‘BN_init’ was not declared in this scope
   BN_init(&bn_);
   ^~~~~~~
/home/akh/tmp/s2geometry/src/s2/util/math/exactfloat/exactfloat.h:576:3: note: suggested alternative: ‘BN_print’
   BN_init(&bn_);
   ^~~~~~~
   BN_print
make[2]: *** [CMakeFiles/s2.dir/build.make:879: CMakeFiles/s2.dir/src/s2/s2edge_crossings.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/s2.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

BN_init() was removed in OpenSSL 1.1.0; use BN_new() instead.
source https://www.openssl.org/docs/man1.1.0/crypto/BN_new.html

Solution for Arch is:
cmake -DOPENSSL_INCLUDE_DIR="/usr/include/openssl-1.0" -DOPENSSL_SSL_LIBRARY=/usr/lib/openssl-1.0/libssl.so ..

It will become an issue for every distribution with recent openssl.

Error while building on windows

C:\Users\shkil\Downloads\s2geometry-master\s2geometry-master\src\s2/third_party/absl/container/internal/layout.h(352): error C2971: std::tuple_element:

Request: Option to not require external dependencies for static linking scenarios

Hi, great to see the new version of S2 out - very cool!

I know a lot of people use the old version of S2 (us for example) and link it statically into their application. That was fairly easy to do with the old version, but now with the GFlags, GLog dependencies it's a lot more onerous and also affects downstream build system requirements.

Is there any chance you might consider an option to allow building the core without requiring any dependencies, aside from libssl of course.

Best

#include <vector> missing?

I got 5 errors on MacOS running make,

is there maybe

#include

missing in s2region.h and s2cap.h?

That at least seemed to solve the issues.

Python bindings installation path is incorrect

The current cmake configuration does not search for the correct python site-packages directory and install the bindings in PREFIX/share/python, so it can't be loaded by the interpreter as is.

One solution would be to look for site-packages directory via python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"

The right way is probably to use python itself to build & install the bindings.

Tag a release

Hey, having read #40, I'd like to push again for a tagged release. Reason for asking is that package managers, e.g. Homebrew, won't accept a package for S2 unless there is a tagged version. It would be very much appreciated.

S2 compatible with python3?

I followed the instructions as given here - http://s2geometry.io/about/platforms.html but I am getting these errors when I run cmake

-- The following features have been enabled:

  • GFLAGS, allows changing command line flags.
  • GLOG, provides logging configurability.
  • SHARED_LIBS, builds shared libraries instead of static.

GTEST_ROOT: /usr/src/googletest
File "/usr/lib/python3.6/site.py", line 183
file=sys.stderr)
^
SyntaxError: invalid syntax
CMake Error at src/python/CMakeLists.txt:30 (install):
install TARGETS given no LIBRARY DESTINATION for module target "_pywraps2".

CMake Error at src/python/CMakeLists.txt:31 (install):
install FILES given no DESTINATION!

-- Configuring incomplete, errors occurred!
See also "/home/winash12/S2source/s2geometry/CMakeFiles/CMakeOutput.log".
See also "/home/winash12/S2source/s2geometry/CMakeFiles/CMakeError.log".
This is on Ubuntu 18.04 LTS.

gcc undefined reference to ‘S2Testing::RandomPoint()’

After compile and install s2, In the s2geometry/doc/examples/ directory. I run the following command
g++ term_index.cc -std=c++17 -I/usr/local/lib/ -ls2
it throw out link error:
/tmp/ccxc1b2Q.o:in ‘main’:
term_index.cc:(.text+0x5a):undefined reference to ‘S2Testing::RandomPoint()’
term_index.cc:(.text+0x2b5):undefined reference to ‘S2Testing::RandomPoint()’
collect2: error: ld returned 1 exit status
Actually, I have included the s2testing.h yet.
#include "s2/s2testing.h"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.