postgis - What approach should I use in PostGIS to find all services that have a radius that intersect a customer
问题描述
I'm new to PostGIS and looking for suggestions on a reasonable approach to solve the following problem. I have services that have a lat/lng and service radius (an area that the service is available in). I have customers that just have a lat/lng. I'd like to setup up a table(s) that support indexed queries that return all services that have a service areas where the users location is contained.
Service
- latitude
- longitude
- radius
- type
Customer
- latitude
- longitude
- Bonus points if the query is easy to extend to filter services by other attributes as well *
解决方案
You can create and index geography columns in both tables, then you can make use of ST_DWITHIN() which makes use of the indexes
SELECT service.*
FROM service
JOIN customer
ON ST_DWITHIN(service.geog, customer.geom, service.radius)
WHERE customer.id=123
AND service.type='abc';
推荐阅读
- r - R read_excel 无法打开文件
- java - 如何在持久层和域对象之间正确映射
- matlab - 带图像处理的接缝跟踪
- scala - Scala Plugin in Intellij
- tensorflow - 带有 keras 的 tensorflow 数据 api(将张量传递给 keras 模型)
- geojson - ArcGIS 3.x 到 4.x 迁移
- angular - HTTP 登录表单在 IOS Ionic 3 上搞砸了,但在 Android 上可以工作
- python - bigquery 中的数据丢失
- python - RSeQC clipping_profiles 上的 multiqc
- python - 如何处理 python 脚本错误并通过电子邮件发送