Small Map fixes to support Severe Weather

Fixes #66
This commit is contained in:
mar-v-in 2016-01-02 15:38:33 +01:00
parent 1c5da4a07a
commit 9abd7ebac3
3 changed files with 9 additions and 0 deletions

View File

@ -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));
}

View File

@ -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)));
}
}

View File

@ -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)