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

[6.x] Added support for separation between geometry and geography types #30545

Merged
merged 7 commits into from Nov 14, 2019

Conversation

@raymondtri
Copy link
Contributor

raymondtri commented Nov 8, 2019

When using postgres with postgis-created types.

This is very important as without these changes, you are pigeon-holed into having to use geography spatial types only.

The problem with this has many facets, one being that generally geometry should be used over geography. Defaulting to the more advanced type also limits the availability of functions included in PostGIS. For more information on the advantages versus disadvantages, the PostGIS literature dives into it here.

With this in mind, the default PostGIS types have been switched to geometry instead of geography. To enable geography, a fluent property is available, which defaults to SRID 4326:
$table->column('col')->geography()

Furthermore, users will now be able to specify spatial reference schemas for projection purposes (which has been available since PostGIS 2.2 (released 2015) and above). You can even add your own spatial reference systems if you decide you want to do spatial geography for non-earth environments. This is made available via the ->projection fluent property, and available on both geography and geometry types.

A geometric type existing in 4326:
$table->column('col')->projection(4326)
A geographic type existing in 4326:
$table->column('col')->geography()->projection(4326)

To keep things simple, there are some defaults (for instance, geographies must have a spatial reference system, but default to SRID:4326.

raymondtri added 3 commits Nov 8, 2019
…n using postgres with postgis-created types
@GrahamCampbell GrahamCampbell changed the title Added support for separation between geometry and geography types [6.x] Added support for separation between geometry and geography types Nov 8, 2019
raymondtri added a commit to raymondtri/framework that referenced this pull request Nov 9, 2019
raymondtri added 2 commits Nov 9, 2019
@raymondtri

This comment has been minimized.

Copy link
Contributor Author

raymondtri commented Nov 9, 2019

In an effort to make this non-breaking for 6.x (breaking change moved to 7.x PR) to provide support for specifying a geometry type:

  • The ->isGeometry fluent property has been added.
  • The ->geography fluent property is removed
  • The ->projection fluent property is still recognized
@GrahamCampbell

This comment has been minimized.

Copy link
Member

GrahamCampbell commented Nov 9, 2019

I think it would be less confusing to only implement this on 7.x.

@raymondtri

This comment has been minimized.

Copy link
Contributor Author

raymondtri commented Nov 9, 2019

It would be less confusing, howerever there should be a way to use the PostGIS-recommended geometry data types, without needing to build a custom grammar package.

This is especially important in the LTS version of Laravel, when the change is very simple if implemented inside of Laravel.

@driesvints

This comment has been minimized.

Copy link
Member

driesvints commented Nov 11, 2019

Closing this because of the breaking change.

@driesvints driesvints closed this Nov 11, 2019
@raymondtri

This comment has been minimized.

Copy link
Contributor Author

raymondtri commented Nov 11, 2019

@driesvints I refactored this in #94b9da7 so it would be non-breaking, can you tell me where it is breaking?

@driesvints

This comment has been minimized.

Copy link
Member

driesvints commented Nov 11, 2019

@raymondtri you're correct, apologies.

@driesvints driesvints reopened this Nov 11, 2019
@taylorotwell taylorotwell merged commit 3f7ee80 into laravel:6.x Nov 14, 2019
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/styleci/pr The analysis has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.