Search in sources :

Example 6 with ElementGeometry

use of de.westnordost.streetcomplete.data.osm.ElementGeometry in project StreetComplete by westnordost.

the class OsmQuestDownloadTest method testIgnoreBlacklistedPositionsAndInvalidGeometry.

public void testIgnoreBlacklistedPositionsAndInvalidGeometry() {
    LatLon blacklistPos = new OsmLatLon(3.0, 4.0);
    ElementWithGeometry blacklistElement = new ElementWithGeometry();
    blacklistElement.element = new OsmNode(0, 0, blacklistPos, null);
    blacklistElement.geometry = new ElementGeometry(blacklistPos);
    ElementWithGeometry invalidGeometryElement = new ElementWithGeometry();
    invalidGeometryElement.element = new OsmNode(0, 0, new OsmLatLon(1.0, 1.0), null);
    invalidGeometryElement.geometry = null;
    OsmElementQuestType questType = new ListBackedQuestType(Arrays.asList(blacklistElement, invalidGeometryElement));
    setUpOsmQuestDaoMockWithNoPreviousElements();
    OsmQuestDownload dl = new OsmQuestDownload(geometryDb, elementDb, osmQuestDao, countryBoundariesFuture);
    VisibleQuestListener listener = mock(VisibleQuestListener.class);
    dl.setQuestListener(listener);
    dl.download(questType, new BoundingBox(0, 0, 1, 1), Collections.singleton(blacklistPos));
    verify(listener, times(0)).onQuestsCreated(any(Collection.class), any(QuestGroup.class));
}
Also used : VisibleQuestListener(de.westnordost.streetcomplete.data.VisibleQuestListener) LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) OsmNode(de.westnordost.osmapi.map.data.OsmNode) OsmElementQuestType(de.westnordost.streetcomplete.data.osm.OsmElementQuestType) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) ElementGeometry(de.westnordost.streetcomplete.data.osm.ElementGeometry) Collection(java.util.Collection) QuestGroup(de.westnordost.streetcomplete.data.QuestGroup) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 7 with ElementGeometry

use of de.westnordost.streetcomplete.data.osm.ElementGeometry in project StreetComplete by westnordost.

the class ElementGeometryCreator method create.

public ElementGeometry create(Way way) {
    if (data == null)
        throw new NullPointerException();
    List<LatLon> polyline = data.getNodePositions(way.getId());
    // unable to create geometry
    if (polyline.isEmpty())
        return null;
    eliminateDuplicates(polyline);
    List<List<LatLon>> polylines = new ArrayList<>(1);
    polylines.add(polyline);
    ElementGeometry result;
    if (OsmAreas.isArea(way)) {
        // it is defined CCW here.
        if (ElementGeometry.isRingDefinedClockwise(polyline)) {
            Collections.reverse(polyline);
        }
        result = new ElementGeometry(null, polylines);
    } else {
        result = new ElementGeometry(polylines, null);
    }
    if (result.center == null)
        return null;
    return result;
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) ArrayList(java.util.ArrayList) ElementGeometry(de.westnordost.streetcomplete.data.osm.ElementGeometry) ArrayList(java.util.ArrayList) List(java.util.List)

Example 8 with ElementGeometry

use of de.westnordost.streetcomplete.data.osm.ElementGeometry in project StreetComplete by westnordost.

the class ElementGeometryDaoTest method testPutAll.

public void testPutAll() {
    ElementGeometry geometry = createSimpleGeometry();
    ArrayList<ElementGeometryDao.Row> rows = new ArrayList<>();
    rows.add(new ElementGeometryDao.Row(Element.Type.NODE, 1, geometry));
    rows.add(new ElementGeometryDao.Row(Element.Type.WAY, 2, geometry));
    dao.putAll(rows);
    assertNotNull(dao.get(Element.Type.WAY, 2));
    assertNotNull(dao.get(Element.Type.NODE, 1));
}
Also used : ArrayList(java.util.ArrayList) ElementGeometry(de.westnordost.streetcomplete.data.osm.ElementGeometry)

Example 9 with ElementGeometry

use of de.westnordost.streetcomplete.data.osm.ElementGeometry in project StreetComplete by westnordost.

the class OsmQuestDaoTest method testDeleteReverted.

public void testDeleteReverted() {
    ElementGeometry geom = new ElementGeometry(new OsmLatLon(5, 5));
    OsmQuest quest1 = createNewQuest(new TestQuestType(), 1, Element.Type.NODE, geom);
    quest1.setStatus(QuestStatus.CLOSED);
    OsmQuest quest2 = createNewQuest(new TestQuestType2(), 1, Element.Type.NODE, geom);
    quest2.setStatus(QuestStatus.REVERT);
    OsmQuest quest3 = createNewQuest(new TestQuestType2(), 2, Element.Type.NODE, geom);
    quest3.setStatus(QuestStatus.REVERT);
    OsmQuest quest4 = createNewQuest(new TestQuestType2(), 1, Element.Type.WAY, geom);
    quest4.setStatus(QuestStatus.REVERT);
    addToDaos(quest1, quest2);
    assertEquals(1, dao.deleteAllReverted(Element.Type.NODE, 1));
}
Also used : ElementGeometry(de.westnordost.streetcomplete.data.osm.ElementGeometry) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) OsmQuest(de.westnordost.streetcomplete.data.osm.OsmQuest) TestQuestType(de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType) TestQuestType2(de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType2)

Example 10 with ElementGeometry

use of de.westnordost.streetcomplete.data.osm.ElementGeometry 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)

Aggregations

ElementGeometry (de.westnordost.streetcomplete.data.osm.ElementGeometry)28 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)11 OsmQuest (de.westnordost.streetcomplete.data.osm.OsmQuest)9 ArrayList (java.util.ArrayList)9 LatLon (de.westnordost.osmapi.map.data.LatLon)7 List (java.util.List)6 TestQuestType (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType)5 TestQuestType2 (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType2)4 BoundingBox (de.westnordost.osmapi.map.data.BoundingBox)3 Element (de.westnordost.osmapi.map.data.Element)3 OsmElementQuestType (de.westnordost.streetcomplete.data.osm.OsmElementQuestType)3 OsmNode (de.westnordost.osmapi.map.data.OsmNode)2 QuestGroup (de.westnordost.streetcomplete.data.QuestGroup)2 QuestStatus (de.westnordost.streetcomplete.data.QuestStatus)2 VisibleQuestListener (de.westnordost.streetcomplete.data.VisibleQuestListener)2 Collection (java.util.Collection)2 Date (java.util.Date)2 Node (de.westnordost.osmapi.map.data.Node)1 Relation (de.westnordost.osmapi.map.data.Relation)1 Way (de.westnordost.osmapi.map.data.Way)1