jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/368377 )

Change subject: Wikibase: "data-values/geo": "2.1.1"
......................................................................


Wikibase: "data-values/geo": "2.1.1"

Change-Id: I6540ba028a2cefb281e384089a0cda55e89d5700
---
M composer.json
M composer.lock
M composer/autoload_classmap.php
M composer/autoload_files.php
M composer/autoload_psr4.php
M composer/autoload_static.php
M composer/installed.json
A data-values/geo/Aliases.php
A data-values/geo/COPYING
A data-values/geo/Geo.php
A data-values/geo/README.md
A data-values/geo/src/Formatters/GlobeCoordinateFormatter.php
A data-values/geo/src/Formatters/LatLongFormatter.php
A data-values/geo/src/GlobeMath.php
A data-values/geo/src/Parsers/DdCoordinateParser.php
A data-values/geo/src/Parsers/DmCoordinateParser.php
A data-values/geo/src/Parsers/DmsCoordinateParser.php
A data-values/geo/src/Parsers/FloatCoordinateParser.php
A data-values/geo/src/Parsers/GlobeCoordinateParser.php
A data-values/geo/src/Parsers/LatLongParser.php
A data-values/geo/src/Parsers/LatLongParserBase.php
A data-values/geo/src/Values/GlobeCoordinateValue.php
A data-values/geo/src/Values/LatLongValue.php
23 files changed, 3,024 insertions(+), 5 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/composer.json b/composer.json
index 54ef086..a136d88 100644
--- a/composer.json
+++ b/composer.json
@@ -41,6 +41,7 @@
                "data-values/data-values": "1.1.0",
                "data-values/interfaces": "0.2.5",
                "data-values/number": "0.9.1",
+               "data-values/geo": "2.1.1",
                "data-values/serialization": "1.2.1",
                "diff/diff": "2.2.0",
                "firebase/php-jwt": "4.0.0",
diff --git a/composer.lock b/composer.lock
index 0702c1a..2b216b9 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at 
https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file";,
         "This file is @generated automatically"
     ],
