-
Notifications
You must be signed in to change notification settings - Fork 1
Test one OverPassApi Query and convert to OSM.org/api/0.6/map #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alazar-tekle
wants to merge
4
commits into
AddisMap:main
Choose a base branch
from
alazar-tekle:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
010f526
Test one OverPassApi Query and convert to OSM.org/api/o.6/map
alazar-tekle 86a513a
Updated the show method and removed overpass-query + code clean-up
alazar-tekle f4e99bf
Removed unimportant files
alazar-tekle d018ded
Merge branch 'AddisMap:main' into main
alazar-tekle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Controllers; | ||
|
|
||
| use Illuminate\Http\Request; | ||
| use Illuminate\Support\Facades\Http; | ||
|
|
||
| use App\Models\Osmap; | ||
|
|
||
| class OsmapController extends Controller | ||
| { | ||
| public function index() | ||
| { | ||
| $query = '[out:json][timeout:400];nwr["name"](8.827402638625081,38.63822937011719,9.104808725563043,38.91632080078125);out%20body;'; | ||
|
|
||
| $osmaps = collect(Http::get('https://www.overpass-api.de/api/map?data='.$query)->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); | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <?php | ||
|
|
||
| namespace App\Models; | ||
|
|
||
| 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; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you do not need to query overpass for this - you already have type and ID and can directly pass it to the show function