畫素點、投影、經緯度座標的轉換
阿新 • • 發佈:2019-02-12
前言:在開發過程中,經常會遇到各種座標的轉換,下面將實現幾個常用的座標的轉換:畫素座標、投影座標、經緯度座標
1.畫素座標
螢幕左上角為座標原點,向右為X軸正方向,向下為Y軸正方向,單位為px畫素
2.投影座標
WebGIS中以Mercator投影為主
Beijing 1954 3 Degree GK Zone 39意思是
3度分帶法的北京54座標系,中央經線在東117度的分帶座標,橫座標前加帶號
3.經緯度座標(地理座標)
Beijing54、Xian80、WGS84(WKID值為4326)等
你必須知道的地理座標系和投影座標系
WKID對照表
基於Arcgis for Android SDKpublic class PointTransUtil { //畫素點 static Point pixelsPoint =new Point(0.0,0.0); //投影座標點 static Point projectPoint=new Point(0.0,0.0); //經緯度點 static Point llPoint=new Point(0.0,0.0); /** * * @param mPixelsPoint * @param mapView * @return */ public static Point pixelsPoint2ProjectPoint(Point mPixelsPoint, MapView mapView){ projectPoint=mapView.toMapPoint((float) mPixelsPoint.getX(),(float) mPixelsPoint.getY()); return projectPoint; } /** * * @param mProjectPoint * @param mapView * @return */ public static Point projectPoint2PixelsPoint(Point mProjectPoint, MapView mapView){ pixelsPoint=mapView.toScreenPoint(mProjectPoint); return pixelsPoint; } /** * * @param mLlPoint * @param mapView * @param spatialReference * @return */ public static Point llPoint2ProjectPoint(Point mLlPoint, MapView mapView,SpatialReference spatialReference){ projectPoint=(Point) GeometryEngine.project(mLlPoint ,spatialReference,mapView.getSpatialReference()); return projectPoint; } /** * * @param mProjectPoint * @param mapView * @param spatialReference * @return */ public static Point projectPoint2LlPoint(Point mProjectPoint, MapView mapView,SpatialReference spatialReference){ llPoint=(Point) GeometryEngine.project(mProjectPoint ,mapView.getSpatialReference(),spatialReference); return llPoint; } /** * * @param mPixelsPoint * @param mapView * @param spatialReference * @return */ public static Point pixelsPoint2LlPoint(Point mPixelsPoint, MapView mapView,SpatialReference spatialReference){ llPoint=projectPoint2LlPoint(pixelsPoint2ProjectPoint(mPixelsPoint,mapView),mapView,spatialReference); return llPoint; } /** * * @param mLlPoint * @param mapView * @param spatialReference * @return */ public static Point llPoint2PixelsPoint(Point mLlPoint, MapView mapView,SpatialReference spatialReference){ pixelsPoint=projectPoint2PixelsPoint(llPoint2ProjectPoint(mLlPoint,mapView,spatialReference),mapView); return pixelsPoint; } }