bulton-fr/nmea-parser
Composer 安装命令:
composer require bulton-fr/nmea-parser
包简介
NMEA PHP parser
README 文档
README
Read a NMEA line, detect the frame type and parse the line to obtain all datas.
Supported frame type :
- GGA
- GLL
- GSA
- GSV
- RMC
- VTG
Install it
Use composer
Add into composer.json file :
{
"require": {
"bulton-fr/nmea-parser": "master",
}
}
Use it
<?php //Require composer autoload require_once(__DIR__.'/vendor/autoload.php'); //Instanciate the parser $parser = new BultonFr\NMEA\Parser; //Déclare a line to parse $line = '$GPGGA,064036.289,4836.5375,N,00740.9373,E,1,04,3.2,200.2,M,,,,0000*0E'; //Parse the line $frame = $parser->readLine($line);
$frame contains all datas about the readed line. If you var_dump($frame) :
class BultonFr\NMEA\Frames\GGA#2 (19) {
protected $frameType => string(3) "GGA"
protected $frameRegex => string(175) "/^([A-Z]{2}[A-Z]{3}),(\d{6}\.\d{2,3}),([0-9\.]+),(N|S),([0-9\.]+),(E|W),(\d{0,1}),(\d{0,2}),([0-9\.]*),([0-9\.]*),([A-Z]{0,1}),([0-9\.-]*),([A-Z]{0,1}),([0-9\.]*),(\d{0,4})$/m"
protected $utcTime => class DateTime#5 (3) {
public $date => string(26) "2017-09-29 06:40:36.289000"
public $timezone_type => int(3)
public $timezone => string(3) "UTC"
}
protected $latitude => string(9) "4836.5375"
protected $latitudeDirection => string(1) "N"
protected $longitude => string(10) "00740.9373"
protected $longitudeDirection => string(1) "E"
protected $gpsQuality => int(1)
protected $nbSatellites => int(4)
protected $horizontalDilutionPrecision => double(3.2)
protected $altitude => double(200.2)
protected $altitudeUnit => string(1) "M"
protected $geoidalSeparation => double(0)
protected $geoidalSeparationUnit => string(0) ""
protected $ageGpsData => double(0)
protected $differentialRefStationId => int(0)
protected $line => string(70) "$GPGGA,064036.289,4836.5375,N,00740.9373,E,1,04,3.2,200.2,M,,,,0000*0E"
protected $message => string(66) "GPGGA,064036.289,4836.5375,N,00740.9373,E,1,04,3.2,200.2,M,,,,0000"
protected $checksum => string(2) "0E"
}
There is a getter for all properties, except for frameRegex, message and checksum.
Add a new frame type
Add a new class into the namespace BultonFr\NMEA\Frames. Else, you need to extends Parser class and redefine the method obtainFrameParser.
The name of the class need to be the frame type name. Example GGA for frame type GGA. This class should extends the class \BultonFr\NMEA\Frame.
You should have properties $frameType and $frameRegex. And the method decodeFrame should be declared.
$frameType should contains the name of the frame type.
$frameRegex is the regex to use for parse the line.
decodeFrame is the method called after the parse of the line with the regex. The argument of this method is the third argument of preg_match function. So this argument contain all part of the message. Into this method, you can populate your properties with the line value.
bulton-fr/nmea-parser 适用场景与选型建议
bulton-fr/nmea-parser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.61k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 05 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「parser」 「nmea」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bulton-fr/nmea-parser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bulton-fr/nmea-parser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bulton-fr/nmea-parser 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
An MT940 bank statement parser for PHP
Library to parse NMEA sentences
Laravel integration for the jsonapi.org parser
A modern HTML DOM parser for PHP using DOMDocument and Symfony CssSelector.
JPOPHP (JSON Parser Object PHP) is a library for parsing the data in JSON format.
统计信息
- 总下载量: 3.61k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPLv3
- 更新时间: 2019-05-26