2015-01-05 85 views
1

我正在使用vaadin插件的v-leaflet(0.61)在地圖上顯示一些圖層。如何將經簡化後的經緯度轉換爲EPSG:4326

點擊地圖,我創建一個wms查詢geoserver。 查詢需要一些參數,其中之一是bbox。 我想,默認情況下,由地圖返回的bbox位於CRS.Simple中,是一個神祕的傳單座標系統。

即使我已經設置屬性

leafletMap.setCrs(Crs.EPSG3857); 

    myoverlayer.setCrs(Crs.EPSG3857); 

既地圖和層。

我學會了here使用JTS拓撲套件從EPSG轉換到另一個的方法。

但我找不到從leafltet使用的Crs.Simple轉換爲EPSG(4326更好)的方法。

如果我設置EPSG3857,無論是地圖和圖層,它返回我是這樣的邊框:

約束:6.0919189453125,45.11617660357484,11.134643554687498, 46.50217348354072

如果我設置EPSG4326,用了同樣的觀點:

約束:6.0919189453125,44.81597900390625,11.1346435546875,
46.80450439453125

似乎只有緯度值已被改變。

我tryed使用也JTSTool(JTS拓撲套房)從EPSG3857轉換爲EPSG4326和值:

BBOX = 4.0528551003362907E-4,5.4724638981914947E-5,4.1773613184440224E -4,1.0002420488398699E-4

這聽起來太奇怪了....

有人可以幫助我瞭解CRS用於定義BBOX?或者任何方式來改變它們?

" 
      CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326"); 
      CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:3857"); 
      MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, false); 
      GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326); 
      com.vividsolutions.jts.geom.Point point = geometryFactory.createPoint(new Coordinate(bbb.getSouthWestLon(),bbb.getSouthWestLat())); 
      com.vividsolutions.jts.geom.Point point2 = geometryFactory.createPoint(new Coordinate(bbb.getNorthEastLon(),bbb.getNorthEastLat())); 
      com.vividsolutions.jts.geom.Point targetPoint = (com.vividsolutions.jts.geom.Point) JTS.transform(point, transform); 
      com.vividsolutions.jts.geom.Point targetPoint2 = (com.vividsolutions.jts.geom.Point) JTS.transform(point2, transform);" 

回答

0

您試過Proj4Leaflet?我用它在標準投影和EPSG:2263之間進行轉換。

這第一個代碼示例是我如何從2263轉換爲標準。

// Set the view to the centroid of the coordinates 
Point p = Leaflet.Point(cx, cy); 
// Unproject the geom into latlng 
currentCentroid = mCrs.Projection.Unproject(p); 

這是來自點擊處理程序。我只是拿單張給出的latlng和投影到2263.

Point proj = mCrs.Projection.Project(e.Latlng) 
+0

問題是我可以導入proj4Leaflet無法在vaadin的Leaflet之前加載它。 所以不可能使用。 –