Java Code Examples for com.spatial4j.core.context.SpatialContext#makePoint()
The following examples show how to use
com.spatial4j.core.context.SpatialContext#makePoint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NavUtils.java From Real-Time-Taxi-Dispatch-Simulator with MIT License | 5 votes |
/** * Returns distance (in meters) between 2 points. * * @param point1 Must not be null * @param point2 Must not be null * @return distance in meters */ public static double getDistance(Point point1, Point point2) { Assert.notNull(point1, "point1 must not be null"); Assert.notNull(point2, "point2 must not be null"); final SpatialContext ctx = SpatialContext.GEO; com.spatial4j.core.shape.Point p1 = ctx.makePoint(point1.getLongitude(), point1.getLatitude()); com.spatial4j.core.shape.Point p2 = ctx.makePoint(point2.getLongitude(), point2.getLatitude()); return DistanceUtils.degrees2Dist(ctx.getDistCalc().distance(p1, p2), DistanceUtils.EARTH_MEAN_RADIUS_KM) * 1000; }
Example 2
Source File: OPointShapeFactory.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@Override public Shape makeShape(OCompositeKey key, SpatialContext ctx) { double lat = ((Double) OType.convert(((OCompositeKey) key).getKeys().get(0), Double.class)).doubleValue(); double lng = ((Double) OType.convert(((OCompositeKey) key).getKeys().get(1), Double.class)).doubleValue(); return ctx.makePoint(lng, lat); }
Example 3
Source File: ORectangleShapeFactory.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@Override public Shape makeShape(OCompositeKey key, SpatialContext ctx) { Point[] points = new Point[2]; int i = 0; for (Object o : key.getKeys()) { List<Number> numbers = (List<Number>) o; double lat = ((Double) OType.convert(numbers.get(0), Double.class)).doubleValue(); double lng = ((Double) OType.convert(numbers.get(1), Double.class)).doubleValue(); points[i] = ctx.makePoint(lng, lat); i++; } return ctx.makeRectangle(points[0], points[1]); }
Example 4
Source File: GeoPoint.java From stratio-cassandra with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public com.spatial4j.core.shape.Shape toSpatial4j(SpatialContext spatialContext) { return spatialContext.makePoint(longitude, latitude); }