承接 longitude-one/geo-parser 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

longitude-one/geo-parser

最新稳定版本:3.0.1

Composer 安装命令:

composer require longitude-one/geo-parser

包简介

Parser for geography coordinate strings

README 文档

README

longitude-one/geo-parser Stable release Packagist License

Lexer and parser library for geographic point string values.

PHP CI Maintainability Test Coverage Coverage Status Minimum PHP Version Tested on PHP 8.1 to 8.3

Downloads

Note

This package is the continuation of the now abandoned creof/geo-parser package.

Installation

composer require longitude-one/geo-parser

Usage

There are two use patterns for the parser. The value to be parsed can be passed into the constructor, then parse() called on the returned Parser object:

$input  = '79°56′55″W, 40°26′46″N';

$parser = new Parser($input);

$value = $parser->parse(); // [-79.948611111111, 40.446111111111]

If many values need to be parsed, a single Parser instance can be used:

$input1 = '56.242 E';
$input2 = '40:26:46 S';

$parser = new Parser();

$value1 = $parser->parse($input1); //56.242
$value2 = $parser->parse($input2); //-40.446111111111

Supported Formats

Both single values and pairs are supported. Some samples of supported formats are below, though not every possible iteration may be explicitly specified:

  1. Simple single-signed values
  • 40
  • -40
  • -8.543
  • +132
  • +77.2
  1. Simple single signed values with degree symbol
  • 40°
  • -40°
  • -5.234°
  • +43°
  • +38.43°
  1. Single unsigned values with or without degree symbol, and cardinal direction
  • 40° N
  • 40 S
  • 56.242 E
  1. Single values of signed integer degrees with degree symbol, and decimal minutes with apostrophe
  • 40° 26.222'
  • -65° 32.22'
  • +165° 52.22'
  1. Single values of unsigned integer degrees with degree symbol, decimal minutes with apostrophe, and cardinal direction
  • 40° 26.222' E
  • 65° 32.22' S
  1. Single values of signed integer degrees with degree symbol, integer minutes with apostrophe, and optional integer or decimal seconds with quote
  • 40° 26' 46"
  • -79° 58' 56"
  • 93° 19' 25.8"
  • +120° 19' 25.8"
  1. Single values of signed integer degrees with colon symbol, integer minutes, and optional colon and integer or decimal seconds
  • +40:26:46
  • -79:58:56
  • 93:19:25.8
  1. Single values of unsigned integer degrees with degree symbol, integer minutes with apostrophe, optional integer or decimal seconds with quote, and cardinal direction
  • 40° 26' 46" S
  • 99° 58' 56" W
  • 44° 58' 53.9" N
  1. Single values of unsigned integer degrees with colon symbol, integer minutes with, optional colon and integer or decimal seconds, and cardinal direction
  • 40:26:46 S
  • 99:58:56 W
  • 44:58:53.9 N
  1. Two of any one format separated by whitespace

  2. Two of any one format separated by a comma

Return

The parser will return an integer/float or an array containing a pair of these values.

Exceptions

The Lexer and Parser will throw exceptions implementing interface LongitudeOne\Geo\String\Exception\ExceptionInterface.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-12