Construct curve of equal distance from two straight lines

المشرف العام

Administrator
طاقم الإدارة
Given two straight lines defined by two points each, I want to get the line which separates points nearer to line a from points nearer to line b. The attached PostGIS code is an example case, it finds points of equal distance by creating a lot of buffers around the lines and intersecting them:



Is there an algorithm to calculate this line more direct, without sampling points or rastering?

I thought the line for this example would have a linear central part, but the dots are placed slightly under that line. Are they placed correctly?



CREATE TABLE tv_lines1 ( id text PRIMARY KEY, geom geometry(linestring, 4326)); -- set meaningless CRS for easy handling in QGISINSERT INTO tv_lines1 (id, geom) SELECT 'a', ST_SetSRID(ST_MakeLine(ST_Point(0.0, 0.0), ST_Point(30.0, 0.0)), 4326);INSERT INTO tv_lines1 (id, geom) SELECT 'b', ST_SetSRID(ST_MakeLine(ST_Point(16.0, 2.0), ST_Point(40.0, 12.0)), 4326);CREATE INDEX ON tv_lines1 USING gist (geom);-- create buffers in Steps of 0.1CREATE TABLE tv_buffers ( line_id text, size float, geom geometry(linestring, 4326), PRIMARY KEY (line_id, size));INSERT INTO tv_buffers (line_id, size) SELECT id, generate_series(1, 1000) / 10.0 FROM tv_lines1;UPDATE tv_buffers bf SET geom = ST_ExteriorRing(ST_Buffer(l1.geom, size)) FROM tv_lines1 l1 WHERE l1.id = bf.line_id;CREATE INDEX ON tv_buffers USING gist(geom);-- find intersectionsCREATE TABLE tv_intersections ( id SERIAL PRIMARY KEY, distance float, geom geometry(point, 4326));INSERT INTO tv_intersections (distance, geom) SELECT bf1.size, (ST_DUMP(ST_Intersection(bf1.geom, bf2.geom))).geom FROM tv_buffers bf1, tv_buffers bf2 WHERE bf1.line_id = 'a' AND bf2.line_id = 'b' AND bf1.size = bf2.size;CREATE INDEX ON tv_intersections USING gist(geom);

أكثر...
 
أعلى