National-Forestry-Authority / brms

1 stars 1 forks source link

Push master polygons to Forests #141

Open peacog opened 1 month ago

peacog commented 1 month ago

BRMS should serve as the source of polygons uses by the Forests website. We have a CFR global id field on BRMS and Forests that uniquely identifies a CFR. Investigate how we can push the master polygon from a BRMS CFR to the equivalent CFR in the Forests system. See Forests issue https://github.com/National-Forestry-Authority/forests/issues/352

The API calls are: POST https://forests.ddev.site/oauth/token with body form data: client_id=brms grant_type=client_credentials client_secret=the secret set in the BRMS consumer at https://forests.ddev.site/admin/config/services/consumer

GET https://forests.ddev.site/api/asset/cfr?filter[cfr_global_id]=9dc69f9c-2340-4d98-b4e3-0c57420b3bd4 to get the UUID of the CFR with the given cfr_global_id. The response includes the id which is used in the PATCH call to update the polygon. Set auth type to Bearer token and use the token returned by the oauth/token call

PATCH https://forests.ddev.site/api/asset/cfr/the-id-returned-by-the-get-call Set auth type to Bearer token and use the token returned by the oauth/token call Set body to raw JSON with this format:

{
  "data": {
    "type": "asset",
    "id": "the-id-returned-by-the-get-call",
    "attributes": {
      "intrinsic_geometry": "POLYGON ((33.3078051280917 0.164148842710992, 33.3135162021597 0.1662771095716, 33.3138880025214 0.164787564489483, 33.3141401631568 0.163001583981742, 33.3144013278441 0.162295614131576, 33.3141440785292 0.161967373889204, 33.3142069804967 0.161667401263258, 33.3144760151102 0.161386368049836, 33.3145377935169 0.161040452618518, 33.3142653760185 0.160505823081059, 33.3137053925244 0.160447873452648, 33.3132745960336 0.160617232206172, 33.312892657874 0.160337481743117, 33.3129403913376 0.159807936422513, 33.3133587926627 0.157145504335687, 33.3133829360648 0.156582032165361, 33.3135463749354 0.156165151216891, 33.314097926884 0.155775122401417, 33.3147741673288 0.155313704675233, 33.3129745690388 0.154257469769129, 33.3125752228888 0.154253941591547, 33.3121753161115 0.154250272112524, 33.3117254153126 0.153960343715384, 33.3116720417683 0.152927265475336, 33.3111929128666 0.151086871398543, 33.3103189348497 0.149495422407841, 33.3102728636457 0.148464605550376, 33.3099791055683 0.148056636496846, 33.309952144729 0.14798835928056, 33.3097909431829 0.147782113293893, 33.3096112042371 0.147420650636012, 33.3093331750745 0.147126337373736, 33.3085468446403 0.147462085339919, 33.3077127765834 0.148029951286981, 33.3059772308428 0.148592600293841, 33.3055245291003 0.148796876046234, 33.3051661901459 0.149171633829766, 33.3046107303749 0.151239214198125, 33.3042091442972 0.151718298793744, 33.3038395898063 0.153345673218183, 33.3074763960265 0.153756703670238, 33.3078051280917 0.164148842710992))"
    }
  }
}