【问题标题】:How to convert lat/long from Leaflet CRS.Simple to EPSG:4326如何将经纬度从 Leaflet CRS.Simple 转换为 EPSG:4326
【发布时间】:2015-03-02 14:18:17
【问题描述】:

我正在使用 v-leaflet (0.61) ,一个 vaadin 插件,在地图上可视化一些图层。

点击地图,我创建了一个到 geoserver 的 wms 查询。 查询需要一些参数,其中之一是 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

好像只有纬度值改变了。

我也尝试使用 JTSTool (jts-topology-suite) 将 EPSG3857 转换为 EPSG4326,其值为:

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

听起来很奇怪....

有人可以帮我理解用于定义 bbox 的 CRS 吗?或者有什么方法可以改造它们?

"
            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);"

【问题讨论】:

    标签: java leaflet vaadin7 topology jts


    【解决方案1】:

    你试过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)
    

    【讨论】:

    • 问题是我可以导入proj4Leaflet 无法在vaadin 中的Leaflet 之前加载它。所以无法使用。
    猜你喜欢
    • 2021-08-28
    • 2017-07-02
    • 2017-10-14
    • 1970-01-01
    • 2014-04-27
    • 2021-11-10
    • 2021-08-09
    • 2016-09-28
    • 1970-01-01
    相关资源
    最近更新 更多