坐標轉換

坐標轉換

TGOS MAP API for iOS之坐標轉換包含WGS84TWD97坐標系統間之轉換。由於台灣大多數的地理空間資料都以TWD97坐標系統建置,在手持平台上的TGOS MAP API亦使用TWD97坐標系統,但手持裝置需要讀取GPS等資訊,元件大都以WGS84坐標系統設計,因此許多資訊必須透過TGTransformation類別中的方法加以轉換。下方以點擊地圖觸發事件為範例,進行取得螢幕坐標,再進行螢幕坐標轉換為TWD97坐標,最後將TWD97坐標轉換為WGS84坐標。

- (void)mapView:(TGMapView *)mapView

didTapAtCoordinate:(CLLocationCoordinate2D)coordinate 

{

NSString * txt = @"Tap : WGS84 = %f,%f , TWD97 = %f,%f , Screen = %f,%f";

PointD *twd97 = [TGTransformation wgs84ToTWD97:coordinate]; 

//WGS84坐標系統轉TWD97坐標系統

CGPoint ScreenPt = [mapView_.projection pointForCoordinate:coordinate];

txt = [NSString stringWithFormat:txt,coordinate.latitude,coordinate.longitude,twd97.X,twd97.Y,ScreenPt.x,ScreenPt.y];

[self setLabelTxt:txt];

NSLog(@"%@",txt);

 

[self addMarker:coordinate];

}

回到上方