Download the PHP package willvincent/turf-php without Composer
On this page you can find all versions of the php package willvincent/turf-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download willvincent/turf-php
More information about willvincent/turf-php
Files in willvincent/turf-php
Package turf-php
Short Description TurfJS-like GeoJSON manipulation in PHP.
License MIT
Informations about the package turf-php
Turf-PHP
Turf-PHP is a PHP port of Turf.js, a powerful spatial analysis library. This package provides robust GeoJSON-based geospatial functions for use in PHP applications, allowing you to perform geometry operations, boolean calculations, and spatial analysis with ease.
NOTE: This is a very early effort to port functionality!
It is incomplete and there should be a reasonable expectation that some output may differ slightly from Turf.js, and some may be outright broken. If you need a feature that's not available, or not working correctly, please consider opening a pull request!
🚀 Features
- Supports PHP 8.2+
- Implements key Turf.js functions
- Uses GeoJSON as the standard input and output format, leveraging the jmikola/geojson package.
- Includes boolean operations, spatial analysis, and geometry transformations
📦 Installation
Install Turf-PHP using Composer:
🛠 Usage
Turf-PHP provides various functions to work with geospatial data. Below are some examples of how to use it in your PHP application.
Example: Calculating the area of a FeatureCollection
Example: Checking if a Point is in a Polygon
Example: Generating a square grid
📚 Supported Functions
The following spatial analysis functions are currently implemented:
- ✅
along
- Takes a LineString and returns a Point at a specified distance along the line. - ✅
angle
- Finds the angle formed by two adjacent segments defined by 3 points. - ✅
area
- Calculates the geodesic area in square meters (or other units) of one or more polygons. - ✅
bbox
- Calculates the bounding box for any GeoJSON object, including FeatureCollection - ✅
bearing
- Takes two points and finds the geographic bearing between them. - ✅
distance
- Calculate the distance between two points
The following generative and manipulation functions are currently implemented:
- ✅
bboxClip
- Clips a feature to the bbox - ✅
bboxPolygon
- Takes a bbox and returns an equivalent polygon. - ✅
circle
- Calculates a circle of a given radius around a center point - ✅
destination
- Calculate the location of a destination point from an origin point - ✅
difference
- Finds the difference between multiple polygons by clipping the subsequent polygons from the first - ✅
envelope
- Creates a rectangle polygon feature around all vertices of input geometries - ✅
rectangleGrid
- Generates a rectangle grid within a bounding box - ✅
rewind
- Rewinds geometry to adhere to geojson spec - ✅
squareGrid
- Generates a square gris within a bounding box - ✅
kinks
- Finds all self-intersecting points - ✅
union
- Merge intersecting polygons into one contiguous polygon - ✅
unkink
- Breaks self-intersecting polygons into separate polygons at the intersection points
The following boolean operations are currently implemented:
- ✅
booleanClockwise
- ✅
booleanConcave
- ✅
booleanContains
- ✅
booleanCrosses
- ✅
booleanDisjoint
- ✅
booleanEqual
- ✅
booleanIntersects
- ✅
booleanOverlap
- ✅
booleanParallel
- ✅
booleanPointInPolygon
- ✅
booleanTouches
- ✅
booleanValid
- ✅
booleanWithin
More functions will be added over time to expand the capabilities of Turf-PHP.
Testing and contributions are welcome!
📖 Documentation
Full documentation for Turf-PHP is pending! In the meantime, you can look at the src/Turf.php
file for detail on
properties for each implemented function.
🤝 Contributing
Contributions are welcome! If you'd like to improve the library, add new functions, or fix bugs, feel free to submit a pull request or open an issue.
📄 License
Turf-PHP is open-source and released under the MIT License.
🚀 Turf-PHP is a powerful tool for geospatial analysis in PHP. Start building today and bring the power of Turf.js to your PHP applications!