Skip to content

Commit

Permalink
Add logo & description to Poitypes
Browse files Browse the repository at this point in the history
  • Loading branch information
amenk committed Jun 2, 2024
1 parent a066c9d commit 1c12592
Show file tree
Hide file tree
Showing 9 changed files with 1,259 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@ PHPunit tests are automatically executed in the GitHub action.
```bash
npx cypress open --e2e --browser chrome
```

11 changes: 8 additions & 3 deletions app/Http/Controllers/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,13 @@ public function osmPlace($type, $id)
// FIXME: don't hard code the data repository
$newPlaceUrl = sprintf('https://github.com/OpenPlaceGuide/data/new/main?filename=places/%s/place.yaml&value=%s', $name, urlencode($newPlaceContent));


$type = Repository::getInstance()->resolveType($main);

$logoUrl = $type->getLogoUrl();

return view('page.place')
->with('place', null)
->with('logoUrl', null)
->with('logoUrl', $logoUrl)
->with('slug', null)
->with('main', $main)
->with('gallery', [])
Expand All @@ -120,12 +121,16 @@ public function typePage(string $areaSlug, string $typeSlug)

$places = (new Overpass())->fetchOsmOverview($type, $area);

$logoUrl = $type->getLogoUrl();


return view('page.overview')
->with('area', $area)
->with('type', $type)
->with('logoUrl', $logoUrl)
->with('places', $places)
->with('color', $type->color)
->with('icon', $type->icon);
->with('logo', $type->logo);
}

/**
Expand Down
1 change: 1 addition & 0 deletions app/Models/PoiType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function __construct(
public readonly ?string $color,
public readonly array $tags,
public readonly array $name = [],
public readonly array $descriptions,
public readonly array $plural = []
)
{
Expand Down
2 changes: 1 addition & 1 deletion app/Services/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getTypeInfo(string $slug)

$parsed = Yaml::parse($yamlSource);

return new PoiType($this, $slug, $parsed['logo'] ?? null, $parsed['icon'] ?? null, $parsed['color'] ?? null, $parsed['tags'], $parsed['name'], $parsed['plural']);
return new PoiType($this, $slug, $parsed['logo'] ?? null, $parsed['icon'] ?? null, $parsed['color'] ?? null, $parsed['tags'], $parsed['name'], $parsed['description'] ?? [], $parsed['plural']);
}

public function isArea(string $slug): bool
Expand Down
19 changes: 19 additions & 0 deletions draft-code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Overpass Queries

### Populate `place.yaml` with branches

You can obtain the query from the laravel.log

```overpass
[out:json][timeout:25];
area(3601707699)->.searchArea;
nwr["amenity"="bank"]["name"~"commercial bank", i](area.searchArea);
out center;
```

-> pass trough xapiJson2yaml.php

-> get a list of nodes for this bank
23 changes: 23 additions & 0 deletions draft-code/xapiJson2yaml.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

function jsonToYaml($json)
{
$data = json_decode($json, true);
$yaml = "osmBranches:\n";

foreach ($data['elements'] as $element) {
$yaml .= " - type: {$element['type']}\n";
$yaml .= " id: {$element['id']}\n";
}

return $yaml;
}

// Read the JSON data from the file
$json_data = file_get_contents('places.json');

// Convert the JSON to YAML format
$yaml_output = jsonToYaml($json_data);

// Print the YAML output
echo $yaml_output;
Loading

0 comments on commit 1c12592

Please sign in to comment.