/** * Compute the distance with another Point type, * http://stackoverflow.com/questions/837872/calculate-distance-in-meters-when-you-know-longitude-and-latitude-in- * java * * @param away : the point to calculate the distance with * @return distance between the two points in meters */ public DecimalType distanceFrom(@Nullable LocationItem awayItem) { if (awayItem != null && awayItem.state instanceof PointType && this.state instanceof PointType) { PointType thisPoint = (PointType) this.state; PointType awayPoint = (PointType) awayItem.state; return thisPoint.distanceFrom(awayPoint); } return new DecimalType(-1); }
/** * Compute the distance with another Point type, * http://stackoverflow.com/questions/837872/calculate-distance-in-meters-when-you-know-longitude-and-latitude-in- * java * * @param away : the point to calculate the distance with * @return distance between the two points in meters */ public DecimalType distanceFrom(@Nullable LocationItem awayItem) { if (awayItem != null && awayItem.state instanceof PointType && this.state instanceof PointType) { PointType thisPoint = (PointType) this.state; PointType awayPoint = (PointType) awayItem.state; return thisPoint.distanceFrom(awayPoint); } return new DecimalType(-1); }