Skip to content
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

Add CLI and listeners to reverse geocode pictures' coordinates #1310

Merged
merged 1 commit into from
Feb 22, 2023

Conversation

artonge
Copy link
Collaborator

@artonge artonge commented Oct 3, 2022

Add commands and listeners to generate location data of files:

The location data is stored inside oc_files_metadata.

Added commands

  • occ photos:update-1000-cities to update the cities1000 file.
  • occ photos:map-media-to-locationto map picture coordinates to a location

Architecture

  • ReverseGeoCoderService download the necessary files and build the KDTree
  • UpdateReverseGeocodingFilesCommand command to allow to manually create the needed reverse geocoding files
  • MediaLocationManager to manager the location mappings
  • MapMediaToLocationCommand command to manually trigger location data mapping. Useful for pre-existing pictures.
  • LocationManagerNodeEventListener to react to node, user and share events.
  • MapMediaToLocationJob to reduce the load in event listeners
                                          ┌─────────────────────┐
                            ┌────────────►│MapMediaToLocationJob│
                            │             └─────────┬───────────┘
                            │                       │
   ┌────────────────────────┴───────┐               │
   │LocationManagerNodeEventListener├──┐            ▼
   └────────────────────────────────┘  │  ┌────────────────────┐     ┌──────────────┐
                                       ├─►│MediaLocationManager├────►│LocationMapper│
   ┌─────────────────────────┐         │  └─────────┬──────────┘     └──────────────┘
   │MapMediaToLocationCommand├─────────┘            │
   └─────────────────────────┘                      │
                                                    ▼
   ┌──────────────────────────────────┐   ┌──────────────────────┐
   │UpdateReverseGeocodingFilesCommand├──►│ReverseGeoCoderService│
   └──────────────────────────────────┘   └──────────────────────┘

@artonge artonge added enhancement New feature or request 2. developing Work in progress labels Oct 3, 2022
@artonge artonge added this to the Nextcloud 26 milestone Oct 3, 2022
@artonge artonge self-assigned this Oct 3, 2022
@artonge
Copy link
Collaborator Author

artonge commented Oct 3, 2022

/backport to stable25

@backportbot-nextcloud backportbot-nextcloud bot added the backport-request Pending backport by the backport-bot label Oct 3, 2022
@artonge artonge force-pushed the artonge/feat/reverse_geocoding_cli branch from 40ba055 to 3d80638 Compare October 5, 2022 10:11
@artonge artonge force-pushed the feat/public_album branch 2 times, most recently from 9bc8195 to 03a153d Compare October 5, 2022 11:26
@artonge artonge force-pushed the artonge/feat/reverse_geocoding_cli branch from 3d80638 to af2731c Compare October 10, 2022 10:22
Base automatically changed from feat/public_album to master October 10, 2022 10:48
@artonge artonge force-pushed the artonge/feat/reverse_geocoding_cli branch 6 times, most recently from 6bb4679 to 01ee346 Compare October 13, 2022 08:58
@artonge artonge changed the title Add CLI to reverse geocode pictures' coordinates Add CLI and hooks to reverse geocode pictures' coordinates Oct 13, 2022
@artonge artonge force-pushed the artonge/feat/reverse_geocoding_cli branch 8 times, most recently from 2d310e1 to 0063898 Compare October 17, 2022 14:30
@artonge artonge force-pushed the artonge/feat/reverse_geocoding_cli branch from 0063898 to b852838 Compare October 24, 2022 15:37

use OC\Metadata\FileMetadata;

