Skip to content

Commit

Permalink
Bounding box optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck ALARY committed Aug 6, 2023
1 parent 2df8c55 commit cf89dcc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
11 changes: 5 additions & 6 deletions src/Circle.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,10 @@ public function draw(Image $image, MapData $mapData): Circle
*/
public function getBoundingBox(): array
{
$distance = GeographicConverter::latLngToMeters($this->center, $this->edge);
$latLng1 = GeographicConverter::metersToLatLng($this->center, $distance, 0);
$latLng2 = GeographicConverter::metersToLatLng($this->center, $distance, 90);
$latLng3 = GeographicConverter::metersToLatLng($this->center, $distance, 180);
$latLng4 = GeographicConverter::metersToLatLng($this->center, $distance, 270);
return [new LatLng($latLng1->getLat(), $latLng4->getLng()), new LatLng($latLng3->getLat(), $latLng2->getLng())];
$distance = GeographicConverter::latLngToMeters($this->center, $this->edge) * 1.4142;
return [
GeographicConverter::metersToLatLng($this->center, $distance, 315),
GeographicConverter::metersToLatLng($this->center, $distance, 135)
];
}
}
16 changes: 3 additions & 13 deletions src/samples/sample3.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,14 @@
->setAnchor(Markers::ANCHOR_CENTER, Markers::ANCHOR_BOTTOM)
->addMarker(new LatLng(44.351933, 2.568113))
->addMarker(new LatLng(44.351510, 2.570020))
->addMarker(new LatLng(44.351873, 2.566250))
->addMarker(new LatLng(44.351073, 2.566480))
)
->addDraw(
(new Circle(
new LatLng(44.351933, 2.568113),
'FF0000',
5,
'FF0000CC'
))
(new Circle(new LatLng(44.351933, 2.568113), 'FF0000', 5, 'FF0000CC'))
->setEdgePoint(new LatLng(44.351510, 2.570020))
)
->addDraw(
(new Circle(
new LatLng(44.351933, 2.568113),
'FF0000',
5,
'FF0000CC'
))
(new Circle(new LatLng(44.351933, 2.568113), 'FF0000', 5, 'FF0000CC'))
->setRadius(40)
)
->fitToDraws(10)
Expand Down

0 comments on commit cf89dcc

Please sign in to comment.