Bug report #10105
How to sent coordinates in the right projection to PostGIS
Status: | Rejected | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | - | ||
Affected QGIS version: | 2.2.0 | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | invalid |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 18573 |
Description
Hello everyone,
When editing a PostGIS table in QGIS I face a "little" problem.
If you force a bad projection (in fact I don't have to -> "little" problem), there is no way for PostGIS to see that transmitted coordinates are not in the right projection (the postgis known one).
For example , I create a table of point with the 2154 EPSG CRS
CREATE TABLE temp.zone_etude ( id serial NOT NULL PRIMARY KEY, geometry geometry ( DOT, 2154 ) );
I edit the table (the projection of the layer is the Lambert 93) and I insert 3 points (id 1-3)
I change the projection of the layer in QGis ( WGS 86 - EPSG 4326 ) and I insert 3 other points (id 4-6)
Here is the result of the query that returns me the x and y coordinates of the point:
SELECT id, ST_X ( geometry ) ST_Y ( geometry ) FROM temp.zone_etude@ ST_X id + () + ST_Y () --- + ----------------------- + ---------------------- - 1 | 737707.543555342 | 6246680.51734156 --- + ----------------------- + ---------------------- - 2 | 730263.998025363 | 6247364.74297523 --- + ----------------------- + ---------------------- - 3 | 729548.671226521 | 6247312.90769996 --- + ----------------------- + ---------------------- - 4 | 3.40598419124953 | 43.304996455616 --- + ----------------------- + ---------------------- - 5 | 3.36998317105245 | 43.3264823404078 --- + ----------------------- + ---------------------- - 6 | 3.36038313789093 | 43.3234371305666 -------------------------------------------------- -
QGIS seems to have sent to PostGIS WGS 84 coordinates saying she was in Lambert 93 It is interesting that relies on the information it has two.
QGis would use both CRS (The one provide by PostGIS metadata and the one forced by the user) to catch the mistake for example to insert something LIKE that :
st_transform(st_setsrid(st_makepoint(3.36038313789093,43.3234371305666),4326),2154)
Mathieu BOSSAERT
History
#1 Updated by Jürgen Fischer over 10 years ago
- Resolution set to invalid
- Status changed from Open to Rejected
Don't change the layer's CRS. If you change the project's CRS instead (and enable on-the-fly-reprojection) you can work in WGS84, while what you save will automatically be transformed from the project's CRS to the layer's CRS - the layer's CRS should always be the CRS the datasource uses.