class PhotosFile {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review hint: extracted from AlbumFile so it can be shared with LocationFile

@artonge artonge changed the title Add CLI and hooks to reverse geocode pictures' coordinates Add CLI and listeners to reverse geocode pictures' coordinates Oct 25, 2022
@artonge artonge force-pushed the artonge/feat/reverse_geocoding_cli branch from 309b238 to ece1721 Compare February 2, 2023 17:09
private int $size;
private int $mtime;
private string $etag;
class AlbumFile extends PhotosFile {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review hint: extracted to PhotosFile so it can be shared with LocationFile

lib/Migration/Version20002Date20221012131022.php Outdated Show resolved Hide resolved
lib/Service/ReverseGeoCoderService.php Outdated Show resolved Hide resolved
lib/Service/ReverseGeoCoderService.php Outdated Show resolved Hide resolved
lib/Service/ReverseGeoCoderService.php Outdated Show resolved Hide resolved
lib/Service/ReverseGeoCoderService.php Outdated Show resolved Hide resolved
lib/Command/MapMediaToLocationCommand.php Outdated Show resolved Hide resolved
lib/Listener/LocationManagerNodeEventListener.php Outdated Show resolved Hide resolved
@artonge artonge force-pushed the artonge/feat/reverse_geocoding_cli branch 3 times, most recently from 520924d to 42dc0a5 Compare February 13, 2023 17:10
@artonge artonge force-pushed the artonge/feat/reverse_geocoding_cli branch 5 times, most recently from 3fecbd9 to 4d4f6fd Compare February 20, 2023 15:47
@artonge artonge force-pushed the artonge/feat/reverse_geocoding_cli branch 2 times, most recently from 419dcc9 to 5f5fc2f Compare February 21, 2023 11:43
appinfo/info.xml Outdated Show resolved Hide resolved
lib/Jobs/AutomaticLocationMapperJob.php Outdated Show resolved Hide resolved
lib/Jobs/AutomaticLocationMapperJob.php Show resolved Hide resolved
lib/AppInfo/Application.php Outdated Show resolved Hide resolved
@artonge artonge force-pushed the artonge/feat/reverse_geocoding_cli branch 2 times, most recently from 5db737a to 24dda33 Compare February 22, 2023 14:06
@artonge artonge enabled auto-merge February 22, 2023 14:10
The location data is stored inside `oc_files_metadata`.

- `occ photos:update-1000-cities` to update the cities1000 file.
- `occ photos:map-media-to-location`to map picture coordinates to a location

- `ReverseGeoCoderService` download the necessary files and build the `KDTree`
- `UpdateReverseGeocodingFilesCommand` command to allow to manually create the needed reverse geocoding files
- `MediaLocationManager` to manager the location mappings
- `MapMediaToLocationCommand` command to manually trigger location data mapping. Useful for pre-existing pictures.
- `LocationManagerNodeEventListener` to react to node, user and share events.
- `MapMediaToLocationJob` to reduce the load in event listeners

```php
                                          ┌─────────────────────┐
                            ┌────────────►│MapMediaToLocationJob│
                            │             └─────────┬───────────┘
                            │                       │
   ┌────────────────────────┴───────┐               │
   │LocationManagerNodeEventListener├──┐            ▼
   └────────────────────────────────┘  │  ┌────────────────────┐     ┌──────────────┐
                                       ├─►│MediaLocationManager├────►│LocationMapper│
   ┌─────────────────────────┐         │  └─────────┬──────────┘     └──────────────┘
   │MapMediaToLocationCommand├─────────┘            │
   └─────────────────────────┘                      │
                                                    ▼
   ┌──────────────────────────────────┐   ┌──────────────────────┐
   │UpdateReverseGeocodingFilesCommand├──►│ReverseGeoCoderService│
   └──────────────────────────────────┘   └──────────────────────┘
```

Signed-off-by: Louis Chemineau <louis@chmn.me>
@artonge artonge force-pushed the artonge/feat/reverse_geocoding_cli branch from 24dda33 to d94f30c Compare February 22, 2023 14:47
@artonge artonge merged commit 4ed1fc1 into master Feb 22, 2023
@artonge artonge deleted the artonge/feat/reverse_geocoding_cli branch February 22, 2023 16:30
@backportbot-nextcloud backportbot-nextcloud bot removed the backport-request Pending backport by the backport-bot label Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants