Skip to content

Instantly share code, notes, and snippets.

@mbohun
Last active November 9, 2024 04:44
Show Gist options
  • Save mbohun/32c078775a83685154a777d642a45d1c to your computer and use it in GitHub Desktop.
Save mbohun/32c078775a83685154a777d642a45d1c to your computer and use it in GitHub Desktop.
Xiaomi Redmi Note 13 Pro cam_app GPS TEST

Redmi Note 13 Pro cam_app GPS TEST

  • TODO
for jpg_photo in `ls *.jpg`; do
    raw_lat=$(identify -format '%[exif:GPSLatitude]' ${jpg_photo})
    raw_lon=$(identify -format '%[exif:GPSLongitude]' ${jpg_photo})
    
    lat=$(echo "$raw_lat" | while IFS="," read -r deg min sec; do echo "scale=6;$deg + $min /60 + $sec / 3600"| bc; done)
    lon=$(echo "$raw_lon" | while IFS="," read -r deg min sec; do echo "scale=6;$deg + $min /60 + $sec / 3600"| bc; done)

    #TEST:
    #echo "$jpg_photo,$lat,$lon"
    echo "${jpg_photo}, https://www.openstreetmap.org/?mlat=${lat}&mlon=${lon}&zoom=18"
done
NOTE: Imagemagick identify exif data format example:
mbohun@mamlas:~/pCloudDrive/fungi/Ramaria stricta, Trencianske Teplice, Slovakia > \
    identify -format '%[EXIF:*]' IMG_20240601_152533.jpg | grep GPS

exif:GPSAltitude=36580/100
exif:GPSAltitudeRef=.
exif:GPSDateStamp=2024:06:01
exif:GPSInfo=8532
exif:GPSLatitude=48/1,54/1,21827087/1000000
exif:GPSLatitudeRef=N
exif:GPSLongitude=18/1,11/1,17156066/1000000
exif:GPSLongitudeRef=E
exif:GPSProcessingMethod=GPS
exif:GPSTimeStamp=13/1,25/1,33/1
exif:GPSVersionID=....
#!/bin/bash
FEATURES='[]'
# NOTE: each photo is represented as a geojson Feature in the following format:
#
# {
# "id": 0,
# "type": "Feature",
# "geometry": {
# "coordinates": [
# 18.197613,
# 48.8985345
# ],
# "type": "Point"
# },
# "properties": {
# "photo": "IMG_20241024_173613.jpg",
# "timestamp": 1730048732
# }
# }
#
# NOTE:
counter_id=0
for jpg_photo in `ls *.jpg`; do
echo "processing geojson feature id: ${counter_id}"
raw_lat=$(identify -format '%[exif:GPSLatitude]' ${jpg_photo})
raw_lon=$(identify -format '%[exif:GPSLongitude]' ${jpg_photo})
lat=$(echo "$raw_lat" | while IFS="," read -r deg min sec; do echo "scale=6;$deg + $min /60 + $sec / 3600"| bc; done)
lon=$(echo "$raw_lon" | while IFS="," read -r deg min sec; do echo "scale=6;$deg + $min /60 + $sec / 3600"| bc; done)
FEATURES=$(echo '{ "id": '${counter_id}', "type": "Feature", "geometry": { "coordinates": ['${lon},${lat}'], "type": "Point"}, "properties": { "photo": "\
'${jpg_photo}'" } }' | jq --argjson features "$FEATURES" '$features + [.]')
counter_id=$((counter_id + 1))
done
echo '{ "type": "FeatureCollection" }' \
| jq --argjson features "$FEATURES" '.["features"]=$features' > album.geojson
@mbohun
Copy link
Author

mbohun commented Nov 9, 2024

GEOJSON Polygon test

{
      "type": "Feature",
      "properties": {},
      "geometry": {
        "coordinates": [
          [
            [
              18.18652154778826,
              48.90401309469868
            ],
            [
              18.18669787196461,
              48.90384400281701
            ],
            [
              18.18672594648669,
              48.9034477954784
            ],
            [
              18.186786312180686,
              48.90342456377698
            ],
            [
              18.186838208449956,
              48.903576868936256
            ],
            [
              18.187140059981374,
              48.903850544716335
            ],
            [
              18.187094765148856,
              48.90410152529216
            ],
            [
              18.186927512776492,
              48.90420496405508
            ],
            [
              18.186629983202153,
              48.90415607154813
            ],
            [
              18.18652154778826,
              48.90401309469868
            ]
          ]
        ],
        "type": "Polygon"
      }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment