teamzac/laravel-shapefiles
最新稳定版本:v0.6.1
Composer 安装命令:
composer require teamzac/laravel-shapefiles
包简介
A wrapper for gasparesganga/php-shapefile with a Laravel-ish collections API
关键字:
README 文档
README
The gasparesganga/php-shapefile package is extremely handy for working directly with Shapefiles, but we work mostly in Laravel and prefer the collection-style APIs found throughout. This package simply wraps the original ShapefileReader class in a LazyCollection to make iterating on it a bit more familiar.
Installation
You can install the package via composer:
composer require teamzac/laravel-shapefiles
Usage
$reader = new TeamZac\LaravelShapefiles\Reader('file_or_directory_path_here'); $reader->count(); // total number of records $reader->each(function($geometry) { // do something });
You can pass a reference to the .shp file, or the directory containing the .shp file, when instantiating the Reader.
When iterating in the original package, you'd receive an instance of Shapefile\Geometry\Geometry. We also wrap this in a class that adds a couple of additional methods:
... $reader->each(function($geometry) { $geometry->asGeoJson(); // passes through to the getGeoJSON() method with the "as" verbiage commonly used in Laravel $geometry->asJson(); // a convenience method that runs the GeoJSON through json_decode first $geometry->getData('ID'); // allows retreival of a specific key in the data array $geometry->ID; // you can also access the data array as properties on the Geometry class $geometry->getDataArray(); // methods are passed through to the underlying Shapefile\Geometry\Geometry class $geometry->getRaw(); // you can retrieve the underlying Shapefile\Geometry\Geometry class with the getRaw() method }); ...
To-do
We don't currently implement a wrapper around the ShapefileWriter class, since we don't use it. That might be added one day if we need it.
Testing
composer test
The package comes with a small shapefile containing two polygons. Note, we've only tested this with polygons but there's no reason why it shouldn't work with any other kind of feature.
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email chad@zactax.com instead of using the issue tracker.
Credits
- Gaspare Sganga - Author of the underlying package
- Chad Janicek
- Laravel Package Boilerplate
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 667
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-03-08