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());
}
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;
}
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);
}
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();
}
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;
}
Aggregations