From 010f526cae93c8761ec288ee90ddf257925760bf Mon Sep 17 00:00:00 2001 From: alazar-tekle Date: Fri, 10 Jun 2022 20:27:12 +0300 Subject: [PATCH 1/3] Test one OverPassApi Query and convert to OSM.org/api/o.6/map --- ToDo.md | 46 ++ app/Exceptions/Handler.php | 12 +- app/Http/Controllers/OsmapController.php | 49 ++ app/Models/Osmap.php | 44 ++ composer.json | 2 + composer.lock | 677 ++++++++++++++++++++++- config/jsonapi.php | 32 ++ openplaceguide.code-workspace | 8 + resources/views/osmaps/index.blade.php | 16 + resources/views/osmaps/show.blade.php | 8 + routes/web.php | 23 +- storage/app/.gitignore | 0 storage/app/public/.gitignore | 0 storage/framework/.gitignore | 0 storage/framework/cache/.gitignore | 0 storage/framework/cache/data/.gitignore | 0 storage/framework/sessions/.gitignore | 0 storage/framework/testing/.gitignore | 0 storage/framework/views/.gitignore | 0 storage/logs/.gitignore | 0 20 files changed, 898 insertions(+), 19 deletions(-) create mode 100644 ToDo.md create mode 100644 app/Http/Controllers/OsmapController.php create mode 100644 app/Models/Osmap.php create mode 100644 config/jsonapi.php create mode 100644 openplaceguide.code-workspace create mode 100644 resources/views/osmaps/index.blade.php create mode 100644 resources/views/osmaps/show.blade.php mode change 100644 => 100755 storage/app/.gitignore mode change 100644 => 100755 storage/app/public/.gitignore mode change 100644 => 100755 storage/framework/.gitignore mode change 100644 => 100755 storage/framework/cache/.gitignore mode change 100644 => 100755 storage/framework/cache/data/.gitignore mode change 100644 => 100755 storage/framework/sessions/.gitignore mode change 100644 => 100755 storage/framework/testing/.gitignore mode change 100644 => 100755 storage/framework/views/.gitignore mode change 100644 => 100755 storage/logs/.gitignore diff --git a/ToDo.md b/ToDo.md new file mode 100644 index 0000000..837d96f --- /dev/null +++ b/ToDo.md @@ -0,0 +1,46 @@ +THE FINAL INTENDED URL Endpoint for Signle POIs (Business Pages) + Make a route that takes a way/node ID + type (similar like the addismap.com URLs) + and loads the data from the openstreetmap.org JSON and displays it + 1. Get all Map data (Node/Way/Relation) from OSM using BBOX or Area + 2. Generate a JSON data generating URL (End Point) for each Map data + 3. Get a JSON Response using OSM_TYPE & OSM_ID obtained from OSM_OVERPASS_API {Elements} + + Get URL https://www.addismap.com/p6624545638/bati-complex + Get URL https://openplaceguide.org/{name} + Get URL https://openplaceguide.org/{osm_type}{osm_id}/{osm_name} + Get URL https://openplaceguide.org/{osm_type}/{osm_id} -> desired URL (Endpoint) + Get URL https://www.openstreetmap.org/api/0.6/way/162817836.json + + +date=`date +%FT%H-%M-%S` +#XAPI="http://xapi.openstreetmap.org/api/0.6/map" +XAPI="http://www.overpass-api.de/api/xapi?map" +## ETHIOPIA via Geofabrik +URL=http://download.geofabrik.de/openstreetmap/africa/ethiopia.osm.bz2 +dir=/srv/downloads/osm/ethiopia +name="ethiopia" +wget $URL -O $dir/$date-$name.osm.bz2 +## ETHIOPIA via Geofabrik +URL=http://download.geofabrik.de/openstreetmap/africa/ethiopia.osm.pbf +dir=/srv/downloads/osm/ethiopia +name="ethiopia" +wget $URL -O $dir/$date-$name.osm.pbf +## Addis via XAPI +dir=/srv/downloads/osm/addis-ababa +name="addis-ababa" +top=9.13 +bottom=8.8 +left=38.61 +right=38.96 +URL=$XAPI?bbox=$left,$bottom,$right,$top +wget $URL -O $dir/$date-$name.osm +bzip2 $dir/$date-$name.osm +/srv/bame-website/scripts/new-osm.sh $dir/$date-$name.osm.bz2 +#XAPI="http://xapi.openstreetmap.org/api/0.6" +#top=14.8922 +#bottom=3.4024 +#left=32.9999 +#right=47.9862 +#URL=$XAPI/map?bbox=$left,$bottom,$right,$top + + diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 8e7fbd1..8ae79e4 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -4,6 +4,7 @@ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Throwable; +use LaravelJsonApi\Core\Exceptions\JsonApiException; class Handler extends ExceptionHandler { @@ -13,7 +14,7 @@ class Handler extends ExceptionHandler * @var array> */ protected $dontReport = [ - // + JsonApiException::class, ]; /** @@ -34,8 +35,11 @@ class Handler extends ExceptionHandler */ public function register() { - $this->reportable(function (Throwable $e) { - // - }); + // $this->reportable(function (Throwable $e) { + // // + // }); + $this->renderable( + \LaravelJsonApi\Exceptions\ExceptionParser::make()->renderable() + ); } } diff --git a/app/Http/Controllers/OsmapController.php b/app/Http/Controllers/OsmapController.php new file mode 100644 index 0000000..39ee792 --- /dev/null +++ b/app/Http/Controllers/OsmapController.php @@ -0,0 +1,49 @@ +json()['elements']); + + return view('osmaps.index', ['osmaps' => $osmaps]); + } + + public function show($type, $id) + { + $query = '[out:json][timeout:400];way["tourism"="guest_house"](8.827402638625081,38.63822937011719,9.104808725563043,38.91632080078125);out%20body;'; + + $osmaps = Http::get('https://www.overpass-api.de/api/map?data='.$query)->json()['elements']; + + $map_length = count($osmaps); + + if ($map_length > 0) { + foreach ($osmaps as $osmap) { + $type = $osmap['type']; + $id = $osmap['id']; + } + } + $osmurl = Http::get('https://www.openstreetmap.org/api/0.6/'.$type.'/'.$id.'.json'); + return $osmurl; + // return view('osmaps.show', compact($osmap)); + } + + public function single($id) + { + // $bbox = '38.61,8.8,38.96,9.13'; + // $xapi = Http::get('http://master.apis.dev.openstreetmap.org/api/0.6/map?bbox=' . $bbox); + $id = '445313461'; + $data = Http::get('https://openstreetmap.org/api/0.6/node/'.$id.'json'); + dump($data); + } +} + diff --git a/app/Models/Osmap.php b/app/Models/Osmap.php new file mode 100644 index 0000000..ab2ee85 --- /dev/null +++ b/app/Models/Osmap.php @@ -0,0 +1,44 @@ +json()['elements']; + + // return $apiUrl; + // } + + public static function osmApiUrl() + { + // Get a single OSM_TYPE and OSM_ID for each JSON elements from the OverPassApi Query + // When user hits /OSM_TYPE/OSM_ID endpoint -> Redirect to the intended URL or Get JSON Data + + $query = '[out:json][timeout:400];way["tourism"="guest_house"](8.827402638625081,38.63822937011719,9.104808725563043,38.91632080078125);out%20body;'; + $osmaps = Http::get('https://www.overpass-api.de/api/map?data='.$query)->json()['elements']; + + $map_length = count($osmaps); + + for ($i=0; $i < $map_length; $i++) { + foreach ($osmaps as $osmap) { + $type = $osmap['type']; + $id = $osmap['id']; + } + $osmurl = Http::get('https://www.openstreetmap.org/api/0.6/'.$type.'/'.$id.'.json'); + return $osmurl; + } + $returnData = file_get_contents($osmurl, true); + $finalData = json_encode($returnData); + return $finalData; + } +} diff --git a/composer.json b/composer.json index 7f25c52..5d113d5 100644 --- a/composer.json +++ b/composer.json @@ -7,12 +7,14 @@ "require": { "php": "^8.0.2", "guzzlehttp/guzzle": "^7.2", + "laravel-json-api/laravel": "^2.3", "laravel/framework": "^9.2", "laravel/sanctum": "^2.14.1", "laravel/tinker": "^2.7" }, "require-dev": { "fakerphp/faker": "^1.9.1", + "laravel-json-api/testing": "^1.1", "laravel/sail": "^1.0.1", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^6.1", diff --git a/composer.lock b/composer.lock index 9f33ed7..ab3b155 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": "ef673328c6f2cf165b0d1c8880bd25b5", + "content-hash": "2a2709d1ebe58bfb3612fbc4429f6042", "packages": [ { "name": "brick/math", @@ -893,6 +893,556 @@ ], "time": "2021-10-06T17:43:30+00:00" }, + { + "name": "laravel-json-api/core", + "version": "v2.3.0", + "source": { + "type": "git", + "url": "https://github.com/laravel-json-api/core.git", + "reference": "3eb91521228c04233d29c61e1cb835c42272f800" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel-json-api/core/zipball/3eb91521228c04233d29c61e1cb835c42272f800", + "reference": "3eb91521228c04233d29c61e1cb835c42272f800", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/contracts": "^8.0|^9.0", + "illuminate/http": "^8.0|^9.0", + "illuminate/support": "^8.0|^9.0", + "php": "^7.4|^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.5.10" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "LaravelJsonApi\\Core\\": "src/Core", + "LaravelJsonApi\\Contracts\\": "src/Contracts" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Cloud Creativity Ltd", + "email": "info@cloudcreativity.co.uk" + }, + { + "name": "Christopher Gammie", + "email": "contact@gammie.co.uk" + } + ], + "description": "Contracts and support classes for Laravel JSON:API packages.", + "homepage": "https://github.com/laravel-json-api/core", + "keywords": [ + "JSON-API", + "jsonapi", + "jsonapi.org", + "laravel" + ], + "support": { + "issues": "https://github.com/laravel-json-api/core/issues", + "source": "https://github.com/laravel-json-api/core/tree/v2.3.0" + }, + "time": "2022-04-17T17:20:35+00:00" + }, + { + "name": "laravel-json-api/eloquent", + "version": "v2.1.1", + "source": { + "type": "git", + "url": "https://github.com/laravel-json-api/eloquent.git", + "reference": "f64ff8c16971fe3918458ee06e47fdf89ccfa4d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel-json-api/eloquent/zipball/f64ff8c16971fe3918458ee06e47fdf89ccfa4d9", + "reference": "f64ff8c16971fe3918458ee06e47fdf89ccfa4d9", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/database": "^8.0|^9.0", + "illuminate/support": "^8.0|^9.0", + "laravel-json-api/core": "^2.0", + "php": "^7.4|^8.0" + }, + "require-dev": { + "orchestra/testbench": "^6.23|^7.0", + "phpunit/phpunit": "^9.5.10" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "LaravelJsonApi\\Eloquent\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Cloud Creativity Ltd", + "email": "info@cloudcreativity.co.uk" + }, + { + "name": "Christopher Gammie", + "email": "contact@gammie.co.uk" + } + ], + "description": "Serialize Eloquent models as JSON:API resources.", + "homepage": "https://github.com/laravel-json-api/eloquent", + "keywords": [ + "JSON-API", + "jsonapi", + "jsonapi.org", + "laravel" + ], + "support": { + "issues": "https://github.com/laravel-json-api/eloquent/issues", + "source": "https://github.com/laravel-json-api/eloquent/tree/v2.1.1" + }, + "time": "2022-04-04T13:16:28+00:00" + }, + { + "name": "laravel-json-api/encoder-neomerx", + "version": "v2.0.0", + "source": { + "type": "git", + "url": "https://github.com/laravel-json-api/encoder-neomerx.git", + "reference": "2dcc119db66818c52706f60689c6f6679114e4a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel-json-api/encoder-neomerx/zipball/2dcc119db66818c52706f60689c6f6679114e4a7", + "reference": "2dcc119db66818c52706f60689c6f6679114e4a7", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/contracts": "^8.0|^9.0", + "illuminate/support": "^8.0|^9.0", + "laravel-json-api/core": "^2.0", + "laravel-json-api/neomerx-json-api": "^5.0", + "php": "^7.4|^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.5.10" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "2.x-dev" + }, + "laravel": { + "providers": [ + "LaravelJsonApi\\Encoder\\Neomerx\\ServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "LaravelJsonApi\\Encoder\\Neomerx\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Cloud Creativity Ltd", + "email": "info@cloudcreativity.co.uk" + }, + { + "name": "Christopher Gammie", + "email": "contact@gammie.co.uk" + } + ], + "description": "Encode JSON:API resources using the neomerx/json-api package.", + "homepage": "https://github.com/laravel-json-api/encoder-neomerx", + "keywords": [ + "JSON-API", + "jsonapi", + "jsonapi.org", + "laravel" + ], + "support": { + "issues": "https://github.com/laravel-json-api/encoder-neomerx/issues", + "source": "https://github.com/laravel-json-api/encoder-neomerx/tree/v2.0.0" + }, + "time": "2022-02-09T19:25:05+00:00" + }, + { + "name": "laravel-json-api/exceptions", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/laravel-json-api/exceptions.git", + "reference": "271c9fe47d8835d1f0c0ee0a2e7c327b94536d05" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel-json-api/exceptions/zipball/271c9fe47d8835d1f0c0ee0a2e7c327b94536d05", + "reference": "271c9fe47d8835d1f0c0ee0a2e7c327b94536d05", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/contracts": "^8.0|^9.0", + "illuminate/pipeline": "^8.0|^9.0", + "laravel-json-api/core": "^1.0|^2.0", + "laravel-json-api/validation": "^1.0|^2.0", + "php": "^7.4|^8.0" + }, + "require-dev": { + "laravel-json-api/testing": "^1.1", + "orchestra/testbench": "^6.23|^7.0", + "phpunit/phpunit": "^9.5.10" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "LaravelJsonApi\\Exceptions\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Cloud Creativity Ltd", + "email": "info@cloudcreativity.co.uk" + }, + { + "name": "Christopher Gammie", + "email": "contact@gammie.co.uk" + } + ], + "description": "JSON:API exception parsing for Laravel applications.", + "homepage": "https://github.com/laravel-json-api/exceptions", + "keywords": [ + "JSON-API", + "jsonapi", + "jsonapi.org", + "laravel" + ], + "support": { + "issues": "https://github.com/laravel-json-api/exceptions/issues", + "source": "https://github.com/laravel-json-api/exceptions/tree/v1.1.0" + }, + "time": "2022-02-09T18:44:45+00:00" + }, + { + "name": "laravel-json-api/laravel", + "version": "v2.3.0", + "source": { + "type": "git", + "url": "https://github.com/laravel-json-api/laravel.git", + "reference": "5da3145033c9f74186b24e38ca0e2b2a6c5353d1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel-json-api/laravel/zipball/5da3145033c9f74186b24e38ca0e2b2a6c5353d1", + "reference": "5da3145033c9f74186b24e38ca0e2b2a6c5353d1", + "shasum": "" + }, + "require": { + "ext-json": "*", + "laravel-json-api/core": "^2.2", + "laravel-json-api/eloquent": "^2.1.1", + "laravel-json-api/encoder-neomerx": "^2.0", + "laravel-json-api/exceptions": "^1.1", + "laravel-json-api/spec": "^1.2", + "laravel-json-api/validation": "^2.1", + "laravel/framework": "^8.76|^9.0", + "php": "^7.4|^8.0" + }, + "require-dev": { + "laravel-json-api/testing": "^1.1", + "orchestra/testbench": "^6.23|^7.0", + "phpunit/phpunit": "^9.5.10" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "2.x-dev" + }, + "laravel": { + "aliases": { + "JsonApi": "LaravelJsonApi\\Core\\Facades\\JsonApi", + "JsonApiRoute": "LaravelJsonApi\\Laravel\\Facades\\JsonApiRoute" + }, + "providers": [ + "LaravelJsonApi\\Laravel\\ServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "LaravelJsonApi\\Laravel\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Cloud Creativity Ltd", + "email": "info@cloudcreativity.co.uk" + }, + { + "name": "Christopher Gammie", + "email": "contact@gammie.co.uk" + } + ], + "description": "JSON:API for Laravel applications.", + "homepage": "https://github.com/laravel-json-api/laravel", + "keywords": [ + "JSON-API", + "jsonapi", + "jsonapi.org", + "laravel" + ], + "support": { + "issues": "https://github.com/laravel-json-api/laravel/issues", + "source": "https://github.com/laravel-json-api/laravel/tree/v2.3.0" + }, + "time": "2022-04-11T17:46:25+00:00" + }, + { + "name": "laravel-json-api/neomerx-json-api", + "version": "v5.0.0", + "source": { + "type": "git", + "url": "https://github.com/laravel-json-api/neomerx-json-api.git", + "reference": "7ed987f6a42a470be0021098ebb456ae32b18248" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel-json-api/neomerx-json-api/zipball/7ed987f6a42a470be0021098ebb456ae32b18248", + "reference": "7ed987f6a42a470be0021098ebb456ae32b18248", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^7.4|^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.4", + "mockery/mockery": "^1.4.4", + "phpmd/phpmd": "^2.11.1", + "phpunit/phpunit": "^9.5.10", + "scrutinizer/ocular": "^1.8", + "squizlabs/php_codesniffer": "^3.6.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "5.x-dev" + } + }, + "autoload": { + "files": [ + "src/I18n/format.php" + ], + "psr-4": { + "Neomerx\\JsonApi\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "neomerx", + "email": "info@neomerx.com" + }, + { + "name": "Christopher Gammie", + "email": "contact@gammie.co.uk" + } + ], + "description": "Framework agnostic JSON API (jsonapi.org) implementation", + "homepage": "https://github.com/neomerx/json-api", + "keywords": [ + "JSON-API", + "api", + "json", + "jsonapi", + "jsonapi.org", + "neomerx" + ], + "support": { + "issues": "https://github.com/neomerx/json-api/issues", + "source": "https://github.com/laravel-json-api/neomerx-json-api/tree/v5.0.0" + }, + "time": "2022-02-09T19:14:22+00:00" + }, + { + "name": "laravel-json-api/spec", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/laravel-json-api/spec.git", + "reference": "b159d1958c15124cbd257289a6da196b45a1573f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel-json-api/spec/zipball/b159d1958c15124cbd257289a6da196b45a1573f", + "reference": "b159d1958c15124cbd257289a6da196b45a1573f", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/contracts": "^8.0|^9.0", + "illuminate/pipeline": "^8.0|^9.0", + "illuminate/support": "^8.0|^9.0", + "laravel-json-api/core": "^1.0|^2.0", + "php": "^7.4|^8.0" + }, + "require-dev": { + "orchestra/testbench": "^6.23|^7.0", + "phpunit/phpunit": "^9.5.10" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "1.x-dev" + }, + "laravel": { + "providers": [ + "LaravelJsonApi\\Spec\\ServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "LaravelJsonApi\\Spec\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Cloud Creativity Ltd", + "email": "info@cloudcreativity.co.uk" + }, + { + "name": "Christopher Gammie", + "email": "contact@gammie.co.uk" + } + ], + "description": "Validate JSON documents for compliance with the JSON:API specification.", + "homepage": "https://github.com/laravel-json-api/spec", + "keywords": [ + "JSON-API", + "jsonapi", + "jsonapi.org", + "laravel" + ], + "support": { + "issues": "https://github.com/laravel-json-api/spec/issues", + "source": "https://github.com/laravel-json-api/spec/tree/v1.2.0" + }, + "time": "2022-04-10T13:29:07+00:00" + }, + { + "name": "laravel-json-api/validation", + "version": "v2.1.0", + "source": { + "type": "git", + "url": "https://github.com/laravel-json-api/validation.git", + "reference": "771e6671fdb94bbcec9801f8688dbb754ff6f875" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel-json-api/validation/zipball/771e6671fdb94bbcec9801f8688dbb754ff6f875", + "reference": "771e6671fdb94bbcec9801f8688dbb754ff6f875", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/contracts": "^8.0|^9.0", + "illuminate/support": "^8.0|^9.0", + "laravel-json-api/core": "^2.0", + "php": "^7.4|^8.0" + }, + "require-dev": { + "orchestra/testbench": "^6.23|^7.0", + "phpunit/phpunit": "^9.5.10" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "2.x-dev" + }, + "laravel": { + "providers": [ + "LaravelJsonApi\\Validation\\ServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "LaravelJsonApi\\Validation\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Cloud Creativity Ltd", + "email": "info@cloudcreativity.co.uk" + }, + { + "name": "Christopher Gammie", + "email": "contact@gammie.co.uk" + } + ], + "description": "Laravel validation for JSON:API resources.", + "homepage": "https://github.com/laravel-json-api/validation", + "keywords": [ + "JSON-API", + "jsonapi", + "jsonapi.org", + "laravel" + ], + "support": { + "issues": "https://github.com/laravel-json-api/validation/issues", + "source": "https://github.com/laravel-json-api/validation/tree/v2.1.0" + }, + "time": "2022-04-11T17:40:26+00:00" + }, { "name": "laravel/framework", "version": "v9.5.1", @@ -5083,6 +5633,64 @@ } ], "packages-dev": [ + { + "name": "cloudcreativity/json-api-testing", + "version": "v4.0.0", + "source": { + "type": "git", + "url": "https://github.com/cloudcreativity/json-api-testing.git", + "reference": "c7c0f0a0fc016853b6e7801e8b873f7b86299680" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cloudcreativity/json-api-testing/zipball/c7c0f0a0fc016853b6e7801e8b873f7b86299680", + "reference": "c7c0f0a0fc016853b6e7801e8b873f7b86299680", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/contracts": "^8.0|^9.0", + "illuminate/support": "^8.0|^9.0", + "php": "^7.4|^8.0", + "phpunit/phpunit": "^9.5.10" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "4.x-dev" + } + }, + "autoload": { + "psr-4": { + "CloudCreativity\\JsonApi\\Testing\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Cloud Creativity Ltd", + "email": "info@cloudcreativity.co.uk" + } + ], + "description": "PHPUnit test helpers to check JSON API documents.", + "homepage": "https://github.com/cloudcreativity/json-api", + "keywords": [ + "JSON-API", + "api", + "cloudcreativity", + "json", + "jsonapi", + "jsonapi.org" + ], + "support": { + "issues": "https://github.com/cloudcreativity/json-api/issues", + "source": "https://github.com/cloudcreativity/json-api-testing/tree/v4.0.0" + }, + "time": "2022-02-08T18:01:42+00:00" + }, { "name": "composer/pcre", "version": "3.0.0", @@ -5466,6 +6074,71 @@ }, "time": "2020-07-09T08:09:16+00:00" }, + { + "name": "laravel-json-api/testing", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/laravel-json-api/testing.git", + "reference": "10c37610c840ad9cba25d4342e3b8ed8b99784cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel-json-api/testing/zipball/10c37610c840ad9cba25d4342e3b8ed8b99784cb", + "reference": "10c37610c840ad9cba25d4342e3b8ed8b99784cb", + "shasum": "" + }, + "require": { + "cloudcreativity/json-api-testing": "^3.3|^4.0", + "ext-json": "*", + "illuminate/http": "^8.0|^9.0", + "illuminate/support": "^8.0|^9.0", + "illuminate/testing": "^8.0|^9.0", + "php": "^7.4|^8.0" + }, + "require-dev": { + "laravel/framework": "^8.0|^9.0", + "phpunit/phpunit": "^9.5.10" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "LaravelJsonApi\\Testing\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Cloud Creativity Ltd", + "email": "info@cloudcreativity.co.uk" + }, + { + "name": "Christopher Gammie", + "email": "contact@gammie.co.uk" + } + ], + "description": "Test helpers for JSON:API compliant APIs.", + "homepage": "https://github.com/laravel-json-api/testing", + "keywords": [ + "JSON-API", + "jsonapi", + "jsonapi.org", + "laravel" + ], + "support": { + "issues": "https://github.com/laravel-json-api/testing/issues", + "source": "https://github.com/laravel-json-api/testing/tree/v1.1.1" + }, + "time": "2022-02-27T12:27:36+00:00" + }, { "name": "laravel/sail", "version": "v1.13.7", @@ -8143,5 +8816,5 @@ "php": "^8.0.2" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.1.0" } diff --git a/config/jsonapi.php b/config/jsonapi.php new file mode 100644 index 0000000..00479d8 --- /dev/null +++ b/config/jsonapi.php @@ -0,0 +1,32 @@ + 'JsonApi', + + /* + |-------------------------------------------------------------------------- + | Servers + |-------------------------------------------------------------------------- + | + | A list of the JSON:API compliant APIs in your application, referred to + | as "servers". They must be listed below, with the array key being the + | unique name for each server, and the value being the fully-qualified + | class name of the server class. + */ + 'servers' => [ +// 'v1' => \App\JsonApi\V1\Server::class, + ], +]; diff --git a/openplaceguide.code-workspace b/openplaceguide.code-workspace new file mode 100644 index 0000000..9b37292 --- /dev/null +++ b/openplaceguide.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} diff --git a/resources/views/osmaps/index.blade.php b/resources/views/osmaps/index.blade.php new file mode 100644 index 0000000..d9d0f33 --- /dev/null +++ b/resources/views/osmaps/index.blade.php @@ -0,0 +1,16 @@ +
+

Total N+W+R = {{ count($osmaps) }}

+ +
+ diff --git a/resources/views/osmaps/show.blade.php b/resources/views/osmaps/show.blade.php new file mode 100644 index 0000000..a8832c7 --- /dev/null +++ b/resources/views/osmaps/show.blade.php @@ -0,0 +1,8 @@ +
+ {{--

+ name: {{ $data['tags']['name'] ?? '' }} | amenity: {{ $data['tags']['tourism'] ?? ''}} +

--}} +

+ Name: {{ $data['tags']['name'] ?? '' }} | osm_type: {{ $data['type'] ?? '' }} | osm_id: {{ $data['id'] ?? ''}} +

+
diff --git a/routes/web.php b/routes/web.php index b130397..23b8389 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,18 +1,15 @@ name('osmaps.show')->scopeBindings(); +Route::get('/osmaps/{id}', [OsmapController::class, 'single'])->name('osmaps.single'); + +// Route::get('/{osmap:type}/{osmap:id}', function($type, $id) { +// $url = 'https://www.openstreetmap.org/api/0.6/'.$type.'/'.$id.'.json'; +// return view('osmaps.mapniks'); +// })->name('osmaps.mapniks')->scopeBindings(); diff --git a/storage/app/.gitignore b/storage/app/.gitignore old mode 100644 new mode 100755 diff --git a/storage/app/public/.gitignore b/storage/app/public/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/.gitignore b/storage/framework/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/cache/.gitignore b/storage/framework/cache/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/cache/data/.gitignore b/storage/framework/cache/data/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/sessions/.gitignore b/storage/framework/sessions/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/testing/.gitignore b/storage/framework/testing/.gitignore old mode 100644 new mode 100755 diff --git a/storage/framework/views/.gitignore b/storage/framework/views/.gitignore old mode 100644 new mode 100755 diff --git a/storage/logs/.gitignore b/storage/logs/.gitignore old mode 100644 new mode 100755 From 86a513aa17ae48040f39e8d4a8d0b860bc94edac Mon Sep 17 00:00:00 2001 From: alazar-tekle Date: Sat, 11 Jun 2022 20:40:01 +0300 Subject: [PATCH 2/3] Updated the show method and removed overpass-query + code clean-up --- app/Http/Controllers/OsmapController.php | 22 ---------------- app/Models/Osmap.php | 33 ------------------------ resources/views/osmaps/index.blade.php | 4 +-- resources/views/osmaps/show.blade.php | 5 +--- routes/web.php | 7 ----- 5 files changed, 3 insertions(+), 68 deletions(-) diff --git a/app/Http/Controllers/OsmapController.php b/app/Http/Controllers/OsmapController.php index 39ee792..1a97b64 100644 --- a/app/Http/Controllers/OsmapController.php +++ b/app/Http/Controllers/OsmapController.php @@ -20,30 +20,8 @@ public function index() public function show($type, $id) { - $query = '[out:json][timeout:400];way["tourism"="guest_house"](8.827402638625081,38.63822937011719,9.104808725563043,38.91632080078125);out%20body;'; - - $osmaps = Http::get('https://www.overpass-api.de/api/map?data='.$query)->json()['elements']; - - $map_length = count($osmaps); - - if ($map_length > 0) { - foreach ($osmaps as $osmap) { - $type = $osmap['type']; - $id = $osmap['id']; - } - } $osmurl = Http::get('https://www.openstreetmap.org/api/0.6/'.$type.'/'.$id.'.json'); return $osmurl; - // return view('osmaps.show', compact($osmap)); - } - - public function single($id) - { - // $bbox = '38.61,8.8,38.96,9.13'; - // $xapi = Http::get('http://master.apis.dev.openstreetmap.org/api/0.6/map?bbox=' . $bbox); - $id = '445313461'; - $data = Http::get('https://openstreetmap.org/api/0.6/node/'.$id.'json'); - dump($data); } } diff --git a/app/Models/Osmap.php b/app/Models/Osmap.php index ab2ee85..6cfc48a 100644 --- a/app/Models/Osmap.php +++ b/app/Models/Osmap.php @@ -4,41 +4,8 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Http; class Osmap extends Model { use HasFactory; - - // public static function map() - // { - // $query = '[out:json][timeout:400];way["tourism"="guest_house"](8.827402638625081,38.63822937011719,9.104808725563043,38.91632080078125);out%20body;'; - - // $apiUrl = Http::get('https://www.overpass-api.de/api/map?data='.$query)->json()['elements']; - - // return $apiUrl; - // } - - public static function osmApiUrl() - { - // Get a single OSM_TYPE and OSM_ID for each JSON elements from the OverPassApi Query - // When user hits /OSM_TYPE/OSM_ID endpoint -> Redirect to the intended URL or Get JSON Data - - $query = '[out:json][timeout:400];way["tourism"="guest_house"](8.827402638625081,38.63822937011719,9.104808725563043,38.91632080078125);out%20body;'; - $osmaps = Http::get('https://www.overpass-api.de/api/map?data='.$query)->json()['elements']; - - $map_length = count($osmaps); - - for ($i=0; $i < $map_length; $i++) { - foreach ($osmaps as $osmap) { - $type = $osmap['type']; - $id = $osmap['id']; - } - $osmurl = Http::get('https://www.openstreetmap.org/api/0.6/'.$type.'/'.$id.'.json'); - return $osmurl; - } - $returnData = file_get_contents($osmurl, true); - $finalData = json_encode($returnData); - return $finalData; - } } diff --git a/resources/views/osmaps/index.blade.php b/resources/views/osmaps/index.blade.php index d9d0f33..36b7803 100644 --- a/resources/views/osmaps/index.blade.php +++ b/resources/views/osmaps/index.blade.php @@ -4,8 +4,8 @@ @foreach ($osmaps as $data)
  • - {{-- --}} - + + {{-- --}} Name: {{ $data['tags']['name'] ?? '' }} || osm=type+id: {{ $data['type'] ?? '' }}-{{ $data['id'] ?? ''}}

    diff --git a/resources/views/osmaps/show.blade.php b/resources/views/osmaps/show.blade.php index a8832c7..8057d82 100644 --- a/resources/views/osmaps/show.blade.php +++ b/resources/views/osmaps/show.blade.php @@ -1,8 +1,5 @@
    - {{--

    - name: {{ $data['tags']['name'] ?? '' }} | amenity: {{ $data['tags']['tourism'] ?? ''}} -

    --}}

    - Name: {{ $data['tags']['name'] ?? '' }} | osm_type: {{ $data['type'] ?? '' }} | osm_id: {{ $data['id'] ?? ''}} + {{-- Name: {{ $data['tags']['name'] ?? '' }} | osm_type: {{ $data['type'] ?? '' }} | osm_id: {{ $data['id'] ?? ''}} --}}

    diff --git a/routes/web.php b/routes/web.php index 23b8389..a11bd29 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,11 +5,4 @@ Route::get('/', [OsmapController::class, 'index']); -// Route::get('/osmaps', [OsmapController::class, 'show']); Route::get('/{type}/{id}', [OsmapController::class, 'show'])->name('osmaps.show')->scopeBindings(); -Route::get('/osmaps/{id}', [OsmapController::class, 'single'])->name('osmaps.single'); - -// Route::get('/{osmap:type}/{osmap:id}', function($type, $id) { -// $url = 'https://www.openstreetmap.org/api/0.6/'.$type.'/'.$id.'.json'; -// return view('osmaps.mapniks'); -// })->name('osmaps.mapniks')->scopeBindings(); From f4e99bf3790a498d734852eae62f535ab1679478 Mon Sep 17 00:00:00 2001 From: alazar-tekle Date: Sat, 11 Jun 2022 20:53:51 +0300 Subject: [PATCH 3/3] Removed unimportant files --- app/Models/Osmap.php | 11 ----------- resources/views/osmaps/show.blade.php | 5 ----- 2 files changed, 16 deletions(-) delete mode 100644 app/Models/Osmap.php delete mode 100644 resources/views/osmaps/show.blade.php diff --git a/app/Models/Osmap.php b/app/Models/Osmap.php deleted file mode 100644 index 6cfc48a..0000000 --- a/app/Models/Osmap.php +++ /dev/null @@ -1,11 +0,0 @@ - -

    - {{-- Name: {{ $data['tags']['name'] ?? '' }} | osm_type: {{ $data['type'] ?? '' }} | osm_id: {{ $data['id'] ?? ''}} --}} -

    -