Giter Site home page Giter Site logo

geo-parser's Introduction

creof/geo-parser

Code Climate Test Coverage Build Status

Lexer and parser library for geometric and geographic point string values.

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();

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);
$value2 = $parser->parse($input2);

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 a integer/float or an array containing a pair of these values.

Exceptions

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.