diff --git a/composer.json b/composer.json
index e91bfc5921..950ae8b393 100644
--- a/composer.json
+++ b/composer.json
@@ -73,7 +73,8 @@
"matomo/matomo-php-tracker": "^3.2",
"palepurple/rate-limit": "^2.0",
"opauth/github": "^0.1.0",
- "delatbabel/apisecurity": "^1.2"
+ "delatbabel/apisecurity": "^1.2",
+ "php-coord/php-coord": "^5.7"
},
"autoload": {
"classmap": [
diff --git a/composer.lock b/composer.lock
index 817685f880..52a53b6c8b 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "786bb64e362287686eb256c369e32924",
+ "content-hash": "fe60425920d1d84baf0c5ee2a98908df",
"packages": [
{
"name": "aws/aws-crt-php",
@@ -905,6 +905,77 @@
},
"time": "2022-10-25T04:18:42+00:00"
},
+ {
+ "name": "composer/pcre",
+ "version": "3.1.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/composer/pcre.git",
+ "reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/composer/pcre/zipball/5b16e25a5355f1f3afdfc2f954a0a80aec4826a8",
+ "reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.4 || ^8.0"
+ },
+ "require-dev": {
+ "phpstan/phpstan": "^1.3",
+ "phpstan/phpstan-strict-rules": "^1.1",
+ "symfony/phpunit-bridge": "^5"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "3.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Composer\\Pcre\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Jordi Boggiano",
+ "email": "j.boggiano@seld.be",
+ "homepage": "http://seld.be"
+ }
+ ],
+ "description": "PCRE wrapping library that offers type-safe preg_* replacements.",
+ "keywords": [
+ "PCRE",
+ "preg",
+ "regex",
+ "regular expression"
+ ],
+ "support": {
+ "issues": "https://github.com/composer/pcre/issues",
+ "source": "https://github.com/composer/pcre/tree/3.1.3"
+ },
+ "funding": [
+ {
+ "url": "https://packagist.com",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/composer",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/composer/composer",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-03-19T10:26:25+00:00"
+ },
{
"name": "delatbabel/apisecurity",
"version": "v1.2",
@@ -2563,6 +2634,196 @@
},
"time": "2018-02-25T03:18:21+00:00"
},
+ {
+ "name": "opis/json-schema",
+ "version": "2.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/opis/json-schema.git",
+ "reference": "c48df6d7089a45f01e1c82432348f2d5976f9bfb"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/opis/json-schema/zipball/c48df6d7089a45f01e1c82432348f2d5976f9bfb",
+ "reference": "c48df6d7089a45f01e1c82432348f2d5976f9bfb",
+ "shasum": ""
+ },
+ "require": {
+ "ext-json": "*",
+ "opis/string": "^2.0",
+ "opis/uri": "^1.0",
+ "php": "^7.4 || ^8.0"
+ },
+ "require-dev": {
+ "ext-bcmath": "*",
+ "ext-intl": "*",
+ "phpunit/phpunit": "^9.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Opis\\JsonSchema\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "Sorin Sarca",
+ "email": "sarca_sorin@hotmail.com"
+ },
+ {
+ "name": "Marius Sarca",
+ "email": "marius.sarca@gmail.com"
+ }
+ ],
+ "description": "Json Schema Validator for PHP",
+ "homepage": "https://opis.io/json-schema",
+ "keywords": [
+ "json",
+ "json-schema",
+ "schema",
+ "validation",
+ "validator"
+ ],
+ "support": {
+ "issues": "https://github.com/opis/json-schema/issues",
+ "source": "https://github.com/opis/json-schema/tree/2.3.0"
+ },
+ "time": "2022-01-08T20:38:03+00:00"
+ },
+ {
+ "name": "opis/string",
+ "version": "2.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/opis/string.git",
+ "reference": "9ebf1a1f873f502f6859d11210b25a4bf5d141e7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/opis/string/zipball/9ebf1a1f873f502f6859d11210b25a4bf5d141e7",
+ "reference": "9ebf1a1f873f502f6859d11210b25a4bf5d141e7",
+ "shasum": ""
+ },
+ "require": {
+ "ext-iconv": "*",
+ "ext-json": "*",
+ "php": "^7.4 || ^8.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Opis\\String\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "Marius Sarca",
+ "email": "marius.sarca@gmail.com"
+ },
+ {
+ "name": "Sorin Sarca",
+ "email": "sarca_sorin@hotmail.com"
+ }
+ ],
+ "description": "Multibyte strings as objects",
+ "homepage": "https://opis.io/string",
+ "keywords": [
+ "multi-byte",
+ "opis",
+ "string",
+ "string manipulation",
+ "utf-8"
+ ],
+ "support": {
+ "issues": "https://github.com/opis/string/issues",
+ "source": "https://github.com/opis/string/tree/2.0.1"
+ },
+ "time": "2022-01-14T15:42:23+00:00"
+ },
+ {
+ "name": "opis/uri",
+ "version": "1.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/opis/uri.git",
+ "reference": "0f3ca49ab1a5e4a6681c286e0b2cc081b93a7d5a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/opis/uri/zipball/0f3ca49ab1a5e4a6681c286e0b2cc081b93a7d5a",
+ "reference": "0f3ca49ab1a5e4a6681c286e0b2cc081b93a7d5a",
+ "shasum": ""
+ },
+ "require": {
+ "opis/string": "^2.0",
+ "php": "^7.4 || ^8.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Opis\\Uri\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "Marius Sarca",
+ "email": "marius.sarca@gmail.com"
+ },
+ {
+ "name": "Sorin Sarca",
+ "email": "sarca_sorin@hotmail.com"
+ }
+ ],
+ "description": "Build, parse and validate URIs and URI-templates",
+ "homepage": "https://opis.io",
+ "keywords": [
+ "URI Template",
+ "parse url",
+ "punycode",
+ "uri",
+ "uri components",
+ "url",
+ "validate uri"
+ ],
+ "support": {
+ "issues": "https://github.com/opis/uri/issues",
+ "source": "https://github.com/opis/uri/tree/1.1.0"
+ },
+ "time": "2021-05-22T15:57:08+00:00"
+ },
{
"name": "palepurple/rate-limit",
"version": "2.0.7",
@@ -2664,6 +2925,108 @@
},
"time": "2024-07-20T06:31:49+00:00"
},
+ {
+ "name": "php-coord/php-coord",
+ "version": "v5.7.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/dvdoug/PHPCoord.git",
+ "reference": "478a8dcfa0a15ee076984c7b41eda9985989ab0d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/dvdoug/PHPCoord/zipball/478a8dcfa0a15ee076984c7b41eda9985989ab0d",
+ "reference": "478a8dcfa0a15ee076984c7b41eda9985989ab0d",
+ "shasum": ""
+ },
+ "require": {
+ "composer-runtime-api": "^2.1",
+ "composer/pcre": "^3.1",
+ "opis/json-schema": "^2.3",
+ "php": "^8.0"
+ },
+ "require-dev": {
+ "ext-json": "*",
+ "ext-sqlite3": "*",
+ "friendsofphp/php-cs-fixer": "^3.41",
+ "nikic/php-parser": "^5.0",
+ "php-coord/datapack-africa": "dev-master",
+ "php-coord/datapack-antarctic": "dev-master",
+ "php-coord/datapack-arctic": "dev-master",
+ "php-coord/datapack-asia": "dev-master",
+ "php-coord/datapack-europe": "dev-master",
+ "php-coord/datapack-northamerica": "dev-master",
+ "php-coord/datapack-oceania": "dev-master",
+ "php-coord/datapack-southamerica": "dev-master",
+ "phpstan/phpstan": "^1.10",
+ "phpunit/phpunit": "^9.6||^10.0"
+ },
+ "suggest": {
+ "php-coord/datapack-africa": "High-accuracy addon datapack for Africa",
+ "php-coord/datapack-antarctic": "High-accuracy addon datapack for the Antarctic",
+ "php-coord/datapack-arctic": "High-accuracy addon datapack for the Arctic",
+ "php-coord/datapack-asia": "High-accuracy addon datapack for Asia",
+ "php-coord/datapack-europe": "High-accuracy addon datapack for Europe",
+ "php-coord/datapack-northamerica": "High-accuracy addon datapack for North America",
+ "php-coord/datapack-oceania": "High-accuracy addon datapack for Oceania",
+ "php-coord/datapack-southamerica": "High-accuracy addon datapack for South America"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "5.x-dev"
+ }
+ },
+ "autoload": {
+ "files": [
+ "src/bc_namespace.php"
+ ],
+ "psr-4": {
+ "PHPCoord\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "(MIT and proprietary)"
+ ],
+ "authors": [
+ {
+ "name": "Doug Wright",
+ "role": "Developer"
+ }
+ ],
+ "description": "PHPCoord is a PHP library to aid in handling coordinates. It can convert coordinates for a point from one system to another and also calculate distance between points.",
+ "homepage": "https://www.phpcoord.net/",
+ "keywords": [
+ "UTM",
+ "coord",
+ "ed50",
+ "epsg",
+ "etrs",
+ "gda",
+ "geo",
+ "grid ref",
+ "latitude",
+ "longitude",
+ "map",
+ "nad",
+ "nzmg",
+ "osgb3",
+ "projection",
+ "wgs84"
+ ],
+ "support": {
+ "issues": "https://github.com/dvdoug/PHPCoord/issues",
+ "source": "https://github.com/dvdoug/PHPCoord/tree/v5.7.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/dvdoug",
+ "type": "github"
+ }
+ ],
+ "time": "2024-01-26T23:28:58+00:00"
+ },
{
"name": "php-http/discovery",
"version": "1.19.4",
@@ -6009,77 +6372,6 @@
}
],
"packages-dev": [
- {
- "name": "composer/pcre",
- "version": "3.1.3",
- "source": {
- "type": "git",
- "url": "https://github.com/composer/pcre.git",
- "reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/composer/pcre/zipball/5b16e25a5355f1f3afdfc2f954a0a80aec4826a8",
- "reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8",
- "shasum": ""
- },
- "require": {
- "php": "^7.4 || ^8.0"
- },
- "require-dev": {
- "phpstan/phpstan": "^1.3",
- "phpstan/phpstan-strict-rules": "^1.1",
- "symfony/phpunit-bridge": "^5"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "3.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Composer\\Pcre\\": "src"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Jordi Boggiano",
- "email": "j.boggiano@seld.be",
- "homepage": "http://seld.be"
- }
- ],
- "description": "PCRE wrapping library that offers type-safe preg_* replacements.",
- "keywords": [
- "PCRE",
- "preg",
- "regex",
- "regular expression"
- ],
- "support": {
- "issues": "https://github.com/composer/pcre/issues",
- "source": "https://github.com/composer/pcre/tree/3.1.3"
- },
- "funding": [
- {
- "url": "https://packagist.com",
- "type": "custom"
- },
- {
- "url": "https://github.com/composer",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/composer/composer",
- "type": "tidelift"
- }
- ],
- "time": "2024-03-19T10:26:25+00:00"
- },
{
"name": "composer/semver",
"version": "3.4.0",
diff --git a/phpunit.xml b/phpunit.xml
index 72cf493e58..f07e778b61 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -12,5 +12,8 @@
+32T E 327620 N 4840069diff --git a/website/app-templates/smarty/js/moves/geokret_move.validation.tpl.js b/website/app-templates/smarty/js/moves/geokret_move.validation.tpl.js index 57a95f04dd..06603106a1 100644 --- a/website/app-templates/smarty/js/moves/geokret_move.validation.tpl.js +++ b/website/app-templates/smarty/js/moves/geokret_move.validation.tpl.js @@ -131,6 +131,7 @@ window.Parsley.addAsyncValidator('checkCoordinates', function(xhr) { this.removeError('errorLatlon'); if (valid) { positionUpdate([data.lat, data.lon]); + showMarker([data.lat, data.lon]); } else { this.addError('errorLatlon', { message: data.error }) } diff --git a/website/app/GeoKrety/Service/CoordinatesConverter.php b/website/app/GeoKrety/Service/CoordinatesConverter.php index e89dbf7fb2..5162d8c278 100644 --- a/website/app/GeoKrety/Service/CoordinatesConverter.php +++ b/website/app/GeoKrety/Service/CoordinatesConverter.php @@ -2,9 +2,14 @@ namespace GeoKrety\Service; +use PHPCoord\CoordinateReferenceSystem\Geographic2D; +use PHPCoord\Point\GeographicPoint; +use PHPCoord\Point\UTMPoint; +use PHPCoord\UnitOfMeasure\Angle\Degree; +use PHPCoord\UnitOfMeasure\Length\Metre; + class CoordinatesConverter { - // N 57° 27.758 E 022° 50.999 [(5)=53] [(7)=55] [(�)=194] [(�)=176] i na koncu: [28(�)=194] [29(�)=160] ??? - // North.: 6189860 East.: 544201 (UTM32) ... lol + // N 57° 27.758 E 022° 50.999 // N 047° 20,363' O 015° 02,705' // N52°47.862 O008°.23.786 // 50.260147°N, 21.970291°E @@ -15,226 +20,147 @@ class CoordinatesConverter { // 50°54′N 15°44′E // 56.326N 54.235O - public static function parse($coords) { - $ret[0] = ''; - $ret[1] = ''; - $ret['format'] = ''; - $ret['error'] = ''; - - if (!empty($coords)) { - $coords = trim($coords); - - $d1 = '[0-9]'; - $d2 = '[0-9]{1,2}'; - $d3 = '[0-9]{1,3}'; - $comma = "[\.\,]"; // kropka, przecinek - $sign1 = "n|s|\+|\-|"; // znak - // $sign1b = "n|s|"; // znak na koncu liczby (nie uzywane) - $sign2 = "w|e|\+|\-|"; // znak - // $sign2b = "w|e|"; // znak na koncu liczby (nie uzywane) - $sp = "[\s]"; // spacja - $deg_sp = "[\s\*\xc2\xb0\xba]"; // space or degrees symbol (dwa bajty w utf-8) - $break = "[\s\,\\/\\\\]"; // space , / \ - $minsec_sp = "[\s\x22\x27\xc2\x60\xb4]"; // space or minutes seconds, rozne wersje: "'`´′ to trzeba chyba zamienic na (?:\s|[^a-z0-9]*)* - $minsec_sp_br = "[\s\x22\x27\xc2\x60\xb4\,\\/\\\\]"; // space or minutes seconds, rozne wersje: "'`´ or / \ , - $smiec = "(?:[^a-z0-9\.\,\-\+\s])"; // smiec ale nie spacja - $smiec_sp = "(?:\s|[^a-z0-9\.\,\-\+])"; // smiec lub spacja - - // -------------------------------------------------------------------------------------------------- - - // N 52° 12' 18.74", E 21° 11' 27.21" - // - 49°49`59.282" E 09°52´21.216" - - // dd mm ss.sss sekundy musza byc z kropka, wtedy nie musza byc znaczki typu ° ' " - $regex = - "($sign1)$sp*($d3)$smiec_sp+($d2)$smiec_sp+(($d2)($comma($d1+)))$smiec_sp*". - "$break*". - "($sign2)$sp*($d3)$smiec_sp+($d2)$smiec_sp+(($d2)($comma($d1+)))$smiec_sp*"; - - if (preg_match('#^'.$regex.'$#i', strtolower($coords), $matches)) { - // for ($i=0; $i