Modifying answer of type GeoPoint before upload from Collect

Hello, I have a form with a question that has an answer of type GeoPoint (it also has another question 'WKT' which has an answer of type Text).

My GeoPoint class has:
@Override
public IAnswerData getAnswer() {
String s = mStringAnswer.getText().toString();
if (s == null || s.equals("")) {
return null;
} else {
try {
// segment lat and lon
String sa = s.split(" ");
double gp = new double[4];
gp[0] = Double.valueOf(sa[0]).doubleValue();
gp[1] = Double.valueOf(sa[1]).doubleValue();
gp[2] = Double.valueOf(sa[2]).doubleValue();
gp[3] = Double.valueOf(sa[3]).doubleValue();

            return new GeoPointData(gp);
        } catch (NumberFormatException e) {
        	Log.e(t, e.getMessage());
        	return null;
        }
    }

I'd like to, instead, return a WKT format Text like Point(103.2, 30.2). I've tried putting it as return new StringData("Point(" + gp[1] + " " + gp[0] + ")"); but I keep getting an error that it's expecting Double Double.

I'd like to know how to go about doing this and where to start looking.

  1. Can I do it easily where, before upload, find the answer and change the value?
  2. Can I change the type detection of GeoPoint so that I can enter string?
  3. Can I change the value of the answer for the other question "WKT" to have the answer from GeoPoint?
  4. Can I create a custom type which would be similar to GeoPoint but, instead, stores as a WKT format string?

(3) If you need a text field, drawn from the values within a GeoPoint, it
is best to define a calculate field that transforms the geopoint string
representation into a string in whatever format you need.

(1) No. There is no post-processing capability in ODK Collect. The
transformation needs to be done as part of the filling out of the form.

(2) There is no capability to redefine the representation of a geopoint to
match your needs. It has a very specific representation.

(4) No. There is no capability to define a custom datatype in ODK Collect.

ยทยทยท On Mon, Jan 12, 2015 at 6:54 AM, wrote:

Hello, I have a form with a question that has an answer of type GeoPoint
(it also has another question 'WKT' which has an answer of type Text).

My GeoPoint class has:
@Override
public IAnswerData getAnswer() {
String s = mStringAnswer.getText().toString();
if (s == null || s.equals("")) {
return null;
} else {
try {
// segment lat and lon
String sa = s.split(" ");
double gp = new double[4];
gp[0] = Double.valueOf(sa[0]).doubleValue();
gp[1] = Double.valueOf(sa[1]).doubleValue();
gp[2] = Double.valueOf(sa[2]).doubleValue();
gp[3] = Double.valueOf(sa[3]).doubleValue();

            return new GeoPointData(gp);
        } catch (NumberFormatException e) {
            Log.e(t, e.getMessage());
            return null;
        }
    }

I'd like to, instead, return a WKT format Text like Point(103.2, 30.2).
I've tried putting it as return new StringData("Point(" + gp[1] + " " + gp[0] + ")"); but I keep getting an error that it's expecting Double
Double.

I'd like to know how to go about doing this and where to start looking.

  1. Can I do it easily where, before upload, find the answer and change the
    value?
  2. Can I change the type detection of GeoPoint so that I can enter string?
  3. Can I change the value of the answer for the other question "WKT" to
    have the answer from GeoPoint?
  4. Can I create a custom type which would be similar to GeoPoint but,
    instead, stores as a WKT format string?

--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com