mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
osm data
This commit is contained in:
@@ -6,18 +6,30 @@ use App\Models\Meetup;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Component;
|
||||
use WireUi\Traits\Actions;
|
||||
|
||||
class PrepareForBtcMapItem extends Component
|
||||
{
|
||||
use Actions;
|
||||
|
||||
public Meetup $meetup;
|
||||
|
||||
public $wikipediaSearchResults;
|
||||
public $population;
|
||||
public $population_date;
|
||||
public $osmSearchResults;
|
||||
public $osmSearchResultsState;
|
||||
public $osmSearchResultsCountry;
|
||||
|
||||
public $selectedItem;
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'population' => 'required|numeric',
|
||||
'population_date' => 'required|string',
|
||||
];
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$response = Http::acceptJson()
|
||||
@@ -40,16 +52,23 @@ class PrepareForBtcMapItem extends Component
|
||||
|
||||
if ($this->meetup->city->osm_relation) {
|
||||
$this->selectedItem = $this->meetup->city->osm_relation;
|
||||
|
||||
$wikipediaUrl = 'https://query.wikidata.org/sparql?query=SELECT%20%3Fpopulation%20WHERE%20%7B%0A%20%20SERVICE%20wikibase%3Amwapi%20%7B%0A%20%20%20%20%20%20bd%3AserviceParam%20mwapi%3Asearch%20%22'.urlencode($this->meetup->city->name).'%22%20.%20%20%20%20%0A%20%20%20%20%20%20bd%3AserviceParam%20mwapi%3Alanguage%20%22en%22%20.%20%20%20%20%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Aapi%20%22EntitySearch%22%20.%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Aendpoint%20%22www.wikidata.org%22%20.%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Alimit%201%20.%0A%20%20%20%20%20%20%3Fitem%20wikibase%3AapiOutputItem%20mwapi%3Aitem%20.%0A%20%20%7D%0A%20%20%3Fitem%20wdt%3AP1082%20%3Fpopulation%0A%7D';
|
||||
$response = Http::acceptJson()
|
||||
->get(
|
||||
$wikipediaUrl
|
||||
);
|
||||
$this->wikipediaSearchResults = $response->json();
|
||||
}
|
||||
}
|
||||
|
||||
public function updatedPopulation($value)
|
||||
{
|
||||
$this->meetup->city->population = $value;
|
||||
$this->meetup->city->save();
|
||||
$this->notification()->success('Population updated', 'Success');
|
||||
}
|
||||
|
||||
public function updatedPopulationDate($value)
|
||||
{
|
||||
$this->meetup->city->population_date = $value;
|
||||
$this->meetup->city->save();
|
||||
$this->notification()->success('Population date updated', 'Success');
|
||||
}
|
||||
|
||||
public function selectItem($index, bool $isState = false, $isCountry = false)
|
||||
{
|
||||
if ($isState) {
|
||||
|
||||
@@ -103,12 +103,10 @@
|
||||
</div>
|
||||
<h1>Wikipedia Search Results</h1>
|
||||
<div class="flex space-x-2">
|
||||
@foreach($wikipediaSearchResults['results']['bindings'] ?? [] as $pop)
|
||||
<div wire:key="pop_{{ $loop->index }}" class="cursor-pointer underline font-bold"
|
||||
wire:click="takePop({{ $pop['population']['value'] }})">
|
||||
population: {{ number_format($pop['population']['value']) }}
|
||||
</div>
|
||||
@endforeach
|
||||
<a target="_blank" class="underline text-amber-500"
|
||||
href="https://de.wikipedia.org/wiki/{{ urlencode($meetup->city->name) }}">Wikipedia: {{ $meetup->city->name }}</a>
|
||||
<x-input wire:model.debounce="population" label="population"/>
|
||||
<x-input wire:model.debounce="population_date" label="population_date"/>
|
||||
</div>
|
||||
<h1>DB population</h1>
|
||||
<code>
|
||||
|
||||
@@ -186,9 +186,7 @@ Route::middleware([
|
||||
* Meetup OSM
|
||||
* */
|
||||
Route::get('/meetup-osm/table', \App\Http\Livewire\Meetup\PrepareForBtcMapTable::class)
|
||||
->name('osm.meetups')
|
||||
->can('NovaAdminPolicy.viewAny');
|
||||
->name('osm.meetups');
|
||||
Route::get('/meetup-osm/item/{meetup}', \App\Http\Livewire\Meetup\PrepareForBtcMapItem::class)
|
||||
->name('osm.meetups.item')
|
||||
->can('NovaAdminPolicy.viewAny');
|
||||
->name('osm.meetups.item');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user