Skip to content
This repository was archived by the owner on May 19, 2020. It is now read-only.

Conversation

@jsanz
Copy link

@jsanz jsanz commented Dec 24, 2019

I realized that I skipped CleanInt and CleanNumeric on my last PR 😞. These two functions implemented the same approach as the as_numeric on OpenMapTiles repo, with the only difference being that these return NULL instead of -1. The approach of using an exception avoids running them in parallel.

Hence, I decided to bring the regular expression approach to these functions I proposed on openmaptiles/openmaptiles#728. Here there is already a testing mechanism, so I added more checks to ensure more cases are covered. I also improved a bit the tests to allow compare rounded results against a given number of decimals, instead of using floor.

Finally, I updated the Travis configuration, since the current one was not working properly. This took more than expected (in fact ended up almost using the same configuration used at CartoDB/cartodb-postgresql, but the outcome is good in my opinion, since we now can test all the functions in PostGIS 2.5 on Postgres 9.6, 10, 11, and 12 and PostGIS 3 on 12. You can see the build execution in my Travis account.

I also found another issue, the function OrientedEnvelope, equivalent to PostGIS 3 ST_OrientedEnvelope but implemented in SQL, yields different results in PostGIS 2.5 and 3. I haven't put time debugging the algorithm, we may want to open a new issue for this, but not sure about how much is worth, being PostGIS 3 the current stable release.

If this PR is merged, we can then make OpenMapTiles as_numeric to be just a wrapper to return a -1, or if it makes more sense, just replace the function to use CleanNumeric I actually prefer a function like this to return a null value instead of a value that is a valid input.

cc. @nyurik

Copy link
Member

@nyurik nyurik left a comment

Choose a reason for hiding this comment

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

looks good, thanks! two minor cleanups, and this is good to go.

@nyurik nyurik requested review from MartinMikita and eva-j December 24, 2019 17:27
@nyurik
Copy link
Member

nyurik commented Dec 24, 2019

@klokan could you enable https://travis-ci.org/openmaptiles/postgis-vt-util to run this? Thanks!

jsanz and others added 2 commits January 13, 2020 15:43
Co-Authored-By: Yuri Astrakhan <yuriastrakhan@gmail.com>
@jsanz jsanz requested a review from nyurik January 13, 2020 14:50
@jsanz
Copy link
Author

jsanz commented Jan 13, 2020

@nyurik thanks for your feedback 🤗

@eva-j @MartinMikita let me know if there's anything else I can do to improve this PR. After this, we can update the function in the OpenMapTiles repo as a simple case statement wrapping this function.

Copy link
Member

@nyurik nyurik left a comment

Choose a reason for hiding this comment

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

thanks, awesome work!

@nyurik nyurik merged commit 3876553 into openmaptiles:master Jan 13, 2020
@sfkeller
Copy link

Out of curiosity: Which query / function uses CleanInt(text)?
/cc @jsanz

@jsanz
Copy link
Author

jsanz commented Jan 22, 2020

@sfkeller this is a generic library of SQL functions.

In the context of OpenMapTiles CleanInt is not used (AFAIK) and CleanNumeric will eventually be used to replace as_numeric, but there's no PR for that yet, only a preliminary work here to have a function with the same parameter and expected output.

@jsanz jsanz deleted the cleanint-cleannumeric branch January 23, 2020 19:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants