@access.public
    @describeRoute(
        Description('Search for items that are in proximity to a GeoJSON'
                    ' point.')
        .param('field', 'Name of field containing GeoJSON on which to search.',
               required=True)
        .param('geometry', 'Search query condition as a GeoJSON point.',
               required=True)
        .param('maxDistance', 'Limits results to items that are at most this'
                              ' distance in meters from the GeoJSON point.',
               required=False, dataType='number')
        .param('minDistance', 'Limits results to items that are at least this'
                              ' distance in meters from the GeoJSON point.',
               required=False, dataType='number')
        .param('ensureIndex', 'Create a 2dsphere index on the field on which to'
                              ' search if one does not exist.', required=False,
               dataType='boolean')
        .param('limit', 'Result set size limit (default=50).', required=False,
               dataType='integer')
        .param('offset', 'Offset into result set (default=0).', required=False,
               dataType='integer')
        .errorResponse()
        .errorResponse('Field on which to search was not indexed.')
        .errorResponse('Index creation was denied.', 403)
        .notes("Field on which to search be indexed by a 2dsphere index."
               " Anonymous users may not use 'ensureIndex' to create such an"
               " index.")
    )
    def near(self, params):
        """
        Search for items that are in proximity to a GeoJSON point. The field on
        which to search must be indexed by a '2dsphere' index. Anonymous users
        may not use 'ensureIndex' to create such an index.

        :param params: parameters to the API call, including 'field' and
                       'geometry'.
        :type params: dict[str, unknown]
        :returns: filtered fields of the matching items with geospatial data
                 appended to the 'geo' field of each item.
        :rtype: list[dict[str, unknown]]
        :raise RestException: on malformed or forbidden API call.
        """
        self.requireParams(('field', 'geometry'), params)

        condition = {
            '$geometry': self._getGeometry(params)
        }

        for param in ('maxDistance', 'minDistance'):
            if param in params:
                try:
                    distance = float(params[param])

                    if distance < 0.0:
                        raise ValueError

                except ValueError:
                    raise RestException("Parameter '%s' must be a number." %
                                        param)

                condition['$'+param] = distance

        if params['field'][:3] == '%s.' % GEOSPATIAL_FIELD:
            field = params['field'].strip()
        else:
            field = '%s.%s' % (GEOSPATIAL_FIELD, params['field'].strip())

        if params.get('ensureIndex', False):
            user = self.getCurrentUser()

            if not user:
                raise RestException('Index creation denied.', 403)

            self.model('item').collection.create_index([(field, GEOSPHERE)])

        query = {
            field: {
                '$near': condition
            }
        }

        limit, offset, sort = self.getPagingParameters(params, 'lowerName')

        try:
            items = self._find(query, limit, offset, sort)
        except OperationFailure:
            raise RestException("Field '%s' must be indexed by a 2dsphere"
                                " index." % field)

        return items
dataset/ETHPy150Open girder/girder/plugins/geospatial/server/geospatial.py/GeospatialItem.near/original