U
U
untley2017-09-08 14:29:30
PostgreSQL
untley, 2017-09-08 14:29:30

How to find objects by radius?

It is required to find all the vehicles that passed by the loading point at a certain time.
The only point: there are many such points.
There is a request:

SELECT
distinct (a.serial_num),
a.start_dt
           FROM full_points a
        where
        start_dt >=    '2017-07-31 12:00:00.000000'::timestamp without time zone
        and start_dt < '2017-07-31 12:05:00.000000'::timestamp without time zone
and ST_DWithin(
    (
     ST_MakePoint(
      (a.points->0 ->> 'lat'::text)::double precision,
      (a.points->0 ->> 'lon'::text)::double precision)
    )::Geography,
   (ST_MakePoint(55.2252, 36.64547))::geography,
    1000
  )
Is it possible to file something like a symbiosis of IN() and ST_DWithin? because go through the table many times, running ST_DWithin'om each loading point - hell for postgres, all coordinates are there in JSON.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2017-09-08
@freeExec

I did not understand the question, what is the radius of many points. But it's okay. It would be better to overtake all the json into points and build a spatial index on them. And then quickly get all the points within a radius of 1000 from the given one and sift them through the time interval.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question