Ticket #74 (closed defect: fixed)
Spatial function with constant and variable fails or gives invalid results
Reported by: | stella | Owned by: | stella |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | generaldb | Version: | |
Keywords: | Cc: |
Description
Given the dataset:
<http://example.org/A> <http://example.org/hasGeometry> "POINT(2 1);http://www.opengis.net/def/crs/EPSG/0/27700"^{}<http://strdf.di.uoa.gr/ontology#WKT> .
the following query fails with PSQLException: ERROR: Operation on mixed SRID geometries
PREFIX ex: <http://example.org/>
PREFIX strdf: <http://strdf.di.uoa.gr/ontology#>
SELECT (strdf:union("POINT(0 1);http://www.opengis.net/def/crs/EPSG/0/27700"^^strdf:WKT, ?g) as ?un)
WHERE
{
ex:A ex:hasGeometry ?g .
}
this happens because PostGIS functions require geometries of the same coordinate projection in order to give consistent results and in this case the constant geometry has srid 27700 and the value of the variable ?g is stored in WGS84.
This requirement of PostGIS is due to the Cartesian coordinate plane that it uses.
Change History
comment:1 Changed 3 years ago by stella
- Owner changed from pyravlos-team to stella
- Status changed from new to assigned
- Component changed from endpoint to generaldb
comment:2 in reply to: ↑ description ; follow-up: ↓ 3 Changed 3 years ago by charnik
Replying to stella:
Given the dataset:
<http://example.org/A> <http://example.org/hasGeometry> "POINT(2 1);http://www.opengis.net/def/crs/EPSG/0/27700"^{}<http://strdf.di.uoa.gr/ontology#WKT> .
the following query fails with PSQLException: ERROR: Operation on mixed SRID geometries
PREFIX ex: <http://example.org/>
PREFIX strdf: <http://strdf.di.uoa.gr/ontology#>
SELECT (strdf:union("POINT(0 1);http://www.opengis.net/def/crs/EPSG/0/27700"^^strdf:WKT, ?g) as ?un)
WHERE
{
ex:A ex:hasGeometry ?g .
}
this happens because PostGIS functions require geometries of the same coordinate projection in order to give consistent results and in this case the constant geometry has srid 27700 and the value of the variable ?g is stored in WGS84.
Well, shouldn't we just do what we already do for all the functions, that is, transform the one to the SRID of the other? And in that case, because we have a constant, the wise approach would be to transform 27700 to 4326. Right? And why that doesn't happen already for the case of strdf:union?
This requirement of PostGIS is due to the Cartesian coordinate plane that it uses.
Eh?
comment:3 in reply to: ↑ 2 Changed 3 years ago by stella
Replying to charnik:
Replying to stella:
Given the dataset:
<http://example.org/A> <http://example.org/hasGeometry> "POINT(2 1);http://www.opengis.net/def/crs/EPSG/0/27700"^{}<http://strdf.di.uoa.gr/ontology#WKT> .
the following query fails with PSQLException: ERROR: Operation on mixed SRID geometries
PREFIX ex: <http://example.org/>
PREFIX strdf: <http://strdf.di.uoa.gr/ontology#>
SELECT (strdf:union("POINT(0 1);http://www.opengis.net/def/crs/EPSG/0/27700"^^strdf:WKT, ?g) as ?un)
WHERE
{
ex:A ex:hasGeometry ?g .
}
this happens because PostGIS functions require geometries of the same coordinate projection in order to give consistent results and in this case the constant geometry has srid 27700 and the value of the variable ?g is stored in WGS84.
Well, shouldn't we just do what we already do for all the functions, that is, transform the one to the SRID of the other? And in that case, because we have a constant, the wise approach would be to transform 27700 to 4326. Right? And why that doesn't happen already for the case of strdf:union?
Currently, since all the geometries are stored in 4326 in the database, then the spatial functions compare geometries of the same coordinate projection (4326), thus no such problem occurs. For the case of constants, we must similarly transform them as well to 4326 in order not to mix the srids.
This requirement of PostGIS is due to the Cartesian coordinate plane that it uses.
Eh?
I mean that because the cartesian coordinate system is a flat projection on the surface of Earth, then all the comparisons must be between geometries of the same srid.