Search in sources :

Example 1 with QuestType

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);
}
Also used : QuestType(de.westnordost.streetcomplete.data.QuestType) OsmNoteQuestDao(de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestDao) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) OsmQuestDao(de.westnordost.streetcomplete.data.osm.persist.OsmQuestDao) ElementGeometryDao(de.westnordost.streetcomplete.data.osm.persist.ElementGeometryDao)

Example 2 with QuestType

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);
}
Also used : QuestType(de.westnordost.streetcomplete.data.QuestType) OsmNoteQuestType(de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestType) OsmNoteQuestType(de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestType)

Example 3 with QuestType

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;
}
Also used : QuestType(de.westnordost.streetcomplete.data.QuestType) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 4 with QuestType

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);
    }
}
Also used : QuestType(de.westnordost.streetcomplete.data.QuestType) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 5 with QuestType

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");
    }
}
Also used : OsmNoteQuestType(de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestType) OsmElementQuestType(de.westnordost.streetcomplete.data.osm.OsmElementQuestType) QuestType(de.westnordost.streetcomplete.data.QuestType) LatLon(de.westnordost.osmapi.map.data.LatLon) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox)

Aggregations

QuestType (de.westnordost.streetcomplete.data.QuestType)11 ArrayList (java.util.ArrayList)5 OsmElementQuestType (de.westnordost.streetcomplete.data.osm.OsmElementQuestType)3 OsmNoteQuestType (de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestType)3 BoundingBox (de.westnordost.osmapi.map.data.BoundingBox)2 List (java.util.List)2 Point (android.graphics.Point)1 LatLon (de.westnordost.osmapi.map.data.LatLon)1 QuestTypeRegistry (de.westnordost.streetcomplete.data.QuestTypeRegistry)1 OsmQuestDownload (de.westnordost.streetcomplete.data.osm.download.OsmQuestDownload)1 ElementGeometryDao (de.westnordost.streetcomplete.data.osm.persist.ElementGeometryDao)1 OsmQuestDao (de.westnordost.streetcomplete.data.osm.persist.OsmQuestDao)1 TestQuestType (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType)1 TestQuestType2 (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType2)1 TestQuestType3 (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType3)1 TestQuestType4 (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType4)1 TestQuestType5 (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType5)1 OsmNoteQuestDao (de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestDao)1 HashSet (java.util.HashSet)1