use of de.westnordost.streetcomplete.data.osm.ElementGeometry in project StreetComplete by westnordost.
the class OverpassMapDataParser method onEndElement.
@Override
protected void onEndElement() {
String name = getName();
Element element = null;
ElementGeometry geometry = null;
switch(name) {
case MEMBER:
wayNodes = null;
break;
case NODE:
Node node = factory.createNode(id, version, lat, lon, tags, null, null);
geometry = elementGeometryCreator.create(node);
element = node;
break;
case WAY:
Way way = factory.createWay(id, version, nodes, tags, null, null);
geometry = elementGeometryCreator.create(way);
element = way;
nodes = null;
nodePositionsByWay = null;
wayNodes = null;
break;
case RELATION:
Relation relation = factory.createRelation(id, version, members, tags, null, null);
geometry = elementGeometryCreator.create(relation);
element = relation;
members = null;
nodePositionsByWay = null;
break;
}
if (element != null) {
tags = null;
handler.handle(element, geometry);
}
}
use of de.westnordost.streetcomplete.data.osm.ElementGeometry in project StreetComplete by westnordost.
the class AOsmQuestDao method createObjectFrom.
@Override
protected OsmQuest createObjectFrom(Cursor cursor) {
int colQuestId = cursor.getColumnIndexOrThrow(Columns.QUEST_ID), colElementId = cursor.getColumnIndexOrThrow(Columns.ELEMENT_ID), colElementType = cursor.getColumnIndexOrThrow(Columns.ELEMENT_TYPE), colQuestStatus = cursor.getColumnIndexOrThrow(Columns.QUEST_STATUS), colQuestType = cursor.getColumnIndexOrThrow(Columns.QUEST_TYPE), colChanges = cursor.getColumnIndexOrThrow(Columns.TAG_CHANGES), colChangesSource = cursor.getColumnIndexOrThrow(Columns.CHANGES_SOURCE), colLastChange = cursor.getColumnIndexOrThrow(Columns.LAST_UPDATE);
long questId = cursor.getLong(colQuestId);
long elementId = cursor.getLong(colElementId);
Element.Type elementType = Element.Type.valueOf(cursor.getString(colElementType));
QuestStatus questStatus = QuestStatus.valueOf(cursor.getString(colQuestStatus));
String questTypeName = cursor.getString(colQuestType);
OsmElementQuestType questType = (OsmElementQuestType) questTypeRegistry.getByName(questTypeName);
if (questType == null) {
throw new IllegalArgumentException("The quest type " + questTypeName + " does not exist!");
}
StringMapChanges changes = null;
if (!cursor.isNull(colChanges)) {
changes = serializer.toObject(cursor.getBlob(colChanges), StringMapChanges.class);
}
String changesSource = null;
if (!cursor.isNull(colChangesSource)) {
changesSource = cursor.getString(colChangesSource);
}
ElementGeometry geometry = ElementGeometryDao.createObjectFrom(serializer, cursor);
Date lastChange = new Date(cursor.getLong(colLastChange));
return new OsmQuest(questId, questType, elementType, elementId, questStatus, changes, changesSource, lastChange, geometry);
}
use of de.westnordost.streetcomplete.data.osm.ElementGeometry in project StreetComplete by westnordost.
the class ElementGeometryDao method createObjectFrom.
static ElementGeometry createObjectFrom(Serializer serializer, Cursor cursor) {
int colGeometryPolygons = cursor.getColumnIndexOrThrow(ElementGeometryTable.Columns.GEOMETRY_POLYGONS), colGeometryPolylines = cursor.getColumnIndexOrThrow(ElementGeometryTable.Columns.GEOMETRY_POLYLINES), colCenterLat = cursor.getColumnIndexOrThrow(ElementGeometryTable.Columns.LATITUDE), colCenterLon = cursor.getColumnIndexOrThrow(ElementGeometryTable.Columns.LONGITUDE);
List<List<LatLon>> polygons = null, polylines = null;
if (!cursor.isNull(colGeometryPolygons)) {
polygons = serializer.toObject(cursor.getBlob(colGeometryPolygons), ArrayList.class);
}
if (!cursor.isNull(colGeometryPolylines)) {
polylines = serializer.toObject(cursor.getBlob(colGeometryPolylines), ArrayList.class);
}
LatLon center = new OsmLatLon(cursor.getDouble(colCenterLat), cursor.getDouble(colCenterLon));
return new ElementGeometry(polylines, polygons, center);
}
use of de.westnordost.streetcomplete.data.osm.ElementGeometry in project StreetComplete by westnordost.
the class ElementGeometryDaoTest method testDeleteUnreferenced.
public void testDeleteUnreferenced() {
Element.Type type = Element.Type.WAY;
long id = 0;
ElementGeometry geometry = createSimpleGeometry();
dao.put(type, id, geometry);
assertEquals(1, dao.deleteUnreferenced());
dao.put(type, id, geometry);
new OsmQuestDao(dbHelper, serializer, null).add(new OsmQuest(Mockito.mock(OsmElementQuestType.class), type, id, geometry));
assertEquals(0, dao.deleteUnreferenced());
}
use of de.westnordost.streetcomplete.data.osm.ElementGeometry in project StreetComplete by westnordost.
the class ElementGeometryDaoTest method testSimplePutGet.
public void testSimplePutGet() {
ElementGeometry geometry = createSimpleGeometry();
dao.put(Element.Type.NODE, 0, geometry);
ElementGeometry dbGeometry = dao.get(Element.Type.NODE, 0);
assertEquals(geometry, dbGeometry);
}
Aggregations