Giter Site home page Giter Site logo

s2geom-poc's People

Contributors

ppkrauss avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

s2geom-poc's Issues

Need for cell's GeoJSON

Each cell ID of S2 Geometry can be represented geometrically, so, this representation can be expessed as a GeoJSON polygon.

We need a funcion that return the GeoJSON of a cell, and similar function that returns the Union of a set of cells, as multipolygon.

check metric and convert area to square meters

Supposing that areas returned by S2 functions are offered in steradians... As this comment at C++ source s2/s2testing.h

the actual metric for a cell is obtained by integrating the differential quantity,
which is not constant across the cell. Therefore cells at low levels
(bigger cells) have smaller variations

and the implementation of conversion functions at s2testing.cc:

const double S2Testing::kEarthRadiusKm = 6371.01;

double S2Testing::AreaToMeters2(double steradians) {
  return 1e6 * AreaToKm2(steradians);
}

double S2Testing::AreaToKm2(double steradians) {
  return steradians * kEarthRadiusKm * kEarthRadiusKm;
}

About kEarthRadiusKm, seems the "Average distance from center to surface", that can be 6,371.230 km by wikipedia. Nominal value: 6.3781ร—10^6 m but in ellipsoid can range from 6,357 to 6,378 km. Ideal is the "Median distance from center to surface", so 6371010 m is near it.

The area in steradians is useful for precise corrections and integration (and/or positioning each cell in its correct altitude). For any other use the m2 is the standard, like PostGIS functions.

The sugestion is to add a flag in the *_exact_area() functions (like ST_Area) to be true for m2 and false for steradians.

error on get area from negative cellid

There are an error on assert02 line 11, all areas are equal (and same as a leaf area). Seems that it is a problem with s2_cellid_parent( s2_cellid_from_latlng(-23.55041,-46.63394), 1+i*5), but the test below, using tokens (the test on token area transform was good) show that is not:

WITH cells AS (
 SELECT 1+i*5 as level,
        s2_cellid_parent( s2_cellid_from_latlng(-23.55041,-46.63394), 1+i*5) pt1_id,
        s2_cellid_parent( s2_cellid_from_latlng(15,15), 1+i*5) pt2_id
 FROM generate_series(0,4) t(i)
) 
  SELECT level, pt1_id, pt2_id,
         s2_token_from_cellid(pt1_id) "pt1_token",
         s2_token_from_cellid(pt2_id) "pt2_token"
  FROM cells;
level pt1_id pt2_id pt1_token pt2_token
1 -7782220156096217088 1441151880758558720 94 14
6 -7723954835917111296 1230327123202277376 94cf 1113
11 -7724137629725229056 1230478580929003520 94ce59c 111389c
16 -7724137722872332288 1230478344437366784 94ce59aa5 11138988f
21 -7724137722769309696 1230478344653635584 94ce59aa5624 11138988fce4

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.