Search in sources :

Example 11 with BoundingBox

use of de.westnordost.osmapi.map.data.BoundingBox in project StreetComplete by westnordost.

the class AQuestDaoTest method testGetAllByBoundingBox.

public void testGetAllByBoundingBox() {
    BoundingBox bbox = new BoundingBox(50, 1, 51, 2);
    // on border
    dao.add(createQuest(1, 50, 1, QuestStatus.NEW));
    // right lat but wrong lon
    dao.add(createQuest(2, 50.5, 50.5, QuestStatus.NEW));
    // wrong lat but right lon
    dao.add(createQuest(3, 1.5, 1.5, QuestStatus.NEW));
    // in
    dao.add(createQuest(4, 50.5, 1.5, QuestStatus.NEW));
    List<Quest> quests = dao.getAll(bbox, QuestStatus.NEW);
    Collections.sort(quests, (lhs, rhs) -> (int) (lhs.getId() - rhs.getId()));
    assertEquals(2, quests.size());
    assertEquals(1, (long) quests.get(0).getId());
    assertEquals(4, (long) quests.get(1).getId());
    assertEquals(2, dao.getCount(bbox, QuestStatus.NEW));
}
Also used : BoundingBox(de.westnordost.osmapi.map.data.BoundingBox)

Example 12 with BoundingBox

use of de.westnordost.osmapi.map.data.BoundingBox in project StreetComplete by westnordost.

the class OsmQuestDaoTest method testGetAllByBBox.

public void testGetAllByBBox() {
    OsmQuest quest1 = createNewQuest(11, Element.Type.NODE);
    OsmQuest quest2 = createNewQuest(12, Element.Type.NODE, new ElementGeometry(new OsmLatLon(11, 11)));
    addToDaos(quest1, quest2);
    assertEquals(1, dao.getAll(new BoundingBox(0, 0, 10, 10), null, null, null, null).size());
    assertEquals(2, dao.getAll(null, null, null, null, null).size());
}
Also used : BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) ElementGeometry(de.westnordost.streetcomplete.data.osm.ElementGeometry) OsmQuest(de.westnordost.streetcomplete.data.osm.OsmQuest) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 13 with BoundingBox

use of de.westnordost.osmapi.map.data.BoundingBox in project StreetComplete by westnordost.

the class CreateNoteDaoTest method testGetAll.

public void testGetAll() {
    CreateNote note1 = new CreateNote();
    note1.text = "this is in";
    note1.position = new OsmLatLon(0.5, 0.5);
    dao.add(note1);
    CreateNote note2 = new CreateNote();
    note2.text = "this is out";
    note2.position = new OsmLatLon(-0.5, 0.5);
    dao.add(note2);
    assertEquals(1, dao.getAll(new BoundingBox(0, 0, 1, 1)).size());
    assertEquals(2, dao.getAll(null).size());
}
Also used : BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 14 with BoundingBox

use of de.westnordost.osmapi.map.data.BoundingBox in project StreetComplete by westnordost.

the class OsmNoteQuestDaoTest method testGetPositions.

public void testGetPositions() {
    Note note = NoteDaoTest.createNote();
    note.position = new OsmLatLon(34, 35);
    noteDao.put(note);
    OsmNoteQuest quest = new OsmNoteQuest(note, questType);
    dao.add(quest);
    List<LatLon> positions = dao.getAllPositions(new BoundingBox(0, 0, 50, 50));
    assertEquals(1, positions.size());
    assertEquals(new OsmLatLon(34, 35), positions.get(0));
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Note(de.westnordost.osmapi.notes.Note) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 15 with BoundingBox

use of de.westnordost.osmapi.map.data.BoundingBox in project StreetComplete by westnordost.

the class AddHousenumberIntegrationTest method verifyYieldsNoQuest.

private void verifyYieldsNoQuest(BoundingBox bbox, String date) {
    OverpassMapDataDao o = OsmModule.overpassOldMapDataDao(OsmModule::overpassMapDataParser, date);
    AddHousenumber quest = new AddHousenumber(o);
    MapDataWithGeometryHandler verifier = (element, geometry) -> {
        fail("Expected zero elements. Element returned: " + element.getType().name() + "#" + element.getId());
    };
    quest.download(bbox, verifier);
}
Also used : OsmModule(de.westnordost.streetcomplete.data.OsmModule) OverpassMapDataDao(de.westnordost.streetcomplete.data.osm.download.OverpassMapDataDao) MapDataWithGeometryHandler(de.westnordost.streetcomplete.data.osm.download.MapDataWithGeometryHandler) AddHousenumber(de.westnordost.streetcomplete.quests.housenumber.AddHousenumber) TestCase(junit.framework.TestCase) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) OverpassMapDataDao(de.westnordost.streetcomplete.data.osm.download.OverpassMapDataDao) AddHousenumber(de.westnordost.streetcomplete.quests.housenumber.AddHousenumber) OsmModule(de.westnordost.streetcomplete.data.OsmModule) MapDataWithGeometryHandler(de.westnordost.streetcomplete.data.osm.download.MapDataWithGeometryHandler)

Aggregations

BoundingBox (de.westnordost.osmapi.map.data.BoundingBox)28 LatLon (de.westnordost.osmapi.map.data.LatLon)13 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)11 ArrayList (java.util.ArrayList)7 Rect (android.graphics.Rect)4 ElementGeometry (de.westnordost.streetcomplete.data.osm.ElementGeometry)4 Point (android.graphics.Point)3 Note (de.westnordost.osmapi.notes.Note)3 QuestGroup (de.westnordost.streetcomplete.data.QuestGroup)3 VisibleQuestListener (de.westnordost.streetcomplete.data.VisibleQuestListener)3 OsmElementQuestType (de.westnordost.streetcomplete.data.osm.OsmElementQuestType)3 Collection (java.util.Collection)3 List (java.util.List)3 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 OsmNode (de.westnordost.osmapi.map.data.OsmNode)2 QuestStatus (de.westnordost.streetcomplete.data.QuestStatus)2 OsmQuest (de.westnordost.streetcomplete.data.osm.OsmQuest)2 Date (java.util.Date)2 Cursor (android.database.Cursor)1 PointF (android.graphics.PointF)1