Skip to content
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

*: Geospatial design #38916

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

Conversation

dveeden
Copy link
Contributor

@dveeden dveeden commented Nov 4, 2022

What problem does this PR solve?

Issue Number: ref #6347

Problem Summary:

First draft of a design for geospatial support.

What is changed and how it works?

Check List

Tests

  • No code

Release note

None

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 4, 2022
@dveeden dveeden requested review from mjonss and bb7133 November 4, 2022 16:01
Copy link
Contributor

@mjonss mjonss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the design is ready for review.

docs/design/2022-10-27-geospatial.md Outdated Show resolved Hide resolved
* [Detailed Design](#detailed-design)
* [Test Design](#test-design)
* [Functional Tests](#functional-tests)
* [Scenario Tests](#scenario-tests)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* [Scenario Tests](#scenario-tests)

docs/design/2022-10-27-geospatial.md Outdated Show resolved Hide resolved
docs/design/2022-10-27-geospatial.md Show resolved Hide resolved

## Introduction

Add support for storing and working with Geospatial data.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe be a bit more clear what 'working with' means here, perhaps exemplify with geospatial functions like ...


The focus is to implement the most used functions that are part of the OpenGIS standards and MySQL first and later on the MySQL specific functions where needed for compatibility.

#### Phase 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to differentiate with 'Data types' support phases.

Suggested change
#### Phase 1
#### Functions support Phase 1


Support for GeoHash functions makes it possible to use regular indexes with generated columns.

Example of `ST_Geohash()` with MySQL 8.0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should ST_GeoHash() be included in the "Functions" section above? Or is it to be implemented when adding support for Geospatial indexes?


As you can see in the example `POINT(1 0)` and `POINT(1.01 0)` have the same prefix. More information about what prefix length gives what precision can be found [on wikipedia](https://en.wikipedia.org/wiki/Geohash#Digits_and_precision_in_km).

Geohash support is useful both for indexing and compatibility. Implementing this should be relatively easy. However this doesn't fully replace geospatial indexes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is GeoHash() indexing limited to POINTs? Then I think it can be mentioned as a reason for why it does not fully replace geospatial indexes (which I assume at least should support some kind of bounding box lookup).


## Impacts & Risks

This adds a new dependency: [github.com/twpayne/go-geom](https://pkg.go.dev/github.com/twpayne/go-geom). The BSD-2-Clause license should be fine. The basic geometric types in this package are ok, but the features that do things like comparing features, calculating distances etc. are not (yet) on the same level as [Boost.Geometry](https://github.com/boostorg/geometry). This means that we may have to add more dependencies and/or implement some missing features ourselves.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to use CGO to link to the BOOST C++ geometry library to get very good implementation compatibility with MySQL? (If so, would the boost licence be compatible/usable?


## Client support

Working with geospatial data is possible with MySQL Client or mycli. However a GUI tool makes many things much easier. MySQL Workbench has [a spatial viewer](https://dev.mysql.com/blog-archive/mysql-workbench-6-2-spatial-data/) since version 6.2. This works with minimal geospatial support in TiDB. However [DBeaver](https://github.com/dbeaver/dbeaver) has a much more advanced [geospatial viewer](https://dbeaver.com/docs/wiki/Working-with-Spatial-GIS-data/).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that DBeaver does not work with the minimal geospatial support in TiDB?

@dveeden dveeden marked this pull request as ready for review January 24, 2023 08:10
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 24, 2023
Copy link

codecov bot commented Dec 19, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.7611%. Comparing base (c48a5ec) to head (d4dde22).
Report is 5556 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #38916         +/-   ##
=================================================
+ Coverage   62.2486%   79.7611%   +17.5124%     
=================================================
  Files           910       3553       +2643     
  Lines        290329    1035933     +745604     
=================================================
+ Hits         180726     826272     +645546     
- Misses        95432     171152      +75720     
- Partials      14171      38509      +24338     

@dveeden dveeden marked this pull request as draft June 27, 2024 10:44
@ti-chi-bot ti-chi-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants