根据经纬度求两点间距离实现源码(java)
研究了一下Google
Map上的根据经纬度求地球表面两点间距离的实现, 用java实现了一把,对我国境内的Beijing54, Xian80,WGS84三种坐标系的空间距离计算感觉这个实现是比较准确的。当然,这里只是个人的感觉而已。。。可能我还没有遇到那种对精度要求非常严格的地方,或许,本身我这个方式就是错误的。。。呵呵。。。这里只是作个记号先。。。各位达人多多指教
package
com.geotools.test;
public class GeoUtils {
public
enum GaussSphere{
Beijing54,
Xian80,
WGS84,
}
private static double Rad(double d){
return d
* Math.PI / 180.0;
}
public double DistanceOfTwoPoints(double
lng1,double lat1,double lng2,double lat2,
GaussSphere gs){
double radLat1 = Rad(lat1);
double radLat2 = Rad(lat2);
double a = radLat1 - radLat2;
double b = Rad(lng1) -
Rad(lng2);
double s = 2 *
Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
Math.cos(radLat1) *
Math.cos(radLat2) * Math.pow(Math.sin(b/2),2)));
s = s * (gs ==
GaussSphere.WGS84 ? 6378137.0 : (gs == GaussSphere.Xian80 ? 6378140.0 :
6378245.0));
s = Math.round(s * 10000) / 10000;
return
s;
}
}
相关文档:
在使用hibernate或者spring的时候,我们往往通过配置文件配置数据库连接属性。但这次项目中并没有用到hibernate和spring,只用到了struts2。要如何实现通过读取文件配置获取属性值呢?ResourceBundle这个类可是实现读取properties文件来获取值
在java中:
public final static Object initLock = new Object();
privat ......
java中使用scoket模拟http post请求发送图片或文件
最近遇到个问题,两个系统共用用户的头像,用户的头像在一个系统中保存,这就涉及到将图片通过scoket发送给另一个系统存储的问题,最初的思路是将图片读成byte[]数组,然后发送,但又发现,发送图片的同时还要发送密钥、uid、username等信息,好通过对方系统的验证,这就 ......
好久没用java,突一写起来,发现机器上没有设置环境变量,把设置方法总结一下
1. 修改/etc/profile文件
如果你的计算机仅仅作为开发使用时推荐使用这种方法,因为所有用户的shell都有权使用这些环境变量,可能会给系统带来安全性问题。
·用文本编辑器打开/etc/profile
·在pr ......
send mail use smtp .u can send text or html, send to many peoples if u have a email user and pwd and the smtp of the email which u use.
package org.lc.smtp;
import java.io.IOException;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.mail.Message;
import javax.mai ......
//写这个程序也为了纪念王江民先生……话说当年他也是写过这个类似程序
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class game extends Applet implements ActionListener{
//定义变量
int num1, num2, num3, jieguo, jilu, ......