Search in sources :

Example 16 with OsmLatLon

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;
    }
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Element(de.westnordost.osmapi.map.data.Element) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 17 with OsmLatLon

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;
}
Also used : ArrayList(java.util.ArrayList) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 18 with OsmLatLon

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;
}
Also used : Note(de.westnordost.osmapi.notes.Note) ArrayList(java.util.ArrayList) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Date(java.util.Date)

Example 19 with OsmLatLon

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)));
}
Also used : WhereSelectionBuilder(de.westnordost.streetcomplete.data.WhereSelectionBuilder) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 20 with OsmLatLon

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;
}
Also used : OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Date(java.util.Date)

Aggregations

OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)61 LatLon (de.westnordost.osmapi.map.data.LatLon)33 ArrayList (java.util.ArrayList)24 BoundingBox (de.westnordost.osmapi.map.data.BoundingBox)9 ElementGeometry (de.westnordost.streetcomplete.data.osm.ElementGeometry)9 Date (java.util.Date)8 List (java.util.List)8 OsmQuest (de.westnordost.streetcomplete.data.osm.OsmQuest)7 Note (de.westnordost.osmapi.notes.Note)6 OsmNode (de.westnordost.osmapi.map.data.OsmNode)5 TestQuestType (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType)5 Element (de.westnordost.osmapi.map.data.Element)4 TestQuestType2 (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType2)4 Node (de.westnordost.osmapi.map.data.Node)3 NoteComment (de.westnordost.osmapi.notes.NoteComment)3 HashMap (java.util.HashMap)3 Point (android.graphics.Point)2 Rect (android.graphics.Rect)2 LongSparseArray (android.util.LongSparseArray)2 QuestGroup (de.westnordost.streetcomplete.data.QuestGroup)2