bulton-fr/nmea-parser 问题修复 & 功能扩展

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

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

bulton-fr/nmea-parser

最新稳定版本:1.0.0

Composer 安装命令:

composer require bulton-fr/nmea-parser

包简介

NMEA PHP parser

关键字:

README 文档

README

Build Status Code Coverage Scrutinizer Code Quality

Latest Stable Version Latest Unstable Version License

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.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: LGPLv3
  • 更新时间: 2019-05-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固