Skip to content

Commit

Permalink
Improve usage instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDeDauw committed Aug 9, 2018
1 parent 90e6fc0 commit 762969b
Showing 1 changed file with 35 additions and 29 deletions.
64 changes: 35 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,56 @@ On [Packagist](https://packagist.org/packages/data-values/geo):
[![Latest Stable Version](https://poser.pugx.org/data-values/geo/version.png)](https://packagist.org/packages/data-values/geo)
[![Download count](https://poser.pugx.org/data-values/geo/d/total.png)](https://packagist.org/packages/data-values/geo)

## Requirements
## Usage

**Geo 4.x:** PHP 7.1 or later (tested with PHP 7.1 up to PHP 7.2)
To **parse a string to a `LatLongValue` object** you use one of the coordinate parsers.

**Geo 3.x:** PHP 5.5 or later (tested with PHP 5.5 up to PHP 7.2 and HHVM)
```php
$parser = new LatLongParser();
$latLongValue = $parser->parse( '55.7557860 N, 37.6176330 W' );
```

## Library functionality
These parsers are provided:

#### Value objects
* `LatLongParser` - Facade for format specific parsers. In most cases you will be using this one
* `DdCoordinateParser` - Parses decimal degree coordinates
* `DmCoordinateParser` - Parses decimal minute coordinates
* `DmsCoordinateParser` - Parses degree minute second coordinates
* `FloatCoordinateParser` - Parses float coordinates
* `GlobeCoordinateParser` - Parses coordinates into `GlobeCoordinateValue` objects

These are simple value objects. They all implement the <code>DataValues\DataValue</code> interface.
To **turn a coordinate object into a string** you use one of the coordinate formatters.

* <code>LatLongValue</code> - Object representing a geographic point specified by latitude and longitude.
* <code>GlobeCoordinateValue</code> - Geographical coordinate with precision and globe.
```php
$formatter = new LatLongFormatter();
$coordinateString = $formatter->format( new LatLongValue( 42.23, 13.37 ) );
```

#### Formatters
These formatters are provided:

These turn value objects into string representations.
They all implement the <code>ValueFormatters\ValueFormatter</code> interface.
* `LatLongFormatter` - Formats a `LatLongValue` into any of the supported formats
* `GlobeCoordinateFormatter` - Formats a `GlobeCoordinateValue`

* <code>LatLongFormatter</code> - Formats a LatLongValue into float, decimal minute,
decimal degree or degree minute second notation. Both directional and non-directional notation
are supported. Directional labels, latitude-longitude separator and precision can be specified.
* <code>GlobeCoordinateFormatter</code> - Formats a GlobeCoordinateValue.
To **represent a set of coordinates** you use one of the Value Objects.

#### Parsers
`LatLongValue` has a float latitude and longitude. `GlobeCoordinateValue` wraps `LatLongValue`
and adds a precision and a globe identifier.

These turn string representations into value objects.
They all implement the <code>ValueParsers\ValueParser</code> interface.
The **supported coordinate formats** are:

Simple parsers:
* Degree minute second (`55° 45' 20.8296", -37° 37' 3.4788"` or `55° 45' 20.8296" N, 37° 37' 3.4788" W`)
* Decimal minute (`55° 30', -37° 30'` or `55° 30' N, 37° 30' W`)
* Decimal degree (`55.7557860°, -37.6176330°` or `55.7557860° N, 37.6176330° W`)
* Float (`55.7557860, -37.6176330` or `55.7557860 N, 37.6176330 W`)

* <code>DdCoordinateParser</code> - Parses decimal degree coordinates into LatLongValue objects.
* <code>DmCoordinateParser</code> - Parses decimal minute coordinates into LatLongValue objects.
* <code>DmsCoordinateParser</code> - Parses degree minute second coordinates into LatLongValue objects.
* <code>FloatCoordinateParser</code> - Parses float coordinates into LatLongValue objects.
The parsers and formatters allow you to customize the used symbols for degrees, minutes and seconds and
to change the letters used to indicate direction (N, E, S, W).

Composite parsers:
## Requirements

**Geo 4.x:** PHP 7.1 or later (tested with PHP 7.1 up to PHP 7.2)

* <code>LatLongParser</code> - Facade for DdCoordinateParser, DmCoordinateParser, DmsCoordinateParser
and FloatCoordinateParser. Parses a coordinate in any of the notations supported by these parsers
into a LatLongValue object. Both directional and non-directional notation are supported. Directional
labels and the latitude-longitude separator can be specified.
* <code>GlobeCoordinateParser</code> - Parses coordinates into GlobeCoordinateValue objects.
**Geo 3.x:** PHP 5.5 or later (tested with PHP 5.5 up to PHP 7.2 and HHVM)

## Installation

Expand Down

0 comments on commit 762969b

Please sign in to comment.