Hello, My name is Marcin and this is my first post here, so if I ma somewhere unclear - please just let me know I have a problem with transforming geometries from one coordinate system to another.
Here is a description of my application. 1. I have a map that uses openstreetmap as a base map in Pseudo Mercator coordinate system (EPSG:3857). The map client uses OpenLayers3 to draw maps. 2. I have two different data sources: shapefiles and postgis. 3. Layers in the sources have coordinate systems different than on the map. That is why I transform the data on the fly, from their native systems to EPSG:3857, before I send them back to the application client side. 4. Data in shapefiles uses the following coordsys definition: PROJCS["ETRS_1989_UWPP_2000_PAS_6", GEOGCS["GCS_ETRS_1989", DATUM["D_ETRS_1989", SPHEROID["GRS_1980", 6378137.0, 298.257222101]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Longitude", EAST], AXIS["Latitude", NORTH]], PROJECTION["Transverse_Mercator"], PARAMETER["central_meridian", 18.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["scale_factor", 0.999923], PARAMETER["false_easting", 6500000.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["x", EAST], AXIS["y", NORTH]] 5. The shapefiles were later imported to postgis using their import tool. During the import I had to specify the EPSG code for the coordinate system I showed above. According to what I read in the net, the EPSG code for the system is 2177 - so I used this as SRID. 6. The imported data showed that it uses the following CRS definition: PROJCS["ETRS89 / Poland CS2000 zone 6", GEOGCS["ETRS89", DATUM["European Terrestrial Reference System 1989", SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], AUTHORITY["EPSG","6258"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic latitude", NORTH], AXIS["Geodetic longitude", EAST], AUTHORITY["EPSG","4258"]], PROJECTION["Transverse_Mercator", AUTHORITY["EPSG","9807"]], PARAMETER["central_meridian", 18.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["scale_factor", 0.999923], PARAMETER["false_easting", 6500000.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["Northing", NORTH], AXIS["Easting", EAST], AUTHORITY["EPSG","2177"]] This definition is in most points identical to the previous one with the exception of names and some parts called: AUTHORITY. But its name suggest that the system in postgis is the right one to use. 7. The problem is: the data stored in shapefile displayed in the correct position, and data from postgis - somewhere else. 8. In my application I do the transformation using geotools 11.1 with the following piece of code: CoordinateReferenceSystem nativeCRS = {I get the source native CRS here}; CoordinateReferenceSystem mapCRS = {I get Pseudo Mercator here}; List<SimpleFeature> features = {here is a list of features I need to transform}; MathTransform transform = CRS.findMathTransform(nativeCRS, mapCRS, true); features.parallelStream().forEach(feature -> { try { feature.setDefaultGeometry(JTS.transform((Geometry) feature.getDefaultGeometry(), transform)); } catch(TransformException e) { LOGGER.warn(e.getLocalizedMessage()); } }); 9. What is more strange, when I used Udig to view the data, they both fit. I would be very grateful if someone could point mw what is wrong. If any more data is needed - just let me know. The server side uses Java 8 and Jboss 8 as an application server. Best regards, Marcin -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Problem-with-reference-systems-transformations-tp5156398.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ _______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users