teamzac/laravel-shapefiles 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest Version on Packagist

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

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 667
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固