등거리 전경 위도 좌표

2501 단어 meteoinfo

			org.meteothinker
			MeteoInfoLib
			0.0.1-SNAPSHOT
		

코드
import org.meteoinfo.projection.proj4j.CRSFactory;
import org.meteoinfo.projection.proj4j.CoordinateReferenceSystem;
import org.meteoinfo.projection.proj4j.CoordinateTransform;
import org.meteoinfo.projection.proj4j.CoordinateTransformFactory;
import org.meteoinfo.projection.proj4j.ProjCoordinate;

public class Grid2WGS84Utils {
	
	  //lat_0\lon_0       
	  private static final String LCC_PARAM = "+proj=lcc +lat_1=30.0 +lat_2=60.0 +lat_0=30.0 +lon_0=102.0 +x_0=3000 +y_0=3000 +units=m";

	  private static final String WGS_PARAM = "+proj=latlong +datum=WGS84";

	  private static final double X_MIN = -2850541D;//X    

	  private static final double X_DEL = 3000D;//X   3KM

	  private static final double Y_MIN = -1932198.7D;//Y    

	  private static final double Y_DEL = 3000D;//Y   3KM
	  
	  public static final int xCount = 1901, yCount = 1801;//X、Y    ,  (xIndex,yIndex)
	  
	  private static final CoordinateTransform transform;

	  static {
	    CoordinateReferenceSystem src = new CRSFactory().createFromParameters("lcc", LCC_PARAM);
	    CoordinateReferenceSystem dst = new CRSFactory().createFromParameters("wgs", WGS_PARAM);
	    transform = new CoordinateTransformFactory().createTransform(src, dst);
	  }

	  private Grid2WGS84Utils() {
	    // empty method
	  }

	  /**
	   * build ProjCoordinate from grid's index
	   *
	   * @param xIndex x index, start from 0, you can use double like 180.5
	   * @param yIndex y index, start from 0, you can use double like 160.5
	   * @return the source ProjCoordinate
	   */
	  public static ProjCoordinate buildSource(double xIndex, double yIndex) {
	    double x = X_MIN + X_DEL * xIndex;
	    double y = Y_MIN + Y_DEL * yIndex;
	    return new ProjCoordinate(x, y);
	  }

	  /**
	   * 
	   * @param buildSource()
	   * @return lon、lat
	   */
	  public static ProjCoordinate transform(ProjCoordinate src) {
	    ProjCoordinate tgt = new ProjCoordinate();
	    transform.transform(src, tgt);
	    return tgt;
	  }
	  public static void main(String[] args) {
//		  ProjCoordinate pc = buildSource(0,0);//   
		  ProjCoordinate pc = buildSource(950,900);//      ,      
		  ProjCoordinate pc2 = transform(pc);
		  System.out.println(pc2.x+"=="+pc2.y);
	}
}


네 개의 각 좌표를 검증해서 정확한지 확인할 수 있다.

좋은 웹페이지 즐겨찾기