• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java GeoPointData类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.javarosa.core.model.data.GeoPointData的典型用法代码示例。如果您正苦于以下问题:Java GeoPointData类的具体用法?Java GeoPointData怎么用?Java GeoPointData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

GeoPointData类属于org.javarosa.core.model.data包,在下文中一共展示了GeoPointData类的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getAnswer

点赞 3

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
@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 (Exception NumberFormatException) {
			return null;
		}
	}
}
 

开发者ID:Last-Mile-Health,
项目名称:ODK-Liberia,
代码行数:22,
代码来源:GeoPointWidget.java

示例2: classForDataType

点赞 3

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
/**
 * map xforms data types to the Class that represents that data in a FormInstance
 * @param dataType
 * @return
 */
public static Class classForDataType (int dataType) {
	switch (dataType) {
	case Constants.DATATYPE_NULL: return StringData.class;
	case Constants.DATATYPE_TEXT: return StringData.class;
	case Constants.DATATYPE_INTEGER: return IntegerData.class;
	case Constants.DATATYPE_LONG: return LongData.class;
	case Constants.DATATYPE_DECIMAL: return DecimalData.class;
	case Constants.DATATYPE_BOOLEAN: return BooleanData.class;
	case Constants.DATATYPE_DATE: return DateData.class;
	case Constants.DATATYPE_TIME: return TimeData.class;
	case Constants.DATATYPE_DATE_TIME: return DateTimeData.class;
	case Constants.DATATYPE_CHOICE: return SelectOneData.class;
	case Constants.DATATYPE_CHOICE_LIST: return SelectMultiData.class;
	case Constants.DATATYPE_GEOPOINT: return GeoPointData.class;
	case Constants.DATATYPE_GEOSHAPE: return GeoShapeData.class;
	case Constants.DATATYPE_GEOTRACE: return GeoTraceData.class;
	default: return null;
	}
}
 

开发者ID:medic,
项目名称:javarosa,
代码行数:25,
代码来源:CompactInstanceWrapper.java

示例3: testGetData

点赞 3

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
@Test
public void testGetData() {
    double[] pointsA = {1.11111, 2.2, -1.111, -4.19999};
    double[] pointsB = {1, 2, -3, 4};
    double[] pointsC = {6.899999999, 3.20000001};
    double[] pointsD = {6, 3, 0.0000000000000001, 0.00000009};
    GeoPointData data = new GeoPointData(pointsA);
    assertTrue("GeoPointData test constructor and decimal truncation",
            "1.11111 2.2 -1.12 -4.2".equals(data.getDisplayText()));
    data.setValue(pointsB);
    assertTrue("GeoPointData test setValue on 4 datapoints and decimal truncation",
            "1.0 2.0 -3.0 4.0".equals(data.getDisplayText()));
    data.setValue(pointsC);
    assertTrue("GeoPointData test setValue on 2 datapoints",
            "6.899999999 3.20000001".equals(data.getDisplayText()));
    data.setValue(pointsD);
    assertTrue("GeoPointData test setValue on 4 datapoints and decimal truncation",
            "6.0 3.0 0.0 0.0".equals(data.getDisplayText()));
}
 

开发者ID:dimagi,
项目名称:commcare-j2me,
代码行数:20,
代码来源:GeoPointDataTests.java

示例4: getAnswer

点赞 3

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
@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]);
            gp[1] = Double.valueOf(sa[1]);
            gp[2] = Double.valueOf(sa[2]);
            gp[3] = Double.valueOf(sa[3]);

            return new GeoPointData(gp);
        } catch (Exception NumberFormatException) {
            return null;
        }
    }
}
 

开发者ID:dimagi,
项目名称:commcare-android,
代码行数:22,
代码来源:GeoPointWidget.java

示例5: distance

点赞 3

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
/**
 * Returns the distance between two GeoPointData locations, in meters, given objects to unpack.
 * Ignores altitude and accuracy.
 * Note that the arguments can be strings.
 * Returns -1 if one of the arguments is null or the empty string.
 */
