2015-01-05 83 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之前加载它。 所以不可能使用。 –