根據經緯度座標點返回所在行政區域實現

2021-09-27 12:05:43 字數 1607 閱讀 2996

public result getposition (double longitude, double latitude)})

; string address = null;

for(center center : centers)}if

(!stringutils.

isempty

(address)

)break;}

return

newresult

(result.success,

"響應成功!"

, address)

;}

public

class

profile

// 將要判斷的橫縱座標組成乙個點

point2d.double point =

newpoint2d.double

(pointlon, pointlat)

;// 將區域各頂點的橫縱座標放到乙個點集合裡面

list

pointlist =

newarraylist

();double polygonpoint_x =

0.0, polygonpoint_y =

0.0;

for(

int i =

0; i < lon.length; i++

)return

check

(point, pointlist);}

/** * 乙個點是否在多邊形內

* @param point 要判斷的點的橫縱座標

* @param polygon 組成的頂點座標集合

* @return

*/private

static

boolean

check

(point2d.double point, list

polygon)

// 將幾何多邊形封閉

peneralpath.

lineto

(first.x, first.y)

; peneralpath.

closepath()

;// 測試指定的 point2d 是否在 shape 的邊界內。

return peneralpath.

contains

(point);}

}

public

class

calulatetwolanlon

/** *

* @param lat1 第乙個緯度

* @param lng1第乙個經度

* @param lat2第二個緯度

* @param lng2第二個經度

* @return 兩個經緯度的距離

*/public

static

double

getdistance

(double lat1,

double lng1,

double lat2,

double lng2)

}

根據經緯度座標獲取位址資訊

獲取地理位置名稱 param location 經緯度座標,經度在前,緯度在後,經緯度間以 分割 return public static string getaddressnamebygeocoder1 string location 向指定url傳送get方法的請求 param url 傳送請求...

經緯度座標轉換

經緯度與xy座標轉換工具類 public class latlngxyzconverthelper xy轉經緯度 需要轉換的x座標 需要轉換的y座標 地圖級別 轉換後的經度 轉換後的緯度 public static void tiletolatlng double tile x,double til...

php根據經緯度排序,根據經緯度篩選距離段

sql 語句 select location.from select round 6378.138 2 asin sqrt pow sin 36.668530 pi 180 px lat pi 180 2 2 cos 36.668530 pi 180 cos px lat pi 180 pow si...