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

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.

@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
Copy link
Contributor Author

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
Copy link
Member

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

@raymondtri
Copy link
Contributor Author

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
Copy link
Member

Closing this because of the breaking change.

@driesvints driesvints closed this Nov 11, 2019
@raymondtri
Copy link
Contributor Author

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

@driesvints
Copy link
Member

@raymondtri you're correct, apologies.

@driesvints driesvints reopened this Nov 11, 2019
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.

5 participants