本文整理汇总了Java中com.spatial4j.core.io.GeohashUtils.encodeLatLon方法的典型用法代码示例。如果您正苦于以下问题:Java GeohashUtils.encodeLatLon方法的具体用法?Java GeohashUtils.encodeLatLon怎么用?Java GeohashUtils.encodeLatLon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.spatial4j.core.io.GeohashUtils
的用法示例。
在下文中一共展示了GeohashUtils.encodeLatLon方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapByGeoHash
import com.spatial4j.core.io.GeohashUtils; //导入方法依赖的package包/类
/**
* Group the points with similar Geohash at specified level
*
* @param points
* @param level Geohash level
* @return
*/
private Map<String, MutableDouble> mapByGeoHash(List<GeoPoint> points, int level) {
if (level < 1 || points == null)
throw new IllegalArgumentException();
Map<String, MutableDouble> hashPoints = new HashMap<String, MutableDouble>();
for (GeoPoint point : points) {
try {
// Calculate geo hash
String hash = GeohashUtils.encodeLatLon(point.getLatitude(), point.getLongitude());
// Cut to geo hash level
hash = hash.substring(0, level);
// Group values
MutableDouble val = hashPoints.get(hash);
if (val == null) {
hashPoints.put(hash, new MutableDouble(point.getValue()));
} else {
val.add(point.getValue());
}
} catch (Exception e) {
log.error(e);
}
}
return hashPoints;
}
示例2: createSpatialQuery
import com.spatial4j.core.io.GeohashUtils; //导入方法依赖的package包/类
@Override
public Query createSpatialQuery(QParser parser, SpatialOptions options) {
double [] point = new double[0];
try {
point = ParseUtils.parsePointDouble(null, options.pointStr, 2);
} catch (InvalidShapeException e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
}
String geohash = GeohashUtils.encodeLatLon(point[0], point[1]);
//TODO: optimize this
return new SolrConstantScoreQuery(new ValueSourceRangeFilter(new GeohashHaversineFunction(getValueSource(options.field, parser),
new LiteralValueSource(geohash), options.radius), "0", String.valueOf(options.distance), true, true));
}
示例3: toInternal
import com.spatial4j.core.io.GeohashUtils; //导入方法依赖的package包/类
@Override
public String toInternal(String val) {
// validate that the string is of the form
// latitude, longitude
double[] latLon = new double[0];
try {
latLon = ParseUtils.parseLatitudeLongitude(null, val);
} catch (InvalidShapeException e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
}
return GeohashUtils.encodeLatLon(latLon[0], latLon[1]);
}
示例4: getCell
import com.spatial4j.core.io.GeohashUtils; //导入方法依赖的package包/类
@Override
public Cell getCell(Point p, int level) {
return new GhCell(GeohashUtils.encodeLatLon(p.getY(), p.getX(), level));//args are lat,lon (y,x)
}
示例5: toInternal
import com.spatial4j.core.io.GeohashUtils; //导入方法依赖的package包/类
@Override
public String toInternal(String val) {
Point point = SpatialUtils.parsePointSolrException(val, SpatialContext.GEO);
return GeohashUtils.encodeLatLon(point.getY(), point.getX());
}
示例6: getNode
import com.spatial4j.core.io.GeohashUtils; //导入方法依赖的package包/类
@Override
public Node getNode(Point p, int level) {
return new GhCell(GeohashUtils.encodeLatLon(p.getY(), p.getX(), level));//args are lat,lon (y,x)
}
示例7: geoHash
import com.spatial4j.core.io.GeohashUtils; //导入方法依赖的package包/类
/**
* Returns a geohash based on Lucene Spatial
*
* @param lat the input latitude Y
* @param lon the input longitude X
* @return
*/
public String geoHash(Double lat, Double lon) {
String encodeLatLon = GeohashUtils.encodeLatLon(lat, lon);
return encodeLatLon;
}