Skip to content

Commit 78b77c9

Browse files
committed
Fixed issue with duplicate artificial waypoints.
albar965/littlenavmap#462
1 parent c0183ab commit 78b77c9

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

resources/sql/fs/db/dfd/populate_navaids_proc.sql

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,18 @@ from (
151151
-- **********************************************************
152152
-- Now delete all waypoints which already exist in the waypoint table
153153

154+
-- Delete all duplicate waypoints that are at the same position having same name, region and type
155+
-- 1 deg manhattan distance about 60-100 nm at the equator
154156
delete from waypoint_temp where waypoint_id in (
155-
select w1.waypoint_id from waypoint_temp w1
156-
join waypoint w2 on w1.ident = w2.ident and
157-
w1.region = w2.region and
158-
(abs(w1.lonx - w2.lonx) + abs(w1.laty - w2.laty)) < 0.00000001);
157+
select distinct w1.waypoint_id
158+
from waypoint_temp w1
159+
join waypoint_temp w2 on w1.ident = w2.ident and w1.region = w2.region and w1.type = w2.type
160+
where w1.waypoint_id < w2.waypoint_id and (abs(w1.lonx - w2.lonx) + abs(w1.laty - w2.laty)) < 0.00000001);
161+
162+
delete from waypoint_temp where waypoint_id in (
163+
select w1.waypoint_id from waypoint_temp w1
164+
join waypoint w2 on w1.ident = w2.ident and w1.region = w2.region and w1.type = w2.type
165+
where (abs(w1.lonx - w2.lonx) + abs(w1.laty - w2.laty)) < 0.00000001);
159166

160167
-- **********************************************************
161168
-- Copy all waypoints from temp table to waypoint table

0 commit comments

Comments
 (0)