New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geo spatial: 2. geography functions #2979
Conversation
29081e0
to
de31c73
Compare
4d52a75
to
340401e
Compare
1adae70
to
5e9d5c5
Compare
996532c
to
53b8b2b
Compare
53b8b2b
to
c1188d7
Compare
c1188d7
to
d56facc
Compare
d56facc
to
f5b54c6
Compare
f5b54c6
to
8beac94
Compare
Codecov Report
@@ Coverage Diff @@
## master #2979 +/- ##
==========================================
- Coverage 84.34% 84.20% -0.15%
==========================================
Files 1283 1296 +13
Lines 113684 115342 +1658
==========================================
+ Hits 95891 97122 +1231
- Misses 17793 18220 +427
Continue to review full report at Codecov.
|
|
||
bool Coordinate::isValid() const { return std::abs(x) <= 180.0 && std::abs(y) <= 90.0; } | ||
|
||
void Point::normalize() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coord.normalize() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method Coordinate::normalize is not used now.
For the illegal coordinate, we want to report an error directly, rather than normalize it for the user
}; | ||
|
||
struct Point { | ||
Coordinate coord; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use x,y
here directly, do we really need the coordinate struct ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two modeling approaches:
1:
Point: Coordinate;
LineString: A list of Coordinate;
Polygon: Lists of list of Coordinate;
2:
Point;
LineString: A list of Point;
Polygon: Lists of LineString.
Both are ok, but almost all geo libraries take the first approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent!
src/common/datatypes/Geography.cpp
Outdated
switch (shape()) { | ||
case GeoShape::POINT: { | ||
const auto& point = geom->point(); | ||
return std::abs(point.coord.x) <= 180.0 && std::abs(point.coord.y) <= 90.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider a macro or constexpr for representing the magic number 180.0
and 90.0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
void __clear() { clear(); } | ||
|
||
// TODO(jie) compare double correctly | ||
bool operator==(const Coordinate& rhs) const { return x == rhs.x && y == rhs.y; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abs(x - rhs) < eps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@@ -302,6 +308,94 @@ std::unordered_map<std::string, std::vector<TypeSignature>> FunctionManager::typ | |||
TypeSignature({Value::Type::DATASET, Value::Type::INT, Value::Type::STRING}, | |||
Value::Type::__EMPTY__), | |||
}}, | |||
// These geo functions of the ST prefix follow the Simple Feature Access and SQL/MM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does ST
means?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SQL/MM standard uses consistently the prefix ST for all tables, views, types, methods, and function names. The prefix stood originally for Spatial and Temporal. It was intended in the early stages of the standard development to define a combination of temporal and spatial extension.
See https://stackoverflow.com/questions/7234679/what-is-st-in-postgis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost all SQL databases use this standard when implementing geo spatial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM
* Geo spatial: 2. Add geo functions * add ByteOrderDataIOStream * add s2 util test * let Geography store variant * address yee's comments
For the definition of the geo function prefixed with ST, see the following documentation: