-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
Add support for geography columns #1627
Conversation
As a side note, I'm getting this error when running
|
9da770e
to
36dcbc2
Compare
This is because your rust version is a bit too old for this lint. We had to allow said lint because otherwise CI failed.. |
Nice, that did the trick, thanks. |
btw, we may want to disable pre commit hooks - it seems it is more of a nuisance than help |
also, we could improve the |
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.
Nice! One possible issue - while this approach works, and does not affect existing cases, I am not sure this is the right path for the geography types -- essentially you are converting all geographies to geometries, loosing some information. This may result in bugs reported by the geography-using people of incorrect visualizations... We may need some tests that are "geography-specific" (like polygons that cross the anti-meridian, or something else similarly non-trivial?).
@@ -38,6 +39,7 @@ WITH | |||
f_geometry_column AS geom, | |||
srid, | |||
type, | |||
-- 'geometry' AS column_type |
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.
need?
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.
That's how we could distinguish between tables using a geometry vs geography column.
I initially thought we might need it, but the approach of simply casting everything to ::geometry
seems to be working well, so this can be removed unless we want to expose this information to the code for some other reason.
@@ -50,6 +52,33 @@ WITH | |||
geometry_columns.f_table_name = sic.table_name AND | |||
geometry_columns.f_geometry_column = sic.column_name | |||
GROUP BY 1, 2, 3, 4, 5, 6), | |||
-- |
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.
is geography metadata here substantially different from geometry to require a separate section? not a biggie, and not a blocker, but if possible - we should have just one consolidated sub-table here
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.
There are a few substantials differences here: geography columns are defined in the geography_columns
table, and the name of the column containing the name of the spatial column is f_geography_column
. I agree that the duplication here is not ideal, but I couldn't think of a better alternative to cover both use cases.
Perhaps one thing we could do is move the JOIN
s to the UNION
'd table, at the cost of adding yet another "with query" block? Not sure which of the two would be more preferable.
DROP TABLE IF EXISTS table_source_geog; | ||
CREATE TABLE table_source_geog(gid serial PRIMARY KEY, geog geography(GEOMETRY, 4326)); | ||
|
||
INSERT INTO table_source_geog(geog) values ('SRID=4326;POINT(0 0)'::geography); |
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.
we usually prefer to have the same type of elements in a table - if you mix points and linestrings, what would be the type of the MVT data? Not a blocker, but for a test we may want a few more tables like this .... although perhaps one mixed table is also good to test the results
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 copied this from the table_source
test case, which is doing the same for geometries.
I agree that we can probably use a few more tests for the geography columns.
Any recommendations on the best approach for this? I could just copy/paste all the tests we have for geometries to run them on geographies as well, but that feels like a lot of duplication, so I was wondering if there could be a more clever way?
I don't think converting geographies to geometries would cause any issue: the main difference between geometry and geography column is how the two are treated internally by postgis, but from a user perspective the data returned in both cases should be equivalent. It's also going to be converted to carthesian (EPSG:3857) coordinates anyways, so it can be encoded in a vector tile. I haven't tested geometries crossing the anti-meridian yet (going to do it now) but I assume they should work as well as their geometry counterparts. AFAIK it's the map renderer (maplibre) that needs to know how to draw the "shortest path" between two points; the vector tile only contains a list of points, but no other information about the path between them. Not sure if there's a convenient way to write an automated test for that, or they can only be verified visually? The only place I think casting to geometry on the fly can negatively affect performance is the |
i think this is ok to merge. I would still like a few more test cases, but that could be done separately |
This addresses #1503
Tests seem to pass, at least as far as detecting the table is concerned.
I feel like this could use some more tests to test the actual tile generation, I could probably use some pointers on the best way to go about that.
I'm fairly new to Rust (and this project), so please be kind 😛
It seems to be doing a good job creating tiles for a few NOAA layers imported in a postgis database and rendered in maplibre: