Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-27248

Provide a way to Calculate Centroid and Radius of Geo Records

    • Type: Icon: Improvement Improvement
    • Resolution: Incomplete
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework, Geo
    • Labels:
      None
    • Query

      Consider the following use case:

      We are developing a new feature for our system that revolves displaying documents from the database on a map. We need to filter the documents by various criteria (not location) and then display the matching documents on a map.

      In order to choose the center and zoom level of the map, we need the centroid of the returned records, and the radius that would contain them. Is there a way to retrieve that information using aggregation framework, or do I need to pull all records from MongoDB and do the calculation on our end?

      It certainly seems like geoNear is the right solution for computing the distance on the last step so they can center their output, but there doesn't seem to be an easy way to do the centroid computation external to the pipeline and pass the resultant values into the geoNear call. Would it be feasible to remove that restriiction on geoNear so that it could be placed anywhere within an aggregation pipeline?

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            lorne.schachter Lorne Schachter
            Votes:
            2 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: