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));
}
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;
}
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));
}
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));
}
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());
}
Aggregations