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

[Bug] function ST_GeometryFromWKB result diff between doris and postgis #46619

Closed
2 of 3 tasks
ScalaFirst opened this issue Jan 8, 2025 · 1 comment · Fixed by #46661
Closed
2 of 3 tasks

[Bug] function ST_GeometryFromWKB result diff between doris and postgis #46619

ScalaFirst opened this issue Jan 8, 2025 · 1 comment · Fixed by #46661

Comments

@ScalaFirst
Copy link

Search before asking

  • I had searched in the issues and found no similar issues.

Version

2.1.7

What's Wrong?

function ST_GeometryFromWKB result diff between doris and postgis.
for example:
select st_astext(ST_GeometryFromWKB('01010000208A11000068270210774C5D40B8DECA334C3B4240'))
result:
POINT (1.461652102e-231 3.34424828009e-59)

but postgis:
select ST_asText('01010000208A11000068270210774C5D40B8DECA334C3B4240')
result:
POINT(117.194767000297 36.46326301008)

What You Expected?

return the same as postgis result
POINT(117.194767000297 36.46326301008)

How to Reproduce?

select st_astext(ST_GeometryFromWKB('01010000208A11000068270210774C5D40B8DECA334C3B4240'))

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@felixwluo
Copy link
Contributor

We also encountered this problem. I will take a look.

HappenLee pushed a commit that referenced this issue Jan 21, 2025
…ng (#46661)

### What problem does this PR solve?

Issue Number: close #46619

Root Cause:
```
1. Unnecessary floating-point number conversions in coordinate handling:
   1.1 converting double to string using absl::StrFormat
   1.2 converting string back to double using std::stod
each conversion caused precision loss.

2. Byte order handling issue in WKB parsing:
    2.1 using machine endian before properly reading WKB byte order flag
    2.2 this caused incorrect interpretation of coordinate values
```

Solution:
```
1. Remove unnecessary coordinate value conversions:
    1.1 directly use S2LatLng's degrees() value without string formatting
    1.2 increase output precision in print_s2point to 15 digits

2. Fix WKB byte order handling:
    2.1 read byte order flag first
    2.2 set correct byte order before parsing coordinates
```

Result:
 before:
 ```
 POINT (1.461652102e-231 3.34424828009e-59)
 ```
 after:
 ```
 POINT(117.194767000297 36.46326301008)
 ```
github-actions bot pushed a commit that referenced this issue Jan 21, 2025
…ng (#46661)

### What problem does this PR solve?

Issue Number: close #46619

Root Cause:
```
1. Unnecessary floating-point number conversions in coordinate handling:
   1.1 converting double to string using absl::StrFormat
   1.2 converting string back to double using std::stod
each conversion caused precision loss.

2. Byte order handling issue in WKB parsing:
    2.1 using machine endian before properly reading WKB byte order flag
    2.2 this caused incorrect interpretation of coordinate values
```

Solution:
```
1. Remove unnecessary coordinate value conversions:
    1.1 directly use S2LatLng's degrees() value without string formatting
    1.2 increase output precision in print_s2point to 15 digits

2. Fix WKB byte order handling:
    2.1 read byte order flag first
    2.2 set correct byte order before parsing coordinates
```

Result:
 before:
 ```
 POINT (1.461652102e-231 3.34424828009e-59)
 ```
 after:
 ```
 POINT(117.194767000297 36.46326301008)
 ```
github-actions bot pushed a commit that referenced this issue Jan 21, 2025
…ng (#46661)

### What problem does this PR solve?

Issue Number: close #46619

Root Cause:
```
1. Unnecessary floating-point number conversions in coordinate handling:
   1.1 converting double to string using absl::StrFormat
   1.2 converting string back to double using std::stod
each conversion caused precision loss.

2. Byte order handling issue in WKB parsing:
    2.1 using machine endian before properly reading WKB byte order flag
    2.2 this caused incorrect interpretation of coordinate values
```

Solution:
```
1. Remove unnecessary coordinate value conversions:
    1.1 directly use S2LatLng's degrees() value without string formatting
    1.2 increase output precision in print_s2point to 15 digits

2. Fix WKB byte order handling:
    2.1 read byte order flag first
    2.2 set correct byte order before parsing coordinates
```

Result:
 before:
 ```
 POINT (1.461652102e-231 3.34424828009e-59)
 ```
 after:
 ```
 POINT(117.194767000297 36.46326301008)
 ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants