Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions api/upsert_images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,15 @@ def create_image_uploads(image_props, survey_sentera_id, sensor_type)
# objects created by the
# create_image_uploads mutation
# @param [string] sensor_type The type of sensor that captured the images
# @param [string] calculated_index The calculated index value for the images
# @param [string] color_applied The color applied value for the images
# @param [string] camera_make The camera make for the image
# @param [string] camera_model The camera model for the image
# @param [Array[Hash]] image_props Array of image properties
#
# @return [Hash] Hash containing results of the GraphQL request
#
def upsert_images(survey_sentera_id, image_uploads, sensor_type, image_props)
def upsert_images(survey_sentera_id, image_uploads, sensor_type, calculated_index, color_applied, camera_make, camera_model, image_props)
puts 'Upsert images'

gql = <<~GQL
Expand Down Expand Up @@ -139,9 +143,11 @@ def upsert_images(survey_sentera_id, image_uploads, sensor_type, image_props)
# Note the use of the file_key attribute to reference
# the previously uploaded image.
altitude: 0,
calculated_index: 'UNKNOWN',
calculated_index: calculated_index,
camera_make: camera_make,
camera_model: camera_model,
captured_at: Time.now.utc.iso8601,
color_applied: 'UNKNOWN',
color_applied: color_applied,
filename: filename,
key: image_upload['id'],
gps_carrier_phase_status: 'STANDARD',
Expand Down Expand Up @@ -169,6 +175,10 @@ def upsert_images(survey_sentera_id, image_uploads, sensor_type, image_props)
images_path = ENV.fetch('IMAGES_PATH', '.') # Your fully qualified path to a folder containing the images to upload
file_ext = ENV.fetch('FILE_EXT', '*.*') # Your image file extension
sensor_type = ENV.fetch('SENSOR_TYPE', 'UNKNOWN') # Your sensor type for the images being uploaded
calculated_index = ENV.fetch('CALCULATED_INDEX', 'UNKNOWN') # Your calculated index for the images being uploaded
colored_applied = ENV.fetch('COLOR_APPLIED', 'UNKNOWN') # Your color applied value for the images being uploaded
camera_make = ENV.fetch('CAMERA_MAKE', nil) # Your Camera Make for the image being uploaded
camera_model = ENV.fetch('CAMERA_MODEL', nil) # Your Camera Model for the image being uploaded
survey_sentera_id = ENV.fetch('SURVEY_SENTERA_ID', nil) # Your existing survey Sentera ID
# **************************************************

Expand All @@ -193,10 +203,14 @@ def upsert_images(survey_sentera_id, image_uploads, sensor_type, image_props)
upload_files(image_uploads, image_paths)

# Step 3: Create images in FieldAgent using the uploaded images
results = upsert_images(survey_sentera_id, image_uploads, sensor_type, image_props)
results = upsert_images(
survey_sentera_id, image_uploads,
sensor_type, calculated_index, colored_applied, camera_make, camera_model,
image_props
)

if results && results['succeeded'].any?
puts "Done! Images for #{survey_sentera_id} were created in FieldAgent."
else
puts "Failed due to error: #{results['failed'].inspect}"
end
end