use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.
the class OverpassMapDataParser method onStartElement.
@Override
protected void onStartElement() throws ParseException {
String name = getName();
switch(name) {
case TAG:
if (tags == null) {
tags = new HashMap<>();
}
tags.put(getAttribute("k"), getAttribute("v"));
break;
case ND:
Long ndRef = getLongAttribute("ref");
if (// null for ND nodes in MEMBER
ndRef != null) {
nodes.add(ndRef);
}
LatLon pos = new OsmLatLon(getDoubleAttribute("lat"), getDoubleAttribute("lon"));
wayNodes.add(pos);
break;
case MEMBER:
long ref = getLongAttribute("ref");
String role = getAttribute("role");
Element.Type type = Element.Type.valueOf(getAttribute("type").toUpperCase(Locale.UK));
members.add(factory.createRelationMember(ref, role, type));
startWayGeometry(ref);
break;
case NODE:
retrieveIdAndVersion();
lat = getDoubleAttribute("lat");
lon = getDoubleAttribute("lon");
break;
case WAY:
retrieveIdAndVersion();
nodes = new ArrayList<>();
nodePositionsByWay = new LongSparseArray<>();
startWayGeometry(id);
break;
case RELATION:
retrieveIdAndVersion();
members = new ArrayList<>();
nodePositionsByWay = new LongSparseArray<>();
break;
}
}
use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.
the class CreateNoteDao method createObjectFrom.
private CreateNote createObjectFrom(Cursor cursor) {
int colNoteId = cursor.getColumnIndexOrThrow(CreateNoteTable.Columns.ID), colLat = cursor.getColumnIndexOrThrow(CreateNoteTable.Columns.LATITUDE), colLon = cursor.getColumnIndexOrThrow(CreateNoteTable.Columns.LONGITUDE), colText = cursor.getColumnIndexOrThrow(CreateNoteTable.Columns.TEXT), colElementType = cursor.getColumnIndexOrThrow(CreateNoteTable.Columns.ELEMENT_TYPE), colElementId = cursor.getColumnIndexOrThrow(CreateNoteTable.Columns.ELEMENT_ID), colQuestTitle = cursor.getColumnIndexOrThrow(CreateNoteTable.Columns.QUEST_TITLE), colImagePaths = cursor.getColumnIndexOrThrow(CreateNoteTable.Columns.IMAGE_PATHS);
CreateNote note = new CreateNote();
note.position = new OsmLatLon(cursor.getDouble(colLat), cursor.getDouble(colLon));
note.text = cursor.getString(colText);
if (!cursor.isNull(colQuestTitle)) {
note.questTitle = cursor.getString(colQuestTitle);
}
if (!cursor.isNull(colElementType)) {
note.elementType = Element.Type.valueOf(cursor.getString(colElementType));
}
if (!cursor.isNull(colElementId)) {
note.elementId = cursor.getLong(colElementId);
}
if (!cursor.isNull(colImagePaths)) {
note.imagePaths = serializer.toObject(cursor.getBlob(colImagePaths), ArrayList.class);
}
note.id = cursor.getLong(colNoteId);
return note;
}
use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.
the class NoteDao method createObjectFrom.
static Note createObjectFrom(Serializer serializer, Cursor cursor) {
int colNoteId = cursor.getColumnIndexOrThrow(NoteTable.Columns.ID), colLat = cursor.getColumnIndexOrThrow(NoteTable.Columns.LATITUDE), colLon = cursor.getColumnIndexOrThrow(NoteTable.Columns.LONGITUDE), colStatus = cursor.getColumnIndexOrThrow(NoteTable.Columns.STATUS), colCreated = cursor.getColumnIndexOrThrow(NoteTable.Columns.CREATED), colClosed = cursor.getColumnIndexOrThrow(NoteTable.Columns.CLOSED), colComments = cursor.getColumnIndexOrThrow(NoteTable.Columns.COMMENTS);
Note note = new Note();
note.id = cursor.getLong(colNoteId);
note.position = new OsmLatLon(cursor.getDouble(colLat), cursor.getDouble(colLon));
note.dateCreated = new Date(cursor.getLong(colCreated));
if (!cursor.isNull(colClosed)) {
note.dateClosed = new Date(cursor.getLong(colClosed));
}
note.status = Note.Status.valueOf(cursor.getString(colStatus));
note.comments = serializer.toObject(cursor.getBlob(colComments), ArrayList.class);
return note;
}
use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.
the class OsmNoteQuestDao method getAllPositions.
public List<LatLon> getAllPositions(BoundingBox bbox) {
String[] cols = { NoteTable.Columns.LATITUDE, NoteTable.Columns.LONGITUDE };
WhereSelectionBuilder qb = new WhereSelectionBuilder();
addBBox(bbox, qb);
return getAllThings(getMergedViewName(), cols, qb, cursor -> new OsmLatLon(cursor.getDouble(0), cursor.getDouble(1)));
}
use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.
the class AQuestDaoTest method createQuest.
private static Quest createQuest(long id, long lastUpdate, QuestStatus status) {
Quest quest = mock(Quest.class);
when(quest.getId()).thenReturn(id);
when(quest.getStatus()).thenReturn(status);
when(quest.getLastUpdate()).thenReturn(new Date(lastUpdate));
when(quest.getMarkerLocation()).thenReturn(new OsmLatLon(0, 0));
return quest;
}
Aggregations