use of fr.free.nrw.commons.location.LatLng in project apps-android-commons by commons-app.
the class NearbyControllerTest method testEmptyList.
@Test
public void testEmptyList() {
LatLng location = new LatLng(0, 0, 0);
List<Place> emptyList = new ArrayList<>();
List<NearbyBaseMarker> options = NearbyController.loadAttractionsFromLocationToBaseMarkerOptions(location, emptyList, instrumentationContext);
Assert.assertThat(options.size(), is(0));
}
use of fr.free.nrw.commons.location.LatLng in project apps-android-commons by commons-app.
the class NearbyControllerTest method testNullAttractions.
@Test
public void testNullAttractions() {
LatLng location = new LatLng(0, 0, 0);
List<NearbyBaseMarker> options = NearbyController.loadAttractionsFromLocationToBaseMarkerOptions(location, null, instrumentationContext);
Assert.assertThat(options.size(), is(0));
}
use of fr.free.nrw.commons.location.LatLng in project apps-android-commons by commons-app.
the class NearbyListFragment method onItemClicked.
@OnItemClick(R.id.listView)
void onItemClicked(int position) {
Place place = (Place) listview.getItemAtPosition(position);
LatLng placeLatLng = place.location;
double latitude = placeLatLng.getLatitude();
double longitude = placeLatLng.getLongitude();
Timber.d("Item at position %d has coords: Lat: %f Long: %f", position, latitude, longitude);
NearbyInfoDialog.showYourself(getActivity(), place);
}
use of fr.free.nrw.commons.location.LatLng in project apps-android-commons by commons-app.
the class NearbyPlaces method getFromWikiNeedsPictures.
List<Place> getFromWikiNeedsPictures() {
if (places != null) {
return places;
} else {
try {
places = new ArrayList<>();
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
URL file = new URL("https://tools.wmflabs.org/wiki-needs-pictures/data/data.csv");
BufferedReader in = new BufferedReader(new InputStreamReader(file.openStream()));
boolean firstLine = true;
String line;
Timber.d("Reading from CSV file...");
while ((line = in.readLine()) != null) {
// Skip CSV header.
if (firstLine) {
firstLine = false;
continue;
}
String[] fields = line.split(",");
String name = Utils.stripLocalizedString(fields[0]);
double latitude;
double longitude;
try {
latitude = Double.parseDouble(fields[1]);
} catch (NumberFormatException e) {
latitude = 0;
}
try {
longitude = Double.parseDouble(fields[2]);
} catch (NumberFormatException e) {
longitude = 0;
}
String type = fields[3];
places.add(new Place(name, // list
type, // details
type, null, new LatLng(latitude, longitude, 0), new Sitelinks.Builder().build()));
}
in.close();
} catch (IOException e) {
Timber.d(e.toString());
}
}
return places;
}
use of fr.free.nrw.commons.location.LatLng in project apps-android-commons by commons-app.
the class LatLngTests method testRounding.
@Test
public void testRounding() {
LatLng place = new LatLng(0.1234567, -0.33333333, 0);
String prettyString = place.getPrettyCoordinateString();
Assert.assertThat(prettyString, is("0.1235 N, 0.3333 W"));
}
Aggregations