Skip to content

Commit

Permalink
Fix pint
Browse files Browse the repository at this point in the history
  • Loading branch information
faytekin committed Mar 14, 2024
1 parent c6af616 commit 5959a9e
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 70 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added
- Laravel 11.x support

## [1.5.0](https://github.com/clickbar/laravel-magellan/tree/1.5.0) - 2024-01-19

### Added
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/UpdatePostgisColumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Illuminate\Support\Str;
use ReflectionClass;
use Symfony\Component\Finder\SplFileInfo;

use function Termwind\render;
use function Termwind\renderUsing;

Expand Down Expand Up @@ -304,7 +305,7 @@ private function getAfterLastTraitOrClassPosition(Collection $modelCodeLines, Re
}

/**
* @param bool $overwrite In case of overwrite, we don't need to add a blank upfront
* @param bool $overwrite In case of overwrite, we don't need to add a blank upfront
*/
private function insertPostgisColumns(Collection $lines, int $startLine, array $columns, bool $overwrite)
{
Expand Down
2 changes: 1 addition & 1 deletion src/DBAL/Types/GeographyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getNormalizedPostGISColumnOptions(array $options = []): array
{
$srid = (int) ($options['srid'] ?? 4326);

if (0 === $srid) {
if ($srid === 0) {
$srid = 4326;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Data/Geometries/Geometry.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Support\Facades\Config;
use JsonSerializable;

abstract class Geometry implements GeometryInterface, JsonSerializable, \Stringable
abstract class Geometry implements \Stringable, GeometryInterface, JsonSerializable
{
public function __construct(
protected ?int $srid = null,
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Builder/BuilderMacros.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function stSelect()
* @param string|null $as
* @return static
*/
return function (MagellanBaseExpression $magellanExpression, string $as = null) {
return function (MagellanBaseExpression $magellanExpression, ?string $as = null) {
$asOrDefault = mb_strtolower($as ?? $magellanExpression->getDefaultAs());

if ($this instanceof EloquentBuilder) {
Expand Down Expand Up @@ -150,7 +150,7 @@ public function stFrom()
* @param \Clickbar\Magellan\Database\MagellanExpressions\MagellanSetExpression $magellanExpression
* @return static
*/
return function (MagellanSetExpression $magellanExpression, string $as = null) {
return function (MagellanSetExpression $magellanExpression, ?string $as = null) {
// NOTE: the `as` field has to be included in the DB expression instead of using the `from` method with the
// `as` parameter, because the latter will try to use the expression in a string concatenation with `as`.
/** @var Builder $this */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,6 @@ public static function zMin($geometry): MagellanNumericExpression
/**
* Returns a bounding box expanded from the bounding box of the input, either by specifying a single distance with which the box should be expanded on both axes, or by specifying an expansion distance for each axis. Uses double-precision. Can be used for distance queries, or to add a bounding box filter to a query to take advantage of a spatial index.
*
* @param float|Expression|\Closure|null $unitsToExpand
* @param float|Expression|\Closure|null $dx
* @param float|Expression|\Closure|null $dy
* @param float|Expression|\Closure|null $dz
* @param float|Expression|\Closure|null $dm
*
* @see https://postgis.net/docs/ST_Expand.html
*/
Expand Down Expand Up @@ -193,8 +188,6 @@ public static function expand($geometry, float|Expression|\Closure|null $unitsTo
/**
* Returns the estimated extent of a spatial table as a box2d. The current schema is used if not specified. The estimated extent is taken from the geometry column's statistics. This is usually much faster than computing the exact extent of the table using ST_Extent or ST_3DExtent.
*
* @param string|Expression|\Closure|null $schemaName
* @param bool|Expression|\Closure|null $parentOnly
*
* @see https://postgis.net/docs/ST_EstimatedExtent.html
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public static function boundary($geometry): MagellanGeometryExpression
/**
* Orders by the diagonal of the supplied geometry's bounding box as a LineString. The diagonal is a 2-point LineString with the minimum values of each dimension in its start point and the maximum values in its end point. If the input geometry is empty, the diagonal line is a LINESTRING EMPTY.
*
* @param bool|Expression|\Closure|null $fits
*
* @see https://postgis.net/docs/ST_BoundingDiagonal.html
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ trait MagellanGeometryProcessingFunctions
* A negative distance shrinks the geometry rather than expanding it. A negative distance may shrink a polygon completely, in which case POLYGON EMPTY is returned.
* For points and lines negative distances always return empty results.
*
* @param float|Expression|\Closure|null $styleMitreLevel
*
* @see https://postgis.net/docs/ST_Buffer.html
*/
Expand Down Expand Up @@ -74,7 +73,6 @@ public static function buildArea($geometry): MagellanGeometryExpression
/**
* Computes a point which is the geometric center of mass of a geometry. For [MULTI]POINTs, the centroid is the arithmetic mean of the input coordinates. For [MULTI]LINESTRINGs, the centroid is computed using the weighted length of each line segment. For [MULTI]POLYGONs, the centroid is computed in terms of area. If an empty geometry is supplied, an empty GEOMETRYCOLLECTION is returned. If NULL is supplied, NULL is returned. If CIRCULARSTRING or COMPOUNDCURVE are supplied, they are converted to linestring with CurveToLine first, then same than for LINESTRING
*
* @param bool|Expression|\Closure|null $useSpheroid
*
* @see https://postgis.net/docs/ST_Centroid.html
*/
Expand All @@ -93,8 +91,6 @@ public static function centroid($geometry, bool|Expression|\Closure|null $useSph
/**
* Returns a "smoothed" version of the given geometry using the Chaikin algorithm. See Chaikins-Algorithm for an explanation of the process. For each iteration the number of vertex points will double. The function puts new vertex points at 1/4 of the line before and after each point and removes the original point. To reduce the number of points use one of the simplification functions on the result. The new points gets interpolated values for all included dimensions, also z and m.
*
* @param int|Expression|\Closure|null $iterations
* @param bool|Expression|\Closure|null $preserveEndPoints
*
* @see https://postgis.net/docs/ST_ChaikinSmoothing.html
*/
Expand All @@ -106,8 +102,7 @@ public static function chaikinSmoothing($geometry, int|Expression|\Closure|null
/**
* A concave hull of a geometry is a possibly concave geometry that encloses the vertices of the input geometry. In the general case the concave hull is a Polygon. The polygon will not contain holes unless the optional param_allow_holes argument is specified as true. The concave hull of two or more collinear points is a two-point LineString. The concave hull of one or more identical points is a Point.
*
* @param float|Expression|\Closure $pctconvex controls the concaveness of the computed hull. A value of 1 produces the convex hull. A value of 0 produces a hull of maximum concaveness (but still a single polygon). Values between 1 and 0 produce hulls of increasing concaveness. Choosing a suitable value depends on the nature of the input data, but often values between 0.3 and 0.1 produce reasonable results.
* @param bool|Expression|\Closure|null $allowHoles
* @param float|Expression|\Closure $pctconvex controls the concaveness of the computed hull. A value of 1 produces the convex hull. A value of 0 produces a hull of maximum concaveness (but still a single polygon). Values between 1 and 0 produce hulls of increasing concaveness. Choosing a suitable value depends on the nature of the input data, but often values between 0.3 and 0.1 produce reasonable results.
*
* @see https://postgis.net/docs/ST_ConcaveHull.html
*/
Expand All @@ -131,7 +126,6 @@ public static function convexHull($geometry): MagellanGeometryExpression
/**
* Return the Delaunay triangulation of the vertices of the input geometry. Output is a COLLECTION of polygons (for flags=0) or a MULTILINESTRING (for flags=1) or TIN (for flags=2). The tolerance, if any, is used to snap input vertices together.
*
* @param float|Expression|\Closure|null $tolerance
*
* @see https://postgis.net/docs/ST_DelaunayTriangles.html
*/
Expand All @@ -143,8 +137,6 @@ public static function delaunayTriangles($geometry, float|Expression|\Closure|nu
/**
* Filters out vertex points based on their M-value. Returns a geometry with only vertex points that have a M-value larger or equal to the min value and smaller or equal to the max value. If max-value argument is left out only min value is considered. If fourth argument is left out the m-value will not be in the resulting geometry. If resulting geometry have too few vertex points left for its geometry type an empty geometry will be returned. In a geometry collection geometries without enough points will just be left out silently.
*
* @param float|Expression|\Closure|null $max
* @param bool|Expression|\Closure|null $returnM
*
* @see https://postgis.net/docs/ST_FilterByM.html
*/
Expand All @@ -156,7 +148,7 @@ public static function filterByM($geometry, float|Expression|\Closure $min, floa
/**
* Generates a given number of pseudo-random points which lie within the input area.
*
* @param int|Expression|\Closure|null $seed is used to regenerate a deterministic sequence of points, and must be greater than zero.
* @param int|Expression|\Closure|null $seed is used to regenerate a deterministic sequence of points, and must be greater than zero.
*
* @see https://postgis.net/docs/ST_GeneratePoints.html
*/
Expand All @@ -168,9 +160,6 @@ public static function generatePoints($geometry, int|Expression|\Closure $number
/**
* Computes the approximate geometric median of a MultiPoint geometry using the Weiszfeld algorithm. The geometric median is the point minimizing the sum of distances to the input points. It provides a centrality measure that is less sensitive to outlier points than the centroid (center of mass).
*
* @param float|Expression|\Closure|null $tolerance
* @param int|Expression|\Closure|null $maxIterations
* @param bool|Expression|\Closure|null $failIfNotConverged
*
* @see https://postgis.net/docs/ST_GeometricMedian.html
*/
Expand All @@ -182,7 +171,6 @@ public static function geometricMedian($geometry, float|Expression|\Closure|null
/**
* Returns a LineString or MultiLineString formed by joining together the line elements of a MultiLineString. Lines are joined at their endpoints at 2-way intersections. Lines are not joined across intersections of 3-way or greater degree.
*
* @param bool|Expression|\Closure|null $directed
*
* @see https://postgis.net/docs/ST_LineMerge.html
*/
Expand All @@ -194,7 +182,7 @@ public static function lineMerge($geometry, bool|Expression|\Closure|null $direc
/**
* Returns the smallest circle polygon that contains a geometry.
*
* @param int|Expression|\Closure|null $numberOfSegmentsPerQuarterCircle The bounding circle is approximated by a polygon with a default of 48 segments per quarter circle. Because the polygon is an approximation of the minimum bounding circle, some points in the input geometry may not be contained within the polygon. The approximation can be improved by increasing the number of segments. For applications where an approximation is not suitable ST_MinimumBoundingRadius may be used.
* @param int|Expression|\Closure|null $numberOfSegmentsPerQuarterCircle The bounding circle is approximated by a polygon with a default of 48 segments per quarter circle. Because the polygon is an approximation of the minimum bounding circle, some points in the input geometry may not be contained within the polygon. The approximation can be improved by increasing the number of segments. For applications where an approximation is not suitable ST_MinimumBoundingRadius may be used.
*
* @see https://postgis.net/docs/ST_MinimumBoundingCircle.html
*/
Expand All @@ -221,8 +209,6 @@ public static function orientedEnvelope($geometry): MagellanGeometryExpression
* All points of the returned geometries are not further than the given distance from the input geometry.
* Useful for computing parallel lines about a center line.
*
* @param int|Expression|\Closure|null $numSegQuarterCircle
* @param float|Expression|\Closure|null $styleMitreLevel
*
* @see https://postgis.net/docs/ST_OffsetCurve.html
*/
Expand Down Expand Up @@ -286,7 +272,6 @@ public static function sharedPaths($geometryA, $geometryB): MagellanGeometryExpr
/**
* Returns a "simplified" version of the given geometry using the Douglas-Peucker algorithm. Will actually do something only with (multi)lines and (multi)polygons but you can safely call it with any kind of geometry. Since simplification occurs on a object-by-object basis you can also feed a GeometryCollection to this function.
*
* @param bool|Expression|\Closure|null $preserveCollapsed
*
* @see https://postgis.net/docs/ST_Simplify.html
*/
Expand All @@ -298,8 +283,7 @@ public static function simplify($geometry, float|Expression|\Closure $tolerance,
/**
* Computes a simplified topology-preserving outer or inner hull of a polygonal geometry. An outer hull completely covers the input geometry. An inner hull is completely covered by the input geometry. The result is a polygonal geometry formed by a subset of the input vertices. MultiPolygons and holes are handled and produce a result with the same structure as the input.
*
* @param float|Expression|\Closure $vertexFraction The reduction in vertex count is controlled by the vertex_fraction parameter, which is a number in the range 0 to 1. Lower values produce simpler results, with smaller vertex count and less concaveness. For both outer and inner hulls a vertex fraction of 1.0 produces the orginal geometry. For outer hulls a value of 0.0 produces the convex hull (for a single polygon); for inner hulls it produces a triangle.
* @param bool|Expression|\Closure|null $isOuter
* @param float|Expression|\Closure $vertexFraction The reduction in vertex count is controlled by the vertex_fraction parameter, which is a number in the range 0 to 1. Lower values produce simpler results, with smaller vertex count and less concaveness. For both outer and inner hulls a vertex fraction of 1.0 produces the orginal geometry. For outer hulls a value of 0.0 produces the convex hull (for a single polygon); for inner hulls it produces a triangle.
*
* @see https://postgis.net/docs/ST_SimplifyPolygonHull.html
*/
Expand Down Expand Up @@ -338,8 +322,6 @@ public static function simplifyVW($geometry, float|Expression|\Closure $toleranc
* If the optional "theshold" parameter is used, a simplified geometry will be returned,
* containing only vertices with an effective area greater than or equal to the threshold value.
*
* @param float|Expression|\Closure|null $threshold
* @param int|Expression|\Closure|null $setArea
*
* @see https://postgis.net/docs/ST_SetEffectiveArea.html
*/
Expand All @@ -363,8 +345,8 @@ public static function triangulatePolygon($geometry): MagellanGeometryExpression
/**
* ST_VoronoiLines computes a two-dimensional Voronoi diagram from the vertices of the supplied geometry and returns the boundaries between cells in that diagram as a MultiLineString. Returns null if input geometry is null. Returns an empty geometry collection if the input geometry contains only one vertex. Returns an empty geometry collection if the extend_to envelope has zero area.
*
* @param float|Expression|\Closure|null $tolerance The distance within which vertices will be considered equivalent. Robustness of the algorithm can be improved by supplying a nonzero tolerance distance. (default = 0.0)
* @param mixed $extendToGeometry If a geometry is supplied as the "extend_to" parameter, the diagram will be extended to cover the envelope of the "extend_to" geometry, unless that envelope is smaller than the default envelope (default = NULL, default envelope is boundingbox of input geometry extended by about 50% in each direction).
* @param float|Expression|\Closure|null $tolerance The distance within which vertices will be considered equivalent. Robustness of the algorithm can be improved by supplying a nonzero tolerance distance. (default = 0.0)
* @param mixed $extendToGeometry If a geometry is supplied as the "extend_to" parameter, the diagram will be extended to cover the envelope of the "extend_to" geometry, unless that envelope is smaller than the default envelope (default = NULL, default envelope is boundingbox of input geometry extended by about 50% in each direction).
*
* @see https://postgis.net/docs/ST_VoronoiLines.html
*/
Expand All @@ -376,8 +358,8 @@ public static function voronoiLines($geometry, float|Expression|\Closure|null $t
/**
* ST_VoronoiPolygons computes a two-dimensional Voronoi diagram from the vertices of the supplied geometry. The result is a GeometryCollection of Polygons that covers an envelope larger than the extent of the input vertices. Returns null if input geometry is null. Returns an empty geometry collection if the input geometry contains only one vertex. Returns an empty geometry collection if the extend_to envelope has zero area.
*
* @param float|Expression|\Closure|null $tolerance The distance within which vertices will be considered equivalent. Robustness of the algorithm can be improved by supplying a nonzero tolerance distance. (default = 0.0)
* @param mixed $extendToGeometry If a geometry is supplied as the "extend_to" parameter, the diagram will be extended to cover the envelope of the "extend_to" geometry, unless that envelope is smaller than the default envelope (default = NULL, default envelope is boundingbox of input geometry extended by about 50% in each direction).
* @param float|Expression|\Closure|null $tolerance The distance within which vertices will be considered equivalent. Robustness of the algorithm can be improved by supplying a nonzero tolerance distance. (default = 0.0)
* @param mixed $extendToGeometry If a geometry is supplied as the "extend_to" parameter, the diagram will be extended to cover the envelope of the "extend_to" geometry, unless that envelope is smaller than the default envelope (default = NULL, default envelope is boundingbox of input geometry extended by about 50% in each direction).
*
* @see https://postgis.net/docs/ST_VoronoiPolygons.html
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static function isValidReason($geometry, ?ValidFlag $validFlag = null): M
* The params argument can be used to supply an options string to select the method to use for building valid geometry. The options string is in the format "method=linework|structure keepcollapsed=true|false".
*
*
* @param bool|null $keepCollapsed The "keepcollapsed" key is only valid for the "structure" algorithm, and takes a value of "true" or "false". When set to "false", geometry components that collapse to a lower dimensionality, for example a one-point linestring would be dropped.
* @param bool|null $keepCollapsed The "keepcollapsed" key is only valid for the "structure" algorithm, and takes a value of "true" or "false". When set to "false", geometry components that collapse to a lower dimensionality, for example a one-point linestring would be dropped.
*
* @see https://postgis.net/docs/ST_MakeValid.html
*/
Expand Down
Loading

0 comments on commit 5959a9e

Please sign in to comment.