-
Notifications
You must be signed in to change notification settings - Fork 18
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
🚧 use int for internal coordinate representation and add static function to convert coordinates to int/double and vice versa #320
Conversation
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.
a few general questions:
why classify this abug
?- does it make sense that these methods live in the
OSHDB
class? at first glance, it seems like that place looks a bit too prominent?! - basically what the implementation does to avoid rounding errors is to use a floating point division instead of a multiplication. note that divisions are not as fast as multiplications on typical CPUs, so this might come with a small(?) performance overhead. I'd guess that for us it wouldn't make a huge difference, but it would perhaps be nice to verify that by some benchmarking.
oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/util/ZGrid.java
Outdated
Show resolved
Hide resolved
oshdb/src/main/java/org/heigit/ohsome/oshdb/index/XYGridTree.java
Outdated
Show resolved
Hide resolved
oshdb/src/main/java/org/heigit/ohsome/oshdb/io/OSHDBOutput.java
Outdated
Show resolved
Hide resolved
oshdb/src/main/java/org/heigit/ohsome/oshdb/utils/ByteUtils.java
Outdated
Show resolved
Hide resolved
oshdb/src/main/java/org/heigit/ohsome/oshdb/utils/OSHDBTags.java
Outdated
Show resolved
Hide resolved
14819ee
to
f952994
Compare
revert conversation from long to double coordinate, from a division to a multiplication. Division over multiplication introduces a slightly worse performance, around 1.5 to 2 times slower. The rounding errors which will occur due the non exact floating point multiplication should be handled in the output methods.
reverting the conversion from long to double back to multiplication over division, makes this test fail, because of the rounding errors from the multiplication.
According to your question, it makes no sense for you, right? So where do you want to have this methods then?
You are right, the multiplication introduces a slightly worse performance. In this case I undo the conversion, to a multiplication over division. The now introduce rounding errors should be handled in outputing methods e.g. System.out.printf("%.7f, %.7f", lon, lat); or for geometries with a precision model Point point = ...;
var pm = new PrecisionModel(10000000);
var writer = new WKTWriter();
writer.setPrecisionModel(pm);
writer.write(point); |
If you ask me: I'd put it somewhere near where they belong conceptionally. And since the coordinates belong (only) to the |
OSHDBBoundingBox also use internally the long coordinate system, and do the long to double conversation. |
True. Then maybe call the utility class |
8db7266
to
a9e26a4
Compare
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.
I noticed that sometimes we perform Math.round
when converting from double to long, and some other times we only cast to (double)
. Should we be more consistent or does it not matter?
...tl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/extract/collector/StatsCollector.java
Outdated
Show resolved
Hide resolved
oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/util/ZGrid.java
Outdated
Show resolved
Hide resolved
oshdb/src/main/java/org/heigit/ohsome/oshdb/util/OSHDBBoundingBox.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Martin Raifer <[email protected]>
|
Changes proposed in this pull request:
improve conversion from long coordinate to double coordinate,
Type of change
Description
the current implementation leads to a "not so nice" representation of long value coordinate as a double coordinate
This pull request adds static functions to the OSHDB class
which improve the conversion from long value coordinates to double value and vice versa.
Checklist