opencaching / okapi

A common API for all National Opencaching.XX sites
22 stars 19 forks source link

Upload field note file via OKAPI #601

Open Lineflyer opened 3 years ago

Lineflyer commented 3 years ago

For c:geo we recently had a discussion about field note upload for other sites than geocaching.com. From OC.de I know that field notes (also including duplicate handling with GC geocodes) is already implemented on their website.

For c:geo it would just be perfect if there is a possibility to upload field notes via OKAPI. I looked over here and other places but could not find a related issue for OKAPI. I hope this is the right place to discuss/address it.

teiling88 commented 3 years ago

Hey @Lineflyer,

can you provide me an file for this use case? I can try to implement it :-)

Greetings, Thomas

wrygiel commented 3 years ago

BTW, could you remind me what's the difference between field notes and personal notes? (I'm not an active geocacher nowadays.)

teiling88 commented 3 years ago

Field Notes are notes about caches created with your GPS Device or an app like c:geo. So you can prepare your Log Notes and submit them finally later.

Lineflyer commented 3 years ago

20210105182416.txt

Attached a sample field note from c:geo containing offline logs for both gc.com and oc.de caches.

hxdimpf commented 10 months ago

I plan to implement that service method shortly ... in a way that is compaitble with what "the other platform" does. Specificly it will be tolerant to filter OC logs and discard "the other logs", just like the other platform does with OC logs.

Also, if you (@Lineflyer) are reading this: There is another important function missing, which cgeo wants to use: save_user_coords it resembles to a large degree what the other platform calls corrected coordinates. A PR for that function is in the pipe, as you probably noticed already. It is now a matter of review, merge, and then integration into opencaching.de production.

hxdimpf commented 10 months ago

@Lineflyer, pls review PR https://github.com/opencaching/okapi/pull/630 to see whether this would work for cgeo. The assumption is that cgep maintains one hybrid filednotes file, which may include log records for more than one platform. My PR will ignore records not starting with OC. Please note that the log types must case sensitively match the log types as defined for the OCDE platform. Also note that the fieldnotes file needs to have utf-8 chacacter encoding and the whole string needs to be passed as base64 encoded. Conseqently, when uploading to more than one platform during the "Export fieldnotes" dialog in cgeo, cgeo must pre-process the data before pushing.

For instance, what is a Write note on one platform must show up as Comment on OCDE. There are a few more discrepancies, even though those will be very rarely encountered.

Also, keep in mind, no UTF-16, and keep in mind the base64 encoding. And last not least: OKAPI equally supports GET and POST requests, however, since fieldnotes files can get rather large, a GET may fail due to length restrictions of URLs. My recommendation for using the service in question would be to use POST requests and put the payload into the request body.

I can make sample client code available for the cgeo team.

bekuno commented 10 months ago

@hxdimpf Thanks for diving in this problem. The discussion to UTF-8 vs. UTF16-LE with BOM is in issue https://github.com/cgeo/cgeo/issues/10044. I believe that using UTF-8 for OKAPI fieldnotes would be fine. Please open a issue on c:geo site to discuss the implementation there.