Skip to content

Polygon example #82

Answered by saibotk
meniv-nl asked this question in Q&A
Mar 19, 2024 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

Hey 👋

Sorry for the late reply, here is a simple example for adding a Polygon to the Ship model (has a polygon field called poly)

use Clickbar\Magellan\Data\Geometries\LineString;
use Clickbar\Magellan\Data\Geometries\Point;
use Clickbar\Magellan\Data\Geometries\Polygon;

// .... 

$ship->poly = Polygon::make([
    LineString::make([
        Point::makeGeodetic(1, 1),
        Point::makeGeodetic(2, 2),
        Point::makeGeodetic(3, 3),
        Point::makeGeodetic(1, 1),
    ]),
]);

$ship->save();

Hope this helps!

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@mikecobb-io
Comment options

@saibotk
Comment options

@mikecobb-io
Comment options

@saibotk
Comment options

Answer selected by meniv-nl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants