daandesmedt/phpwktadapter
Composer 安装命令:
composer require daandesmedt/phpwktadapter
包简介
Read and parse 2D, 3D and 4D WKT (Well Known Text) / EWKT (Extended Well-Known Text) object strings into geometry objects with this simple WKT PHP adapter library.
README 文档
README
Well-known text (WKT) is a text markup language for representing vector geometry objects on a map, spatial reference systems of spatial objects and transformations between spatial reference systems.
EWKT (Extended Well-Known Text), a PostGIS-specific format that includes the spatial reference system identifier (SRID) and up to 4 ordinate values (XYZM), is also supported (ex: SRID=31370;POINT(44 60)).
PHPWKTParser provides a simple usage helper class to read WKT and EWKT and parse this text representation to a workable PHP array holding the parsed WKT/EWKT definition. Read and parse 2D, 3D and 4D WKT (Well Known Text) / EWKT (Extended Well-Known Text) object strings into geometry objects with this simple WKT PHP adapter library.
Installation
Install the package through composer:
composer require daandesmedt/phpwktadapter
Make sure, that you include the composer autoloader somewhere in your codebase.
Supported geometry
| Geometry Type | Example |
|---|---|
| POINT | POINT(30 10) |
| LNESTRING | LINESTRING(30 10, 10 30, 40 40) |
| POLYGON | POLYGON((0 0,10 0,10 10,0 10,0 0)) |
| MULTIPOINT | MULTIPOINTZM(0 0 10 10,10 0 0 0,10 10 0 0,20 20 0 10) |
| MULTILINESTRING | MULTILINESTRING((0 0,10 0,10 10,0 10)) |
| MULTIPOLYGON | MULTIPOLYGON(((40 40, 20 45, 45 30, 40 40)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20))) |
| GEOMETRYCOLLECTION | GEOMETRYCOLLECTION(POINT(10 20),LINESTRING(0 0,10 0)) |
PHPWKTParser parsed and returned geometry array response
The read($wkt) function of the PHPWKTParser adapter will return a associative array as representation of the parsed WKT/EWKT (in case of valid).
array(
// the geometry object type
"type" => string,
// integer or float values for POINT - nested array (integer or float) for other geometry types
"value" => array,
// integer representing the EWKT SRID, null when not present
"srid" => integer | null,
// string (Z, M or ZM) representing the dimension, null when not present
"dimension" => string | null
)
Working examples
Working examples can be found in the examples folder.
Sample usage
<?php require __DIR__ . '/../vendor/autoload.php'; use daandesmedt\PHPWKTAdapter\WKTAdapter; $adapter = new WKTAdapter(); $res = $adapter->read('SRID=31370;POINT(30 10)'); var_dump($res);
Handling exceptions
Invalid format in the specified WKT / EWKT will result in a UnexpectedValueException thrown by the WKTAdapter .
<?php require __DIR__ . '/../vendor/autoload.php'; use daandesmedt\PHPWKTAdapter\WKTAdapter; $adapter = new WKTAdapter(); try { $res = $adapter->read('SRID=31370;POINT(bad format)'); } catch (UnexpectedValueException $e) { var_dump($e->getMessage()); }
daandesmedt/phpwktadapter 适用场景与选型建议
daandesmedt/phpwktadapter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.05k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 07 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「geometry」 「text」 「geography」 「string」 「spatial」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 daandesmedt/phpwktadapter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 daandesmedt/phpwktadapter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 daandesmedt/phpwktadapter 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
Common libraries used by Zimbra Api
Geo-related tools PHP 7.3+ library
PHP Countries and Currencies
Text file manipulation
Plain text view engine
统计信息
- 总下载量: 1.05k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 27
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-19