(I'm very new to (Post)GIS in general, and I couldn't find an existing answer to this (or just don't know the right terminology) -- sorry if it's already been asked & answered)
I have a bunch of company addresses, each with a Point and a range of operations (radius in m):
create table public.company_addresses ( id bigserial not null, -- some more data range_of_operation int4 not null, "location" geometry(POINT, 4326) NULL, ); CREATE INDEX company_addresses_location_index ON public.company_addresses USING gist (location);
Now I have some other Point (long,lat) and I want to find all the company addresses in which the circle from their Point + radius overlaps with that point.
I've been able to do this with:
select id from company_addresses ca where ST_DWithin(ca."location"::geography, st_setsrid(st_makepoint(long, lat), 4326), ca.range_of_operation);
I was wondering if this is the best way to do this? Should I store the data differently?