Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Geographical Calculator Laravel Package

kmlaravel/laravel-geographical-calculator

A Laravel/PHP package for geographical calculations, offering distance and radius queries between coordinates using Haversine and related formulas. Easily find nearby records, compute distances in multiple units, and add location-aware features to your Eloquent models with a simple, fluent API.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Baseline note: No prior assessment existed. This is a first-pass evaluation derived almost entirely from the v2.2.0 release notes; the package's name, repository, license, maintainer, and version-support matrix were not supplied and must be confirmed before any commitment.

Architecture fit

  • The package exposes geometric primitives — points, sets of points, and areas — with operations such as "farthest point from a set" and "is point in area." This positions it as a pure-PHP, in-memory geometry helper, not a spatial database layer. It belongs in the domain/service layer of a Laravel application, behind an application-owned interface.
  • It is a good fit for bounded, low-cardinality problems: service-area eligibility checks, nearest/farthest depot or technician selection over a few hundred candidates, simple geofence validation at request time.
  • It is a poor fit as a substitute for PostGIS, MySQL ST_Contains, or a dedicated geo index. Any workflow that filters large tables by geometry must stay in the database; this package cannot push predicates down to SQL.

Integration feasibility

  • Both v2.2.0 changes are additive feature work on a minor version bump, which is a positive maintenance signal: the library is actively evolving and the authors are respecting semver (no breaking change implied).
  • Integration is conventional Composer + Laravel service provider/facade territory. Expect a composer require, optionally a publishable config, and no schema migration. Effort is low; the real cost is validating geometric correctness, not wiring.

Technical risk

  • Coordinate reference system ambiguity is the dominant risk. The notes do not state whether distances are Euclidean (planar) or geodesic (haversine/vincenty) and whether inputs are lat/lng degrees or projected units. If the library computes Euclidean distance over raw lat/lng, results are plausible-looking but materially wrong outside the equator. This must be verified empirically before use.
  • "Farthest point from a set" is O(n) per query with no stated indexing or bounding-box pruning. Acceptable at hundreds of points; unacceptable at hundreds of thousands inside a request cycle.
  • Area containment edge cases: boundary-inclusive vs boundary-exclusive semantics, polygons with holes, self-intersecting rings, antimeridian crossing, and points exactly on a vertex are all unspecified. Silent off-by-epsilon behaviour is the most likely production defect class.
  • Degenerate geometry handling: duplicate points, empty sets, single-point sets, zero-area polygons. farthest point on an empty set has no defined answer — behaviour (exception vs null vs INF) is unknown.
  • Floating-point determinism: results may differ across PHP builds/platforms, which complicates snapshot testing.

Key questions

  1. What CRS and units does the package assume, and is distance Euclidean or geodesic? Is there an explicit API for choosing?
  2. Is area containment boundary-inclusive? How are holes and antimeridian-spanning polygons handled?
  3. What is the algorithmic complexity and benchmark for farthest point at 1k / 100k / 1M points?
  4. What is the supported PHP and Laravel version matrix, and are PHP 8.3/8.4 and Laravel 11/12 covered?
  5. Who maintains it — single maintainer or team? License? Release cadence and security disclosure path?
  6. Test coverage and CI status; are the two new features covered by tests at release?
  7. Does it already wrap or conflict with geocoder-php, brick/geo, or similar if those are in the stack?

Integration Approach

Stack fit

  • Assumes a standard Laravel app on PHP 8.x with Composer. No queue, cache, or database dependency is implied — which is good for portability and bad for scale (nothing is precomputed for you).
  • Introduce it as an implementation detail behind a first-party interface (e.g. GeoService with farthestFrom() and contains()), so the package can be swapped for PostGIS, brick/geo, or a custom haversine implementation without touching call sites. This is the single highest-value integration decision given the unknowns.

Migration path

  • No data migration and no schema change are expected for a minor release of a computation-only library. Confirm by diffing the changelog and composer.json constraints.
  • Pin with a caret constraint (^2.2) and commit the lockfile. Because v2.2.0 is additive, an in-place bump from 2.0/2.1 should be safe; if you are on 1.x, treat it as a major and re-verify the point/area API signatures.

Compatibility

  • Verify against your actual PHP and Laravel versions before merging — Laravel service-provider auto-discovery and facade aliases are common breakage points across major framework versions.
  • Check transitive dependencies for a competing geometry library that could cause autoload or version-resolution conflicts.
  • If the app already uses PostGIS, confirm this package is not duplicating authoritative spatial logic — divergent results between the DB and PHP are a serious correctness hazard.

Sequencing

  1. Spike (0.5–1 day): install in a scratch branch, run the two new v2.2.0 features against known-good reference coordinates (a handful of hand-computed haversine cases plus one boundary point) to establish CRS and boundary semantics empirically.
  2. Characterisation tests: encode the observed behaviour as tests in your repo before writing any feature code, so an upstream patch release that changes semantics fails loudly.
  3. Adapter layer: wrap farthestFrom() and contains() behind your own interface; forbid direct package imports outside that namespace (enforce with a static-analysis rule).
  4. Pilot one bounded use case — a single endpoint with a small candidate set and a non-critical outcome.
  5. Scale gate: only proceed to wider use after benchmarking the target cardinality; if the set is large or the query is hot-path, move the computation to the database or a precomputed cache instead.

Operational Impact

Maintenance

  • Small dependency surface and an active release cadence are favourable. The countervailing risk is bus factor — small geo utilities are frequently single-maintainer projects. The adapter layer is the mitigation; budget a half-day per year to re-evaluate the dependency and a defined exit path.
  • Track upstream releases. Minor bumps in a geometry library can silently alter rounding or boundary behaviour; treat any change touching contains or distance as requiring re-running the characterisation suite.

Support

  • Community open-source support only: no SLA, no vendor escalation. Internal ownership must be explicit — name a team and an on-call contact for "geo results look wrong" tickets.
  • Write a short internal runbook: assumed CRS, boundary semantics, known limitations (cardinality ceiling, no antimeridian handling if confirmed), and how to reproduce a disputed result.

Scaling

  • Compute is CPU-bound in PHP with no built-in caching or indexing. Scale ceilings are per-request point count and vertices-per-polygon, not QPS.
  • For static datasets (depots, service areas), precompute and cache the derived answers rather than recomputing per request. For batch work, move to queued jobs and chunk the point sets to bound memory.
  • Horizontal scaling helps only linearly; past a threshold, push the query into the database's spatial extensions and retire the PHP path for that use case.

Failure modes

  • Correctness (highest likelihood, highest severity): wrong CRS assumption yields distances that are wrong by a large factor but never throw — the failure is silent. Boundary-exclusive containment drops edge cases in production only.
  • Degenerate input: empty or single-element point sets, zero-area or self-intersecting polygons, duplicate vertices — behaviour undefined, may throw, may return INF/NaN that propagates into business logic.
  • Latency/memory: large point arrays exhaust memory_limit or breach request timeouts under load; the failure correlates with data growth rather than traffic, so it will not appear in load tests on small fixtures.
  • Silent divergence: if the database and this package both compute geometry, they will disagree at boundaries; pick one as authoritative.
  • All of the above fail open in the sense that a wrong coordinate answer typically still returns a valid-looking value. Build validation at the boundary (range checks, explicit null/exception handling) rather than trusting output.

Ramp-up

  • Low. The API is small and intention-revealing; a mid-level Laravel developer is productive in roughly half a day.
  • The non-obvious ramp-up cost is domain literacy, not API literacy: the team must understand what CRS the data is in and what "inside" means at the boundary. Budget a short review with someone who owns the geospatial data before the first production use — this is where the schedule risk sits, not in the integration itself.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource