koi2000 commented on code in PR #48695: URL: https://github.com/apache/doris/pull/48695#discussion_r2013321866
########## be/src/geo/geo_types.cpp: ########## @@ -476,6 +656,155 @@ std::string GeoPolygon::as_wkt() const { return ss.str(); } +bool GeoPolygon::intersects(const GeoShape* rhs) const { + switch (rhs->type()) { + case GEO_SHAPE_POINT: { + const GeoPoint* point = (const GeoPoint*)rhs; Review Comment: I need to get to the point variable in the subclass to determine if it's Intersects or not. ########## be/src/geo/geo_types.cpp: ########## @@ -299,6 +315,57 @@ const std::unique_ptr<GeoCoordinateListList> GeoPolygon::to_coords() const { return coordss; } +bool GeoPoint::intersects(const GeoShape* rhs) const { + switch (rhs->type()) { + case GEO_SHAPE_POINT: { + // points and points are considered to intersect when they are equal + const GeoPoint* point = (const GeoPoint*)rhs; + return *_point == *point->point(); + } + case GEO_SHAPE_LINE_STRING: { + const GeoLine* line = (const GeoLine*)rhs; + return line->intersects(this); + } + case GEO_SHAPE_POLYGON: { + const GeoPolygon* polygon = (const GeoPolygon*)rhs; + return polygon->intersects(this); + } + case GEO_SHAPE_CIRCLE: { + const GeoCircle* circle = (const GeoCircle*)rhs; + return circle->intersects(this); + } + default: + return false; + } +} + +bool GeoPoint::disjoint(const GeoShape* rhs) const { + return !intersects(rhs); +} + +bool GeoPoint::touches(const GeoShape* rhs) const { + switch (rhs->type()) { + case GEO_SHAPE_POINT: { + // always returns false because the point has no boundaries + return false; + } + case GEO_SHAPE_LINE_STRING: { + const GeoLine* line = (const GeoLine*)rhs; + return line->touches(this); + } + case GEO_SHAPE_POLYGON: { + const GeoPolygon* polygon = (const GeoPolygon*)rhs; + return polygon->touches(this); + } + case GEO_SHAPE_CIRCLE: { + const GeoCircle* circle = (const GeoCircle*)rhs; + return circle->touches(this); + } + default: Review Comment: Now Doris only supports Point, Line, Polygon, Circle, do I need to implement MultiPoint, etc.? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org