-    "content-hash": "28c433941e7f201a5fa18304960e2a63",
+    "content-hash": "1432d5bc5c17c43f6945b8babd4fa423",
     "packages": [
         {
             "name": "composer/semver",
@@ -224,6 +224,73 @@
             "time": "2017-08-09T15:56:46+00:00"
         },
         {
+            "name": "data-values/geo",
+            "version": "2.1.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/DataValues/Geo.git";,
+                "reference": "8fd88298e30403dc9ef2756695bc183542fa36f2"
+            },
+            "dist": {
+                "type": "zip",
+                "url": 
"https://api.github.com/repos/DataValues/Geo/zipball/8fd88298e30403dc9ef2756695bc183542fa36f2";,
+                "reference": "8fd88298e30403dc9ef2756695bc183542fa36f2",
+                "shasum": ""
+            },
+            "require": {
+                "data-values/common": "~0.4.0|~0.3.0|~0.2.0",
+                "data-values/data-values": "~1.0|~0.1",
+                "data-values/interfaces": "~0.2.0|~0.1.5",
+                "php": ">=5.5.9"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~4.8",
+                "wikibase/wikibase-codesniffer": "^0.1.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.0.x-dev"
+                }
+            },
+            "autoload": {
+                "files": [
+                    "Geo.php"
+                ],
+                "psr-4": {
+                    "DataValues\\Geo\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/";,
+            "license": [
+                "GPL-2.0+"
+            ],
+            "authors": [
+                {
+                    "name": "Jeroen De Dauw",
+                    "email": "jeroended...@gmail.com",
+                    "homepage": "http://jeroendedauw.com";,
+                    "role": "Developer"
+                },
+                {
+                    "name": "The Wikidata team",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Geographical value objects, parsers and 
formatters",
+            "homepage": "https://github.com/DataValues/Geo";,
+            "keywords": [
+                "datavalues",
+                "formatters",
+                "geo",
+                "geographical",
+                "latlong",
+                "parsers",
+                "wikidata"
+            ],
+            "time": "2017-08-09T19:37:51+00:00"
+        },
+        {
             "name": "data-values/interfaces",
             "version": "0.2.5",
             "source": {
diff --git a/composer/autoload_classmap.php b/composer/autoload_classmap.php
index 7f39982..c899a56 100644
--- a/composer/autoload_classmap.php
+++ b/composer/autoload_classmap.php
@@ -79,6 +79,18 @@
     'DataValues\\DecimalMath' => $vendorDir . 
'/data-values/number/src/DataValues/DecimalMath.php',
     'DataValues\\DecimalValue' => $vendorDir . 
'/data-values/number/src/DataValues/DecimalValue.php',
     'DataValues\\Deserializers\\DataValueDeserializer' => $vendorDir . 
'/data-values/serialization/src/Deserializers/DataValueDeserializer.php',
+    'DataValues\\Geo\\Formatters\\GlobeCoordinateFormatter' => $vendorDir . 
'/data-values/geo/src/Formatters/GlobeCoordinateFormatter.php',
+    'DataValues\\Geo\\Formatters\\LatLongFormatter' => $vendorDir . 
'/data-values/geo/src/Formatters/LatLongFormatter.php',
+    'DataValues\\Geo\\GlobeMath' => $vendorDir . 
'/data-values/geo/src/GlobeMath.php',
+    'DataValues\\Geo\\Parsers\\DdCoordinateParser' => $vendorDir . 
'/data-values/geo/src/Parsers/DdCoordinateParser.php',
+    'DataValues\\Geo\\Parsers\\DmCoordinateParser' => $vendorDir . 
'/data-values/geo/src/Parsers/DmCoordinateParser.php',
+    'DataValues\\Geo\\Parsers\\DmsCoordinateParser' => $vendorDir . 
'/data-values/geo/src/Parsers/DmsCoordinateParser.php',
+    'DataValues\\Geo\\Parsers\\FloatCoordinateParser' => $vendorDir . 
'/data-values/geo/src/Parsers/FloatCoordinateParser.php',
+    'DataValues\\Geo\\Parsers\\GlobeCoordinateParser' => $vendorDir . 
'/data-values/geo/src/Parsers/GlobeCoordinateParser.php',
+    'DataValues\\Geo\\Parsers\\LatLongParser' => $vendorDir . 
'/data-values/geo/src/Parsers/LatLongParser.php',
+    'DataValues\\Geo\\Parsers\\LatLongParserBase' => $vendorDir . 
'/data-values/geo/src/Parsers/LatLongParserBase.php',
+    'DataValues\\Geo\\Values\\GlobeCoordinateValue' => $vendorDir . 
'/data-values/geo/src/Values/GlobeCoordinateValue.php',
+    'DataValues\\Geo\\Values\\LatLongValue' => $vendorDir . 
'/data-values/geo/src/Values/LatLongValue.php',
     'DataValues\\IllegalValueException' => $vendorDir . 
'/data-values/data-values/src/DataValues/IllegalValueException.php',
     'DataValues\\MonolingualTextValue' => $vendorDir . 
'/data-values/common/src/DataValues/MonolingualTextValue.php',
     'DataValues\\MultilingualTextValue' => $vendorDir . 
'/data-values/common/src/DataValues/MultilingualTextValue.php',
diff --git a/composer/autoload_files.php b/composer/autoload_files.php
index ca46d85..c0e6918 100644
--- a/composer/autoload_files.php
+++ b/composer/autoload_files.php
@@ -7,14 +7,15 @@
 
 return array(
     '7cb394c3af2b1ae832979b0368e0da62' => $vendorDir . 
'/data-values/data-values/DataValues.php',
-    'a24b5daa493ecb5e767c7d1592a8da36' => $vendorDir . 
'/mediawiki/at-ease/src/Functions.php',
     'd1715cacc3c23b16a030645514266a76' => $vendorDir . 
'/data-values/interfaces/Interfaces.php',
-    'f4c767faab43077fd89ff7cf99ffb4b8' => $vendorDir . 
'/serialization/serialization/Serialization.php',
+    'a24b5daa493ecb5e767c7d1592a8da36' => $vendorDir . 
'/mediawiki/at-ease/src/Functions.php',
     '90559502573a0d473dc66fde5c0ff7e2' => $vendorDir . 
'/data-values/common/Common.php',
+    'f4c767faab43077fd89ff7cf99ffb4b8' => $vendorDir . 
'/serialization/serialization/Serialization.php',
     'c3f7f0e81464740a933532e81fa26cc7' => $vendorDir . 
'/wikimedia/base-convert/src/Functions.php',
     'c50606d667a3fde2b80a955639479d3d' => $vendorDir . 
'/wikimedia/timestamp/src/defines.php',
     '04c6c5c2f7095ccf6c481d3e53e1776f' => $vendorDir . 
'/mustangostang/spyc/Spyc.php',
     'd55c27a601de788b19a09b7d057d07ae' => $vendorDir . 
'/wikimedia/relpath/src/RelPath.php',
     '3ef87127dc6892a0a78f223558a0b940' => $vendorDir . '/diff/diff/Diff.php',
     'c15f8000750e4e04ba559d9745044427' => $vendorDir . 
'/data-values/number/Number.php',
+    '5a494680c593293bd6035e42e2a6825c' => $vendorDir . 
'/data-values/geo/Geo.php',
 );
diff --git a/composer/autoload_psr4.php b/composer/autoload_psr4.php
index a4fffb5..3bbccf5 100644
--- a/composer/autoload_psr4.php
+++ b/composer/autoload_psr4.php
@@ -27,6 +27,7 @@
     'Diff\\' => array($vendorDir . '/diff/diff/src'),
     'Deserializers\\' => array($vendorDir . 
'/serialization/serialization/src/Deserializers'),
     'DataValues\\Serializers\\' => array($vendorDir . 
'/data-values/serialization/src/Serializers'),
+    'DataValues\\Geo\\' => array($vendorDir . '/data-values/geo/src'),
     'DataValues\\Deserializers\\' => array($vendorDir . 
'/data-values/serialization/src/Deserializers'),
     'DataValues\\' => array($vendorDir . '/data-values/common/src/DataValues'),
     'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
diff --git a/composer/autoload_static.php b/composer/autoload_static.php
index c785d0a..0c0f007 100644
--- a/composer/autoload_static.php
+++ b/composer/autoload_static.php
@@ -8,16 +8,17 @@
 {
     public static $files = array (
         '7cb394c3af2b1ae832979b0368e0da62' => __DIR__ . '/..' . 
'/data-values/data-values/DataValues.php',
-        'a24b5daa493ecb5e767c7d1592a8da36' => __DIR__ . '/..' . 
'/mediawiki/at-ease/src/Functions.php',
         'd1715cacc3c23b16a030645514266a76' => __DIR__ . '/..' . 
'/data-values/interfaces/Interfaces.php',
-        'f4c767faab43077fd89ff7cf99ffb4b8' => __DIR__ . '/..' . 
'/serialization/serialization/Serialization.php',
+        'a24b5daa493ecb5e767c7d1592a8da36' => __DIR__ . '/..' . 
'/mediawiki/at-ease/src/Functions.php',
         '90559502573a0d473dc66fde5c0ff7e2' => __DIR__ . '/..' . 
'/data-values/common/Common.php',
+        'f4c767faab43077fd89ff7cf99ffb4b8' => __DIR__ . '/..' . 
'/serialization/serialization/Serialization.php',
         'c3f7f0e81464740a933532e81fa26cc7' => __DIR__ . '/..' . 
'/wikimedia/base-convert/src/Functions.php',
         'c50606d667a3fde2b80a955639479d3d' => __DIR__ . '/..' . 
'/wikimedia/timestamp/src/defines.php',
         '04c6c5c2f7095ccf6c481d3e53e1776f' => __DIR__ . '/..' . 
'/mustangostang/spyc/Spyc.php',
         'd55c27a601de788b19a09b7d057d07ae' => __DIR__ . '/..' . 
'/wikimedia/relpath/src/RelPath.php',
         '3ef87127dc6892a0a78f223558a0b940' => __DIR__ . '/..' . 
'/diff/diff/Diff.php',
         'c15f8000750e4e04ba559d9745044427' => __DIR__ . '/..' . 
'/data-values/number/Number.php',
+        '5a494680c593293bd6035e42e2a6825c' => __DIR__ . '/..' . 
'/data-values/geo/Geo.php',
     );
 
     public static $prefixLengthsPsr4 = array (
@@ -74,6 +75,7 @@
             'Diff\\' => 5,
             'Deserializers\\' => 14,
             'DataValues\\Serializers\\' => 23,
+            'DataValues\\Geo\\' => 15,
             'DataValues\\Deserializers\\' => 25,
             'DataValues\\' => 11,
         ),
@@ -170,6 +172,10 @@
         'DataValues\\Serializers\\' => 
         array (
             0 => __DIR__ . '/..' . 
'/data-values/serialization/src/Serializers',
+        ),
+        'DataValues\\Geo\\' => 
+        array (
+            0 => __DIR__ . '/..' . '/data-values/geo/src',
         ),
         'DataValues\\Deserializers\\' => 
         array (
@@ -353,6 +359,18 @@
         'DataValues\\DecimalMath' => __DIR__ . '/..' . 
'/data-values/number/src/DataValues/DecimalMath.php',
         'DataValues\\DecimalValue' => __DIR__ . '/..' . 
'/data-values/number/src/DataValues/DecimalValue.php',
         'DataValues\\Deserializers\\DataValueDeserializer' => __DIR__ . '/..' 
. '/data-values/serialization/src/Deserializers/DataValueDeserializer.php',
+        'DataValues\\Geo\\Formatters\\GlobeCoordinateFormatter' => __DIR__ . 
'/..' . '/data-values/geo/src/Formatters/GlobeCoordinateFormatter.php',
+        'DataValues\\Geo\\Formatters\\LatLongFormatter' => __DIR__ . '/..' . 
'/data-values/geo/src/Formatters/LatLongFormatter.php',
+        'DataValues\\Geo\\GlobeMath' => __DIR__ . '/..' . 
'/data-values/geo/src/GlobeMath.php',
+        'DataValues\\Geo\\Parsers\\DdCoordinateParser' => __DIR__ . '/..' . 
'/data-values/geo/src/Parsers/DdCoordinateParser.php',
+        'DataValues\\Geo\\Parsers\\DmCoordinateParser' => __DIR__ . '/..' . 
'/data-values/geo/src/Parsers/DmCoordinateParser.php',
+        'DataValues\\Geo\\Parsers\\DmsCoordinateParser' => __DIR__ . '/..' . 
'/data-values/geo/src/Parsers/DmsCoordinateParser.php',
+        'DataValues\\Geo\\Parsers\\FloatCoordinateParser' => __DIR__ . '/..' . 
'/data-values/geo/src/Parsers/FloatCoordinateParser.php',
+        'DataValues\\Geo\\Parsers\\GlobeCoordinateParser' => __DIR__ . '/..' . 
'/data-values/geo/src/Parsers/GlobeCoordinateParser.php',
+        'DataValues\\Geo\\Parsers\\LatLongParser' => __DIR__ . '/..' . 
'/data-values/geo/src/Parsers/LatLongParser.php',
+        'DataValues\\Geo\\Parsers\\LatLongParserBase' => __DIR__ . '/..' . 
'/data-values/geo/src/Parsers/LatLongParserBase.php',
+        'DataValues\\Geo\\Values\\GlobeCoordinateValue' => __DIR__ . '/..' . 
'/data-values/geo/src/Values/GlobeCoordinateValue.php',
+        'DataValues\\Geo\\Values\\LatLongValue' => __DIR__ . '/..' . 
'/data-values/geo/src/Values/LatLongValue.php',
         'DataValues\\IllegalValueException' => __DIR__ . '/..' . 
'/data-values/data-values/src/DataValues/IllegalValueException.php',
         'DataValues\\MonolingualTextValue' => __DIR__ . '/..' . 
'/data-values/common/src/DataValues/MonolingualTextValue.php',
         'DataValues\\MultilingualTextValue' => __DIR__ . '/..' . 
'/data-values/common/src/DataValues/MultilingualTextValue.php',
diff --git a/composer/installed.json b/composer/installed.json
index 4125eeb..0817f56 100644
--- a/composer/installed.json
+++ b/composer/installed.json
@@ -2828,5 +2828,74 @@
             "valueparsers",
             "wikidata"
         ]
+    },
+    {
+        "name": "data-values/geo",
+        "version": "2.1.1",
+        "version_normalized": "2.1.1.0",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/DataValues/Geo.git";,
+            "reference": "8fd88298e30403dc9ef2756695bc183542fa36f2"
+        },
+        "dist": {
+            "type": "zip",
+            "url": 
"https://api.github.com/repos/DataValues/Geo/zipball/8fd88298e30403dc9ef2756695bc183542fa36f2";,
+            "reference": "8fd88298e30403dc9ef2756695bc183542fa36f2",
+            "shasum": ""
+        },
+        "require": {
+            "data-values/common": "~0.4.0|~0.3.0|~0.2.0",
+            "data-values/data-values": "~1.0|~0.1",
+            "data-values/interfaces": "~0.2.0|~0.1.5",
+            "php": ">=5.5.9"
+        },
+        "require-dev": {
+            "phpunit/phpunit": "~4.8",
+            "wikibase/wikibase-codesniffer": "^0.1.0"
+        },
+        "time": "2017-08-09T19:37:51+00:00",
+        "type": "library",
+        "extra": {
+            "branch-alias": {
+                "dev-master": "2.0.x-dev"
+            }
+        },
+        "installation-source": "dist",
+        "autoload": {
+            "files": [
+                "Geo.php"
+            ],
+            "psr-4": {
+                "DataValues\\Geo\\": "src"
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/";,
+        "license": [
+            "GPL-2.0+"
+        ],
+        "authors": [
+            {
+                "name": "Jeroen De Dauw",
+                "email": "jeroended...@gmail.com",
+                "homepage": "http://jeroendedauw.com";,
+                "role": "Developer"
+            },
+            {
+                "name": "The Wikidata team",
+                "role": "Developer"
+            }
+        ],
+        "description": "Geographical value objects, parsers and formatters",
+        "homepage": "https://github.com/DataValues/Geo";,
+        "keywords": [
+            "datavalues",
+            "formatters",
+            "geo",
+            "geographical",
+            "latlong",
+            "parsers",
+            "wikidata"
+        ]
     }
 ]
diff --git a/data-values/geo/Aliases.php b/data-values/geo/Aliases.php
new file mode 100644
index 0000000..c653915
--- /dev/null
+++ b/data-values/geo/Aliases.php
@@ -0,0 +1,52 @@
+<?php
+
+// This is a IDE helper to understand class aliasing.
+// It should not be included anywhere.
+// Actual aliasing happens in the entry point using class_alias.
+
+namespace {
+
+       throw new Exception( 'This code is not meant to be executed' );
+
+}
+
+namespace DataValues {
+
+       /**
+        * @since 0.1
+        * @deprecated since 1.0, use the base class instead.
+        */
+       class LatLongValue extends \DataValues\Geo\Values\LatLongValue {
+       }
+
+       /**
+        * @since 0.1
+        * @deprecated since 1.0, use the base class instead.
+        * @codingStandardsIgnoreStart
+        */
+       class GlobeCoordinateValue extends 
\DataValues\Geo\Values\GlobeCoordinateValue {
+       }
+
+}
+
+namespace DataValues\Geo\Formatters {
+
+       /**
+        * @since 1.0
+        * @deprecated since 2.0, use the base class instead.
+        */
+       class GeoCoordinateFormatter extends 
\DataValues\Geo\Formatters\LatLongFormatter {
+       }
+
+}
+
+namespace DataValues\Geo\Parsers {
+
+       /**
+        * @since 1.0
+        * @deprecated since 2.0, use the base class instead.
+        */
+       class GeoCoordinateParser extends \DataValues\Geo\Parsers\LatLongParser 
{
+       }
+
+}
diff --git a/data-values/geo/COPYING b/data-values/geo/COPYING
new file mode 100644
index 0000000..ebba08a
--- /dev/null
+++ b/data-values/geo/COPYING
@@ -0,0 +1,347 @@
+The license text below "----" applies to all files within this distribution, 
other
+than those that are in a directory which contains files named "LICENSE" or
+"COPYING", or a subdirectory thereof. For those files, the license text 
contained in
+said file overrides any license information contained in directories of 
smaller depth.
+Alternative licenses are typically used for software that is provided by 
external
+parties, and merely packaged with this software for convenience.
+----
+
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/data-values/geo/Geo.php b/data-values/geo/Geo.php
new file mode 100644
index 0000000..bde3bd8
--- /dev/null
+++ b/data-values/geo/Geo.php
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Entry point of the DataValues Geo library.
+ *
+ * @since 0.1
+ * @codeCoverageIgnore
+ *
+ * @license GPL-2.0+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+
+if ( defined( 'DATAVALUES_GEO_VERSION' ) ) {
+       // Do not initialize more than once.
+       return 1;
+}
+
+define( 'DATAVALUES_GEO_VERSION', '2.1.1' );
+
+// Aliases introduced in 1.0
+class_alias( DataValues\Geo\Values\LatLongValue::class, 
'DataValues\LatLongValue' );
+class_alias( DataValues\Geo\Values\GlobeCoordinateValue::class, 
'DataValues\GlobeCoordinateValue' );
+
+// Aliases introduced in 2.0
+class_alias(
+       DataValues\Geo\Formatters\LatLongFormatter::class,
+       'DataValues\Geo\Formatters\GeoCoordinateFormatter'
+);
+class_alias(
+       DataValues\Geo\Parsers\LatLongParser::class,
+       'DataValues\Geo\Parsers\GeoCoordinateParser'
+);
diff --git a/data-values/geo/README.md b/data-values/geo/README.md
new file mode 100644
index 0000000..1d5dadd
--- /dev/null
+++ b/data-values/geo/README.md
@@ -0,0 +1,221 @@
+# DataValues Geo
+
+Library containing value objects to represent geographical information, 
parsers to turn user input
+into such value objects, and formatters to turn them back into user consumable 
representations.
+
+It is part of the [DataValues set of libraries](https://github.com/DataValues).
+
+[![Build 
Status](https://secure.travis-ci.org/DataValues/Geo.png?branch=master)](http://travis-ci.org/DataValues/Geo)
+[![Code 
Coverage](https://scrutinizer-ci.com/g/DataValues/Geo/badges/coverage.png?s=bf4cfd11f3b985fd05918f395c350b376a9ce0ee)](https://scrutinizer-ci.com/g/DataValues/Geo/)
+[![Scrutinizer Quality 
Score](https://scrutinizer-ci.com/g/DataValues/Geo/badges/quality-score.png?s=e695e42b53d74fc02e5cfa2aa218420f062edbd2)](https://scrutinizer-ci.com/g/DataValues/Geo/)
+[![Dependency 
Status](https://www.versioneye.com/php/data-values:geo/badge.png)](https://www.versioneye.com/php/data-values:geo)
+
+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)
+
+## Installation
+
+The recommended way to use this library is via 
[Composer](http://getcomposer.org/).
+
+### Composer
+
+To add this package as a local, per-project dependency to your project, simply 
add a
+dependency on `data-values/geo` to your project's `composer.json` file.
+Here is a minimal example of a `composer.json` file that just defines a 
dependency on
+version 1.1 of this package:
+
+    {
+        "require": {
+            "data-values/geo": "1.1.*"
+        }
+    }
+
+### Manual
+
+Get the code of this package, either via git, or some other means. Also get 
all dependencies.
+You can find a list of the dependencies in the "require" section of the 
composer.json file.
+Then take care of autoloading the classes defined in the src directory.
+
+## Library functionality
+
+#### Value objects
+
+These are simple value objects. They all implement the 
<code>DataValues\DataValue</code> interface.
+
+* <code>LatLongValue</code> - Object representing a geographic point specified 
by latitude and longitude.
+* <code>GlobeCoordinateValue</code> - Geographical coordinate with precision 
and globe.
+
+#### Formatters
+
+These turn value objects into string representations.
+They all implement the <code>ValueFormatters\ValueFormatter</code> interface.
+
+* <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.
+
+#### Parsers
+
+These turn string representations into value objects.
+They all implement the <code>ValueParsers\ValueParser</code> interface.
+
+Simple parsers:
+
+* <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.
+
+Composite parsers:
+
+* <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.
+
+## Tests
+
+This library comes with a set up PHPUnit tests that cover all non-trivial 
code. You can run these
+tests using the PHPUnit configuration file found in the root directory. The 
tests can also be run
+via TravisCI, as a TravisCI configuration file is also provided in the root 
directory.
+
+## Authors
+
+DataValues Geo has been written by the Wikidata team, as [Wikimedia Germany]
+(https://wikimedia.de) employees for the [Wikidata 
project](https://wikidata.org/).
+
+It is based upon and contains a lot of code written by [Jeroen De Dauw]
+(https://github.com/JeroenDeDauw) for the 
[Maps](https://github.com/JeroenDeDauw/Maps) and
+[Semantic MediaWiki](https://semantic-mediawiki.org/) projects.
+
+## Release notes
+
+### 2.1.1 (2017-08-09)
+
+* Allow use with ~0.4.0 of DataValues/Common
+
+### 2.1.0 (2017-08-09)
+
+* Remove MediaWiki integration
+* Make use of the …::class feature
+* Add .gitattributes to exclude not needed files from git exports
+* Use Wikibase CodeSniffer instead of Mediawiki's
+* Move to short array syntax
+
+### 2.0.1 (2017-06-26)
+
+* Fixed `GlobeCoordinateValue::newFromArray` and `LatLongValue::newFromArray` 
not accepting mixed
+  values.
+* Deprecated `GlobeCoordinateValue::newFromArray` and 
`LatLongValue::newFromArray`.
+* Updated minimal required PHP version from 5.3 to 5.5.9.
+
+### 2.0.0 (2017-05-09)
+
+* `GlobeCoordinateValue` does not accept empty strings as globes any more.
+* `GlobeCoordinateValue` does not accept precisions outside the [-360..+360] 
interval any more.
+* Changed hash calculation of `GlobeCoordinateValue` in an incompatible way.
+* Renamed `GeoCoordinateFormatter` to `LatLongFormatter`, leaving a deprecated 
alias.
+* Renamed `GeoCoordinateParser` to `LatLongParser`, leaving a deprecated alias.
+* Renamed `GeoCoordinateParserBase` to `LatLongParserBase`.
+* Deprecated `LatLongParser::areCoordinates`.
+
+### 1.2.2 (2017-03-14)
+
+* Fixed multiple rounding issues in `GeoCoordinateFormatter`.
+
+### 1.2.1 (2016-12-16)
+
+* Fixed another IEEE issue in `GeoCoordinateFormatter`.
+
+### 1.2.0 (2016-11-11)
+
+* Added missing inline documentation to public methods and constants.
+* Added a basic PHPCS rule set, can be run with `composer phpcs`.
+
+### 1.1.8 (2016-10-12)
+
+* Fixed an IEEE issue in `GeoCoordinateFormatter`
+* Fixed a PHP 7.1 compatibility issue in a test
+
+### 1.1.7 (2016-05-25)
+
+* Made minor documentation improvements
+
+### 1.1.6 (2016-04-02)
+
+* Added compatibility with DataValues Common 0.3.x
+
+### 1.1.5 (2015-12-28)
+
+* The component can now be installed together with DataValues Interfaces 0.2.x
+
+### 1.1.4 (2014-11-25)
+
+* Add fall back to default on invalid precision to more places.
+
+### 1.1.3 (2014-11-19)
+
+* Fall back to default on invalid precision instead of dividing by zero.
+
+### 1.1.2 (2014-11-18)
+
+* Precision detection in `GlobeCoordinateParser` now has a lower bound of 
0.00000001°
+
+### 1.1.1 (2014-10-21)
+
+* Removed remaining uses of class aliases from messages and comments
+* Fixed some types in documentation
+
+### 1.1 (2014-10-09)
+
+* Made the component installable with DataValues 1.x
+* `GeoCoordinateFormatter` now supports precision in degrees
+* `GlobeCoordinateFormatter` now passes the globe precision to the 
`GeoCoordinateFormatter` it uses
+* Introduced `FORMAT_NAME` class constants on ValueParsers in order to use 
them as expectedFormat
+* Changed ValueParsers to pass rawValue and expectedFormat arguments when 
constructing a `ParseException`
+
+### 1.0 (2014-07-31)
+
+* All classes and interfaces have been moved into the `DataValues\Geo` 
namespace
+    * `DataValues\LatLongValue` has been left as deprecated alias
+    * `DataValues\GlobeCoordinateValue` has been left as deprecated alias
+* Globe in `GlobeCoordinateValue` now defaults to 
`http://www.wikidata.org/entity/Q2`
+
+### 0.2 (2014-07-07)
+
+* Removed deprecated `GeoCoordinateValue`
+* Added `GlobeMath`
+
+### 0.1.2 (2014-01-22)
+
+* Added support for different levels of spacing in GeoCoordinateFormatter
+
+### 0.1.1 (2013-11-30)
+
+* Added support for direction notation to GeoCoordinateFormatter
+* Decreased complexity of GeoCoordinateFormatter
+* Decreased complexity and coupling of GeoCoordinateFormatterTest
+
+### 0.1 (2013-11-17)
+
+Initial release with these features:
+
+* LatLongValue
+* GlobeCoordinateValue
+* GeoCoordinateFormatter
+* GlobeCoordinateFormatter
+* DdCoordinateParser
+* DmCoordinateParser
+* DmsCoordinateParser
+* FloatCoordinateParser
+* GeoCoordinateParser
+* GlobeCoordinateParser
+
+## Links
+
+* [DataValues Geo on Packagist](https://packagist.org/packages/data-values/geo)
+* [DataValues Geo on TravisCI](https://travis-ci.org/DataValues/Geo)
+* [DataValues on Wikimedia's 
Phabricator](https://phabricator.wikimedia.org/project/view/122/)
diff --git a/data-values/geo/src/Formatters/GlobeCoordinateFormatter.php 
b/data-values/geo/src/Formatters/GlobeCoordinateFormatter.php
new file mode 100644
index 0000000..54f62f0
--- /dev/null
+++ b/data-values/geo/src/Formatters/GlobeCoordinateFormatter.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace DataValues\Geo\Formatters;
+
+use DataValues\Geo\Values\GlobeCoordinateValue;
+use InvalidArgumentException;
+use ValueFormatters\ValueFormatterBase;
+
+/**
+ * Geographical coordinates formatter.
+ * Formats GlobeCoordinateValue objects.
+ *
+ * Formatting of latitude and longitude is done via LatLongFormatter.
+ *
+ * For now this is a trivial implementation that only forwards to 
LatLongFormatter.
+ * TODO: add formatting of globe and precision
+ *
+ * @since 0.1
+ *
+ * @license GPL-2.0+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class GlobeCoordinateFormatter extends ValueFormatterBase {
+
+       /**
+        * @see ValueFormatter::format
+        *
+        * @param GlobeCoordinateValue $value
+        *
+        * @return string Plain text
+        * @throws InvalidArgumentException
+        */
+       public function format( $value ) {
+               if ( !( $value instanceof GlobeCoordinateValue ) ) {
+                       throw new InvalidArgumentException( 'Data value type 
mismatch. Expected a GlobeCoordinateValue.' );
+               }
+
+               $formatter = new LatLongFormatter( $this->options );
+
+               return $formatter->formatLatLongValue( $value->getLatLong(), 
$value->getPrecision() );
+       }
+
+}
diff --git a/data-values/geo/src/Formatters/LatLongFormatter.php 
b/data-values/geo/src/Formatters/LatLongFormatter.php
new file mode 100644
index 0000000..beaac93
--- /dev/null
+++ b/data-values/geo/src/Formatters/LatLongFormatter.php
@@ -0,0 +1,404 @@
+<?php
+
+namespace DataValues\Geo\Formatters;
+
+use DataValues\Geo\Values\LatLongValue;
+use InvalidArgumentException;
+use ValueFormatters\FormatterOptions;
+use ValueFormatters\ValueFormatterBase;
+
+/**
+ * Geographical coordinates formatter.
+ * Formats LatLongValue objects.
+ *
+ * Supports the following notations:
+ * - Degree minute second
+ * - Decimal degrees
+ * - Decimal minutes
+ * - Float
+ *
+ * Some code in this class has been borrowed from the
+ * MapsCoordinateParser class of the Maps extension for MediaWiki.
+ *
+ * @since 0.1, renamed in 2.0
+ *
+ * @license GPL-2.0+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ * @author Addshore
+ * @author Thiemo Mättig
+ */
+class LatLongFormatter extends ValueFormatterBase {
+
+       /**
+        * Output formats for use with the self::OPT_FORMAT option.
+        */
+       const TYPE_FLOAT = 'float';
+       const TYPE_DMS = 'dms';
+       const TYPE_DM = 'dm';
+       const TYPE_DD = 'dd';
+
+       /**
+        * The symbols representing the different directions for usage in 
directional notation.
+        * @since 0.1
+        */
+       const OPT_NORTH_SYMBOL = 'north';
+       const OPT_EAST_SYMBOL = 'east';
+       const OPT_SOUTH_SYMBOL = 'south';
+       const OPT_WEST_SYMBOL = 'west';
+
+       /**
+        * The symbols representing degrees, minutes and seconds.
+        * @since 0.1
+        */
+       const OPT_DEGREE_SYMBOL = 'degree';
+       const OPT_MINUTE_SYMBOL = 'minute';
+       const OPT_SECOND_SYMBOL = 'second';
+
+       /**
+        * Flags for use with the self::OPT_SPACING_LEVEL option.
+        */
+       const OPT_SPACE_LATLONG = 'latlong';
+       const OPT_SPACE_DIRECTION = 'direction';
+       const OPT_SPACE_COORDPARTS = 'coordparts';
+
+       /**
+        * Option specifying the output format (also referred to as output 
type). Must be one of the
+        * self::TYPE_… constants.
+        */
+       const OPT_FORMAT = 'geoformat';
+
+       /**
+        * Boolean option specifying if negative coordinates should have minus 
signs, e.g. "-1°, -2°"
+        * (false) or cardinal directions, e.g. "1° S, 2° W" (true). Default is 
false.
+        */
+       const OPT_DIRECTIONAL = 'directional';
+
+       /**
+        * Option for the separator character between latitude and longitude. 
Defaults to a comma.
+        */
+       const OPT_SEPARATOR_SYMBOL = 'separator';
+
+       /**
+        * Option specifying the amount and position of space characters in the 
output. Must be an array
+        * containing zero or more of the self::OPT_SPACE_… flags.
+        */
+       const OPT_SPACING_LEVEL = 'spacing';
+
+       /**
+        * Option specifying the precision in fractional degrees. Must be a 
number or numeric string.
+        */
+       const OPT_PRECISION = 'precision';
+
+       public function __construct( FormatterOptions $options = null ) {
+               parent::__construct( $options );
+
+               $this->defaultOption( self::OPT_NORTH_SYMBOL, 'N' );
+               $this->defaultOption( self::OPT_EAST_SYMBOL, 'E' );
+               $this->defaultOption( self::OPT_SOUTH_SYMBOL, 'S' );
+               $this->defaultOption( self::OPT_WEST_SYMBOL, 'W' );
+
+               $this->defaultOption( self::OPT_DEGREE_SYMBOL, '°' );
+               $this->defaultOption( self::OPT_MINUTE_SYMBOL, "'" );
+               $this->defaultOption( self::OPT_SECOND_SYMBOL, '"' );
+
+               $this->defaultOption( self::OPT_FORMAT, self::TYPE_FLOAT );
+               $this->defaultOption( self::OPT_DIRECTIONAL, false );
+
+               $this->defaultOption( self::OPT_SEPARATOR_SYMBOL, ',' );
+               $this->defaultOption( self::OPT_SPACING_LEVEL, [
+                       self::OPT_SPACE_LATLONG,
+                       self::OPT_SPACE_DIRECTION,
+                       self::OPT_SPACE_COORDPARTS,
+               ] );
+               $this->defaultOption( self::OPT_PRECISION, 0 );
+       }
+
+       /**
+        * @see ValueFormatter::format
+        *
+        * Calls formatLatLongValue() using OPT_PRECISION for the $precision 
parameter.
+        *
+        * @param LatLongValue $value
+        *
+        * @return string Plain text
+        * @throws InvalidArgumentException
+        */
+       public function format( $value ) {
+               if ( !( $value instanceof LatLongValue ) ) {
+                       throw new InvalidArgumentException( 'Data value type 
mismatch. Expected a LatLongValue.' );
+               }
+
+               $precision = $this->options->getOption( self::OPT_PRECISION );
+
+               return $this->formatLatLongValue( $value, $precision );
+       }
+
+       /**
+        * Formats a LatLongValue with the desired precision.
+        *
+        * @since 0.5
+        *
+        * @param LatLongValue $value
+        * @param float|int $precision The desired precision, given as 
fractional degrees.
+        *
+        * @return string Plain text
+        * @throws InvalidArgumentException
+        */
+       public function formatLatLongValue( LatLongValue $value, $precision ) {
+               if ( $precision <= 0 || !is_finite( $precision ) ) {
+                       $precision = 1 / 3600;
+               }
+
+               $formatted = implode(
+                       $this->getOption( self::OPT_SEPARATOR_SYMBOL ) . 
$this->getSpacing( self::OPT_SPACE_LATLONG ),
+                       [
+                               $this->formatLatitude( $value->getLatitude(), 
$precision ),
+                               $this->formatLongitude( $value->getLongitude(), 
$precision )
+                       ]
+               );
+
+               return $formatted;
+       }
+
+       /**
+        * @param string $spacingLevel One of the self::OPT_SPACE_… constants
+        *
+        * @return string
+        */
+       private function getSpacing( $spacingLevel ) {
+               if ( in_array( $spacingLevel, $this->getOption( 
self::OPT_SPACING_LEVEL ) ) ) {
+                       return ' ';
+               }
+               return '';
+       }
+
+       /**
+        * @param float $latitude
+        * @param float|int $precision
+        *
+        * @return string
+        */
+       private function formatLatitude( $latitude, $precision ) {
+               return $this->makeDirectionalIfNeeded(
+                       $this->formatCoordinate( $latitude, $precision ),
+                       $this->options->getOption( self::OPT_NORTH_SYMBOL ),
+                       $this->options->getOption( self::OPT_SOUTH_SYMBOL )
+               );
+       }
+
+       /**
+        * @param float $longitude
+        * @param float|int $precision
+        *
+        * @return string
+        */
+       private function formatLongitude( $longitude, $precision ) {
+               return $this->makeDirectionalIfNeeded(
+                       $this->formatCoordinate( $longitude, $precision ),
+                       $this->options->getOption( self::OPT_EAST_SYMBOL ),
+                       $this->options->getOption( self::OPT_WEST_SYMBOL )
+               );
+       }
+
+       /**
+        * @param string $coordinate
+        * @param string $positiveSymbol
+        * @param string $negativeSymbol
+        *
+        * @return string
+        */
+       private function makeDirectionalIfNeeded( $coordinate, $positiveSymbol, 
$negativeSymbol ) {
+               if ( $this->options->getOption( self::OPT_DIRECTIONAL ) ) {
+                       return $this->makeDirectional( $coordinate, 
$positiveSymbol, $negativeSymbol );
+               }
+
+               return $coordinate;
+       }
+
+       /**
+        * @param string $coordinate
+        * @param string $positiveSymbol
+        * @param string $negativeSymbol
+        *
+        * @return string
+        */
+       private function makeDirectional( $coordinate, $positiveSymbol, 
$negativeSymbol ) {
+               $isNegative = substr( $coordinate, 0, 1 ) === '-';
+
+               if ( $isNegative ) {
+                       $coordinate = substr( $coordinate, 1 );
+               }
+
+               $symbol = $isNegative ? $negativeSymbol : $positiveSymbol;
+
+               return $coordinate . $this->getSpacing( 
self::OPT_SPACE_DIRECTION ) . $symbol;
+       }
+
+       /**
+        * @param float $degrees
+        * @param float|int $precision
+        *
+        * @return string
+        */
+       private function formatCoordinate( $degrees, $precision ) {
+               // Remove insignificant detail
+               $degrees = $this->roundDegrees( $degrees, $precision );
+               $format = $this->getOption( self::OPT_FORMAT );
+
+               if ( $format === self::TYPE_FLOAT ) {
+                       return $this->getInFloatFormat( $degrees );
+               }
+
+               if ( $format !== self::TYPE_DD ) {
+                       if ( $precision >= 1 - 1 / 60 && $precision < 1 ) {
+                               $precision = 1;
+                       } elseif ( $precision >= 1 / 60 - 1 / 3600 && 
$precision < 1 / 60 ) {
+                               $precision = 1 / 60;
+                       }
+               }
+
+               if ( $format === self::TYPE_DD || $precision >= 1 ) {
+                       return $this->getInDecimalDegreeFormat( $degrees, 
$precision );
+               }
+               if ( $format === self::TYPE_DM || $precision >= 1 / 60 ) {
+                       return $this->getInDecimalMinuteFormat( $degrees, 
$precision );
+               }
+               if ( $format === self::TYPE_DMS ) {
+                       return $this->getInDegreeMinuteSecondFormat( $degrees, 
$precision );
+               }
+
+               throw new InvalidArgumentException( 'Invalid coordinate format 
specified in the options' );
+       }
+
+       /**
+        * Round degrees according to OPT_PRECISION
+        *
+        * @param float $degrees
+        * @param float|int $precision
+        *
+        * @return float
+        */
+       private function roundDegrees( $degrees, $precision ) {
+               $sign = $degrees > 0 ? 1 : -1;
+               $reduced = round( abs( $degrees ) / $precision );
+               $expanded = $reduced * $precision;
+
+               return $sign * $expanded;
+       }
+
+       /**
+        * @param float $floatDegrees
+        *
+        * @return string
+        */
+       private function getInFloatFormat( $floatDegrees ) {
+               $stringDegrees = (string)$floatDegrees;
+
+               // Floats are fun...
+               if ( $stringDegrees === '-0' ) {
+                       $stringDegrees = '0';
+               }
+
+               return $stringDegrees;
+       }
+
+       /**
+        * @param float $floatDegrees
+        * @param float|int $precision
+        *
+        * @return string
+        */
+       private function getInDecimalDegreeFormat( $floatDegrees, $precision ) {
+               $degreeDigits = $this->getSignificantDigits( 1, $precision );
+               $stringDegrees = $this->formatNumber( $floatDegrees, 
$degreeDigits );
+
+               return $stringDegrees . $this->options->getOption( 
self::OPT_DEGREE_SYMBOL );
+       }
+
+       /**
+        * @param float $floatDegrees
+        * @param float|int $precision
+        *
+        * @return string
+        */
+       private function getInDegreeMinuteSecondFormat( $floatDegrees, 
$precision ) {
+               $isNegative = $floatDegrees < 0;
+               $secondDigits = $this->getSignificantDigits( 3600, $precision );
+
+               $seconds = round( abs( $floatDegrees ) * 3600, max( 0, 
$secondDigits ) );
+               $minutes = (int)( $seconds / 60 );
+               $degrees = (int)( $minutes / 60 );
+
+               $seconds -= $minutes * 60;
+               $minutes -= $degrees * 60;
+
+               $space = $this->getSpacing( self::OPT_SPACE_COORDPARTS );
+               $result = $this->formatNumber( $degrees )
+                       . $this->options->getOption( self::OPT_DEGREE_SYMBOL )
+                       . $space
+                       . $this->formatNumber( $minutes )
+                       . $this->options->getOption( self::OPT_MINUTE_SYMBOL )
+                       . $space
+                       . $this->formatNumber( $seconds, $secondDigits )
+                       . $this->options->getOption( self::OPT_SECOND_SYMBOL );
+
+               if ( $isNegative && ( $degrees + $minutes + $seconds ) > 0 ) {
+                       $result = '-' . $result;
+               }
+
+               return $result;
+       }
+
+       /**
+        * @param float $floatDegrees
+        * @param float|int $precision
+        *
+        * @return string
+        */
+       private function getInDecimalMinuteFormat( $floatDegrees, $precision ) {
+               $isNegative = $floatDegrees < 0;
+               $minuteDigits = $this->getSignificantDigits( 60, $precision );
+
+               $minutes = round( abs( $floatDegrees ) * 60, max( 0, 
$minuteDigits ) );
+               $degrees = (int)( $minutes / 60 );
+
+               $minutes -= $degrees * 60;
+
+               $space = $this->getSpacing( self::OPT_SPACE_COORDPARTS );
+               $result = $this->formatNumber( $degrees )
+                       . $this->options->getOption( self::OPT_DEGREE_SYMBOL )
+                       . $space
+                       . $this->formatNumber( $minutes, $minuteDigits )
+                       . $this->options->getOption( self::OPT_MINUTE_SYMBOL );
+
+               if ( $isNegative && ( $degrees + $minutes ) > 0 ) {
+                       $result = '-' . $result;
+               }
+
+               return $result;
+       }
+
+       /**
+        * @param float|int $unitsPerDegree The number of target units per 
degree
+        * (60 for minutes, 3600 for seconds)
+        * @param float|int $degreePrecision
+        *
+        * @return int The number of digits to show after the decimal point
+        * (resp. before, if the result is negative).
+        */
+       private function getSignificantDigits( $unitsPerDegree, 
$degreePrecision ) {
+               return (int)ceil( -log10( $unitsPerDegree * $degreePrecision ) 
);
+       }
+
+       /**
+        * @param float $number
+        * @param int $digits The number of digits after the decimal point.
+        *
+        * @return string
+        */
+       private function formatNumber( $number, $digits = 0 ) {
+               // TODO: use NumberLocalizer
+               return sprintf( '%.' . ( $digits > 0 ? $digits : 0 ) . 'F', 
$number );
+       }
+
+}
diff --git a/data-values/geo/src/GlobeMath.php 
b/data-values/geo/src/GlobeMath.php
new file mode 100644
index 0000000..390ff6f
--- /dev/null
+++ b/data-values/geo/src/GlobeMath.php
@@ -0,0 +1,114 @@
+<?php
+
+namespace DataValues\Geo;
+
+use DataValues\Geo\Values\GlobeCoordinateValue;
+use DataValues\Geo\Values\LatLongValue;
+
+/**
+ * Logical and mathematical helper functions for normalizations and 
calculations with
+ * GlobeCoordinateValue objects.
+ *
+ * @since 0.2
+ *
+ * @license GPL-2.0+
+ * @author Thiemo Mättig
+ */
+class GlobeMath {
+
+       /**
+        * @todo Move this constant next to GlobeCoordinateValue::GLOBE_EARTH?
+        */
+       const GLOBE_MOON = 'http://www.wikidata.org/entity/Q405';
+
+       /**
+        * @param string|null $globe IRI of a globe.
+        *
+        * @return string Normalized IRI, defaults to 
'http://www.wikidata.org/entity/Q2'.
+        */
+       public function normalizeGlobe( $globe ) {
+               if ( !is_string( $globe ) || $globe === '' ) {
+                       return GlobeCoordinateValue::GLOBE_EARTH;
+               }
+
+               return $globe;
+       }
+
+       /**
+        * Normalizes latitude to [-90°..+90°]. Normalizes longitude to 
[-180°..+180°[ on Earth and
+        * Moon and to [0°..+360°[ on all other globes.
+        * @see http://planetarynames.wr.usgs.gov/TargetCoordinates
+        *
+        * @param GlobeCoordinateValue $value
+        *
+        * @return GlobeCoordinateValue
+        */
+       public function normalizeGlobeCoordinate( GlobeCoordinateValue $value ) 
{
+               return new GlobeCoordinateValue(
+                       $this->normalizeGlobeLatLong( $value->getLatLong(), 
$value->getGlobe() ),
+                       $value->getPrecision(),
+                       $value->getGlobe()
+               );
+       }
+
+       /**
+        * @param LatLongValue $value
+        * @param string|null $globe
+        *
+        * @return LatLongValue
+        */
+       public function normalizeGlobeLatLong( LatLongValue $value, $globe = 
null ) {
+               switch ( $this->normalizeGlobe( $globe ) ) {
+                       case GlobeCoordinateValue::GLOBE_EARTH:
+                       case self::GLOBE_MOON:
+                               $minimumLongitude = -180;
+                               break;
+                       default:
+                               $minimumLongitude = 0;
+               }
+
+               return $this->normalizeLatLong( $value, $minimumLongitude );
+       }
+
+       /**
+        * @param LatLongValue $value
+        * @param float $minimumLongitude
+        *
+        * @return LatLongValue
+        */
+       public function normalizeLatLong( LatLongValue $value, 
$minimumLongitude = -180.0 ) {
+               $lat = $value->getLatitude();
+               $lon = $value->getLongitude();
+
+               // Normalize to [-180°..+180°[ on Earth/Moon, [0°..+360°[ on 
other globes.
+               if ( $lon >= $minimumLongitude + 360 ) {
+                       $lon -= 360;
+               } elseif ( $lon < $minimumLongitude ) {
+                       $lon += 360;
+               }
+
+               if ( $lat >= 270 ) {
+                       // Same side of the globe, on the southern hemisphere.
+                       $lat -= 360;
+               } elseif ( $lat <= -270 ) {
+                       // Same side of the globe, on the northern hemisphere.
+                       $lat += 360;
+               } elseif ( $lat > 90 ) {
+                       // Other side of the globe
+                       $lat = 180 - $lat;
+                       $lon += $lon - 180 >= $minimumLongitude ? -180 : 180;
+               } elseif ( $lat < -90 ) {
+                       // Other side of the globe
+                       $lat = -180 - $lat;
+                       $lon += $lon - 180 >= $minimumLongitude ? -180 : 180;
+               }
+
+               // North/south pole
+               if ( abs( $lat ) === 90.0 ) {
+                       $lon = 0;
+               }
+
+               return new LatLongValue( $lat, $lon );
+       }
+
+}
diff --git a/data-values/geo/src/Parsers/DdCoordinateParser.php 
b/data-values/geo/src/Parsers/DdCoordinateParser.php
new file mode 100644
index 0000000..f21b8e0
--- /dev/null
+++ b/data-values/geo/src/Parsers/DdCoordinateParser.php
@@ -0,0 +1,217 @@
+<?php
+
+namespace DataValues\Geo\Parsers;
+
+use DataValues\Geo\Values\LatLongValue;
+use ValueParsers\ParserOptions;
+
+/**
+ * Parser for geographical coordinates in Decimal Degree notation.
+ *
+ * @since 0.1
+ *
+ * @license GPL-2.0+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ * @author H. Snater < mediaw...@snater.com >
+ */
+class DdCoordinateParser extends LatLongParserBase {
+
+       /**
+        * The symbol representing degrees.
+        * @since 0.1
+        */
+       const OPT_DEGREE_SYMBOL = 'degree';
+
+       /**
+        * @param ParserOptions|null $options
+        */
+       public function __construct( ParserOptions $options = null ) {
+               parent::__construct( $options );
+
+               $this->defaultOption( self::OPT_DEGREE_SYMBOL, '°' );
+
+               $this->defaultDelimiters = [ $this->getOption( 
self::OPT_DEGREE_SYMBOL ) ];
+       }
+
+       /**
+        * @see LatLongParserBase::getParsedCoordinate
+        *
+        * @param string $coordinateSegment
+        *
+        * @return float
+        */
+       protected function getParsedCoordinate( $coordinateSegment ) {
+               $coordinateSegment = $this->resolveDirection( 
$coordinateSegment );
+               return $this->parseCoordinate( $coordinateSegment );
+       }
+
+       /**
+        * @see LatLongParserBase::areValidCoordinates
+        *
+        * @param string[] $normalizedCoordinateSegments
+        *
+        * @return bool
+        */
+       protected function areValidCoordinates( array 
$normalizedCoordinateSegments ) {
+               // TODO: Implement localized decimal separator.
+               $baseRegExp = '\d{1,3}(\.\d{1,20})?' . $this->getOption( 
self::OPT_DEGREE_SYMBOL );
+
+               // Cache whether the coordinates are specified in directional 
format (a mixture of
+               // directional and non-directional is regarded invalid).
+               $directional = false;
+
+               $match = false;
+
+               foreach ( $normalizedCoordinateSegments as $i => $segment ) {
+                       $direction = '('
+                               . $this->getOption( self::OPT_NORTH_SYMBOL ) . 
'|'
+                               . $this->getOption( self::OPT_SOUTH_SYMBOL ) . 
')';
+
+                       if ( $i === 1 ) {
+                               $direction = '('
+                                       . $this->getOption( 
self::OPT_EAST_SYMBOL ) . '|'
+                                       . $this->getOption( 
self::OPT_WEST_SYMBOL ) . ')';
+                       }
+
+                       $match = preg_match(
+                               '/^(' . $baseRegExp . $direction . '|' . 
$direction . $baseRegExp . ')$/i',
+                               $segment
+                       );
+
+                       if ( $directional ) {
+                               // Directionality is only set after parsing 
latitude: When the latitude is
+                               // is directional, the longitude needs to be as 
well. Therefore we break here since
+                               // checking for directionality is the only 
check needed for longitude.
+                               break;
+                       } elseif ( $match ) {
+                               // Latitude is directional, no need to check 
for non-directionality.
+                               $directional = true;
+                               continue;
+                       }
+
+                       $match = preg_match( '/^(-)?' . $baseRegExp . '$/i', 
$segment );
+
+                       if ( !$match ) {
+                               // Does neither match directional nor 
non-directional.
+                               break;
+                       }
+               }
+
+               return ( 1 === $match );
+       }
+
+       /**
+        * @see LatLongParserBase::stringParse
+        *
+        * @param string $value
+        *
+        * @return LatLongValue
+        */
+       protected function stringParse( $value ) {
+               return parent::stringParse( $this->getNormalizedNotation( 
$value ) );
+       }
+
+       /**
+        * Returns a normalized version of the coordinate string.
+        *
+        * @param string $coordinates
+        *
+        * @return string
+        */
+       protected function getNormalizedNotation( $coordinates ) {
+               $coordinates = str_replace(
+                       [ '&#176;', '&deg;' ],
+                       $this->getOption( self::OPT_DEGREE_SYMBOL ), 
$coordinates
+               );
+
+               $coordinates = $this->removeInvalidChars( $coordinates );
+
+               return $coordinates;
+       }
+
+       /**
+        * Returns a string with whitespace, control characters and characters 
with ASCII values above
+        * 126 removed.
+        *
+        * @see LatLongParserBase::removeInvalidChars
+        *
+        * @param string $string
+        *
+        * @return string
+        */
+       protected function removeInvalidChars( $string ) {
+               return str_replace( ' ', '', parent::removeInvalidChars( 
$string ) );
+       }
+
+       /**
+        * Converts a coordinate segment to float representation.
+        *
+        * @param string $coordinateSegment
+        *
+        * @return float
+        */
+       protected function parseCoordinate( $coordinateSegment ) {
+               return (float)str_replace(
+                       $this->getOption( self::OPT_DEGREE_SYMBOL ),
+                       '',
+                       $coordinateSegment
+               );
+       }
+
+       /**
+        * @see LatLongParserBase::splitString
+        *
+        * @param string $normalizedCoordinateString
+        *
+        * @return string[]
+        */
+       protected function splitString( $normalizedCoordinateString ) {
+               $separator = $this->getOption( self::OPT_SEPARATOR_SYMBOL );
+
+               $normalizedCoordinateSegments = explode( $separator, 
$normalizedCoordinateString );
+
+               if ( count( $normalizedCoordinateSegments ) !== 2 ) {
+                       // Separator not present within the string, trying to 
figure out the segments by
+                       // splitting after the first direction character or 
degree symbol:
+                       $delimiters = $this->defaultDelimiters;
+
+                       $ns = [
+                               $this->getOption( self::OPT_NORTH_SYMBOL ),
+                               $this->getOption( self::OPT_SOUTH_SYMBOL )
+                       ];
+
+                       $ew = [
+                               $this->getOption( self::OPT_EAST_SYMBOL ),
+                               $this->getOption( self::OPT_WEST_SYMBOL )
+                       ];
+
+                       foreach ( $ns as $delimiter ) {
+                               if ( mb_strpos( $normalizedCoordinateString, 
$delimiter ) === 0 ) {
+                                       // String starts with "north" or "west" 
symbol: Separation needs to be done
+                                       // before the "east" or "west" symbol.
+                                       $delimiters = array_merge( $ew, 
$delimiters );
+                                       break;
+                               }
+                       }
+
+                       if ( count( $delimiters ) !== count( 
$this->defaultDelimiters ) + 2 ) {
+                               $delimiters = array_merge( $ns, $delimiters );
+                       }
+
+                       foreach ( $delimiters as $delimiter ) {
+                               $delimiterPos = mb_strpos( 
$normalizedCoordinateString, $delimiter );
+                               if ( $delimiterPos !== false ) {
+                                       $adjustPos = ( in_array( $delimiter, 
$ew ) ) ? 0 : mb_strlen( $delimiter );
+                                       $normalizedCoordinateSegments = [
+                                               mb_substr( 
$normalizedCoordinateString, 0, $delimiterPos + $adjustPos ),
+                                               mb_substr( 
$normalizedCoordinateString, $delimiterPos + $adjustPos )
+                                       ];
+                                       break;
+                               }
+                       }
+               }
+
+               return $normalizedCoordinateSegments;
+       }
+
+}
diff --git a/data-values/geo/src/Parsers/DmCoordinateParser.php 
b/data-values/geo/src/Parsers/DmCoordinateParser.php
new file mode 100644
index 0000000..d6ddafb
--- /dev/null
+++ b/data-values/geo/src/Parsers/DmCoordinateParser.php
@@ -0,0 +1,164 @@
+<?php
+
+namespace DataValues\Geo\Parsers;
+
+use ValueParsers\ParseException;
+use ValueParsers\ParserOptions;
+
+/**
+ * Parser for geographical coordinates in Decimal Minute notation.
+ *
+ * @since 0.1
+ *
+ * @license GPL-2.0+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ * @author H. Snater < mediaw...@snater.com >
+ */
+class DmCoordinateParser extends DdCoordinateParser {
+
+       const FORMAT_NAME = 'dm-coordinate';
+
+       /**
+        * The symbols representing minutes.
+        * @since 0.1
+        */
+       const OPT_MINUTE_SYMBOL = 'minute';
+
+       /**
+        * @param ParserOptions|null $options
+        */
+       public function __construct( ParserOptions $options = null ) {
+               parent::__construct( $options );
+
+               $this->defaultOption( self::OPT_MINUTE_SYMBOL, "'" );
+
+               $this->defaultDelimiters = [ $this->getOption( 
self::OPT_MINUTE_SYMBOL ) ];
+       }
+
+       /**
+        * @see LatLongParserBase::areValidCoordinates
+        *
+        * @param string[] $normalizedCoordinateSegments
+        *
+        * @return bool
+        */
+       protected function areValidCoordinates( array 
$normalizedCoordinateSegments ) {
+               // At least one coordinate segment needs to have minutes 
specified.
+               $regExpStrict = '\d{1,3}'
+                       . preg_quote( $this->getOption( self::OPT_DEGREE_SYMBOL 
) )
+                       // TODO: Implement localized decimal separator.
+                       . '(\d{1,2}(\.\d{1,20})?'
+                       . preg_quote( $this->getOption( self::OPT_MINUTE_SYMBOL 
) )
+                       . ')';
+               $regExpLoose = $regExpStrict . '?';
+
+               // Cache whether minutes have been detected within the 
coordinate:
+               $detectedMinute = false;
+
+               // Cache whether the coordinates are specified in directional 
format (a mixture of
+               // directional and non-directional is regarded invalid).
+               $directional = false;
+
+               foreach ( $normalizedCoordinateSegments as $i => $segment ) {
+                       $direction = '('
+                               . $this->getOption( self::OPT_NORTH_SYMBOL ) . 
'|'
+                               . $this->getOption( self::OPT_SOUTH_SYMBOL ) . 
')';
+
+                       if ( $i === 1 ) {
+                               $direction = '('
+                                       . $this->getOption( 
self::OPT_EAST_SYMBOL ) . '|'
+                                       . $this->getOption( 
self::OPT_WEST_SYMBOL ) . ')';
+                       }
+
+                       $match = preg_match(
+                               '/^(' . $regExpStrict . $direction . '|' . 
$direction . $regExpStrict . ')$/i',
+                               $segment
+                       );
+
+                       if ( $match ) {
+                               $detectedMinute = true;
+                       } else {
+                               $match = preg_match(
+                                       '/^(' . $regExpLoose . $direction . '|' 
. $direction . $regExpLoose . ')$/i',
+                                       $segment
+                               );
+                       }
+
+                       if ( $match ) {
+                               $directional = true;
+                       } elseif ( !$directional ) {
+                               $match = preg_match( '/^(-)?' . $regExpStrict . 
'$/i', $segment );
+
+                               if ( $match ) {
+                                       $detectedMinute = true;
+                               } else {
+                                       $match = preg_match( '/^(-)?' . 
$regExpLoose . '$/i', $segment );
+                               }
+                       }
+
+                       if ( !$match ) {
+                               return false;
+                       }
+               }
+
+               return $detectedMinute;
+       }
+
+       /**
+        * @see DdCoordinateParser::getNormalizedNotation
+        *
+        * @param string $coordinates
+        *
+        * @return string
+        */
+       protected function getNormalizedNotation( $coordinates ) {
+               $minute = $this->getOption( self::OPT_MINUTE_SYMBOL );
+
+               $coordinates = str_replace( [ '&#8242;', '&prime;', '´', '′' ], 
$minute, $coordinates );
+
+               $coordinates = parent::getNormalizedNotation( $coordinates );
+
+               $coordinates = $this->removeInvalidChars( $coordinates );
+
+               return $coordinates;
+       }
+
+       /**
+        * @see DdCoordinateParser::parseCoordinate
+        *
+        * @param string $coordinateSegment
+        *
+        * @return float
+        */
+       protected function parseCoordinate( $coordinateSegment ) {
+               $isNegative = substr( $coordinateSegment, 0, 1 ) === '-';
+
+               if ( $isNegative ) {
+                       $coordinateSegment = substr( $coordinateSegment, 1 );
+               }
+
+               $degreeSymbol = $this->getOption( self::OPT_DEGREE_SYMBOL );
+               $exploded = explode( $degreeSymbol, $coordinateSegment );
+
+               if ( count( $exploded ) !== 2 ) {
+                       throw new ParseException(
+                               'Unable to explode coordinate segment by degree 
symbol (' . $degreeSymbol . ')',
+                               $coordinateSegment,
+                               self::FORMAT_NAME
+                       );
+               }
+
+               list( $degrees, $minutes ) = $exploded;
+
+               $minutes = substr( $minutes, 0, -1 );
+
+               $coordinateSegment = $degrees + $minutes / 60;
+
+               if ( $isNegative ) {
+                       $coordinateSegment *= -1;
+               }
+
+               return (float)$coordinateSegment;
+       }
+
+}
diff --git a/data-values/geo/src/Parsers/DmsCoordinateParser.php 
b/data-values/geo/src/Parsers/DmsCoordinateParser.php
new file mode 100644
index 0000000..c343802
--- /dev/null
+++ b/data-values/geo/src/Parsers/DmsCoordinateParser.php
@@ -0,0 +1,192 @@
+<?php
+
+namespace DataValues\Geo\Parsers;
+
+use ValueParsers\ParseException;
+use ValueParsers\ParserOptions;
+
+/**
+ * Parser for geographical coordinates in Degree Minute Second notation.
+ *
+ * @since 0.1
+ *
+ * @license GPL-2.0+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ * @author H. Snater < mediaw...@snater.com >
+ */
+class DmsCoordinateParser extends DmCoordinateParser {
+
+       const FORMAT_NAME = 'dms-coordinate';
+
+       /**
+        * The symbol representing seconds.
+        * @since 0.1
+        */
+       const OPT_SECOND_SYMBOL = 'second';
+
+       /**
+        * @param ParserOptions|null $options
+        */
+       public function __construct( ParserOptions $options = null ) {
+               parent::__construct( $options );
+
+               $this->defaultOption( self::OPT_SECOND_SYMBOL, '"' );
+
+               $this->defaultDelimiters = [ $this->getOption( 
self::OPT_SECOND_SYMBOL ) ];
+       }
+
+       /**
+        * @see LatLongParserBase::areValidCoordinates
+        *
+        * @param string[] $normalizedCoordinateSegments
+        *
+        * @return bool
+        */
+       protected function areValidCoordinates( array 
$normalizedCoordinateSegments ) {
+               // At least one coordinate segment needs to have seconds 
specified (which additionally
+               // requires minutes to be specified).
+               $regExpLoose = '(\d{1,3}'
+                       . preg_quote( $this->getOption( self::OPT_DEGREE_SYMBOL 
) )
+                       . ')(\d{1,2}'
+                       . preg_quote( $this->getOption( self::OPT_MINUTE_SYMBOL 
) )
+                       . ')?((\d{1,2}'
+                       . preg_quote( $this->getOption( self::OPT_SECOND_SYMBOL 
) )
+                       // TODO: Implement localized decimal separator.
+                       . ')?|(\d{1,2}\.\d{1,20}'
+                       . preg_quote( $this->getOption( self::OPT_SECOND_SYMBOL 
) )
+                       . ')?)';
+               $regExpStrict = str_replace( '?', '', $regExpLoose );
+
+               // Cache whether seconds have been detected within the 
coordinate:
+               $detectedSecond = false;
+
+               // Cache whether the coordinates are specified in directional 
format (a mixture of
+               // directional and non-directional is regarded invalid).
+               $directional = false;
+
+               foreach ( $normalizedCoordinateSegments as $i => $segment ) {
+                       $direction = '('
+                               . $this->getOption( self::OPT_NORTH_SYMBOL ) . 
'|'
+                               . $this->getOption( self::OPT_SOUTH_SYMBOL ) . 
')';
+
+                       if ( $i === 1 ) {
+                               $direction = '('
+                                       . $this->getOption( 
self::OPT_EAST_SYMBOL ) . '|'
+                                       . $this->getOption( 
self::OPT_WEST_SYMBOL ) . ')';
+                       }
+
+                       $match = preg_match(
+                               '/^(' . $regExpStrict . $direction . '|' . 
$direction . $regExpStrict . ')$/i',
+                               $segment
+                       );
+
+                       if ( $match ) {
+                               $detectedSecond = true;
+                       } else {
+                               $match = preg_match(
+                                       '/^(' . $regExpLoose . $direction . '|' 
. $direction . $regExpLoose . ')$/i',
+                                       $segment
+                               );
+                       }
+
+                       if ( $match ) {
+                               $directional = true;
+                       } elseif ( !$directional ) {
+                               $match = preg_match( '/^(-)?' . $regExpStrict . 
'$/i', $segment );
+
+                               if ( $match ) {
+                                       $detectedSecond = true;
+                               } else {
+                                       $match = preg_match( '/^(-)?' . 
$regExpLoose . '$/i', $segment );
+                               }
+                       }
+
+                       if ( !$match ) {
+                               return false;
+                       }
+               }
+
+               return $detectedSecond;
+       }
+
+       /**
+        * @see DdCoordinateParser::getNormalizedNotation
+        *
+        * @param string $coordinates
+        *
+        * @return string
+        */
+       protected function getNormalizedNotation( $coordinates ) {
+               $second = $this->getOption( self::OPT_SECOND_SYMBOL );
+               $minute = $this->getOption( self::OPT_MINUTE_SYMBOL );
+
+               $coordinates = str_replace(
+                       [ '&#8243;', '&Prime;', $minute . $minute, '´´', '′′', 
'″' ],
+                       $second,
+                       $coordinates
+               );
+               $coordinates = str_replace( [ '&acute;', '&#180;' ], $second, 
$coordinates );
+
+               $coordinates = parent::getNormalizedNotation( $coordinates );
+
+               $coordinates = $this->removeInvalidChars( $coordinates );
+
+               return $coordinates;
+       }
+
+       /**
+        * @see DdCoordinateParser::parseCoordinate
+        *
+        * @param string $coordinateSegment
+        *
+        * @return float
+        */
+       protected function parseCoordinate( $coordinateSegment ) {
+               $isNegative = substr( $coordinateSegment, 0, 1 ) === '-';
+
+               if ( $isNegative ) {
+                       $coordinateSegment = substr( $coordinateSegment, 1 );
+               }
+
+               $degreeSymbol = $this->getOption( self::OPT_DEGREE_SYMBOL );
+               $degreePosition = strpos( $coordinateSegment, $degreeSymbol );
+
+               if ( $degreePosition === false ) {
+                       throw new ParseException(
+                               'Did not find degree symbol (' . $degreeSymbol 
. ')',
+                               $coordinateSegment,
+                               self::FORMAT_NAME
+                       );
+               }
+
+               $degrees = (float)substr( $coordinateSegment, 0, 
$degreePosition );
+
+               $minutePosition = strpos( $coordinateSegment, $this->getOption( 
self::OPT_MINUTE_SYMBOL ) );
+
+               if ( $minutePosition === false ) {
+                       $minutes = 0;
+               } else {
+                       $degSignLength = strlen( $this->getOption( 
self::OPT_DEGREE_SYMBOL ) );
+                       $minuteLength = $minutePosition - $degreePosition - 
$degSignLength;
+                       $minutes = substr( $coordinateSegment, $degreePosition 
+ $degSignLength, $minuteLength );
+               }
+
+               $secondPosition = strpos( $coordinateSegment, $this->getOption( 
self::OPT_SECOND_SYMBOL ) );
+
+               if ( $secondPosition === false ) {
+                       $seconds = 0;
+               } else {
+                       $secondLength = $secondPosition - $minutePosition - 1;
+                       $seconds = substr( $coordinateSegment, $minutePosition 
+ 1, $secondLength );
+               }
+
+               $coordinateSegment = $degrees + ( $minutes + $seconds / 60 ) / 
60;
+
+               if ( $isNegative ) {
+                       $coordinateSegment *= -1;
+               }
+
+               return (float)$coordinateSegment;
+       }
+
+}
diff --git a/data-values/geo/src/Parsers/FloatCoordinateParser.php 
b/data-values/geo/src/Parsers/FloatCoordinateParser.php
new file mode 100644
index 0000000..aa68bf8
--- /dev/null
+++ b/data-values/geo/src/Parsers/FloatCoordinateParser.php
@@ -0,0 +1,134 @@
+<?php
+
+namespace DataValues\Geo\Parsers;
+
+use ValueParsers\ParseException;
+
+/**
+ * @since 0.1
+ *
+ * @license GPL-2.0+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ * @author H. Snater < mediaw...@snater.com >
+ */
+class FloatCoordinateParser extends LatLongParserBase {
+
+       const FORMAT_NAME = 'float-coordinate';
+
+       /**
+        * @see LatLongParserBase::getParsedCoordinate
+        *
+        * @param string $coordinateSegment
+        *
+        * @return float
+        */
+       protected function getParsedCoordinate( $coordinateSegment ) {
+               return (float)$this->resolveDirection( str_replace( ' ', '', 
$coordinateSegment ) );
+       }
+
+       /**
+        * @see LatLongParserBase::areValidCoordinates
+        *
+        * @param string[] $normalizedCoordinateSegments
+        *
+        * @return bool
+        */
+       protected function areValidCoordinates( array 
$normalizedCoordinateSegments ) {
+               // TODO: Implement localized decimal separator.
+               $baseRegExp = '\d{1,3}(\.\d{1,20})?';
+
+               // Cache whether the coordinates are specified in directional 
format (a mixture of
+               // directional and non-directional is regarded invalid).
+               $directional = false;
+
+               $match = false;
+
+               foreach ( $normalizedCoordinateSegments as $i => $segment ) {
+                       $segment = str_replace( ' ', '', $segment );
+
+                       $direction = '('
+                               . $this->getOption( self::OPT_NORTH_SYMBOL ) . 
'|'
+                               . $this->getOption( self::OPT_SOUTH_SYMBOL ) . 
')';
+
+                       if ( $i === 1 ) {
+                               $direction = '('
+                                       . $this->getOption( 
self::OPT_EAST_SYMBOL ) . '|'
+                                       . $this->getOption( 
self::OPT_WEST_SYMBOL ) . ')';
+                       }
+
+                       $match = preg_match(
+                               '/^(' . $baseRegExp . $direction . '|' . 
$direction . $baseRegExp . ')$/i',
+                               $segment
+                       );
+
+                       if ( $directional && !$match ) {
+                               // Latitude is directional, longitude not.
+                               break;
+                       } elseif ( $match ) {
+                               continue;
+                       }
+
+                       $match = preg_match( '/^(-)?' . $baseRegExp . '$/i', 
$segment );
+
+                       if ( !$match ) {
+                               // Does neither match directional nor 
non-directional.
+                               break;
+                       }
+               }
+
+               return ( 1 === $match );
+       }
+
+       /**
+        * @see LatLongParserBase::splitString
+        *
+        * @param string $normalizedCoordinateString
+        *
+        * @throws ParseException if unable to split input string into two 
segments
+        * @return string[]
+        */
+       protected function splitString( $normalizedCoordinateString ) {
+               $separator = $this->getOption( self::OPT_SEPARATOR_SYMBOL );
+
+               $normalizedCoordinateSegments = explode( $separator, 
$normalizedCoordinateString );
+
+               if ( count( $normalizedCoordinateSegments ) !== 2 ) {
+                       // Separator not present within the string, trying to 
figure out the segments by
+                       // splitting at the the first SPACE after the first 
direction character or digit:
+                       $numberRegEx = '-?\d{1,3}(\.\d{1,20})?';
+
+                       $ns = '('
+                               . $this->getOption( self::OPT_NORTH_SYMBOL ) . 
'|'
+                               . $this->getOption( self::OPT_SOUTH_SYMBOL ) 
.')';
+
+                       $latitudeRegEx = '(' . $ns . '\s*)?' . $numberRegEx . 
'(\s*' . $ns . ')?';
+
+                       $ew = '('
+                               . $this->getOption( self::OPT_EAST_SYMBOL ) . 
'|'
+                               . $this->getOption( self::OPT_WEST_SYMBOL ) 
.')';
+
+                       $longitudeRegEx = '(' . $ew . '\s*)?' . $numberRegEx . 
'(\s*' . $ew . ')?';
+
+                       $match = preg_match(
+                               '/^(' . $latitudeRegEx . ') (' . 
$longitudeRegEx . ')$/i',
+                               $normalizedCoordinateString,
+                               $matches
+                       );
+
+                       if ( $match ) {
+                               $normalizedCoordinateSegments = [ $matches[1], 
$matches[7] ];
+                       }
+               }
+
+               if ( count( $normalizedCoordinateSegments ) !== 2 ) {
+                       throw new ParseException(
+                               'Unable to split input into two coordinate 
segments',
+                               $normalizedCoordinateString,
+                               self::FORMAT_NAME
+                       );
+               }
+
+               return $normalizedCoordinateSegments;
+       }
+
+}
diff --git a/data-values/geo/src/Parsers/GlobeCoordinateParser.php 
b/data-values/geo/src/Parsers/GlobeCoordinateParser.php
new file mode 100644
index 0000000..236f9ec
--- /dev/null
+++ b/data-values/geo/src/Parsers/GlobeCoordinateParser.php
@@ -0,0 +1,162 @@
+<?php
+
+namespace DataValues\Geo\Parsers;
+
+use DataValues\Geo\Values\GlobeCoordinateValue;
+use DataValues\Geo\Values\LatLongValue;
+use ValueParsers\ParseException;
+use ValueParsers\ParserOptions;
+use ValueParsers\StringValueParser;
+
+/**
+ * Extends the LatLongParser by adding precision detection support.
+ *
+ * The object that gets constructed is a GlobeCoordinateValue rather then a 
LatLongValue.
+ *
+ * @since 0.1
+ *
+ * @license GPL-2.0+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ * @author H. Snater < mediaw...@snater.com >
+ * @author Thiemo Mättig
+ */
+class GlobeCoordinateParser extends StringValueParser {
+
+       const FORMAT_NAME = 'globe-coordinate';
+
+       /**
+        * Option specifying the globe. Should be a string containing a 
Wikidata concept URI. Defaults
+        * to Earth.
+        */
+       const OPT_GLOBE = 'globe';
+
+       /**
+        * @param ParserOptions|null $options
+        */
+       public function __construct( ParserOptions $options = null ) {
+               parent::__construct( $options );
+
+               $this->defaultOption( self::OPT_GLOBE, 
'http://www.wikidata.org/entity/Q2' );
+       }
+
+       /**
+        * @see StringValueParser::stringParse
+        *
+        * @param string $value
+        *
+        * @return GlobeCoordinateValue
+        * @throws ParseException
+        */
+       protected function stringParse( $value ) {
+               foreach ( $this->getParsers() as $precisionDetector => $parser 
) {
+                       try {
+                               $latLong = $parser->parse( $value );
+
+                               return new GlobeCoordinateValue(
+                                       new LatLongValue(
+                                               $latLong->getLatitude(),
+                                               $latLong->getLongitude()
+                                       ),
+                                       $this->detectPrecision( $latLong, 
$precisionDetector ),
+                                       $this->getOption( self::OPT_GLOBE )
+                               );
+                       } catch ( ParseException $parseException ) {
+                               continue;
+                       }
+               }
+
+               throw new ParseException(
+                       'The format of the coordinate could not be determined.',
+                       $value,
+                       self::FORMAT_NAME
+               );
+       }
+
+       /**
+        * @param LatLongValue $latLong
+        * @param string $precisionDetector
+        *
+        * @return float|int
+        */
+       private function detectPrecision( LatLongValue $latLong, 
$precisionDetector ) {
+               if ( $this->options->hasOption( 'precision' ) ) {
+                       return $this->getOption( 'precision' );
+               }
+
+               return min(
+                       call_user_func( [ $this, $precisionDetector ], 
$latLong->getLatitude() ),
+                       call_user_func( [ $this, $precisionDetector ], 
$latLong->getLongitude() )
+               );
+       }
+
+       /**
+        * @return  StringValueParser[]
+        */
+       private function getParsers() {
+               $parsers = [];
+
+               $parsers['detectFloatPrecision'] = new FloatCoordinateParser( 
$this->options );
+               $parsers['detectDmsPrecision'] = new DmsCoordinateParser( 
$this->options );
+               $parsers['detectDmPrecision'] = new DmCoordinateParser( 
$this->options );
+               $parsers['detectDdPrecision'] = new DdCoordinateParser( 
$this->options );
+
+               return $parsers;
+       }
+
+       /**
+        * @param float $degree
+        *
+        * @return float|int
+        */
+       protected function detectDdPrecision( $degree ) {
+               return $this->detectFloatPrecision( $degree );
+       }
+
+       /**
+        * @param float $degree
+        *
+        * @return float|int
+        */
+       protected function detectDmPrecision( $degree ) {
+               $minutes = $degree * 60;
+               $split = explode( '.', round( $minutes, 6 ) );
+
+               if ( isset( $split[1] ) ) {
+                       return $this->detectDmsPrecision( $degree );
+               }
+
+               return 1 / 60;
+       }
+
+       /**
+        * @param float $degree
+        *
+        * @return float|int
+        */
+       protected function detectDmsPrecision( $degree ) {
+               $seconds = $degree * 3600;
+               $split = explode( '.', round( $seconds, 4 ) );
+
+               if ( isset( $split[1] ) ) {
+                       return pow( 10, -strlen( $split[1] ) ) / 3600;
+               }
+
+               return 1 / 3600;
+       }
+
+       /**
+        * @param float $degree
+        *
+        * @return float|int
+        */
+       protected function detectFloatPrecision( $degree ) {
+               $split = explode( '.', round( $degree, 8 ) );
+
+               if ( isset( $split[1] ) ) {
+                       return pow( 10, -strlen( $split[1] ) );
+               }
+
+               return 1;
+       }
+
+}
diff --git a/data-values/geo/src/Parsers/LatLongParser.php 
b/data-values/geo/src/Parsers/LatLongParser.php
new file mode 100644
index 0000000..aea1991
--- /dev/null
+++ b/data-values/geo/src/Parsers/LatLongParser.php
@@ -0,0 +1,115 @@
+<?php
+
+namespace DataValues\Geo\Parsers;
+
+use DataValues\Geo\Values\LatLongValue;
+use ValueParsers\ParseException;
+use ValueParsers\StringValueParser;
+
+/**
+ * ValueParser that parses the string representation of a geographical 
coordinate.
+ *
+ * The resulting objects are of type @see LatLongValue.
+ *
+ * Supports the following notations:
+ * - Degree minute second
+ * - Decimal degrees
+ * - Decimal minutes
+ * - Float
+ *
+ * And for all these notations direction can be indicated either with
+ * + and - or with N/E/S/W, the later depending on the set options.
+ *
+ * The delimiter between latitude and longitude can be set in the options.
+ * So can the symbols used for degrees, minutes and seconds.
+ *
+ * Some code in this class has been borrowed from the
+ * MapsCoordinateParser class of the Maps extension for MediaWiki.
+ *
+ * @since 0.1, name changed in 2.0
+ *
+ * @license GPL-2.0+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class LatLongParser extends StringValueParser {
+
+       const TYPE_FLOAT = 'float';
+       const TYPE_DMS = 'dms';
+       const TYPE_DM = 'dm';
+       const TYPE_DD = 'dd';
+
+       /**
+        * The symbols representing the different directions for usage in 
directional notation.
+        */
+       const OPT_NORTH_SYMBOL = 'north';
+       const OPT_EAST_SYMBOL = 'east';
+       const OPT_SOUTH_SYMBOL = 'south';
+       const OPT_WEST_SYMBOL = 'west';
+
+       /**
+        * The symbols representing degrees, minutes and seconds.
+        */
+       const OPT_DEGREE_SYMBOL = 'degree';
+       const OPT_MINUTE_SYMBOL = 'minute';
+       const OPT_SECOND_SYMBOL = 'second';
+
+       /**
+        * The symbol to use as separator between latitude and longitude.
+        */
+       const OPT_SEPARATOR_SYMBOL = 'separator';
+
+       /**
+        * @see StringValueParser::stringParse
+        *
+        * @param string $value
+        *
+        * @return LatLongValue
+        * @throws ParseException
+        */
+       protected function stringParse( $value ) {
+               foreach ( $this->getParsers() as $parser ) {
+                       try {
+                               return $parser->parse( $value );
+                       } catch ( ParseException $ex ) {
+                               continue;
+                       }
+               }
+
+               throw new ParseException( 'The format of the coordinate could 
not be determined. Parsing failed.' );
+       }
+
+       /**
+        * @return  StringValueParser[]
+        */
+       protected function getParsers() {
+               $parsers = [];
+
+               $parsers[] = new FloatCoordinateParser( $this->options );
+               $parsers[] = new DmsCoordinateParser( $this->options );
+               $parsers[] = new DmCoordinateParser( $this->options );
+               $parsers[] = new DdCoordinateParser( $this->options );
+
+               return $parsers;
+       }
+
+       /**
+        * Convenience function for determining if something is a valid 
coordinate string.
+        * Analogous to creating an instance of the parser, parsing the string 
and checking isValid on the result.
+        *
+        * @deprecated since 2.0, please instantiate and call isValid() instead
+        *
+        * @param string $string
+        *
+        * @return boolean
+        */
+       public static function areCoordinates( $string ) {
+               static $parser = null;
+
+               if ( $parser === null ) {
+                       $parser = new self();
+               }
+
+               return $parser->parse( $string )->isValid();
+       }
+
+}
diff --git a/data-values/geo/src/Parsers/LatLongParserBase.php 
b/data-values/geo/src/Parsers/LatLongParserBase.php
new file mode 100644
index 0000000..9a8817c
--- /dev/null
+++ b/data-values/geo/src/Parsers/LatLongParserBase.php
@@ -0,0 +1,231 @@
+<?php
+
+namespace DataValues\Geo\Parsers;
+
+use DataValues\Geo\Values\LatLongValue;
+use ValueParsers\ParseException;
+use ValueParsers\ParserOptions;
+use ValueParsers\StringValueParser;
+
+/**
+ * @since 0.1, renamed in 2.0
+ *
+ * @license GPL-2.0+
+ * @author H. Snater < mediaw...@snater.com >
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+abstract class LatLongParserBase extends StringValueParser {
+
+       const FORMAT_NAME = 'geo-coordinate';
+
+       /**
+        * The symbols representing the different directions for usage in 
directional notation.
+        */
+       const OPT_NORTH_SYMBOL = 'north';
+       const OPT_EAST_SYMBOL = 'east';
+       const OPT_SOUTH_SYMBOL = 'south';
+       const OPT_WEST_SYMBOL = 'west';
+
+       /**
+        * The symbol to use as separator between latitude and longitude.
+        */
+       const OPT_SEPARATOR_SYMBOL = 'separator';
+
+       /**
+        * Delimiters used to split a coordinate string when unable to split by 
using the separator.
+        * @var string[]
+        */
+       protected $defaultDelimiters;
+
+       public function __construct( ParserOptions $options = null ) {
+               parent::__construct( $options );
+
+               $this->defaultOption( self::OPT_NORTH_SYMBOL, 'N' );
+               $this->defaultOption( self::OPT_EAST_SYMBOL, 'E' );
+               $this->defaultOption( self::OPT_SOUTH_SYMBOL, 'S' );
+               $this->defaultOption( self::OPT_WEST_SYMBOL, 'W' );
+
+               $this->defaultOption( self::OPT_SEPARATOR_SYMBOL, ',' );
+       }
+
+       /**
+        * Parses a single coordinate segment (either latitude or longitude) 
and returns it as a float.
+        *
+        * @param string $coordinateSegment
+        *
+        * @throws ParseException
+        * @return float
+        */
+       abstract protected function getParsedCoordinate( $coordinateSegment );
+
+       /**
+        * Returns whether a coordinate split into its two segments is in the 
representation expected by
+        * this parser.
+        *
+        * @param string[] $normalizedCoordinateSegments
+        *
+        * @return boolean
+        */
+       abstract protected function areValidCoordinates( array 
$normalizedCoordinateSegments );
+
+       /**
+        * @see StringValueParser::stringParse
+        *
+        * @param string $value
+        *
+        * @throws ParseException
+        * @return LatLongValue
+        */
+       protected function stringParse( $value ) {
+               $rawValue = $value;
+
+               $value = $this->removeInvalidChars( $value );
+
+               $normalizedCoordinateSegments = $this->splitString( $value );
+
+               if ( !$this->areValidCoordinates( $normalizedCoordinateSegments 
) ) {
+                       throw new ParseException( 'Not a valid geographical 
coordinate', $rawValue, static::FORMAT_NAME );
+               }
+
+               list( $latitude, $longitude ) = $normalizedCoordinateSegments;
+
+               return new LatLongValue(
+                       $this->getParsedCoordinate( $latitude ),
+                       $this->getParsedCoordinate( $longitude )
+               );
+       }
+
+       /**
+        * Returns a string trimmed and with control characters and characters 
with ASCII values above
+        * 126 removed. SPACE characters within the string are not removed to 
retain the option to split
+        * the string using that character.
+        *
+        * @param string $string
+        *
+        * @return string
+        */
+       protected function removeInvalidChars( $string ) {
+               $filtered = [];
+
+               foreach ( str_split( $string ) as $character ) {
+                       $asciiValue = ord( $character );
+
+                       if (
+                               ( $asciiValue >= 32 && $asciiValue < 127 )
+                               || $asciiValue == 194
+                               || $asciiValue == 176
+                       ) {
+                               $filtered[] = $character;
+                       }
+               }
+
+               return trim( implode( '', $filtered ) );
+       }
+
+       /**
+        * Splits a string into two strings using the separator specified in 
the options. If the string
+        * could not be split using the separator, the method will try to split 
the string by analyzing
+        * the used symbols. If the string could not be split into two parts, 
an empty array is
+        * returned.
+        *
+        * @param string $normalizedCoordinateString
+        *
+        * @throws ParseException if unable to split input string into two 
segments
+        * @return string[]
+        */
+       protected function splitString( $normalizedCoordinateString ) {
+               $separator = $this->getOption( self::OPT_SEPARATOR_SYMBOL );
+
+               $normalizedCoordinateSegments = explode( $separator, 
$normalizedCoordinateString );
+
+               if ( count( $normalizedCoordinateSegments ) !== 2 ) {
+                       // Separator not present within the string, trying to 
figure out the segments by
+                       // splitting after the first direction character or 
degree symbol:
+                       $delimiters = $this->defaultDelimiters;
+
+                       $ns = [
+                               $this->getOption( self::OPT_NORTH_SYMBOL ),
+                               $this->getOption( self::OPT_SOUTH_SYMBOL )
+                       ];
+
+                       $ew = [
+                               $this->getOption( self::OPT_EAST_SYMBOL ),
+                               $this->getOption( self::OPT_WEST_SYMBOL )
+                       ];
+
+                       foreach ( $ns as $delimiter ) {
+                               if ( mb_strpos( $normalizedCoordinateString, 
$delimiter ) === 0 ) {
+                                       // String starts with "north" or "west" 
symbol: Separation needs to be done
+                                       // before the "east" or "west" symbol.
+                                       $delimiters = array_merge( $ew, 
$delimiters );
+                                       break;
+                               }
+                       }
+
+                       if ( count( $delimiters ) !== count( 
$this->defaultDelimiters ) + 2 ) {
+                               $delimiters = array_merge( $ns, $delimiters );
+                       }
+
+                       foreach ( $delimiters as $delimiter ) {
+                               $delimiterPos = mb_strpos( 
$normalizedCoordinateString, $delimiter );
+                               if ( $delimiterPos !== false ) {
+                                       $adjustPos = ( in_array( $delimiter, 
$ew ) ) ? 0 : mb_strlen( $delimiter );
+                                       $normalizedCoordinateSegments = [
+                                               mb_substr( 
$normalizedCoordinateString, 0, $delimiterPos + $adjustPos ),
+                                               mb_substr( 
$normalizedCoordinateString, $delimiterPos + $adjustPos )
+                                       ];
+                                       break;
+                               }
+                       }
+               }
+
+               if ( count( $normalizedCoordinateSegments ) !== 2 ) {
+                       throw new ParseException( __CLASS__ . ': Unable to 
split string '
+                               . $normalizedCoordinateString . ' into two 
coordinate segments' );
+               }
+
+               return $normalizedCoordinateSegments;
+       }
+
+       /**
+        * Turns directional notation (N/E/S/W) of a single coordinate into 
non-directional notation
+        * (+/-).
+        * This method assumes there are no preceding or tailing spaces.
+        *
+        * @param string $coordinateSegment
+        *
+        * @return string
+        */
+       protected function resolveDirection( $coordinateSegment ) {
+               $n = $this->getOption( self::OPT_NORTH_SYMBOL );
+               $e = $this->getOption( self::OPT_EAST_SYMBOL );
+               $s = $this->getOption( self::OPT_SOUTH_SYMBOL );
+               $w = $this->getOption( self::OPT_WEST_SYMBOL );
+
+               // If there is a direction indicator, remove it, and prepend a 
minus sign for south and west
+               // directions. If there is no direction indicator, the 
coordinate is already non-directional
+               // and no work is required.
+               foreach ( [ $n, $e, $s, $w ] as $direction ) {
+                       // The coordinate segment may either start or end with 
a direction symbol.
+                       preg_match(
+                               '/^(' . $direction . '|)([^' . $direction . 
']+)(' . $direction . '|)$/i',
+                               $coordinateSegment,
+                               $matches
+                       );
+
+                       if ( $matches[1] === $direction || $matches[3] === 
$direction ) {
+                               $coordinateSegment = $matches[2];
+
+                               if ( in_array( $direction, [ $s, $w ] ) ) {
+                                       $coordinateSegment = '-' . 
$coordinateSegment;
+                               }
+
+                               return $coordinateSegment;
+                       }
+               }
+
+               // Coordinate segment does not include a direction symbol.
+               return $coordinateSegment;
+       }
+
+}
diff --git a/data-values/geo/src/Values/GlobeCoordinateValue.php 
b/data-values/geo/src/Values/GlobeCoordinateValue.php
new file mode 100644
index 0000000..19631a6
--- /dev/null
+++ b/data-values/geo/src/Values/GlobeCoordinateValue.php
@@ -0,0 +1,231 @@
+<?php
+
+namespace DataValues\Geo\Values;
+
+use DataValues\DataValueObject;
+use DataValues\IllegalValueException;
+
+/**
+ * Class representing a geographical coordinate value.
+ *
+ * @since 0.1
+ *
+ * @license GPL-2.0+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ * @author Thiemo Mättig
+ */
+class GlobeCoordinateValue extends DataValueObject {
+
+       /**
+        * @var LatLongValue
+        */
+       private $latLong;
+
+       /**
+        * The precision of the coordinate in degrees, e.g. 0.01.
+        *
+        * @var float|int|null
+        */
+       private $precision;
+
+       /**
+        * IRI of the globe on which the location resides.
+        *
+        * @var string
+        */
+       private $globe;
+
+       /**
+        * Wikidata concept URI for the Earth. Used as default value when no 
other globe was specified.
+        */
+       const GLOBE_EARTH = 'http://www.wikidata.org/entity/Q2';
+
+       /**
+        * @param LatLongValue $latLong
+        * @param float|int|null $precision in degrees, e.g. 0.01.
+        * @param string|null $globe IRI, defaults to 
'http://www.wikidata.org/entity/Q2'.
+        *
+        * @throws IllegalValueException
+        */
+       public function __construct( LatLongValue $latLong, $precision = null, 
$globe = null ) {
+               $this->assertIsPrecision( $precision );
+
+               if ( $globe === null ) {
+                       $globe = self::GLOBE_EARTH;
+               } elseif ( !is_string( $globe ) || $globe === '' ) {
+                       throw new IllegalValueException( '$globe must be a 
non-empty string or null' );
+               }
+
+               $this->latLong = $latLong;
+               $this->precision = $precision;
+               $this->globe = $globe;
+       }
+
+       /**
+        * @see LatLongValue::assertIsLatitude
+        * @see LatLongValue::assertIsLongitude
+        *
+        * @param float|int|null $precision
+        *
+        * @throws IllegalValueException
+        */
+       private function assertIsPrecision( $precision ) {
+               if ( $precision !== null ) {
+                       if ( !is_float( $precision ) && !is_int( $precision ) ) 
{
+                               throw new IllegalValueException( '$precision 
must be a number or null' );
+                       } elseif ( $precision < -360 || $precision > 360 ) {
+                               throw new IllegalValueException( '$precision 
needs to be between -360 and 360' );
+                       }
+               }
+       }
+
+       /**
+        * @see Serializable::serialize
+        *
+        * @return string
+        */
+       public function serialize() {
+               return json_encode( array_values( $this->getArrayValue() ) );
+       }
+
+       /**
+        * @see Serializable::unserialize
+        *
+        * @param string $value
+        *
+        * @throws IllegalValueException
+        */
+       public function unserialize( $value ) {
+               list( $latitude, $longitude, $altitude, $precision, $globe ) = 
json_decode( $value );
+               $this->__construct( new LatLongValue( $latitude, $longitude ), 
$precision, $globe );
+       }
+
+       /**
+        * @see DataValue::getType
+        *
+        * @return string
+        */
+       public static function getType() {
+               return 'globecoordinate';
+       }
+
+       /**
+        * @see DataValue::getSortKey
+        *
+        * @return float
+        */
+       public function getSortKey() {
+               return $this->getLatitude();
+       }
+
+       /**
+        * @return float
+        */
+       public function getLatitude() {
+               return $this->latLong->getLatitude();
+       }
+
+       /**
+        * @return float
+        */
+       public function getLongitude() {
+               return $this->latLong->getLongitude();
+       }
+
+       /**
+        * @see DataValue::getValue
+        *
+        * @return self
+        */
+       public function getValue() {
+               return $this;
+       }
+
+       /**
+        * @return LatLongValue
+        */
+       public function getLatLong() {
+               return $this->latLong;
+       }
+
+       /**
+        * Returns the precision of the coordinate in degrees, e.g. 0.01.
+        *
+        * @return float|int|null
+        */
+       public function getPrecision() {
+               return $this->precision;
+       }
+
+       /**
+        * Returns the IRI of the globe on which the location resides.
+        *
+        * @return string
+        */
+       public function getGlobe() {
+               return $this->globe;
+       }
+
+       /**
+        * @see Hashable::getHash
+        *
+        * @since 2.0
+        *
+        * @return string
+        */
+       public function getHash() {
+               return md5( $this->latLong->getLatitude() . '|'
+                       . $this->latLong->getLongitude() . '|'
+                       . $this->precision . '|'
+                       . $this->globe );
+       }
+
+       /**
+        * @see DataValue::getArrayValue
+        *
+        * @return array
+        */
+       public function getArrayValue() {
+               return [
+                       'latitude' => $this->latLong->getLatitude(),
+                       'longitude' => $this->latLong->getLongitude(),
+
+                       // The altitude field is no longer used in this class.
+                       // It is kept here for compatibility reasons.
+                       'altitude' => null,
+
+                       'precision' => $this->precision,
+                       'globe' => $this->globe,
+               ];
+       }
+
+       /**
+        * Constructs a new instance from the provided data. Required for @see 
DataValueDeserializer.
+        * This is expected to round-trip with @see getArrayValue.
+        *
+        * @deprecated since 2.0.1. Static DataValue::newFromArray constructors 
like this are
+        *  underspecified (not in the DataValue interface), and misleadingly 
named (should be named
+        *  newFromArrayValue). Instead, use DataValue builder callbacks in 
@see DataValueDeserializer.
+        *
+        * @param mixed $data Warning! Even if this is expected to be a value 
as returned by
+        *  @see getArrayValue, callers of this specific newFromArray 
implementation can not guarantee
+        *  this. This is not even guaranteed to be an array!
+        *
+        * @throws IllegalValueException if $data is not in the expected 
format. Subclasses of
+        *  InvalidArgumentException are expected and properly handled by @see 
DataValueDeserializer.
+        * @return self
+        */
+       public static function newFromArray( $data ) {
+               self::requireArrayFields( $data, [ 'latitude', 'longitude' ] );
+
+               return new static(
+                       new LatLongValue(
+                               $data['latitude'],
+                               $data['longitude']
+                       ),
+                       ( isset( $data['precision'] ) ) ? $data['precision'] : 
null,
+                       ( isset( $data['globe'] ) ) ? $data['globe'] : null
+               );
+       }
+
+}
diff --git a/data-values/geo/src/Values/LatLongValue.php 
b/data-values/geo/src/Values/LatLongValue.php
new file mode 100644
index 0000000..ce9e488
--- /dev/null
+++ b/data-values/geo/src/Values/LatLongValue.php
@@ -0,0 +1,191 @@
+<?php
+
+namespace DataValues\Geo\Values;
+
+use DataValues\DataValueObject;
+use InvalidArgumentException;
+use OutOfRangeException;
+
+/**
+ * Object representing a geographic point.
+ *
+ * Latitude is specified in degrees within the range [-360, 360].
+ * Longitude is specified in degrees within the range [-360, 360].
+ *
+ * @since 0.1
+ *
+ * @license GPL-2.0+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class LatLongValue extends DataValueObject {
+
+       /**
+        * The locations latitude.
+        *
+        * @var float
+        */
+       protected $latitude;
+
+       /**
+        * The locations longitude.
+        *
+        * @var float
+        */
+       protected $longitude;
+
+       /**
+        * @param float|int $latitude
+        * @param float|int $longitude
+        *
+        * @throws InvalidArgumentException
+        */
+       public function __construct( $latitude, $longitude ) {
+               if ( is_int( $latitude ) ) {
+                       $latitude = (float)$latitude;
+               }
+
+               if ( is_int( $longitude ) ) {
+                       $longitude = (float)$longitude;
+               }
+
+               $this->assertIsLatitude( $latitude );
+               $this->assertIsLongitude( $longitude );
+
+               $this->latitude = $latitude;
+               $this->longitude = $longitude;
+       }
+
+       /**
+        * @param float $latitude
+        */
+       protected function assertIsLatitude( $latitude ) {
+               if ( !is_float( $latitude ) ) {
+                       throw new InvalidArgumentException( 'Can only construct 
LatLongValue with a numeric latitude' );
+               }
+
+               if ( $latitude < -360 || $latitude > 360 ) {
+                       throw new OutOfRangeException( 'Latitude needs to be 
between -360 and 360' );
+               }
+       }
+
+       /**
+        * @param float $longitude
+        */
+       protected function assertIsLongitude( $longitude ) {
+               if ( !is_float( $longitude ) ) {
+                       throw new InvalidArgumentException( 'Can only construct 
LatLongValue with a numeric longitude' );
+               }
+
+               if ( $longitude < -360 || $longitude > 360 ) {
+                       throw new OutOfRangeException( 'Longitude needs to be 
between -360 and 360' );
+               }
+       }
+
+       /**
+        * @see Serializable::serialize
+        *
+        * @return string
+        */
+       public function serialize() {
+               $data = [
+                       $this->latitude,
+                       $this->longitude
+               ];
+
+               return implode( '|', $data );
+       }
+
+       /**
+        * @see Serializable::unserialize
+        *
+        * @param string $value
+        *
+        * @throws InvalidArgumentException
+        */
+       public function unserialize( $value ) {
+               $data = explode( '|', $value, 2 );
+
+               if ( count( $data ) < 2 ) {
+                       throw new InvalidArgumentException( 'Invalid 
serialization provided in ' . __METHOD__ );
+               }
+
+               $this->__construct( (float)$data[0], (float)$data[1] );
+       }
+
+       /**
+        * @see DataValue::getType
+        *
+        * @return string
+        */
+       public static function getType() {
+               // TODO: This really should be 'latlong' but serializations may 
explode if we rename it.
+               return 'geocoordinate';
+       }
+
+       /**
+        * @see DataValue::getSortKey
+        *
+        * @return float
+        */
+       public function getSortKey() {
+               return $this->latitude;
+       }
+
+       /**
+        * @see DataValue::getValue
+        *
+        * @return self
+        */
+       public function getValue() {
+               return $this;
+       }
+
+       /**
+        * @return float
+        */
+       public function getLatitude() {
+               return $this->latitude;
+       }
+
+       /**
+        * @return float
+        */
+       public function getLongitude() {
+               return $this->longitude;
+       }
+
+       /**
+        * @see DataValue::getArrayValue
+        *
+        * @return float[]
+        */
+       public function getArrayValue() {
+               return [
+                       'latitude' => $this->latitude,
+                       'longitude' => $this->longitude
+               ];
+       }
+
+       /**
+        * Constructs a new instance from the provided data. Required for @see 
DataValueDeserializer.
+        * This is expected to round-trip with @see getArrayValue.
+        *
+        * @deprecated since 2.0.1. Static DataValue::newFromArray constructors 
like this are
+        *  underspecified (not in the DataValue interface), and misleadingly 
named (should be named
+        *  newFromArrayValue). Instead, use DataValue builder callbacks in 
@see DataValueDeserializer.
+        *
+        * @param mixed $data Warning! Even if this is expected to be a value 
as returned by
+        *  @see getArrayValue, callers of this specific newFromArray 
implementation can not guarantee
+        *  this. This is not even guaranteed to be an array!
+        *
+        * @throws InvalidArgumentException if $data is not in the expected 
format. Subclasses of
+        *  InvalidArgumentException are expected and properly handled by @see 
DataValueDeserializer.
+        * @return self
+        */
+       public static function newFromArray( $data ) {
+               self::requireArrayFields( $data, [ 'latitude', 'longitude' ] );
+
+               return new static( $data['latitude'], $data['longitude'] );
+       }
+
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/368377
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6540ba028a2cefb281e384089a0cda55e89d5700
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/vendor
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to