use of de.westnordost.streetcomplete.data.QuestType in project StreetComplete by westnordost.
the class OsmQuestUnlockerTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
ElementGeometryDao elementGeometryDao = mock(ElementGeometryDao.class);
when(elementGeometryDao.get(Element.Type.NODE, 1)).thenReturn(new ElementGeometry(POS));
osmNoteQuestDao = mock(OsmNoteQuestDao.class);
when(osmNoteQuestDao.getAllPositions(any(BoundingBox.class))).thenReturn(Collections.emptyList());
osmQuestDao = mock(OsmQuestDao.class);
when(osmQuestDao.getAll(null, null, null, Element.Type.NODE, 1L)).thenReturn(Collections.emptyList());
questType = mock(OsmElementQuestType.class);
final List<QuestType> questTypes = Collections.singletonList(questType);
osmQuestUnlocker = new OsmQuestUnlocker(osmNoteQuestDao, osmQuestDao, elementGeometryDao, () -> questTypes);
}
use of de.westnordost.streetcomplete.data.QuestType in project StreetComplete by westnordost.
the class SimpleOverpassQuestsValidityTest method testQueryValid.
public void testQueryValid() {
List<QuestType> questTypes = QuestModule.questTypeRegistry(new OsmNoteQuestType(), null, null, null).getAll();
for (QuestType questType : questTypes) {
if (questType instanceof SimpleOverpassQuestType) {
// if this fails and the returned exception is not informative, catch here and record
// the name of the SimpleOverpassQuestType
((SimpleOverpassQuestType) questType).getOverpassQuery(null);
}
}
// parsing the query threw no errors -> valid
assertTrue(true);
}
use of de.westnordost.streetcomplete.data.QuestType in project StreetComplete by westnordost.
the class QuestTypeOrderList method getAsQuestTypeLists.
private List<List<QuestType>> getAsQuestTypeLists() {
List<List<String>> stringLists = get();
List<List<QuestType>> result = new ArrayList<>(stringLists.size());
for (List<String> stringList : stringLists) {
List<QuestType> questTypes = new ArrayList<>(stringList.size());
for (String string : stringList) {
QuestType qt = questTypeRegistry.getByName(string);
if (qt != null)
questTypes.add(qt);
}
if (questTypes.size() > 1) {
result.add(questTypes);
}
}
return result;
}
use of de.westnordost.streetcomplete.data.QuestType in project StreetComplete by westnordost.
the class QuestTypeOrderList method sort.
/**
* Sort given list by the user defined order
*/
public synchronized void sort(List<QuestType> questTypes) {
List<List<QuestType>> orderLists = getAsQuestTypeLists();
for (List<QuestType> list : orderLists) {
List<QuestType> reorderedQuestTypes = new ArrayList<>(list.size() - 1);
for (QuestType questType : list.subList(1, list.size())) {
if (questTypes.remove(questType)) {
reorderedQuestTypes.add(questType);
}
}
int startIndex = questTypes.indexOf(list.get(0));
questTypes.addAll(startIndex + 1, reorderedQuestTypes);
}
}
use of de.westnordost.streetcomplete.data.QuestType in project StreetComplete by westnordost.
the class QuestDownload method download.
public void download() {
if (cancelState.get())
return;
List<QuestType> questTypes = getQuestTypesToDownload();
if (questTypes.isEmpty()) {
finished = true;
progressListener.onNotStarted();
return;
}
totalQuestTypes = questTypes.size();
BoundingBox bbox = SlippyMapMath.asBoundingBox(tiles, ApplicationConstants.QUEST_TILE_ZOOM);
try {
Log.i(TAG, "(" + bbox.getAsLeftBottomRightTopString() + ") Starting");
progressListener.onStarted();
Set<LatLon> notesPositions;
if (questTypes.contains(getOsmNoteQuestType())) {
notesPositions = downloadNotes(bbox);
} else {
notesPositions = getNotePositionsFromDb(bbox);
}
downloadQuestTypes(bbox, questTypes, notesPositions);
progressListener.onSuccess();
} finally {
finished = true;
progressListener.onFinished();
Log.i(TAG, "(" + bbox.getAsLeftBottomRightTopString() + ") Finished");
}
}
Aggregations