public static List<Geocache> getCachesAround( final Geopoint center, final OCApiConnector connector) { final String centerString = GeopointFormatter.format(GeopointFormatter.Format.LAT_DECDEGREE_RAW, center) + SEPARATOR + GeopointFormatter.format(GeopointFormatter.Format.LON_DECDEGREE_RAW, center); final Parameters params = new Parameters("search_method", METHOD_SEARCH_NEAREST); final Map<String, String> valueMap = new LinkedHashMap<String, String>(); valueMap.put("center", centerString); valueMap.put("limit", "20"); return requestCaches(connector, params, valueMap); }
public static List<cgCache> getCachesAround(final Geopoint center, IConnector connector) { String centerString = GeopointFormatter.format(GeopointFormatter.Format.LAT_DECDEGREE_RAW, center) + "|" + GeopointFormatter.format(GeopointFormatter.Format.LON_DECDEGREE_RAW, center); final Parameters params = new Parameters("center", centerString); final JSONObject data = request(connector, SERVICE_NEAREST, params); if (data == null) { return null; } return parseCaches(data); }
public static List<Geocache> getCachesNamed( final Geopoint center, final String namePart, final OCApiConnector connector) { final Map<String, String> valueMap = new LinkedHashMap<>(); final Parameters params; // search around current position, if there is a position if (center != null) { final String centerString = GeopointFormatter.format(GeopointFormatter.Format.LAT_DECDEGREE_RAW, center) + SEPARATOR + GeopointFormatter.format(GeopointFormatter.Format.LON_DECDEGREE_RAW, center); params = new Parameters("search_method", METHOD_SEARCH_NEAREST); valueMap.put("center", centerString); valueMap.put("limit", "20"); } else { params = new Parameters("search_method", METHOD_SEARCH_ALL); valueMap.put("limit", "20"); } // full wildcard search, maybe we need to change this after some testing and evaluation valueMap.put("name", "*" + namePart + "*"); return requestCaches(connector, params, valueMap, false); }
/** Assumes level 3 OAuth. */ public static List<Geocache> getCachesBBox( final Viewport viewport, final OCApiConnector connector) { if (viewport.getLatitudeSpan() == 0 || viewport.getLongitudeSpan() == 0) { return Collections.emptyList(); } final String bboxString = GeopointFormatter.format(GeopointFormatter.Format.LAT_DECDEGREE_RAW, viewport.bottomLeft) + SEPARATOR + GeopointFormatter.format( GeopointFormatter.Format.LON_DECDEGREE_RAW, viewport.bottomLeft) + SEPARATOR + GeopointFormatter.format( GeopointFormatter.Format.LAT_DECDEGREE_RAW, viewport.topRight) + SEPARATOR + GeopointFormatter.format( GeopointFormatter.Format.LON_DECDEGREE_RAW, viewport.topRight); final Parameters params = new Parameters("search_method", METHOD_SEARCH_BBOX); final Map<String, String> valueMap = new LinkedHashMap<>(); valueMap.put("bbox", bboxString); return requestCaches(connector, params, valueMap, false); }