2

I'm using v-leaflet (0.61) , a vaadin plugin, to visualize some layers over a map.

Clicking on the map, I create a wms query to geoserver. The query needs some parameters and one of them is the bbox. I suppose, by default, that the bbox, returned by the map, is in CRS.Simple, a mysterious coordinate system of leaflet.

Even if I've set the attribute

  leafletMap.setCrs(Crs.EPSG3857);

  myoverlayer.setCrs(Crs.EPSG3857);

both to the map and the layer.

I've learned here the way to convert from an EPSG to another, using JTS Topology Suite.

But I can't find a way to convert from Crs.Simple, used by leafltet, to an EPSG ( 4326 is better ).

if I set EPSG3857, both on the map and the layers, it returns me something like this as bounding box :

Bound:6.0919189453125, 45.11617660357484, 11.134643554687498, 46.50217348354072

if I set EPSG4326, with the same view :

Bound:6.0919189453125, 44.81597900390625, 11.1346435546875,
46.80450439453125

Seems that only the latitude values have been changed.

I've tryed also to use JTSTool (jts-topology-suite) to convert from EPSG3857 to EPSG4326 and the values are :

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

It sounds so strange....

Can someone help me to understand the CRS used to define the bbox ? Or any way to transform them ?

"
            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);"
Community
  • 1
  • 1
docHell
  • 121
  • 3
  • 8

1 Answers1

1

Have you tried Proj4Leaflet? I use it to convert between the standard projection and EPSG:2263.

This first code sample is how I convert from 2263 to standard.

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

This is from a click handler. I just take the latlng that leaflet gives and project to 2263.

Point proj = mCrs.Projection.Project(e.Latlng)
pk.
  • 956
  • 7
  • 13
  • The problem is that I can import proj4Leaflet can't load it before Leaflet in vaadin. So it is impossible to use. – docHell Jan 05 '15 at 16:00