Class GeoNear


  • public class GeoNear
    extends Stage
    Outputs documents in order of nearest to farthest from a specified point.
    • Constructor Detail

      • GeoNear

        protected GeoNear​(Point point)
      • GeoNear

        protected GeoNear()
      • GeoNear

        protected GeoNear​(double[] coordinates)
    • Method Detail

      • geoNear

        public static GeoNear geoNear​(Point point)
        Creates a new geoNear stage
        Parameters:
        point - the center point
        Returns:
        the new stage
        Since:
        2.2
      • geoNear

        public static GeoNear geoNear​(double[] coordinates)
        Creates a new geoNear stage
        Parameters:
        coordinates - the center point coordinates
        Returns:
        the new stage
        Since:
        2.2
      • to

        @Deprecated(forRemoval=true)
        public static GeoNear to​(Point point)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Creates a new geoNear stage
        Parameters:
        point - the center point
        Returns:
        the new stage
      • to

        @Deprecated(forRemoval=true)
        public static GeoNear to​(double[] coordinates)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Creates a new geoNear stage
        Parameters:
        coordinates - the center point coordinates
        Returns:
        the new stage
      • distanceField

        public GeoNear distanceField​(String distanceField)
        The output field that contains the calculated distance.
        Parameters:
        distanceField - the field name
        Returns:
        this
      • distanceMultiplier

        public GeoNear distanceMultiplier​(Number distanceMultiplier)
        Optional. The factor to multiply all distances returned by the query. For example, use the distanceMultiplier to convert radians, as returned by a spherical query, to kilometers by multiplying by the radius of the Earth.
        Parameters:
        distanceMultiplier - the multiplier
        Returns:
        this
      • getCoordinates

        @MorphiaInternal
        public double[] getCoordinates()
        Returns:
        the coordinates
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getDistanceField

        @MorphiaInternal
        public String getDistanceField()
        Returns:
        the distance field
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getDistanceMultiplier

        @MorphiaInternal
        public Number getDistanceMultiplier()
        Returns:
        the distance multiplier
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getFilters

        @Nullable
        @MorphiaInternal
        public Filter[] getFilters()
        Returns:
        the query
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getIncludeLocs

        @MorphiaInternal
        public String getIncludeLocs()
        Returns:
        includeLocs
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getKey

        @MorphiaInternal
        public String getKey()
        Returns:
        the key
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getMaxDistance

        @MorphiaInternal
        public Number getMaxDistance()
        Returns:
        the max distance
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getMinDistance

        @MorphiaInternal
        public Number getMinDistance()
        Returns:
        the min distance
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getPoint

        @MorphiaInternal
        public Point getPoint()
        Returns:
        the point
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getSpherical

        @MorphiaInternal
        public Boolean getSpherical()
        Returns:
        spherical?
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • includeLocs

        public GeoNear includeLocs​(String includeLocs)
        Optional. This specifies the output field that identifies the location used to calculate the distance. This option is useful when a location field contains multiple locations.
        Parameters:
        includeLocs - include the field if true
        Returns:
        this
      • key

        public GeoNear key​(String key)
        Optional. Specify the geospatial indexed field to use when calculating the distance.
        Parameters:
        key - the indexed field
        Returns:
        this
      • maxDistance

        public GeoNear maxDistance​(Number maxDistance)
        Optional. The maximum distance from the center point that the documents can be. MongoDB limits the results to those documents that fall within the specified distance from the center point.

        Specify the distance in meters if the specified point is GeoJSON and in radians if the specified point is legacy coordinate pairs.

        Parameters:
        maxDistance - the max distance
        Returns:
        this
      • minDistance

        public GeoNear minDistance​(Number minDistance)
        Optional. The minimum distance from the center point that the documents can be. MongoDB limits the results to those documents that fall outside the specified distance from the center point.

        Specify the distance in meters for GeoJSON data and in radians for legacy coordinate pairs.

        Parameters:
        minDistance - the min distance
        Returns:
        this
      • query

        public GeoNear query​(Filter... filters)
        Optional. Limits the results to the documents that match the query.

        You cannot specify a $near predicate in the query field of the $geoNear stage.

        Parameters:
        filters - the filters to apply
        Returns:
        this
      • spherical

        public GeoNear spherical​(Boolean spherical)
        Optional. Determines how MongoDB calculates the distance between two points:
      • When true, MongoDB uses $nearSphere semantics and calculates distances using spherical geometry.
      • When false, MongoDB uses $near semantics: spherical geometry for 2dsphere indexes and planar geometry for 2d indexes.
Parameters:
spherical - true if spherical
Returns:
this