Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9abd7eba authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Small Map fixes to support Severe Weather

Fixes #66
parent 1c5da4a0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ public class GmsMapsTypeHelper {
        double maxLon = MercatorProjection.toLongitude(box.xmax);
        double minLat = MercatorProjection.toLatitude(box.ymax);
        double maxLat = MercatorProjection.toLatitude(box.ymin);
        if (Double.isNaN(minLon) || Double.isNaN(maxLon) || Double.isNaN(minLat) || Double.isNaN(maxLat))
            minLon = maxLon = minLat = maxLat = 0;
        return new LatLngBounds(new LatLng(minLat, minLon), new LatLng(maxLat, maxLon));
    }

+3 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import org.oscim.map.Viewport;

public class ProjectionImpl extends IProjectionDelegate.Stub {
    private Viewport viewport;
    private float[] extents = new float[8];

    public ProjectionImpl(Viewport viewport) {
        this.viewport = viewport;
@@ -51,6 +52,8 @@ public class ProjectionImpl extends IProjectionDelegate.Stub {

    @Override
    public VisibleRegion getVisibleRegion() throws RemoteException {
        viewport.getMapExtents(extents, 0);
        // TODO: Support non-flat map extents
        return new VisibleRegion(GmsMapsTypeHelper.toLatLngBounds(viewport.getBBox(null, 0)));
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -152,6 +152,10 @@ public class PolygonImpl extends IPolygonDelegate.Stub implements DrawableMarkup
        for (LatLng point : options.getPoints()) {
            points.add(GmsMapsTypeHelper.fromLatLng(point));
        }
        if (points.size() < 3 || (points.size() == 3 && points.get(2).equals(points.get(0)))) {
            // Need at least 3 distinguished points to draw a polygon
            return null;
        }
        // TODO: holes
        return new PolygonDrawable(points, Style.builder()
                .fillAlpha(1)