Search in sources :

Example 21 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, double lat, double lon, QuestStatus status) {
    Quest quest = mock(Quest.class);
    when(quest.getStatus()).thenReturn(status);
    when(quest.getId()).thenReturn(id);
    when(quest.getMarkerLocation()).thenReturn(new OsmLatLon(lat, lon));
    when(quest.getLastUpdate()).thenReturn(new Date());
    return quest;
}
Also used : OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Date(java.util.Date)

Example 22 with OsmLatLon

use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.

the class TestQuestDao method createQuest.

public static Quest createQuest(long id, double lat, double lon, QuestStatus status, long time) {
    Quest quest = mock(Quest.class);
    when(quest.getStatus()).thenReturn(status);
    when(quest.getId()).thenReturn(id);
    when(quest.getMarkerLocation()).thenReturn(new OsmLatLon(lat, lon));
    when(quest.getLastUpdate()).thenReturn(new Date(time));
    return quest;
}
Also used : OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Date(java.util.Date)

Example 23 with OsmLatLon

use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.

the class OverpassMapDataParserTest method testNode.

public void testNode() {
    LatLon pos = new OsmLatLon(51.7463194, 0.2428181);
    String xml = " <node id='5' version='1' lat='" + pos.getLatitude() + "' lon='" + pos.getLongitude() + "'/>";
    Element e = parseOne(xml, null);
    assertTrue(e instanceof Node);
    Node node = (Node) e;
    assertEquals(pos, node.getPosition());
    assertEquals(5, node.getId());
    assertEquals(1, node.getVersion());
    assertNull(node.getTags());
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Element(de.westnordost.osmapi.map.data.Element) Node(de.westnordost.osmapi.map.data.Node) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 24 with OsmLatLon

use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.

the class OverpassMapDataParserTest method testRelation.

public void testRelation() {
    OsmLatLon[] p = new OsmLatLon[5];
    p[0] = new OsmLatLon(1, 2);
    p[1] = new OsmLatLon(3, 4);
    p[2] = new OsmLatLon(5, 6);
    p[3] = new OsmLatLon(7, 8);
    p[4] = new OsmLatLon(9, 10);
    String xml = "<relation id='10' version='1'>\n" + " <member type='relation' ref='4' role=''/>\n" + " <member type='way' ref='1' role='outer'>\n" + "  <nd lat='" + p[0].getLatitude() + "' lon='" + p[0].getLongitude() + "'/>\n" + "  <nd lat='" + p[1].getLatitude() + "' lon='" + p[1].getLongitude() + "'/>\n" + " </member>\n" + " <member type='way' ref='2' role='inner'>\n" + "  <nd lat='" + p[2].getLatitude() + "' lon='" + p[2].getLongitude() + "'/>\n" + "  <nd lat='" + p[3].getLatitude() + "' lon='" + p[3].getLongitude() + "'/>\n" + " </member>\n" + " <member type='node' ref='3' role='point'>\n" + "  <nd lat='" + p[4].getLatitude() + "' lon='" + p[4].getLongitude() + "'/>\n" + " </member>\n" + "</relation>";
    LongSparseArray<List<LatLon>> expectedGeometry = new LongSparseArray<>();
    expectedGeometry.put(1, new ArrayList<>(Arrays.asList(p[0], p[1])));
    expectedGeometry.put(2, new ArrayList<>(Arrays.asList(p[2], p[3])));
    Element e = parseOne(xml, expectedGeometry);
    assertTrue(e instanceof Relation);
    Relation relation = (Relation) e;
    assertEquals(10, relation.getId());
    assertEquals(1, relation.getVersion());
    assertEquals(4, relation.getMembers().size());
    RelationMember[] rm = new RelationMember[relation.getMembers().size()];
    relation.getMembers().toArray(rm);
    assertEquals(4, rm[0].getRef());
    assertEquals(Element.Type.RELATION, rm[0].getType());
    assertEquals("", rm[0].getRole());
    assertEquals(1, rm[1].getRef());
    assertEquals(Element.Type.WAY, rm[1].getType());
    assertEquals("outer", rm[1].getRole());
    assertEquals(2, rm[2].getRef());
    assertEquals(Element.Type.WAY, rm[2].getType());
    assertEquals("inner", rm[2].getRole());
    assertEquals(3, rm[3].getRef());
    assertEquals(Element.Type.NODE, rm[3].getType());
    assertEquals("point", rm[3].getRole());
    assertNull(relation.getTags());
}
Also used : LongSparseArray(android.util.LongSparseArray) Relation(de.westnordost.osmapi.map.data.Relation) RelationMember(de.westnordost.osmapi.map.data.RelationMember) Element(de.westnordost.osmapi.map.data.Element) ArrayList(java.util.ArrayList) List(java.util.List) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 25 with OsmLatLon

use of de.westnordost.osmapi.map.data.OsmLatLon 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)

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