Search in sources :

Example 21 with LatLon

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

the class RoadNameSuggestionsDaoTest method testGetNoNames.

public void testGetNoNames() {
    List<LatLon> positions = new ArrayList<>();
    positions.add(new OsmLatLon(5, 5));
    List<Map<String, String>> result = dao.getNames(positions, 0);
    assertEquals(0, result.size());
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) ArrayList(java.util.ArrayList) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Map(java.util.Map) HashMap(java.util.HashMap)

Example 22 with LatLon

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

the class RoadNameSuggestionsDaoTest method createPosOnRoad.

private static ArrayList<LatLon> createPosOnRoad() {
    ArrayList<LatLon> roadPositions = new ArrayList<>();
    roadPositions.add(new OsmLatLon(0, 0.00005));
    return roadPositions;
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) ArrayList(java.util.ArrayList) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 23 with LatLon

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

the class SlippyMapMathTest method testForthAndBack.

public void testForthAndBack() {
    LatLon p = new OsmLatLon(53.0, 9.0);
    Point tile = SlippyMapMath.enclosingTile(p, 15);
    BoundingBox bbox = SlippyMapMath.asBoundingBox(tile, 15);
    assertTrue(bbox.getMinLatitude() <= p.getLatitude());
    assertTrue(bbox.getMaxLatitude() >= p.getLatitude());
    assertTrue(bbox.getMinLongitude() <= p.getLongitude());
    assertTrue(bbox.getMaxLongitude() >= p.getLongitude());
    Rect r = SlippyMapMath.enclosingTiles(bbox, 15);
    BoundingBox bbox2 = SlippyMapMath.asBoundingBox(r, 15);
    assertEquals(bbox, bbox2);
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Rect(android.graphics.Rect) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) Point(android.graphics.Point) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 24 with LatLon

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

the class MainActivity method onLeaveNote.

@Override
public void onLeaveNote(String note, ArrayList<String> imagePaths, Point screenPosition) {
    int[] mapPosition = new int[2];
    View mapView = mapFragment.getView();
    if (mapView == null)
        return;
    mapView.getLocationInWindow(mapPosition);
    PointF notePosition = new PointF(screenPosition);
    notePosition.offset(-mapPosition[0], -mapPosition[1]);
    LatLon position = mapFragment.getPositionAt(notePosition);
    questController.createNote(note, imagePaths, position);
    unsyncedChangesCounter.increase(null);
    closeBottomSheet();
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) PointF(android.graphics.PointF) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 25 with LatLon

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

the class ElementGeometryCreator method joinWays.

private static ConnectedWays joinWays(List<List<LatLon>> waysNodePositions) {
    NodeWayMap<LatLon> nodeWayMap = new NodeWayMap<>(waysNodePositions);
    ConnectedWays result = new ConnectedWays();
    List<LatLon> currentWay = new ArrayList<>();
    while (nodeWayMap.hasNextNode()) {
        LatLon node;
        if (currentWay.isEmpty()) {
            node = nodeWayMap.getNextNode();
        } else {
            node = currentWay.get(currentWay.size() - 1);
        }
        List<List<LatLon>> waysAtNode = nodeWayMap.getWaysAtNode(node);
        if (waysAtNode == null) {
            result.rest.add(currentWay);
            currentWay = new ArrayList<>();
        } else {
            List<LatLon> way = waysAtNode.get(0);
            addTo(way, currentWay);
            nodeWayMap.removeWay(way);
            // finish ring and start new one
            if (isRing(currentWay)) {
                result.rings.add(currentWay);
                currentWay = new ArrayList<>();
            }
        }
    }
    if (!currentWay.isEmpty()) {
        result.rest.add(currentWay);
    }
    return result;
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

LatLon (de.westnordost.osmapi.map.data.LatLon)63 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)45 ArrayList (java.util.ArrayList)29 BoundingBox (de.westnordost.osmapi.map.data.BoundingBox)13 List (java.util.List)12 ElementGeometry (de.westnordost.streetcomplete.data.osm.ElementGeometry)8 OsmNode (de.westnordost.osmapi.map.data.OsmNode)5 HashMap (java.util.HashMap)5 Point (android.graphics.Point)3 PointF (android.graphics.PointF)3 Node (de.westnordost.osmapi.map.data.Node)3 OsmElementQuestType (de.westnordost.streetcomplete.data.osm.OsmElementQuestType)3 LngLat (com.mapzen.tangram.LngLat)2 Point (com.vividsolutions.jts.geom.Point)2 Element (de.westnordost.osmapi.map.data.Element)2 QuestGroup (de.westnordost.streetcomplete.data.QuestGroup)2 VisibleQuestListener (de.westnordost.streetcomplete.data.VisibleQuestListener)2 OsmNoteQuestType (de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestType)2 Collection (java.util.Collection)2 Map (java.util.Map)2