Skip to content

Using API to Upload Spots

Jason Ash edited this page Dec 7, 2017 · 10 revisions

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, 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.67959707921358,
               38.576863618037294
            ]
         },
         "properties":{
            "date":"2017-12-07T20:29:06.000Z",
            "time":"2017-12-07T20:29:06.000Z",
            "id":15126785461116,
            "name":"My Test Spot",
            "modified_timestamp":1512678602405,
            "orientation_data":[
               {
                  "type":"planar_orientation",
                  "id":15126785592652,
                  "label":"Plane here",
                  "strike":22,
                  "dip_direction":55,
                  "dip":53,
                  "associated_orientation":[
                     {
                        "type":"linear_orientation",
                        "id":15126785811923,
                        "label":"Associated line here",
                        "trend":44,
                        "plunge":12,
                        "rake":53,
                        "rake_calculated":"no"
                     }
                  ]
               }
            ]
         }
      }
   ]
}