Skip to content

Dwithin spatial_query bug - don't check units and always puts degrees #1213

@asafMasa

Description

@asafMasa

When a CSW GetRecords request is run against a PostgreSQL backend and uses Dwithin spatial_query, the query that is generated to PostgreSQL is in "degree" units instead of "metres" as requested

Problem Description
When querying the PYCSW with the dwithin spatial_query, for example:

ogc:Filter
ogc:DWithin
ogc:PropertyNameows:BoundingBox</ogc:PropertyName>
<gml:Point srsName="urn:ogc:def:crs:EPSG::4326">
gml:pos23.7342660 37.974720</gml:pos>
</gml:Point>
<ogc:Distance units="meters">50</ogc:Distance>
</ogc:DWithin>
</ogc:Filter>

When pycsw translates the query, it ignores the Distance units="meters"
From:

elif spatial_predicate == 'dwithin':

Image

We need to change the generated query from:
WHERE st_dwithin(wkb_geometry, st_geomfromtext('POINT(23.7342660 37.974720)',4326), 50.000000) = 'true'
To:
WHERE st_dwithin(wkb_geometry::geography, st_geomfromtext('POINT(23.7342660 37.974720)',4326)::geography, 50.000000) = 'true'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions