当前位置:首页 > 开发 > 数据库 > 正文

MongoDB Geospatial Indexing

发表于: 2013-10-28   作者:AriesX   来源:转载   浏览次数:
摘要: IOS开发中地图功能的后台处理:   radius的单位是度(°)一度是大约 111.12 公里如果你需要查询一公里的之内的东西,如下:center = [50, 50]radius = 1/111.12db.places.find({"loc" : {"$within" : {"$center" : [center

IOS开发中地图功能的后台处理:

 

radius的单位是度(°)一度是大约 111.12 公里
如果你需要查询一公里的之内的东西,如下:
center = [50, 50]
radius = 1/111.12
db.places.find({"loc" : {"$within" : {"$center" : [center, radius]}}}).

 

 

Play中:

public static Result getMomentAround(double radius, double latitude,
            double longitude) {

        // if u login
        if (!Security.isLogin())
            return ok(Pencho_tools.toJsend("fail", "4"));

        momentCollectionJackson.ensureIndex(new BasicDBObject("loc", "2d"),
                "geospacialIdx");
        LinkedList<Object> circle = new LinkedList<Object>();
        circle.addLast(new double[] { latitude, longitude });
        circle.addLast(radius/111.12);
        ArrayNode temp = new ArrayNode(null);
        BasicDBObject query = new BasicDBObject("loc", new BasicDBObject(
                "$within", new BasicDBObject("$center", circle)));
        DBCursor<D_moment> venue = momentCollectionJackson.find(query);
        while (venue.hasNext()) {
            temp.add(venue.next().toJson());
        }
        return ok(Pencho_tools.toJsend("success", "moment-list", temp));
    }

MongoDB Geospatial Indexing

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
1. Not so long time ago, I got a report from customer. It's reported that they had a report g
Advanced Text Indexing with Lucene by Otis Gospodnetic 03/05/2003 Lucene Index Structure Luce
Advanced Text Indexing with Lucene by Otis Gospodnetic 03/05/2003 Lucene Index Structure Luce
In particular embodiments, a method includes, from an indexer in a sensor network, accessing
IndexWriter IndexWriter is the central component of the indexing process. This class creates
INDEX SEGMENTS Every Lucene index consists of one or more segments. Each segment is a standal
At a high level, the Solr indexing process distills down to three key tasks: Convert a docume
Field types for structured nontext fields In general, Solr provides a number of built-in fiel
Abstract First i give my conclusion: Lucene can index and search simultaneously, what's more,
Disable Search Indexing In Windows 8 And Windows 7 By Aun on Sep 02 2009 13 Comments In order
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号