Example usage for com.google.common.geometry S2LatLngRect fromPointPair

List of usage examples for com.google.common.geometry S2LatLngRect fromPointPair

Introduction

In this page you can find the example usage for com.google.common.geometry S2LatLngRect fromPointPair.

Prototype

public static S2LatLngRect fromPointPair(S2LatLng p1, S2LatLng p2) 

Source Link

Document

Convenience method to construct the minimal bounding rectangle containing the two given points.

Usage

From source file:com.norman0406.slimgress.API.Common.Utils.java

public static String[] getCellIdsFromMinMax(Location min, Location max, int minLevel, int maxLevel) {
    S2LatLngRect region = S2LatLngRect.fromPointPair(S2LatLng.fromE6(min.getLatitude(), min.getLongitude()),
            S2LatLng.fromE6(max.getLatitude(), max.getLongitude()));
    return getCellIdsFromRegion(region, minLevel, maxLevel);
}

From source file:com.norman0406.slimgress.ScannerView.java

private void startWorldUpdate() {
    // TODO: problems blocking execution and causing out-of-memory exception

    final Handler uiHandler = new Handler();

    long updateInterval = mGame.getKnobs().getScannerKnobs().getUpdateIntervalMS();

    Timer updateTimer = new Timer();
    updateTimer.scheduleAtFixedRate(new TimerTask() {
        final Handler timerHandler = new Handler();

        @Override/*ww w .  j a  v  a 2  s .  co  m*/
        public void run() {
            uiHandler.post(new Runnable() {
                @Override
                public void run() {
                    // get map boundaries (on ui thread)
                    LatLng northeast = mMap.getProjection().getVisibleRegion().latLngBounds.northeast;
                    LatLng southwest = mMap.getProjection().getVisibleRegion().latLngBounds.southwest;
                    final S2LatLngRect region = S2LatLngRect.fromPointPair(
                            S2LatLng.fromDegrees(southwest.latitude, southwest.longitude),
                            S2LatLng.fromDegrees(northeast.latitude, northeast.longitude));

                    // update world (on timer thread)
                    timerHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            if (mGame.getLocation() != null)
                                updateWorld(region, uiHandler);
                        }
                    });
                }
            });
        }
    }, 0, updateInterval);
}