-
Notifications
You must be signed in to change notification settings - Fork 144
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 Custom SRID #76
Conversation
Changes Unknown when pulling 2e8374f on v1r0x:master into ** on njbarrett:master**. |
It's honestly been so long since I worked on this project I can't remember the intricacies, but I think you pretty much found the current show stopper. You need to figure out how you can tell the type of a field: Geometry or Geography. My suggestion is probably the latter. The user has to specify $postgisFields on all models anyway, perhaps telling them to specify whether a field is a Geometry or Geography could be a good idea? @njbarrett should probably weigh in here since he owns the project now. |
After some more testing I agree with you. I tried to get the datatype from the DB, but due to this line |
I updated the PR using option 2) from your comment @phaza. Was rather easy to do, but one thing which should be considered before making a decision:
|
ping @phaza and @njbarrett |
Is this ok to merge or any further update required? @njbarrett |
Hi @v1r0x sorry for delay in responding to this PR. |
Thanks for the response @njbarrett |
One possible solution: $postgisFields = ['geom', 'whatever', ...]; and add an additional array: $postgisTypes = [
'geom' => [
'type' => 'geography',
'srid' => -1 // may be ignored for geography
],
'whatever' => [
'type' => 'geography',
'srid' => 1337
]
] If array |
Changes Unknown when pulling 2e7b85e on v1r0x:master into ** on njbarrett:master**. |
1 similar comment
Changes Unknown when pulling 2e7b85e on v1r0x:master into ** on njbarrett:master**. |
I pushed my idea from above. Should keep backwards compat. |
@v1r0x Thanks. I think I've fixed the builds now. Could you please update your changes to the README as well explaining the new procedure |
@njbarrett Thanks for fixing the builds. I adjusted my changes in the README. Is this ok? |
I'm going to fix the coverage in another comnit. |
2 similar comments
Thanks @v1r0x ! Lets do this. Thanks for all your hard work. |
Released tag 3.2 with this |
You're welcome. Thanks for the support and merging it. |
This PR is based on #35
Additionally I fixed a broken test and added a new exception (if an unsupported geomtype or illegal srid is given). Based on @phaza s comments I tried to fix the models, but could not figure out what exactly needs to be fixed.
To check what's wrong I created a model (
Location
) based on the example and tried to set it's columnlocation3
(which is type geometry) to$location->location3 = new Point(37.422009, -122.084047);
. But this throws an error, because in the PostgisTrait.php file it usesST_GeogFromText
if the following check is trueif ($value instanceof GeometryInterface && ! $value instanceof GeometryCollection)
. My idea was to also check thegeomtype
parameter which is added in the Blueprint.php. Unfortunately I couldn't find a method to perform this check. Could anyone confirm that this is the correct idea or help me what to do ( @phaza @njbarrett ) ? Thanks!