List of usage examples for com.google.common.geometry S2LatLng fromE6
public static S2LatLng fromE6(long latE6, long lngE6)
From source file:com.norman0406.slimgress.API.Common.Utils.java
public static String[] getCellIdsFromLocationArea(Location location, double areaM2, int minLevel, int maxLevel) { final double radius_m2 = 6371 * 1000; final double sr = areaM2 / (radius_m2 * radius_m2); S2LatLng pointLatLng = S2LatLng.fromE6(location.getLatitude(), location.getLongitude()); S2Cap cap = S2Cap.fromAxisArea(pointLatLng.toPoint(), sr); return getCellIdsFromRegion(cap, minLevel, maxLevel); }
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.API.Common.Location.java
public LatLng getLatLng() { S2LatLng pos = S2LatLng.fromE6(latitude, longitude); return new LatLng(pos.latDegrees(), pos.lngDegrees()); }
From source file:com.norman0406.slimgress.API.Game.GameState.java
public void intLoadCommunication(final double radiusKM, final boolean factionOnly, final Handler handler) { try {//from www.jav a 2s .c om checkInterface(); final double earthKM = 2 * Math.PI * 6371; // circumference S2LatLng center = S2LatLng.fromE6(mLocation.getLatitude(), mLocation.getLongitude()); S2LatLng size = S2LatLng.fromRadians((Math.PI / earthKM) * radiusKM, (2 * Math.PI / earthKM) * radiusKM); S2LatLngRect region = S2LatLngRect.fromCenterSize(center, size); // get cell ids for area String[] cellIds = Utils.getCellIdsFromRegion(region, 8, 12); // create cells JSONArray cellsAsHex = new JSONArray(); for (int i = 0; i < cellIds.length; i++) cellsAsHex.put(cellIds[i]); // create params JSONObject params = new JSONObject(); params.put("cellsAsHex", cellsAsHex); params.put("minTimestampMs", -1); params.put("maxTimestampMs", -1); params.put("desiredNumItems", 50); params.put("factionOnly", factionOnly); params.put("ascendingTimestampOrder", false); mInterface.request(mHandshake, "playerUndecorated/getPaginatedPlexts", mLocation, params, new RequestResult(handler) { @Override public void handleResult(JSONArray result) { try { // add plexts for (int i = 0; i < result.length(); i++) { PlextBase newPlext = PlextBase.createByJSON(result.getJSONArray(i)); mPlexts.add(newPlext); } } catch (JSONException e) { e.printStackTrace(); } } }); } catch (JSONException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }