# nberardi/ravendb forked from ravendb/ravendb

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
663 lines (651 sloc) 35.5 KB

See Why is law of cosines more preferable than haversine when calculating distance between two latitude-longitude points?

The arguments and return value are in radians. Calculates the great circle distance using the Vincenty Formula, simplified for a spherical model. This formula is accurate for any pair of points. The equation was taken from Wikipedia.

Converts a distance in the units of the radius to degrees (360 degrees are in a circle). A spherical earth model is assumed.
Converts a distance in the units of radius (e.g. kilometers) to radians (multiples of the radius). A spherical earth model is assumed. Same as {@link Math#toRadians(double)} but 3x faster (multiply vs. divide). See CompareRadiansSnippet.java in tests. Same as {@link Math#toDegrees(double)} but 3x faster (multiply vs. divide). See CompareRadiansSnippet.java in tests. A base class for a Distance Calculator that assumes a spherical earth model. Reads a shape from a given string (ie, X Y, XMin XMax... WKT)
• Point: X Y
1.23 4.56
• BOX: XMin YMin XMax YMax
1.23 4.56 7.87 4.56
• WKT (Well Known Text)
POLYGON( ... )
Note:Polygons and WKT might not be supported by this spatial context; you'll have to use {@link com.spatial4j.core.context.jts.JtsSpatialContext}.
@param value A string representation of the shape; not null. @return A Shape; not null. @see #writeShape
Writes a shape to a String, in a format that can be read by {@link #readShape(String)}. Reads geospatial latitude then a comma then longitude. Reads the standard shape format + WKT. Reads a shape from a byte array, using an internal format written by {@link #writeShapeToBytes(com.spatial4j.core.shape.Shape)}. A circle, also known as a point-radius since that is what it is comprised of. Describe the relationship between the two objects. For example
• this is WITHIN other
• this CONTAINS other
• this is DISJOINT other
• this INTERSECTS other
Note that a Shape implementation may choose to return INTERSECTS when the true answer is WITHIN or CONTAINS for performance reasons. If a shape does this then it must document when it does. Ideally the shape will not do this approximation in all circumstances, just sometimes.

If the shapes are equal then the result is CONTAINS (preferred) or WITHIN.

Get the bounding box for this Shape. This means the shape is within the bounding box and that it touches each side of the rectangle.

Postcondition: this.getBoundingBox().relate(this) == CONTAINS

Does the shape have area? This will be false for points and lines. It will also be false for shapes that normally have area but are constructed in a degenerate case as to not have area (e.g. a circle with 0 radius or rectangle with no height or no width). Calculates the area of the shape in the units of {@link com.spatial4j.core.distance.DistanceUnits}. If ctx is null then simple Euclidean calculations will be used. This figure can be an estimate. Returns the center point of this shape. This is usually the same as getBoundingBox().getCenter() but it doesn't have to be.

Postcondition: this.relate(this.getCenter()) == CONTAINS