Examples of setting GPS Info

gps

#1

Different examples setting GPS info.

from community member 200cm3

- (void)setGpsLocation:(double)lat lng:(double)lng alt:(double) alt
{
 [self setOptions:@{@"gpsInfo":
                           @{@"lat": [NSNumber numberWithDouble: lat],
                             @"lng": [NSNumber numberWithDouble: lng],
                             @"dateTimeZone": @"2014:05:18 01:04:29+08:00",
                             @"_altitude": [NSNumber numberWithDouble:alt],
                             @"datum": @"\"WGS84\""}}];
    
}

Using shell script from Jason Charcalla.

JSON_GPS_SET_REQ=$(< <(cat <<EOF
{
  "name": "camera.setOptions",
  "parameters": {
    "sessionId": "SID_${SID}",
    "options": {
                  "gpsInfo": {
                 "lat": ${GPS_LAT},
                 "lng": ${GPS_LON},
                 "_altitude": ${GPS_ALT},
                 "_dateTimeZone":"${GPS_DATE} ${GPS_TIME}+00:00",
                  "_datum":"WGS84"
            }
        }
  }
}
EOF
))
                   # Set the gps values on the camera via wifi
                echo ${JSON_GPS_SET_REQ}
                   curl -s -X POST -d "${JSON_GPS_SET_REQ}" http://${CAMIP}:${PORT}/osc/commands/execute >> /dev/null
             else
            # Set the gps via usb
            ptpcam --set-property=0xD801 --val="${GPS_LAT},${GPS_LON},${GPS_ALT}m@${GPS_DATE}${GPS_TIME}Z,WGS84"
         fi

       else
          echo "GPS enabled but now location found."
       fi
    fi

Full code for the shell script, including use of input from a GPS unit connected to a Raspberry Pi