PHPackages                             hular369/geo-shapify - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. hular369/geo-shapify

ActiveLibrary

hular369/geo-shapify
====================

A PHP library that allows to check if a coordinate(lat,long) is inside or outside of a country or a circle or a polygon, calculate area occupied by a polygon/circle, and find out the nearest vertex of a country or a polygon from a given point.

v2.0.0(6mo ago)011MITPHPPHP &gt;=7.0

Since Sep 17Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/hular369/shapify)[ Packagist](https://packagist.org/packages/hular369/geo-shapify)[ RSS](/packages/hular369-geo-shapify/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

A PHP library that allows to check if a coordinate(lat,long) is inside or outside of a circle or a country or a polygon or a circle.
------------------------------------------------------------------------------------------------------------------------------------

[](#a-php-library-that-allows-to-check-if-a-coordinatelatlong-is-inside-or-outside-of-a-circle-or-a-country-or-a-polygon-or-a-circle)

This package enables you to check if a coordinate is inside a defined boundary of a country or a polygon. It also provides a feature to calculate the area of a given boundary defined by a country or a polygon coordinates (latitude, longitude), and also for circles.

Features
--------

[](#features)

- **Country Boundaries**:

    - Check if a coordinate is inside a country.
    - Determine which boundary coordinate is nearest to a given point(lat, long),
    - Calculate the area of a country.
- **Polygon Boundaries**:

    - Check if a coordinate is inside a polygon.
    - Calculate the area of a polygon.
- **Circular Boundaries**:

    - Check if a coordinate is inside a circle defined by a center and radius.
    - Calculate the area of a circle.

Usage
-----

[](#usage)

### For Countries and Polygons:

[](#for-countries-and-polygons)

1. Define the polygon coordinates.
2. Create a polygon shape using `ShapeFactory`.
3. Check if a coordinate is inside the polygon using `contains`.
4. Calculate the area of the polygon using `area`.

### For Circles:

[](#for-circles)

1. Create a circle shape using `ShapeFactory` with center coordinates and radius.
2. Check if a coordinate is inside the circle using `contains`.
3. Calculate the area of the circle using `area`.

This package enables you to check if a coordinate is inside a defined boundary of a polygon. It also facilitates with a feature to calculate area of a given boundary defined by polygon coordinates (Lat,long).

To work features on countries, you can implement as follows:

```
Note: currently the feature is available only for 'norway', 'sweden', 'finland', 'denmark', 'germany', 'lithuania', 'nepal'.
