posm / OpenMapKitAndroid

http://openmapkit.org
BSD 3-Clause "New" or "Revised" License
128 stars 38 forks source link

Constraints #117

Closed hallahan closed 8 years ago

hallahan commented 8 years ago

This is the master issue for implementing constraint functionality. Here are the constraints we want to think about.

Multiple Values Per Key

Required Tags Force User To Answer

Implicit Tag Recorded Wihtout UI

Default Value for a Tag

Typeahead Based off of Tag Index

Skip Logic

Numeric Input

Enable / Disable Custom Value Input

Let's discuss here how we want to actually get constraint metadata into OpenMapKit Android so that we can do these things.

PaulUithol commented 8 years ago

Another one you might want to add is whether or not to show the 'custom' value input in addition to the predefined list. It's useful the vast majority of the time! - but sometimes, the answer should just be straight yes/no without the option for other values.

hallahan commented 8 years ago

Good call @PaulUithol. I will add it to the list.

hallahan commented 8 years ago

Thinking a bit about how the iD editor was built, constraints are built in as part of the UX. In fact, there are JSON configs determining how all of that stuff works.

If we have a certain OSM tag that merits a numeric input, or maybe skip logic determining what tags to ask for based off of previous answers, this is OSM specific, and it should be dictated by OSM best practices. These sort of constraints, I think, are universal in nature, and are a bit more default than something that should be declared in a specific form.

Maybe we should have a JSON config file that OpenMapKit Android looks at to determine OSM based constraints. This could be editable and served on an OMK Server endpoint, and we could also just pack a default in the app's assets.

I feel like this would serve well in the future if one were to make an OSM editor not associated with ODK. Also, if we really really absolutely had to integrate with pyxform and JavaRosa, it might make sense to compile constraints into this concept of a JSON config anyway.

hallahan commented 8 years ago

The basic approach with defining constraints will be JSON based. We copy JSON files form the constraints directory in the application assets to openmapkit/constraints in ExternalStorage. This way we will have a default setup, and then the constraints JSON settings can later be altered based on a REST endpoint in OpenMapKitServer (or a definition in XForms).

This approach is more extensible than building constraints into XForms up-front.

default.json - default constraints for all surveys <form_id>.json - constraints that just apply to a specific form, overriding default.json

We can implement the actual functionality of constraints in OpenMapKit Android via this JSON settings mechanism. Later, we can go in and build XLSForm (pyxform) -> XForm (JavaRosa) -> Constraint JSON.

Doing pyxform and JavaRosa work right now will derail progress in the project as a whole. Also, this approach would lend well for development of a tag editor outside of an ODK context.

By having a set of constraints settings files in the Android application assets, we will have good defaults ship with the app. We can then have a simple OpenMapKit Server REST endpoint with modified constraints, but we won't require OMK Server for constraint functionality to work in Android.

See 0d58f2aca2e86d6f81c93648712f1e0ff096c111 showing how we take app assets and move them to ExternalStorage, allowing us to not rely on republishing the app to update an assets setting file. @ccabanero & @shawnaparadee - you can use this code in TechTracker.

cc/ @PaulUithol @dalekunce

dalekunce commented 8 years ago

+1 for this approach as long as the contraints.json can be easily made. Can we borrow anything from the iD or JOSM ontology to enforce stuff like this. Heck maybe maps.me even, there ontology looks pretty good as well.

PaulUithol commented 8 years ago

See this release is out now, great! I'm trying out some of the features, and it does seem to make an educated guess as to the type of input you're looking for? Some questions get an empty input for me, some checkboxes, etc. Quite handy! Do you have an example of a constraints json somewhere, showing of the features and how to use them? Or other documentation on how to make these.

dalekunce commented 8 years ago

http://openmapkit.org/docs_constraints.html

@PaulUithol

PaulUithol commented 8 years ago

Great, thanks! That's pretty elaborate.

Found the default.json. The constraints folder didn't show in file explorer on my device for some reason, but there's the 'magic' behavior happens then ;).

On 21-06-2016 17:37, Dale Kunce wrote:

http://openmapkit.org/docs_constraints.html

@PaulUithol https://github.com/PaulUithol

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AmericanRedCross/OpenMapKitAndroid/issues/117#issuecomment-227460089, or mute the thread https://github.com/notifications/unsubscribe/AAo7zpAA_y1uLhb38Vw8VRLin-O6Gakeks5qN_crgaJpZM4G_FRk.

PaulUithol commented 8 years ago

(sorry, I know I should open a new issue for this, but I can't login to github.. something going wrong with timezones and two factor auth while in Tanzania it seems)

Got a custom constraints file for a form to work with some fiddling, but not quite according to the docs; these instruct to use the form title of the form (not it's filename).

I tried a number of different names for the constraint file since it wouldn't work, and the one that does it for me in this case is hot_01_toilet.json, while the form title is <h:title>01 Toilets</h:title>. However, hot_01_toilet is the name of the form file, and is also in the file as <instance><hot_01_toilet id="01_toilets">.

On 21-06-2016 17:45, Paul Uithol wrote:

Great, thanks! That's pretty elaborate.

Found the default.json. The constraints folder didn't show in file explorer on my device for some reason, but there's the 'magic' behavior happens then ;).

On 21-06-2016 17:37, Dale Kunce wrote:

http://openmapkit.org/docs_constraints.html

@PaulUithol https://github.com/PaulUithol

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AmericanRedCross/OpenMapKitAndroid/issues/117#issuecomment-227460089, or mute the thread https://github.com/notifications/unsubscribe/AAo7zpAA_y1uLhb38Vw8VRLin-O6Gakeks5qN_crgaJpZM4G_FRk.

Humanitarian OpenStreetMap Team Project Manager "Ramani Huria" (Dar es Salaam) & "Mapping Financial Inclusion" (Uganda)

Email: paul.uithol@hotosm.org Skype: paul.uithol NL: +31 6 2423 7614 TZ: +255 7 8546 2836 UG: +256 7 8573 9853

hallahan commented 8 years ago

Hi @PaulUithol - could you send me your form? I'd like to take a look.

PaulUithol commented 8 years ago

Will do as soon as I'm near a computer again. Must say I don't mind this behavior though, if the docs were matching it. When dealing with large amounts of forms, it'd be easier to see which belongs to which constraints file if the filenames match, as opposed to having to open all the spreadsheets searching for a match? On Jun 22, 2016 8:54 PM, "Nicholas Hallahan" notifications@github.com wrote:

Hi @PaulUithol https://github.com/PaulUithol - could you send me your form? I'd like to take a look.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AmericanRedCross/OpenMapKitAndroid/issues/117#issuecomment-227824823, or mute the thread https://github.com/notifications/unsubscribe/AAo7ztegooD1kPqcU22d8yk3w9Qf5jjCks5qOXbmgaJpZM4G_FRk .

hallahan commented 8 years ago

Totally. The reason is that the form title is the only thing available in the data structure in ODK Collect.