Nowadays my interest is to install verious apps on Nextcloud.
I found good app Maps and wanted to introduce to you!
What is Maps ?
Maps is geographic map application like Google Maps.
Maps automatically links your photoes onto world maps like below.
This is my Maps demo.
I store my vacation stay memories like this.
We can remember at home with my family and it is so fun.
Video is not so smooth but actual behavior is very smooth you don’t need to mind.
Some years ago I stayed in Germany as expatration, and my wife is Hong Konger.
This is why most of photoes are taken in Europe and Hong Kong.
As you can see in video, there is several photoes taken in South Afrika and South America where I haven’t visited.
This is bug of photo file, not Maps application.
Altitute/Attitute of photo file is (0, 0) (0, 0) is the sea near South Arfika. Altitute/Attitute of photo file is (NaN, NaN) If Maps application reads this kind of file DivisionByZeroError would happen. I modified source code of Maps and Error will not happen. Altitute/Attitute of photo file differs actual ones This wrong Altitute/Attitute values are stored during taking photo by my smart phone.
How to install
As usual log in with administrator account and select Apps.
In Multimedia you can easily find Maps like this.
That’s it!
Import photoes to Maps
You need to import photo files to Maps after install.
You can run this command line and then next cron will import them.
# If you want to do for all users sudo docker-compose exec --user www-data nextcloud php occ maps:scan-photos # If you want to do for specific user sudo docker-compose exec --user www-data nextcloud php occ maps:scan-photos $(userid)
Next steps is to run cron.php.
If you have already setup cron.php, you will soon see on Maps.
In my case I manually ran.
If you want to setup cron.php environment, rcdailey/nextcloud-cronjob is very easy to use.
sudo docker-compose exec --user www-data nextcloud php /var/www/html/cron.php
My Nextcloud has about 40000 photo files.
And cron.php automatically ends after 14 minutes execution time.
So I performed many times like below command line.
while true; do sudo docker-compose exec --user www-data nextcloud php /var/www/html/cron.php; sleep 1; done
I needed to increase PHP memory capacity to 2048MB.
Before increasing I faced this error.
PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 4606288 bytes) in /var/www/html/lib/private/Files/Storage/Local.php on line 277
This is error when Maps intends to read (NaN, NaN) photo.
DivisionByZeroError: Division by zero in /var/www/html/apps/maps/lib/Service/PhotofilesService.php:414 Stack trace: #0 /var/www/html/apps/maps/lib/Service/PhotofilesService.php(264): OCA\Maps\Service\PhotofilesService->getExif() #1 /var/www/html/apps/maps/lib/BackgroundJob/AddPhotoJob.php(56): OCA\Maps\Service\PhotofilesService->addPhotoNow() #2 /var/www/html/lib/public/BackgroundJob/Job.php(79): OCA\Maps\BackgroundJob\AddPhotoJob->run() #3 /var/www/html/lib/public/BackgroundJob/QueuedJob.php(47): OCP\BackgroundJob\Job->execute() #4 /var/www/html/cron.php(126): OCP\BackgroundJob\QueuedJob->execute() #5 {main}
I temporarily fixed by below modification.
# This is inside of private function getExif($file) # Before foreach ($gps as $key => $value){ $pos = strpos($value, '/'); if ($pos !== false){ $temp = explode('/',$value); $gps[$key] = $temp[0] / $temp[1]; } } $file_object = new \stdClass(); //calculate the decimal degree $file_object->lat = $LatM * ($gps['LatDegree'] + ($gps['LatMinute'] / 60) + ($gps['LatgSeconds'] / 3600)); $file_object->lng = $LongM * ($gps['LongDegree'] + ($gps['LongMinute'] / 60) + ($gps['LongSeconds'] / 3600)); $has_info = true; # After $NaNFound = false; foreach ($gps as $key => $value){ $pos = strpos($value, '/'); if ($pos !== false){ $temp = explode('/',$value); if('0' !== $temp[1]) { $gps[$key] = $temp[0] / $temp[1]; } else { $NaNFound = true; break; } } } $file_object = new \stdClass(); if (false == $NaNFound) { //calculate the decimal degree $file_object->lat = $LatM * ($gps['LatDegree'] + ($gps['LatMinute'] / 60) + ($gps['LatgSeconds'] / 3600)); $file_object->lng = $LongM * ($gps['LongDegree'] + ($gps['LongMinute'] / 60) + ($gps['LongSeconds'] / 3600)); $has_info = true; }
$gps[‘LatDegree’] and $gps[‘LongDegree’] will be ‘0/0’ if altitude and attribute are (NaN, NaN).
This is why zero devided error happens.
So I modified to avoid this error to forcibly set null.
This is not the best but better than error.
Also apps/maps/lib/Service/PhotofilesService.php needs to be fixed as well.
# Inside of private function insertPhoto($photo, $userId, $exif) # Before $photoEntity->setLat( is_numeric($exif->lat)&&!is_nan($exif->lat) ? $exif->lat : null ); $photoEntity->setLng( is_numeric($exif->lng)&&!is_nan($exif->lng) ? $exif->lng : null ); # After $photoEntity->setLat( isset($exif->lat)&&is_numeric($exif->lat)&&!is_nan($exif->lat) ? $exif->lat : null ); $photoEntity->setLng( isset($exif->lng)&&is_numeric($exif->lng)&&!is_nan($exif->lng) ? $exif->lng : null );
After this modification you should be able to see your photoes are mapped on world map!
Below is example of my wife account👩
Many photo will raise high CPU usage like below.
My host is Raspberry Pi which doesn’t have high CPU, that’s why…
Maps also has tracking function of your mobile device.
If you are interested in this feature let’s try!
Conclusion
How was it?
You will be fun if you like vacation stay!
Comments