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

Add geometry and geography from text Doctrine functions #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kolyunya
Copy link
Contributor

@Kolyunya Kolyunya commented Jan 7, 2021

I found myself using these functions extensively. They seem to be quite commonly used to me, that's why I wonder whether they can be included into the library.

@BenMorel
Copy link
Member

Hi, they can be useful indeed, though Geography is PostGIS-specific, so I'm not comfortable with including this function in the library.

I'd love to think about transparently supporting Geography first, as at the moment everything is calculated as a Geometry, and thus calculations with GPS coordinates cannot be performed in meters in PostGIS with brick/geo, AFAIK.

I'm not sure how brick/geo could support geographies transparently. In MySQL it is simpler, as some SRIDs (4326) will make calculations happen in meters, whereas to get the same result, you have to use Geography in PostGIS instead, if I'm not mistaken.

Maybe it would just be a matter on transparently using ST_GeographyFromText instead of ST_GeomFromText in the database engine for specific SRIDs?

@Kolyunya
Copy link
Contributor Author

Kolyunya commented Jan 24, 2021

calculations with GPS coordinates cannot be performed in meters in PostGIS with brick/geo.

@BenMorel calculations can be performed in meters. You just have to convert at least one parameter of a calculation function to a geography.

For example if you pass some st_GeographyFromText(...) and some geometry column to ST_DWithin it's going to convert it to the geography automatically and the calculations will be performed in meters.

@BenMorel
Copy link
Member

That's what I mean, brick/geo needs to explicitly use geographies (ST_GeographyFromText instead of ST_GeomFromText in the engine) when you want meters, but when? Should we do that automatically for SRID 4326, for example?

PostGIS may be the only GIS engine that distinguishes between Geometry and Geography; MySQL has a single Geometry type, and whether the calculations are performed in meters depends on the SRID. Not sure about SpatiaLite & GEOS, I'd be interested to see how it's handled there.

@Kolyunya
Copy link
Contributor Author

Should we do that automatically for SRID 4326, for example?

@BenMorel not sure. What is someone needs to use another SRID with geographies?

@BenMorel
Copy link
Member

What is someone needs to use another SRID with geographies?

Geographies imply using GPS coordinates, so there aren't many SRIDs that match. These could be hardcoded in the library to use Geographies instead of Geometries on PostGIS.

I'm not sure this is the best idea though, I'm open to suggestions!

@Kolyunya
Copy link
Contributor Author

Kolyunya commented Feb 2, 2021

Sorry, at this point I can not suggest any generic solution for that problem. In my project I solved it by manually casting geometries to geographies.

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 this pull request may close these issues.

2 participants