| | |
| | | |
| | | s = s * EARTH_RADIUS1; |
| | | |
| | | return Math.round(s * 100) / 100; |
| | | return round2(s); |
| | | } |
| | | |
| | | /** |
| | |
| | | // 计算距离,单位:米 |
| | | double distance = geodeticCalculator.getOrthodromicDistance(); |
| | | |
| | | return Math.round(distance * 100) / 100; |
| | | return round2(distance); |
| | | } |
| | | |
| | | public static double round2(double d) { |
| | | return ((long)(d * 100)) / 100D; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | double angle = gc.getAzimuth(); |
| | | |
| | | return Math.round(angle * 100) / 100; |
| | | return round2(angle); |
| | | } catch (Exception ex) { |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 计算角度2 |
| | | */ |
| | | public static double getAngle2(double x1, double y1, double x2, double y2){ |
| | | try { |
| | | DirectPosition2D p1 = new DirectPosition2D( x1, y1); |
| | | DirectPosition2D p2 = new DirectPosition2D(x2, y2); |
| | | |
| | | GeodeticCalculator gc = new GeodeticCalculator(); |
| | | gc.setStartingGeographicPoint(p1); |
| | | gc.setDestinationGeographicPoint(p2); |
| | | |
| | | double angle = gc.getAzimuth(); |
| | | |
| | | return round2(angle); |
| | | }catch (Exception ex){ |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取坐标 |
| | | * @param su |
| | | * @return |