2016-09-22 41 views
0

如何可編程轉換點與(X,Y)(LAT,LON)鑑於X_left < X_point < X_rightY_bottom < Y_point <Y_top(即矩形內框)。轉換X,Y座標到緯度,經度GPS位置給出了一些參考點

(X_left,Y_bottom)點有(緯度,經度)已經,同樣與其他3點,這構建了一個矩形(在這種情況下,平面圖)

一些現實世界的數據雲:

"floor_name": "buildingName_floor_4", 

{ 
     "name": "GPS_Marker_0", 
     "GeoCoordinate": { 
     "latitude": 1.298825, 
     "longitude": 103.77004, 
     "unit": "DEGREES" 
     }, 
     "MapCoordinate": { 
     "x": 0, 
     "y": 0, 
     "unit": "FEET" 
     } 
    }, 
    { 
     "name": "GPS_Marker_1", 
     "GeoCoordinate": { 
     "latitude": 1.298825, 
     "longitude": 103.77134, 
     "unit": "DEGREES" 
     }, 
     "MapCoordinate": { 
     "x": 473.9, 
     "y": 0, 
     "unit": "FEET" 
     } 
    }, 
    { 
     "name": "GPS_Marker_2", 
     "GeoCoordinate": { 
     "latitude": 1.29694, 
     "longitude": 103.77134, 
     "unit": "DEGREES" 
     }, 
     "MapCoordinate": { 
     "x": 474.7, 
     "y": 683.8, 
     "unit": "FEET" 
     } 
    }, 
    { 
     "name": "GPS_Marker_3", 
     "GeoCoordinate": { 
     "latitude": 1.29694, 
     "longitude": 103.77004, 
     "unit": "DEGREES" 
     }, 
     "MapCoordinate": { 
     "x": 0, 
     "y": 683.8, 
     "unit": "FEET" 
     } 
    } 

Access Point (need to get lat,lon from its X,Y) 

"name": "AP_No_4", 
     "radioMacAddress": "xx:xx:xx:xx:xx:xx" 
     "MapCoordinate": { 
     "x": 179.8, 
     "y": 299, 
     "unit": "FEET" 
     }, 

我明白,我們可能需要應用任何數學前要弄清楚的映射投影,但讓我解釋一下,這個長方形的盒子(即平面圖)通常是沒有那麼大那麼一些錯誤(例如1米或2)公認。

我更喜歡javascript代碼,但如果你可以指出公式來做到這一點,我很樂意在代碼上工作。謝謝。

回答

1

我相信地圖JavaScript API中有一種方法可以做到這一點。一旦地圖初始化,您可以使用Map類的getProjection()方法來檢索的投影:

https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map

之後,你可以使用fromPointToLatLng(像素:點,NOWRAP:布爾)投影的方法:

https://developers.google.com/maps/documentation/javascript/3.exp/reference#Projection

沒有在文檔中的一篇文章,解釋不同類型的座標:

https://developers.google.com/maps/documentation/javascript/maptypes#MapCoordinates

希望它有幫助!

相關問題