java火星坐标转百度坐标_各种地理坐标系的转换,火星坐标,百度坐标,wsg84等...

# -*- coding: utf-8 -*-

import json

import requests

import math

key = 'your key here' # 这里填写你的百度开放平台的key

x_pi = 3.14159265358979324 * 3000.0 / 180.0

pi = 3.1415926535897932384626 # π

a = 6378245.0 # 长半轴

ee = 0.00669342162296594323 # 扁率

def geocode(address):

"""

利用百度geocoding服务解析地址获取位置坐标

:param address:需要解析的地址

:return:

"""

geocoding = {'s': 'rsv3',

'key': key,

'city': '全国',

'address': address}

res = requests.get(

"http://restapi.amap.com/v3/geocode/geo", params=geocoding)

if res.status_code == 200:

json = res.json()

status = json.get('status')

count = json.get('count')

if status

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
package com.map; public class GPSConverterUtils { public static final String BAIDU_LBS_TYPE = "bd09ll"; public static double pi = 3.1415926535897932384626; public static double a = 6378245.0; public static double ee = 0.00669342162296594323; /** * 84 to 火星坐标系 (GCJ-02) World Geodetic System ==> Mars Geodetic System * 天地图 火星 * @param lat * @param lon */ public static GPS gps84_To_Gcj02(double lat, double lon) { if (outOfChina(lat, lon)) { return null; } double dLat = transformLat(lon - 105.0, lat - 35.0); double dLon = transformLon(lon - 105.0, lat - 35.0); double radLat = lat / 180.0 * pi; double magic = Math.sin(radLat); magic = 1 - ee * magic * magic; double sqrtMagic = Math.sqrt(magic); dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi); double mgLat = lat + dLat; double mgLon = lon + dLon; return new GPS(mgLat, mgLon); } /** * * 火星坐标系 (GCJ-02) to 84 * * @param lon * @param lat * @return *火星天地图 */ public static GPS gcj_To_Gps84(double lat, double lon) { GPS gps = transform(lat, lon); double lontitude = lon * 2 - gps.getLon(); double latitude = lat * 2 - gps.getLat(); return new GPS(latitude, lontitude); } /** * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 将 GCJ-02 坐标转换成 BD-09 坐标 *火星百度 * @param gg_lat * @param gg_lon */ public static GPS gcj02_To_Bd09(double gg_lat, double gg_lon) { double x = gg_lon, y = gg_lat; double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi); double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi); double bd_lon = z * Math.cos(theta) + 0.0065; double bd_lat = z * Math.sin(theta) + 0.006;
WSG84(World Geodetic System 1984)和CGCS2000(中国大地坐标系统2000)是两种常用的地理坐标系。在Java中将WSG84转换为CGCS2000可以通过使用坐标转换库来实现。 首先,我们需要确定所使用的坐标转换库。Java中有许多开源的坐标转换库可以使用,例如Geotools和Proj4j。这里以使用Geotools为例进行说明。 在使用Geotools进行坐标转换之前,我们需要先导入相关的库文件。可以在Maven项目中的pom.xml文件中添加以下依赖项: ```xml <dependency> <groupId>org.geotools</groupId> <artifactId>gt-epsg-hsql</artifactId> <version>24.1</version> </dependency> ``` 接下来,我们可以使用以下代码将WSG84坐标转换为CGCS2000坐标: ```java import org.geotools.geometry.DirectPosition2D; import org.geotools.referencing.CRS; import org.opengis.referencing.FactoryException; import org.opengis.referencing.NoSuchAuthorityCodeException; import org.opengis.referencing.crs.CoordinateReferenceSystem; public class CoordinateConversion { public static void main(String[] args) { // 输入的坐标点(WSG84) double longitude = 116.3975; double latitude = 39.9085; // 设置源坐标系WSG84) CoordinateReferenceSystem sourceCRS; try { sourceCRS = CRS.decode("EPSG:4326"); } catch (NoSuchAuthorityCodeException | FactoryException e) { e.printStackTrace(); return; } // 设置目标坐标系(CGCS2000) CoordinateReferenceSystem targetCRS; try { targetCRS = CRS.decode("EPSG:4490"); } catch (NoSuchAuthorityCodeException | FactoryException e) { e.printStackTrace(); return; } // 创建源坐标点 DirectPosition2D sourcePosition = new DirectPosition2D(sourceCRS, longitude, latitude); // 坐标转换 try { DirectPosition2D targetPosition = (DirectPosition2D) CRS.transform(sourcePosition, targetCRS); double targetLongitude = targetPosition.x; double targetLatitude = targetPosition.y; System.out.println("转换后的坐标(CGCS2000):"); System.out.println("经度:" + targetLongitude); System.out.println("纬度:" + targetLatitude); } catch (Exception e) { e.printStackTrace(); } } } ``` 上述代码中,首先设置源坐标系WSG84(EPSG:4326)和目标坐标系为CGCS2000(EPSG:4490),然后创建源坐标点并利用`CRS.transform()`方法进行坐标转换。 运行上述代码后,将输出转换后的CGCS2000坐标,包括经度和纬度。 需要注意的是,WSG84和CGCS2000的坐标系定义可能因使用的地理坐标转换库而有所不同,可以根据实际情况进行相应的调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值