public static Double distance(Object from, Object to) {
    String unpackedFrom = (String)FunctionUtils.unpack(from);
    String unpackedTo = (String)FunctionUtils.unpack(to);

    if (unpackedFrom == null || "".equals(unpackedFrom) || unpackedTo == null || "".equals(unpackedTo)) {
        return new Double(-1.0);
    }

    try {
        // Casting and uncasting seems strange but is consistent with the codebase
        GeoPointData castedFrom = new GeoPointData().cast(new UncastData(unpackedFrom));
        GeoPointData castedTo = new GeoPointData().cast(new UncastData(unpackedTo));

        return new Double(GeoPointUtils.computeDistanceBetween(castedFrom, castedTo));
    } catch (NumberFormatException e) {
        throw new XPathTypeMismatchException("distance() function requires arguments containing " +
                "numeric values only, but received arguments: " + unpackedFrom + " and " + unpackedTo);
    }
}
 

开发者ID:dimagi,
项目名称:commcare-core,
代码行数:26,
代码来源:XPathDistanceFunc.java

示例6: unpackValue

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
public static Object unpackValue (IAnswerData val) {
	if (val == null) {
		return "";
	} else if (val instanceof UncastData) {
		return val.getValue();
	} else if (val instanceof IntegerData) {
		return new Double(((Integer)val.getValue()).doubleValue());
	} else if (val instanceof LongData) {
		return new Double(((Long)val.getValue()).doubleValue());
	} else if (val instanceof DecimalData) {
		return val.getValue();
	} else if (val instanceof StringData) {
		return val.getValue();
	} else if (val instanceof SelectOneData) {
		return ((Selection)val.getValue()).getValue();
	} else if (val instanceof SelectMultiData) {
		return (new XFormAnswerDataSerializer()).serializeAnswerData(val);
	} else if (val instanceof DateData) {
		return val.getValue();
	} else if (val instanceof BooleanData) {
		return val.getValue();
	} else if (val instanceof GeoPointData) {
		// we have no access fns that interact with double[4] arrays (the getValue() data type)...
		return val.getDisplayText();
	} else if (val instanceof GeoShapeData) {
		// we have no access fns that interact with GeoShape objects (the getValue() data type)...
		return val.getDisplayText();
	} else if (val instanceof GeoTraceData) {
		// we have no access fns that interact with GeoTrace objects (the getValue() data type)...
		return val.getDisplayText();
	} else {
		System.out.println("warning: unrecognized data type in xpath expr: " + val.getClass().getName());
		return val.getValue(); //is this a good idea?
	}
}
 

开发者ID:medic,
项目名称:javarosa,
代码行数:36,
代码来源:XPathPathExpr.java

示例7: canSerialize

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
public boolean canSerialize(IAnswerData data) {
	if (data instanceof StringData || data instanceof DateData || data instanceof TimeData ||
	    data instanceof SelectMultiData || data instanceof SelectOneData ||
	    data instanceof IntegerData || data instanceof DecimalData || data instanceof PointerAnswerData	||
	    data instanceof MultiPointerAnswerData ||
	    data instanceof GeoPointData || data instanceof GeoTraceData || data instanceof GeoShapeData ||
	    data instanceof LongData || data instanceof DateTimeData || data instanceof UncastData) {
		return true;
	} else {
		return false;
	}
}
 

开发者ID:medic,
项目名称:javarosa,
代码行数:13,
代码来源:XFormAnswerDataSerializer.java

示例8: serializeAnswerData

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
public Object serializeAnswerData(IAnswerData data) {
	if (data instanceof StringData) {
		return serializeAnswerData((StringData)data);
	} else if (data instanceof SelectMultiData) {
		return serializeAnswerData((SelectMultiData)data);
	} else if (data instanceof SelectOneData) {
		return serializeAnswerData((SelectOneData)data);
	} else if (data instanceof IntegerData){
		return serializeAnswerData((IntegerData)data);
	} else if (data instanceof LongData){
		return serializeAnswerData((LongData)data);
	} else if (data instanceof DecimalData) {
		return serializeAnswerData((DecimalData)data);
	} else if (data instanceof DateData) {
		return serializeAnswerData((DateData)data);
	} else if (data instanceof TimeData) {
		return serializeAnswerData((TimeData)data);
	} else if (data instanceof PointerAnswerData) {
		return serializeAnswerData((PointerAnswerData)data);
	} else if (data instanceof MultiPointerAnswerData) {
		return serializeAnswerData((MultiPointerAnswerData)data);
	} else if (data instanceof GeoShapeData) {
           return serializeAnswerData((GeoShapeData)data);
	} else if (data instanceof GeoTraceData) {
           return serializeAnswerData((GeoTraceData)data);
	} else if (data instanceof GeoPointData) {
           return serializeAnswerData((GeoPointData)data);
       } else if (data instanceof DateTimeData) {
           return serializeAnswerData((DateTimeData)data);
       } else if (data instanceof BooleanData) {
           return serializeAnswerData((BooleanData)data);
       } else if (data instanceof UncastData) {
           return serializeAnswerData((UncastData)data);
       }

	return null;
}
 

开发者ID:medic,
项目名称:javarosa,
代码行数:38,
代码来源:XFormAnswerDataSerializer.java

示例9: distance

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
/**
 * Returns the distance between two GeoPointData locations, in meters, given objects to unpack.
 * Ignores altitude and accuracy.
 * Note that the arguments can be strings.
 * Returns -1 if one of the arguments is null or the empty string.
 */
public static Double distance(Object from, Object to) {
    String unpackedFrom = (String) unpack(from);
    String unpackedTo = (String) unpack(to);

    if (unpackedFrom == null || "".equals(unpackedFrom) || unpackedTo == null || "".equals(unpackedTo)) {
        return new Double(-1.0);
    }

    // Casting and uncasting seems strange but is consistent with the codebase
    GeoPointData castedFrom = new GeoPointData().cast(new UncastData(unpackedFrom));
    GeoPointData castedTo = new GeoPointData().cast(new UncastData(unpackedTo));

    return new Double(GeoPointUtils.computeDistanceBetween(castedFrom, castedTo));
}
 

开发者ID:dimagi,
项目名称:commcare-j2me,
代码行数:21,
代码来源:XPathFuncExpr.java

示例10: unpackValue

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
public static Object unpackValue(IAnswerData val) {
    if (val == null) {
        return "";
    } else if (val instanceof UncastData) {
        return val.getValue();
    } else if (val instanceof IntegerData) {
        return new Double(((Integer)val.getValue()).doubleValue());
    } else if (val instanceof LongData) {
        return new Double(((Long)val.getValue()).doubleValue());
    } else if (val instanceof DecimalData) {
        return val.getValue();
    } else if (val instanceof StringData) {
        return val.getValue();
    } else if (val instanceof SelectOneData) {
        return ((Selection)val.getValue()).getValue();
    } else if (val instanceof SelectMultiData) {
        return (new XFormAnswerDataSerializer()).serializeAnswerData(val);
    } else if (val instanceof DateData) {
        return val.getValue();
    } else if (val instanceof DateTimeData) {
        return val.getValue();
    } else if (val instanceof BooleanData) {
        return val.getValue();
    } else if (val instanceof GeoPointData) {
        return val.uncast().getString();
    } else {
        System.out.println("warning: unrecognized data type in xpath expr: " + val.getClass().getName());

        //TODO: Does this mess up any of our other plans?
        return val.uncast().getString();
    }
}
 

开发者ID:dimagi,
项目名称:commcare-j2me,
代码行数:33,
代码来源:XPathPathExpr.java

示例11: computeDistanceBetween

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
/**
 * Returns the distance between two GeoPointData locations, in meters.
 * Ignores altitude and accuracy.
 */
public static double computeDistanceBetween(GeoPointData from, GeoPointData to) {
    return EARTH_RADIUS * distanceRadians(
            Math.toRadians(from.getLatitude()),
            Math.toRadians(from.getLongitude()),
            Math.toRadians(to.getLatitude()),
            Math.toRadians(to.getLongitude())
    );
}
 

开发者ID:dimagi,
项目名称:commcare-j2me,
代码行数:13,
代码来源:GeoPointUtils.java

示例12: serializeAnswerData

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
public Object serializeAnswerData(IAnswerData data) {
    if (data instanceof StringData) {
        return serializeAnswerData((StringData)data);
    } else if (data instanceof SelectMultiData) {
        return serializeAnswerData((SelectMultiData)data);
    } else if (data instanceof SelectOneData) {
        return serializeAnswerData((SelectOneData)data);
    } else if (data instanceof IntegerData) {
        return serializeAnswerData((IntegerData)data);
    } else if (data instanceof LongData) {
        return serializeAnswerData((LongData)data);
    } else if (data instanceof DecimalData) {
        return serializeAnswerData((DecimalData)data);
    } else if (data instanceof DateData) {
        return serializeAnswerData((DateData)data);
    } else if (data instanceof TimeData) {
        return serializeAnswerData((TimeData)data);
    } else if (data instanceof PointerAnswerData) {
        return serializeAnswerData((PointerAnswerData)data);
    } else if (data instanceof GeoPointData) {
        return serializeAnswerData((GeoPointData)data);
    } else if (data instanceof DateTimeData) {
        return serializeAnswerData((DateTimeData)data);
    } else if (data instanceof BooleanData) {
        return serializeAnswerData((BooleanData)data);
    } else if (data instanceof UncastData) {
        return serializeAnswerData((UncastData)data);
    }

    return null;
}
 

开发者ID:dimagi,
项目名称:commcare-j2me,
代码行数:32,
代码来源:XFormAnswerDataSerializer.java

示例13: toGeoPointData

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
private static GeoPointData toGeoPointData(Location location) {
    return new GeoPointData(new double[]{
            location.getLatitude(),
            location.getLongitude(),
            location.getAltitude(),
            (double)location.getAccuracy()
    });
}
 

开发者ID:dimagi,
项目名称:commcare-android,
代码行数:9,
代码来源:AndroidHereFunctionHandler.java

示例14: getGeoIntentURI

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
/**
 * Pass in a string representing either a GeoPoint or an address and get back a valid
 * GeoURI that can be passed as an intent argument
 */
public static String getGeoIntentURI(String rawInput) {
    try {
        GeoPointData mGeoPointData = new GeoPointData().cast(new UncastData(rawInput));
        String latitude = Double.toString(mGeoPointData.getValue()[0]);
        String longitude = Double.toString(mGeoPointData.getValue()[1]);
        return "geo:" + latitude + "," + longitude + "?q=" + latitude + "," + longitude;

    } catch (IllegalArgumentException iae) {
        return "geo:0,0?q=" + rawInput;
    }
}
 

开发者ID:dimagi,
项目名称:commcare-android,
代码行数:16,
代码来源:GeoUtils.java

示例15: getLatLngFromAddress

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
private LatLng getLatLngFromAddress(@NonNull String address) {
    LatLng location = null;
    try {
        GeoPointData data = new GeoPointData().cast(new UncastData(address));
        if (data != null) {
            location = new LatLng(data.getLatitude(), data.getLongitude());
        }
    } catch (IllegalArgumentException ignored) {
    }
    return location;
}
 

开发者ID:dimagi,
项目名称:commcare-android,
代码行数:12,
代码来源:EntityMapActivity.java

示例16: unpackValue

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
public static Object unpackValue(IAnswerData val) {
    if (val == null) {
        return "";
    } else if (val instanceof UncastData) {
        return val.getValue();
    } else if (val instanceof IntegerData) {
        return ((Integer)val.getValue()).doubleValue();
    } else if (val instanceof LongData) {
        return ((Long)val.getValue()).doubleValue();
    } else if (val instanceof DecimalData) {
        return val.getValue();
    } else if (val instanceof StringData) {
        return val.getValue();
    } else if (val instanceof SelectOneData) {
        return ((Selection)val.getValue()).getValue();
    } else if (val instanceof SelectMultiData) {
        return (new XFormAnswerDataSerializer()).serializeAnswerData(val);
    } else if (val instanceof DateData) {
        return val.getValue();
    } else if (val instanceof DateTimeData) {
        return val.getValue();
    } else if (val instanceof BooleanData) {
        return val.getValue();
    } else if (val instanceof GeoPointData) {
        return val.uncast().getString();
    } else {
        System.out.println("warning: unrecognized data type in xpath expr: " + val.getClass().getName());

        //TODO: Does this mess up any of our other plans?
        return val.uncast().getString();
    }
}
 

开发者ID:dimagi,
项目名称:commcare-core,
代码行数:33,
代码来源:XPathPathExpr.java

示例17: canSerialize

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
@Override
public boolean canSerialize(IAnswerData data) {
    return data instanceof StringData || data instanceof DateData || data instanceof TimeData ||
            data instanceof SelectMultiData || data instanceof SelectOneData ||
            data instanceof IntegerData || data instanceof DecimalData || data instanceof PointerAnswerData ||
            data instanceof GeoPointData || data instanceof LongData || data instanceof DateTimeData || data instanceof UncastData;
}
 

开发者ID:dimagi,
项目名称:commcare-core,
代码行数:8,
代码来源:XFormAnswerDataSerializer.java

示例18: serializeAnswerData

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
@Override
public Object serializeAnswerData(IAnswerData data) {
    if (data instanceof StringData) {
        return serializeAnswerData((StringData)data);
    } else if (data instanceof SelectMultiData) {
        return serializeAnswerData((SelectMultiData)data);
    } else if (data instanceof SelectOneData) {
        return serializeAnswerData((SelectOneData)data);
    } else if (data instanceof IntegerData) {
        return serializeAnswerData((IntegerData)data);
    } else if (data instanceof LongData) {
        return serializeAnswerData((LongData)data);
    } else if (data instanceof DecimalData) {
        return serializeAnswerData((DecimalData)data);
    } else if (data instanceof DateData) {
        return serializeAnswerData((DateData)data);
    } else if (data instanceof TimeData) {
        return serializeAnswerData((TimeData)data);
    } else if (data instanceof PointerAnswerData) {
        return serializeAnswerData((PointerAnswerData)data);
    } else if (data instanceof GeoPointData) {
        return serializeAnswerData((GeoPointData)data);
    } else if (data instanceof DateTimeData) {
        return serializeAnswerData((DateTimeData)data);
    } else if (data instanceof BooleanData) {
        return serializeAnswerData((BooleanData)data);
    } else if (data instanceof UncastData) {
        return serializeAnswerData((UncastData)data);
    }

    return null;
}
 

开发者ID:dimagi,
项目名称:commcare-core,
代码行数:33,
代码来源:XFormAnswerDataSerializer.java

示例19: getAnswerTemplate

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
protected IAnswerData getAnswerTemplate() {
    return new GeoPointData();
}
 

开发者ID:dimagi,
项目名称:commcare-j2me,
代码行数:4,
代码来源:GeoPointWidget.java

示例20: fixObtained

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
public void fixObtained(Fix fix) {
    controller.answerQuestion(new GeoPointData(new double [] {fix.getLat(), fix.getLon(), fix.getAccuracy(), fix.getAltitude()}));
    controller.getView().show(capturing);
}
 

开发者ID:dimagi,
项目名称:commcare-j2me,
代码行数:5,
代码来源:FormEntryState.java

示例21: canSerialize

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
public boolean canSerialize(IAnswerData data) {
    return data instanceof StringData || data instanceof DateData || data instanceof TimeData ||
            data instanceof SelectMultiData || data instanceof SelectOneData ||
            data instanceof IntegerData || data instanceof DecimalData || data instanceof PointerAnswerData ||
            data instanceof GeoPointData || data instanceof LongData || data instanceof DateTimeData || data instanceof UncastData;
}
 

开发者ID:dimagi,
项目名称:commcare-j2me,
代码行数:7,
代码来源:XFormAnswerDataSerializer.java

示例22: eval

点赞 2

import org.javarosa.core.model.data.GeoPointData; //导入依赖的package包/类
@Override
public Object eval(Object[] args, EvaluationContext ec) {
    return new GeoPointData(new double[]{lat, lon, 0, 10}).getDisplayText();
}
 

开发者ID:dimagi,
项目名称:commcare-core,
代码行数:5,
代码来源:ScreenUtils.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)