rvwoens/geometry
Composer 安装命令:
composer require rvwoens/geometry
包简介
Geometry 2D shapes helper functions
README 文档
README
Geometry 2D shapes helper functions
Coord
A coord is a simple latitude / longitude coordinate class with some calculation and manipulation methods
// instantiation
$coord = new Coord(52.40010210009, 4.5776320002);
// properties
$lat=$coord->latitude; // latitude property
$lng=$coord->longitude; // longitude property
// methods
round(5) - round lat/long to a precision (default 6 = approx 10 cm)
movedClone(50, 180) - make a clone and move it 50 meter southwards (bearing 180)
toString() - "52.400102,4.577632" 6 digits significant (approx 10 cm)
toWktString() - "4.577632 52.400102" WKT (Well Known Text format)
equals($coord2) - a coord is equal when within a millimeter of another coord
distance($coord3) - calculate distance between coords in meters
bearing($coordTo) - Bearing (degrees) between 2 coords (vector TOWARDS coordTo, 0=north)
move($distance,$bearing); - move of coord (use movedclone for immutable variant)
isRDcoord() - true if the coord is a RD (dutch: Rijksdriehoeksmeting) coordinate
makeWGS84fromRD() - Factory to create a converted Wgs84 coordinate from a RD coordiante
Polygon
A polygon is a number of locations on a map defining an area.
// instantiation. The last segment is automatically closed using the first coordinate
$polygon = new Polygon( [ [52.1,4.2], [52.2,4.2], [52.2,4.3] ]); // define with simple lat/lng array
$polygon = new Polygon( [ ['lat'=>52.1,'lng'=>4.2],
['lat'=>52.2,'lng'=>4.2],
['lat'=>52.2,'lng'=>4.3] ]); // or using this format
$c1=new Coord(52.1,4.2);
$c2=new Coord(52.2,4.2);
$c3=new Coord(52.2,4.3);
$polygon = new Polygon( [ $c1,$c2,$c3 ]); // or using an array of Coords
$polygon = new Polygon("POLYGON ((4.2 52.1, 52.2 4.2, 4.3 52.2, 4.2 52.1))"); // or using a WKT definition
$polygon = new Polygon("52.1,4.2|52.2,4.2|52.2,4.3"); // or using the internal serialisation
// methods
valid() - a polygon is valid when it is at least a triangle with 3 valid Coords
size() - number of sides of the polygon or n of the n-gon.
polyString() - to internal serialisation string "52.1,4.2|52.2,4.2|52.2,4.3"
polyWktString() - to WKT definition "POLYGON ((4.2 52.1, 52.2 4.2, 4.3 52.2, 4.2 52.1))"
polyGeoJsonArray() - convert to Geojson but in php array format
polyGeoJsonString() - convert to Geojson json string
polyLatLngArray() - convert to array format [ ['lat'=>lat,'lng'=>lng]...]
equals($polyon2) - true when each node is within 1mm of the other
farAway($coord) - true when polygon is "far away" from the coord (fast!) to speed up some calculations
distance($coord | $polygon) - closest distance to a point or another polygon
round($precision) - round each node of the polygon to a certain precision (default 6 approx 10cm)
contains($coord) - true when Coord is inside the polygon
areaSquareMeters() - returns area of polygon in square meters using earth projection
center() - calculate the center of mass of the polygon as a Coord
// note: smallest outer circle and largest inner circle are simplifications. Both use polygon center
smallestOuterCircleRadius() - calculate the smallest outer circle (simple version)
largestInnerCircleRadius() - calculate the smallest inner circle (simple version)
// Each method creates a clone. Polygon is immutable
expand(10) - create an expanded (inflated) polygon by x meters (negative values will deflate the polygon)
movedClone($distance,$bearing) - create a moved copy of the polygon
simplify($distance,$highQuality)- create a simplified polygon by removing coordinates but keeping shape
makeCombined(Polygon $add) - add a polygon, create a connection between both (for converting multipolygons)
makeWgsFromRd() - convert polygon to Wgs84
rvwoens/geometry 适用场景与选型建议
rvwoens/geometry 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.61k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 08 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「geometry」 「library」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rvwoens/geometry 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rvwoens/geometry 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rvwoens/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
统计信息
- 总下载量: 1.61k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-08-08