-
-
Notifications
You must be signed in to change notification settings - Fork 246
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
Z dimension not saved in db unless X or Y changed #364
Comments
Thanks for the detailed write-up. I'll start looking into this soon. |
@pcboy I looked into this and the reason is that in GEOS and RGeo implementations of Z and M coordinates, they are essentially just labels and not used in any computation (including equality checks). Ex. require 'rgeo'
fac = RGeo::Geographic.spherical_factory(has_z_coordinate: true)
p fac.point(1,2,3) == fac.point(1,2,4)
# => true
fac = RGeo::Geos.factory(has_z_coordinate: true)
p fac.point(1,2,3) == fac.point(1,2,4)
# => true For now, I think the best solution is to use @BuonOmo what are your thoughts on this? Is it worthwhile to look into including z and m in equality checks? It technically would be out of spec with GEOS then, but it is pretty confusing IMO. |
I think I'd stick with GEOS spec, to avoid having a heavy CAPI codebase and to keep clarity. This is not a strong opinion though |
I also agree that it's best to stick with the spec for the core gem. I wonder if there might be a solution for this repo or |
@keithdoggett this can be sensible indeed if it is needed by AR to trigger a change. |
I have a 3D point set in my database.
If I try to manually change the Z only.
I can see it correctly in memory.
But then if I
save!
my object, nothing is being saved (I can't see any SQL query being made, and no exception triggered).But now if I change the Y or the X, everything gets saved:
In my schema dump I have:
In my rgeo initializer I have:
I'm on:
Did I miss something obvious? The Z coordinate seem to never be saved unless X or Y changed.
EDIT: If I use ActiveModel::Dirty and manually set my lnglat attribute as dirty with
lnglat_will_change!
after setting the elevation, lnglat always gets saved properly. So it seems setting the Z value is failing the dirtiness check for some reason.The text was updated successfully, but these errors were encountered: