Search in sources :

Example 1 with MapPoint

use of org.odk.collect.geo.maps.MapPoint in project collect by opendatakit.

the class FormMapActivityTest method tappingOnDeletedInstances_showsSubmissionSummaryWithAppropriateMessage.

// Geometry is removed from the database on instance deletion but just in case there is a
// deleted instance with geometry available, show a deleted toast.
@Test
public void tappingOnDeletedInstances_showsSubmissionSummaryWithAppropriateMessage() {
    Pair<Instance, MapPoint> deleted = new Pair<>(testInstances[0], new MapPoint(10.0, 125.6));
    int featureId = map.getFeatureIdFor(deleted.second);
    activity.onFeatureClicked(featureId);
    assertSubmissionSummaryContent(deleted.first.getDisplayName(), deleted.first.getStatus(), new Date(deleted.first.getLastStatusChangeDate()), DELETED_TOAST);
}
Also used : Instance(org.odk.collect.forms.instances.Instance) MapPoint(org.odk.collect.geo.maps.MapPoint) MapPoint(org.odk.collect.geo.maps.MapPoint) Date(java.util.Date) Pair(android.util.Pair) Test(org.junit.Test)

Example 2 with MapPoint

use of org.odk.collect.geo.maps.MapPoint in project collect by opendatakit.

the class FormMapActivityTest method centerAndZoomLevel_areRestoredAfterOrientationChange.

@Ignore("Doesn't work with field-based dependency injection because we don't get an opportunity" + "to set test doubles before onCreate() is called after the orientation change")
@Test
public void centerAndZoomLevel_areRestoredAfterOrientationChange() {
    map.zoomToPoint(new MapPoint(7, 7), 7, false);
    RuntimeEnvironment.setQualifiers("+land");
    activityController.configurationChange();
    assertThat(map.getCenter(), is(new MapPoint(7, 7)));
    assertThat(map.getZoom(), is(7));
}
Also used : MapPoint(org.odk.collect.geo.maps.MapPoint) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with MapPoint

use of org.odk.collect.geo.maps.MapPoint in project collect by opendatakit.

the class FormMapActivityTest method tappingOnUneditableInstances_showsSubmissionSummaryWithAppropriateMessage.

@Test
public void tappingOnUneditableInstances_showsSubmissionSummaryWithAppropriateMessage() {
    Pair<Instance, MapPoint> sent = new Pair<>(testInstances[5], new MapPoint(10.3, 125.7));
    int featureId = map.getFeatureIdFor(sent.second);
    activity.onFeatureClicked(featureId);
    assertSubmissionSummaryContent(sent.first.getDisplayName(), sent.first.getStatus(), new Date(sent.first.getLastStatusChangeDate()), OPEN_READ_ONLY);
}
Also used : Instance(org.odk.collect.forms.instances.Instance) MapPoint(org.odk.collect.geo.maps.MapPoint) MapPoint(org.odk.collect.geo.maps.MapPoint) Date(java.util.Date) Pair(android.util.Pair) Test(org.junit.Test)

Example 4 with MapPoint

use of org.odk.collect.geo.maps.MapPoint in project collect by opendatakit.

the class GeoPolyActivity method startInput.

@Override
public void startInput() {
    inputActive = true;
    if (recordingEnabled && recordingAutomatic) {
        boolean retainMockAccuracy = getIntent().getBooleanExtra(Constants.EXTRA_RETAIN_MOCK_ACCURACY, false);
        locationTracker.start(retainMockAccuracy);
        recordPoint(map.getGpsLocation());
        schedulerHandler = scheduler.scheduleAtFixedRate(() -> runOnUiThread(() -> {
            Location currentLocation = locationTracker.getCurrentLocation();
            if (currentLocation != null) {
                MapPoint currentMapPoint = new MapPoint(currentLocation.getLatitude(), currentLocation.getLongitude(), currentLocation.getAltitude(), currentLocation.getAccuracy());
                recordPoint(currentMapPoint);
            }
        }), INTERVAL_OPTIONS[intervalIndex], INTERVAL_OPTIONS[intervalIndex], TimeUnit.SECONDS);
    }
    updateUi();
}
Also used : MapPoint(org.odk.collect.geo.maps.MapPoint) Location(org.odk.collect.location.Location)

Example 5 with MapPoint

use of org.odk.collect.geo.maps.MapPoint in project collect by opendatakit.

the class GeoPolyActivity method saveAsPolygon.

private void saveAsPolygon() {
    if (map.getPolyPoints(featureId).size() > 2) {
        // Close the polygon.
        List<MapPoint> points = map.getPolyPoints(featureId);
        int count = points.size();
        if (count > 1 && !points.get(0).equals(points.get(count - 1))) {
            map.appendPointToPoly(featureId, points.get(0));
        }
        finishWithResult();
    } else {
        ToastUtils.showShortToastInMiddle(this, getString(R.string.polygon_validator));
    }
}
Also used : MapPoint(org.odk.collect.geo.maps.MapPoint) MapPoint(org.odk.collect.geo.maps.MapPoint)

Aggregations

MapPoint (org.odk.collect.geo.maps.MapPoint)28 Test (org.junit.Test)8 SuppressLint (android.annotation.SuppressLint)7 IGeoPoint (org.osmdroid.api.IGeoPoint)5 GeoPoint (org.osmdroid.util.GeoPoint)5 Paint (android.graphics.Paint)4 Pair (android.util.Pair)4 Date (java.util.Date)4 Instance (org.odk.collect.forms.instances.Instance)4 Intent (android.content.Intent)3 Handler (android.os.Handler)3 ArrayList (java.util.ArrayList)3 ImageButton (android.widget.ImageButton)2 NonNull (androidx.annotation.NonNull)2 LatLng (com.google.android.gms.maps.model.LatLng)1 LatLngBounds (com.google.android.gms.maps.model.LatLngBounds)1 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)1 LatLngBounds (com.mapbox.mapboxsdk.geometry.LatLngBounds)1 Ignore (org.junit.Ignore)1 Location (org.odk.collect.location.Location)1