Skip to content

Instantly share code, notes, and snippets.

@hallahan
Last active August 29, 2015 14:14
Show Gist options
  • Save hallahan/217dc21ed04baeb20022 to your computer and use it in GitHub Desktop.
Save hallahan/217dc21ed04baeb20022 to your computer and use it in GitHub Desktop.
Modified XForms With OSM Upload Media Type
list name name label
osm_building name **unimplemented**
osm_building name:fr **ignore what is**
osm_building building **in this column**
osm_building addr:house number
osm_building addr:street
osm_building addr:city
osm_building addr:postcode
and this will result in the tags in the XForm xml as such:
<upload ref="/data/osm_building" mediatype="osm/*">
<label ref="jr:itext('/data/osm_building:label')"/>
<hint ref="jr:itext('/data/osm_building:hint')"/>
<tag>name</tag>
<tag>name:fr</tag>
<tag>building</tag>
<tag>addr:housenumber</tag>
<tag>addr:street</tag>
<tag>addr:city</tag>
<tag>addr:postcode</tag>
</upload>

OSM Upload Media Type for OpenDataKit

With very minimal modification to JavaRosa, we have created a new upload media type called "osm" that will point to OSM XML files generated by OpenMapKit.

The changes to JavaRosa can be found here:

https://bitbucket.org/nhallahan/javarosa/branches/compare/nhallahan/javarosa:tip..m.sundt/javarosa:default#diff

I have created a compiled JavaRosa build with these changes available here:

https://www.dropbox.com/s/h8y7a9mt7tubm7r/javarosa-libraries-osm-2015-02-05.jar

Below, you can see the first UI iteration of an OSM form question showing a launch button and a list of the required OSM tags: Default Question

I have some new XML for you showing what a valid XForm looks like.

<?xml version='1.0' ?><data id="build_nh-test_1416094424"><meta><instanceID>uuid:2acee148-c543-4236-9557-5c547b091a9f</instanceID></meta><magic_number>5.0</magic_number><name>Vladimir</name><current_location>47.6687237 -122.3842931 0.0 34.833</current_location><photo>1422910735157.jpg</photo><osm>some_file_path.osm</osm><fav_color>blue</fav_color><form_completed>2015-02-02T12:59:08.958-08</form_completed></data>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa">
<h:head>
<h:title>osm_upload_type_many_tags</h:title>
<model>
<instance>
<data id="build_nh-test_1416094424">
<meta>
<instanceID/>
</meta>
<photo/>
<osm_road/>
<osm_building/>
<fav_color>
red
</fav_color>
<form_completed/>
</data>
</instance>
<itext>
<translation lang="eng">
<text id="/data/photo:label">
<value>Take a picture of something.</value>
</text>
<text id="/data/photo:hint">
<value>We don't care what it is.</value>
</text>
<text id="/data/fav_color:label">
<value>What is your favorite color?</value>
</text>
<text id="/data/fav_color:hint">
<value>You must pick one of our choices.</value>
</text>
<text id="/data/osm_road:label">
<value>Road</value>
</text>
<text id="/data/osm_road:hint">
<value>Tag the road in front of the building.</value>
</text>
<text id="/data/osm_building:label">
<value>Building</value>
</text>
<text id="/data/osm_building:hint">
<value>Tag attributes about this building.</value>
</text>
<text id="/data/fav_color:option0">
<value>red</value>
</text>
<text id="/data/fav_color:option1">
<value>green</value>
</text>
<text id="/data/fav_color:option2">
<value>blue</value>
</text>
<text id="/data/fav_color:option3">
<value>The color of the sun.</value>
</text>
</translation>
</itext>
<bind nodeset="/data/meta/instanceID" type="string" readonly="true()" calculate="concat('uuid:', uuid())"/>
<bind nodeset="/data/photo" type="binary"/>
<bind nodeset="/data/osm_road" type="binary"/>
<bind nodeset="/data/osm_building" type="binary"/>
<bind nodeset="/data/fav_color" type="select1"/>
<bind nodeset="/data/form_completed" type="dateTime" jr:preload="timestamp" jr:preloadParams="end"/>
</model>
</h:head>
<h:body>
<upload ref="/data/photo" mediatype="image/*">
<label ref="jr:itext('/data/photo:label')"/>
<hint ref="jr:itext('/data/photo:hint')"/>
</upload>
<upload ref="/data/osm_road" mediatype="osm/*">
<label ref="jr:itext('/data/osm_road:label')"/>
<hint ref="jr:itext('/data/osm_road:hint')"/>
<tag>highway</tag>
<tag>name</tag>
<tag>maxspeed</tag>
<tag>maxspeed:winter</tag>
</upload>
<upload ref="/data/osm_building" mediatype="osm/*">
<label ref="jr:itext('/data/osm_building:label')"/>
<hint ref="jr:itext('/data/osm_building:hint')"/>
<tag>name</tag>
<tag>name:fr</tag>
<tag>building</tag>
<tag>addr:housenumber</tag>
<tag>addr:street</tag>
<tag>addr:city</tag>
<tag>addr:postcode</tag>
</upload>
<select1 ref="/data/fav_color">
<label ref="jr:itext('/data/fav_color:label')"/>
<hint ref="jr:itext('/data/fav_color:hint')"/>
<item>
<label ref="jr:itext('/data/fav_color:option0')"/>
<value>red</value>
</item>
<item>
<label ref="jr:itext('/data/fav_color:option1')"/>
<value>green</value>
</item>
<item>
<label ref="jr:itext('/data/fav_color:option2')"/>
<value>blue</value>
</item>
<item>
<label ref="jr:itext('/data/fav_color:option3')"/>
<value>yellow</value>
</item>
</select1>
</h:body>
</h:html>
@dalekunce
Copy link

Woot.

@dalekunce
Copy link

oh man this is so awesome. I love the green button by the way.

@hallahan
Copy link
Author

hallahan commented Feb 5, 2015

😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment