Using API to Upload Spots - StraboSpot/strabo-mobile GitHub Wiki

Steps to use API to upload Spots

Notes:

modified_timestamp is unix_time + milliseconds for a total of 13 digits.

id is unix_time + 4 random integers for a total of 14 digits.

All API calls use HTTP Basic Auth for authentication

First, create a project...

POST https://strabospot.org/db/project

{
   "modified_timestamp":1512678555360,
   "description":{
      "project_name":"My test project"
   },
   "date":"2017-12-07T20:28:54.036Z",
   "id":15126785340366
}

Next, create a dataset...

POST https://strabospot.org/db/dataset

{
   "name":"My Test Dataset",
   "date":"2017-12-07T20:28:54.116Z",
   "id":15126785341167,
   "modified_timestamp":1512678534116
}

Next, add dataset to project...

POST https://strabospot.org/db/projectDatasets/15126785340366

{
	"id":15126785341167
}

Next, upload your image(s) using the API:

POST: https://strabospot.org/db/image

Due to a file being uploaded, this service accepts multiple POST variables:

Variable Name: "id" - ID of image being uploaded. (required)
Variable Name: "image_file" - File containing image to be uploaded. (required)


Also, please note the the encapsulation type MUST be set to "multipart/form-data".


Note: Due to the complexity of using multipart/form-data, a test page has been created to test this service. This page can be found at: https://strabospot.org/imageupload.

Next, use datasetspots controller to add spots to dataset...

POST https://strabospot.org/db/datasetspots/15126785341167

{
   "type":"FeatureCollection",
   "features":[
      {
         "type":"Feature",
         "geometry":{
            "type":"Point",
            "coordinates":[
               -97.67941037592203,
               38.5767240414678
            ]
         },
         "properties":{
            "date":"2017-12-08T02:37:04.000Z",
            "time":"2017-12-08T02:37:04.000Z",
            "id":15127006246996,
            "name":"my spot name",
            "spot_radius":123,
            "altitude":55,
            "notes":"Spot notes here",
            "modified_timestamp":1512700893733,
            "orientation_data":[
               {
                  "type":"planar_orientation",
                  "id":15127006596617,
                  "label":"Plane label",
                  "strike":12,
                  "dip_direction":23,
                  "dip":34,
                  "quality":"4",
                  "feature_type":"fault",
                  "fault_or_sz_type":"sinistral_normal",
                  "movement":"ne_side_up",
                  "movement_justification":[
                     "offset_bedding"
                  ],
                  "directional_indicators":[
                     "riedel_shear"
                  ],
                  "movement_amount_m":1,
                  "movement_amount_qualifier":"maximum_amount",
                  "thickness":0.5,
                  "length":12,
                  "notes":"Notes here"
               },
               {
                  "type":"linear_orientation",
                  "id":15127008204398,
                  "label":"Line label",
                  "trend":12,
                  "plunge":23,
                  "rake":34,
                  "rake_calculated":"yes",
                  "quality":"4",
                  "feature_type":"pencil_cleav",
                  "defined_by":"Defined by here",
                  "notes":"Line notes here"
               }
            ]
         }
      },
      {
         "type":"Feature",
         "geometry":{
            "type":"LineString",
            "coordinates":[
               [
                  -97.68078,
                  38.576966
               ],
               [
                  -97.679372,
                  38.578238
               ],
               [
                  -97.678595,
                  38.576184
               ],
               [
                  -97.679723,
                  38.576018
               ],
               [
                  -97.679839,
                  38.57462
               ],
               [
                  -97.678316,
                  38.575165
               ],
               [
                  -97.678195,
                  38.575119
               ]
            ]
         },
         "properties":{
            "date":"2019-05-09T20:26:32.000Z",
            "time":"2019-05-09T20:26:32.000Z",
            "id":15574335922005,
            "name":"Line Spot here",
            "modified_timestamp":1557433848274,
            "images":[
               {
                  "image_type":"photo",
                  "id":15574337432107,
                  "height":3024,
                  "width":4032
               }
            ],
            "trace":{
               "trace_feature":true,
               "trace_quality":"approximate",
               "trace_type":"bedding"
            },
            "samples":[
               {
                  "sample_type":"field",
                  "id":15574338057137,
                  "label":"My test sample",
                  "sample_id_name":"Mysampleid",
                  "main_sampling_purpose":"fabric___micro",
                  "sample_description":"Sample description",
                  "material_type":"intact_rock",
                  "inplaceness_of_sample":"4"
               }
            ]
         }
      }
   ]
}