当前位置: 首页> 科技> 数码 > 免费ui设计网站_莱芜在线广告信息_最专业的seo公司_设计一个公司网站多少钱

免费ui设计网站_莱芜在线广告信息_最专业的seo公司_设计一个公司网站多少钱

时间:2025/7/10 9:11:38来源:https://blog.csdn.net/qq_31745863/article/details/142939905 浏览次数:0次
免费ui设计网站_莱芜在线广告信息_最专业的seo公司_设计一个公司网站多少钱

业务:比较微信小程序定位是否在系统设置的某个位置的某个范围内

问题:微信小程序的定位是拿的腾讯地图的经纬度(假设为点A),系统设置的某个位置是百度地图的经纬度(假设为点B),需要判断点A是否在点B的Range(米)范围内

解决方案:将腾讯点A的经纬度转换为百度地图的经纬度后再进行比较

package com.applets.manager.core.util;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.geotools.referencing.GeodeticCalculator;/*** @author zr 2024/5/11*/
@Slf4j
public class GeoUtil {/*** 判断一个点是否在某个圆形范围内(startingPoint为腾讯地图点位,endPoint为百度地图点位)* @param startingPoint* @param endPoint* @param range* @return转换*/public static boolean inDistanceWithConversion(MyPoint startingPoint , MyPoint endPoint , Integer range){MyPoint myPoint = qqMapTransBMap(startingPoint);return inDistance(myPoint,endPoint,range);}/*** 判断一个点是否在某个圆形范围内* @param startingPoint* @param endPoint* @param Range* @return*/public static boolean inDistance(MyPoint startingPoint , MyPoint endPoint , Integer Range) {// 84坐标系构造GeodeticCalculatorGeodeticCalculator geodeticCalculator = new GeodeticCalculator();// 起点经纬度geodeticCalculator.setStartingGeographicPoint(startingPoint.getLongitude(), startingPoint.getLatitude());// 末点经纬度geodeticCalculator.setDestinationGeographicPoint( endPoint.getLatitude(),endPoint.getLongitude());// 计算距离,单位:米double orthodromicDistance = geodeticCalculator.getOrthodromicDistance();if (orthodromicDistance < Range){return true;}else {return false;}}/*** 腾讯地图经纬度转百度地图经纬度* @param myPoint* @return*/public static MyPoint qqMapTransBMap(MyPoint myPoint) {double x_pi = 3.14159265358979324 * 3000.0 / 180.0;double x =  myPoint.getLatitude();double y =  myPoint.getLongitude();double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);double lngs = z * Math.cos(theta) + 0.0065;double lats = z * Math.sin(theta) + 0.006;return new MyPoint(lngs, lats);}@Data@AllArgsConstructor@NoArgsConstructorpublic static class MyPoint {public double longitude;public double latitude;}
}
关键字:免费ui设计网站_莱芜在线广告信息_最专业的seo公司_设计一个公司网站多少钱

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: