訓練家的快寫筆記

The legend of trainer's paper


搜尋:

     關閉     
標題:openlayer2 轉坐標
內容:

  window.Proj4js = {
    Proj: function(code) {
      return proj4(Proj4js.defs[code]);
    },
    defs: proj4.defs,
    transform: proj4
  };
  // Definition comes from http://epsg.io/31466/
  proj4.defs["EPSG:3828"] = "+proj=tmerc +lat_0=0 +lon_0=121 +k=0.9999 +x_0=250000 +y_0=0 +ellps=aust_SA +towgs84=-752,-358,-179,-0.0000011698,0.0000018398,0.0000009822,0.00002329 +units=m +no_defs";
  proj4.defs["EPSG:3821"] = "+title=經緯度:TWD67 +proj=longlat  +towgs84=-752,-358,-179,-.0000011698,.0000018398,.0000009822,.00002329 +ellps=aust_SA +units=度 +no_defs";
  proj4.defs["EPSG:3822"] = "+proj=tmerc +ellps=GRS67 +towgs84=-752,-358,-179,-.0000011698,.0000018398,.0000009822,.00002329 +lon_0=121 +x_0=250000 +k=0.9999 +to +proj=tmerc +datum=WGS84 +lon_0=121 +x_0=250000 +k=0.9999";
  proj4.defs["EPSG:3825"] = "+title=二度分帶:TWD97 TM2 澎湖 +proj=tmerc  +lat_0=0 +lon_0=119 +k=0.9999 +x_0=250000 +y_0=0 +ellps=GRS80 +units=公尺 +no_defs";
  proj4.defs["EPSG:3826"] = "+title=二度分帶:TWD97 TM2 台灣 +proj=tmerc  +lat_0=0 +lon_0=121 +k=0.9999 +x_0=250000 +y_0=0 +ellps=GRS80 +units=公尺 +no_defs";
  proj4.defs["EPSG:3827"] = "+title=二度分帶:TWD67 TM2 澎湖 +proj=tmerc  +towgs84=-752,-358,-179,-.0000011698,.0000018398,.0000009822,.00002329 +lat_0=0 +lon_0=119 +x_0=250000 +y_0=0 +k=0.9999 +ellps=aust_SA  +units=公尺";
//有修正 3828
  proj4.defs["EPSG:3828"] = "+title=EPSG:3828 TWD67 / TM2 zone 121 +proj=tmerc +lat_0=0 +lon_0=121 +k=0.9999 +x_0=250000 +y_0=0 +ellps=aust_SA +towgs84=-752,-358,-179,-0.0000011698,0.0000018398,0.0000009822,0.00002329 +units=m +no_defs";  
  proj4.defs["EPSG:3857"] = "+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=公尺 +no_defs";
  proj4.defs["EPSG:900913"] = "+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=公尺 +no_defs";
  console.log(Proj4js.defs["EPSG:3828"]);
      var proj_wgs84 = new OpenLayers.Projection("EPSG:4326");
      var proj_3828 = new OpenLayers.Projection("EPSG:3828");
      // Center for projection EPSG:31466
      var point = new OpenLayers.LonLat(120.674894, 24.122472);
      var new_point= point.transform(proj_wgs84, proj_3828);
      console.log(new_point.lon, new_point.lat);