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 3D coordinates #102

Merged
merged 6 commits into from
Aug 22, 2018
Merged

Add 3D coordinates #102

merged 6 commits into from
Aug 22, 2018

Conversation

v1r0x
Copy link
Contributor

@v1r0x v1r0x commented Jul 31, 2018

Fix #18

I (hopefully) added a third dimension as optional paramter to all neccessary constructors/create functions. In functions that return the content have a 3d check as well.
The 3d check is implemented as is3d() which does a simple check on the first element in the geometry (e.g. first LineString in Polygon or first Polygon in MultiPolygon, ...). I don't know if there is a better check. Any idea/suggestion is much appreciated :)

cc @njbarrett

@coveralls
Copy link

coveralls commented Jul 31, 2018

Coverage Status

Coverage increased (+2.9%) to 87.166% when pulling 1a691ea on v1r0x:3d-geometries into 7c2b8cf on njbarrett:master.

@v1r0x
Copy link
Contributor Author

v1r0x commented Jul 31, 2018

Sorry for the commit/travis spam 😅
CI looks good now, besides the hhvm test. Any idea what's wrong with that @njbarrett ?

@njbarrett
Copy link
Collaborator

@v1r0x Thanks for your contribution. Sorry for the delay.
I couldn't work out why the HHVM tests were failing, but it all looks good otherwise so happy to merge.

@njbarrett njbarrett merged commit bc9f24b into mstaack:master Aug 22, 2018
@v1r0x
Copy link
Contributor Author

v1r0x commented Aug 22, 2018

Thanks for merging it! 🎉
Maybe I should have squashed the commits 😅

@spawn-guy
Copy link

@v1r0x does this PR cover Migrations support? i.e. Schema Blueprints

@v1r0x
Copy link
Contributor Author

v1r0x commented Jul 2, 2020

@spawn-guy Sorry, I think I don't understand your question. What do you want achive?

@spawn-guy
Copy link

spawn-guy commented Jul 6, 2020

@v1r0x i am referring to laravel database migrations and this (similar) piece of code

Schema::table('locations', static function (Blueprint $table) {
    $table->point('location')->nullable()->default(null); // GEOGRAPHY POINT column with SRID of 4326
});

what do i need to use/pass-as-parameter to create a 3D point column? not a 2D point(as it does now)

@v1r0x
Copy link
Contributor Author

v1r0x commented Jul 6, 2020

Good question. I think there should be no difference in storing 2D or 3D coordinates.
Have you tried something like that:

$lat = 10;
$lon = 5;
$alt = 250;
$l = new \App\Location();
$l->location = new Point($lat, $lon, $alt);
$l->save();

@spawn-guy
Copy link

spawn-guy commented Jul 6, 2020

@v1r0x yes i did ;) and, just to verify, i did it again just now

SQLSTATE[22023]: Invalid parameter value: 7 ERROR:  Geometry has Z dimension but column does not (SQL: update "locations" set "updated_at" = 2020-07-06 11:57:56, "location" = public.ST_GeogFromText('POINT Z(2 1 3)') where "id" = 42)

@v1r0x
Copy link
Contributor Author

v1r0x commented Jul 6, 2020

I think I only tested it with geography as column type, because that's what I use in my projects.
You might need something like this PR (#120) to create only 3d points.

Sorry for the confusion. It's been a long time working with that code here 😉

@spawn-guy
Copy link

@v1r0x yeah. that PR seems to do a similar thing for multipoligonZ. whelp, we need the same thing for pointZ. and i was thinking that this PR should have it included. to have a Complex approach on adding support for 3D-point/polygon/line/etc. guess not :/

chrisreedio referenced this pull request in reedtechus/laravel-postgis Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants