spinen/laravel-geometry
Composer 安装命令:
composer require spinen/laravel-geometry
包简介
Wrapper over the geoPHP Class to make it integrate with Laravel better.
README 文档
README
Wrapper over the geoPHP Class to make it integrate with Laravel better.
Build Status
| Branch | Status | Coverage | Code Quality |
|---|---|---|---|
| Develop | |||
| Master |
Prerequisite
NOTES
1) If you need to use < php7.2, please stay with version 1.x
2) Aside from Laravel >= 5.5, the package below is required
Install
Install Geometry:
$ composer require spinen/laravel-geometry
The package uses the auto registration feature.
Using the package
The Geometry Class exposes parseType methods where "Type" is StudlyCase of the geometry type that geoPHP supports. Here is a full list...
- parseEwkb($geometry)
- parseEwkt($geometry)
- parseGeoHash($geometry)
- parseGeoJson($geometry)
- parseGeoRss($geometry)
- parseGoogleGeocode($geometry)
- parseGpx($geometry)
- parseJson($geometry)
- parseKml($geometry)
- parseWkb($geometry)
- parseWkt($geometry)
The geometries are wrapped in a Spinen\Geometry\Geometries namespace with a little sugar to be able to do
- toEwkb()
- toEwkt()
- toGeoHash()
- toGeoJson()
- toGeoRss()
- toGoogleGeocode()
- toGpx()
- toJson()
- toKml()
- toWkb()
- toWkt()
In addition to the above export methods, we have added a toArray that gives an array from the toJson method. For convenience, we have exposed all of the properties of the geometry through a getter, so you have direct access to the property without having ask for the keys in the array.
Area of the polygon
We are estimating the area in meters squared & acres. We expect the estimation to be within 1%, so it is not very accurate. We essentially refactored a js method that Mapbox has in their geojson-area package . You get the area by calling the getAcres or getSquareMeters. There is a shortcut to them as properties, so you can read the "acres" or "square_meters" property.
Example
// Area of Polygon $points = [[1,1], [2,2], [3,2], [3,4]]; $geoJson = '{"type":"Polygon", "coordinates":[' . json_encode($points) . ']}'; $geo = new geoPHP(); $mapper = new Spinen\Geometry\Support\TypeMapper(); $geometry = new Spinen\Geometry\Geometry($geo, $mapper); $collection = $geometry->parseGeoJson($geoJson); // see above for more parse options $squareMeters = $collection->getSquareMeters(); $acres = $collection->getAcres();
spinen/laravel-geometry 适用场景与选型建议
spinen/laravel-geometry 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 501.44k 次下载、GitHub Stars 达 41, 最近一次更新时间为 2015 年 11 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「geometry」 「library」 「laravel」 「spinen」 「geoPHP」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 spinen/laravel-geometry 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 spinen/laravel-geometry 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 spinen/laravel-geometry 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Inbox pattern process implementation for your Laravel Applications
Geo-related tools PHP 7.3+ library
PHP Countries and Currencies
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
Provides command to manage a web library directory
统计信息
- 总下载量: 501.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 42
- 点击次数: 31
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-11-10