I have a database table that currently stores geometric data in the SRID 27700 (British National Grid). However, when I receive the data, I need to convert it to SRID 4326 (WGS84). Is there a way to apply a function like ST_Transform found in PostGIS to my data to get the result I need?
NOTE. The solution must be implemented using T-SQL and non-stored procedures, etc. I should be able to build a statement and save it in the table as a row field for later search. This is because my solution is an agnostic database.
The way I'm doing it now in Oracle is as follows:
select CLUSTER_ID, NUM_POINTS, FEATURE_PK, A.CELL_CENTROID.SDO_POINT.X, A.CELL_CENTROID.SDO_POINT.Y, A.CLUSTER_CENTROID.SDO_POINT.X, A.CLUSTER_CENTROID.SDO_POINT.Y, TO_CHAR (A.CLUSTER_EXTENT.GET_WKT ()), TO_CHAR (A.CELL_GEOM.GET_WKT ()), A.CLUSTER_EXTENT.SDO_SRID from (SELECT CLUSTER_ID, NUM_POINTS, FEATURE_PK, SDO_CS.transform (CLUSTER_CENTROID, 4326) cluster_centroid, CLUSTER_EXTENT, SDO_CS.transform (CELL_CENTROID, 4326) cell_centroid, CELL_GEOM FROM :0) a where sdo_filter( A.CELL_GEOM, SDO_CS.transform(mdsys.sdo_geometry(2003, :1, NULL, mdsys.sdo_elem_info_array(1,1003,3),mdsys.sdo_ordinate_array(:2, :3, :4, :5)),81989)) = 'TRUE'
In PostgreSQL using PostGIS, I do it like this:
select CLUSTER_ID, NUM_POINTS, FEATURE_PK, ST_X(a.CELL_CENTROID), ST_Y(a.CELL_CENTROID), ST_X(ST_TRANSFORM(a.CLUSTER_CENTROID, 4326)), ST_Y(ST_TRANSFORM(a.CLUSTER_CENTROID, 4326)), ST_AsText(a.CLUSTER_EXTENT), ST_AsText(a.CELL_GEOM), ST_SRID(a.CLUSTER_EXTENT) FROM (SELECT CLUSTER_ID, NUM_POINTS, FEATURE_PK, ST_TRANSFORM(ST_SetSRID(CLUSTER_CENTROID, 27700), 4326) cluster_centroid, CLUSTER_EXTENT, ST_TRANSFORM(ST_SetSRID(CELL_CENTROID, 27700), 4326) cell_centroid, CELL_GEOM from :0) AS a where ST_Intersects(ST_Transform(ST_SetSRID(a.CELL_GEOM, 27700), :1), ST_Transform(ST_GeomFromText('POLYGON(('||:2||' '||:3||', '||:4||' '||:3||', '||:4||' '||:5||', '||:2||' '||:5||', '||:2||' '||:3||'))', 4326), :1))