gpst: %Cmd: Remove it, unused
[gpstools.git] / postgres / Patch / track-id-1.patch
blobeb6c2339e388e98fbf538fc97a6450e92dfbcefa
1 Index: create_funcs.sql
2 ===================================================================
3 --- create_funcs.sql (revision 2828)
4 +++ create_funcs.sql (working copy)
5 @@ -149,18 +149,23 @@
6 round(coor[0]::numeric, 6),
7 round(coor[1]::numeric, 6)
8 );
9 + CREATE TEMPORARY TABLE tmpids (
10 + id integer
11 + ) ON COMMIT DROP;
12 LOOP
13 curr_id = first_wayp_new();
14 IF curr_id IS NOT NULL THEN
15 RAISE NOTICE 'curr_id er ikke null: %', curr_id;
16 currpoint = (SELECT coor FROM wayp_new WHERE id = curr_id);
17 - IF (SELECT coor FROM wayp WHERE coor[0] = currpoint[0] AND coor[1] = currpoint[1]) IS NOT NULL THEN
18 + IF (SELECT coor FROM wayp WHERE coor[0] = currpoint[0] AND coor[1] = currpoint[1] LIMIT 1) IS NOT NULL THEN
19 RAISE NOTICE '% finnes allerede i wayp', currpoint;
20 INSERT INTO wayp_rej SELECT * FROM wayp_new WHERE id = curr_id;
21 ELSE
22 RAISE NOTICE '% er ikke i wayp', currpoint;
23 INSERT INTO wayp SELECT * FROM wayp_new WHERE id = curr_id;
24 - PERFORM update_trackpoint(currpoint);
25 + RAISE NOTICE 'Før INSERT INTO tmpids...';
26 + INSERT INTO tmpids SELECT id FROM logg WHERE coor <-> currpoint < 0.05;
27 + RAISE NOTICE '...INSERT INTO tmpids er ferdig.';
28 END IF;
29 DELETE FROM wayp_new WHERE id = curr_id;
30 -- COPY (SELECT name FROM wayp WHERE coor::varchar = currpoint::varchar)
31 @@ -170,17 +175,42 @@
32 EXIT;
33 END IF;
34 END LOOP;
35 + RAISE NOTICE 'Før CREATE TABLE tmpsortid.';
36 + CREATE TEMPORARY TABLE tmpsortid (
37 + id integer
38 + ) ON COMMIT DROP;
39 + RAISE NOTICE 'Før INSERT INTO tmpsortid.';
40 + INSERT INTO tmpsortid SELECT DISTINCT id FROM tmpids;
41 + RAISE NOTICE 'Totalt %', (SELECT count(*) FROM tmpids);
42 + RAISE NOTICE 'Unique %', (SELECT count(*) FROM tmpsortid);
43 + RAISE NOTICE 'Etter INSERT INTO tmpsortid';
44 + curr_id = 0;
45 + CREATE INDEX tmp_idx ON tmpsortid (id);
46 + LOOP
47 + curr_id = (SELECT id FROM tmpsortid WHERE id > curr_id LIMIT 1);
48 + IF curr_id IS NOT NULL THEN
49 + RAISE NOTICE 'Skal modifisere id %', curr_id;
50 + -- PERFORM update_trackpoint(curr_id);
51 + UPDATE logg SET sted = clname(coor), dist = cldist(coor) WHERE id = curr_id;
52 + -- DELETE FROM tmpsortid WHERE id = curr_id;
53 + ELSE
54 + RAISE NOTICE 'Ser ut som vi er ferdigtråla.';
55 + EXIT;
56 + END IF;
57 + END LOOP;
58 + -- PERFORM (SELECT DISTINCT id FROM tmpids);
59 + -- PERFORM (SELECT * from tmpids);
60 + ROLLBACK;
61 END;
62 $$ LANGUAGE plpgsql; -- }}}
64 -- update_trackpoint(): Oppdater alle feltene i en viss omkrets av punktet som spesifiseres.
65 -CREATE OR REPLACE FUNCTION update_trackpoint(currpoint point) RETURNS void AS $$ -- {{{
66 +CREATE OR REPLACE FUNCTION update_trackpoint(currid integer) RETURNS void AS $$ -- {{{
67 BEGIN
68 - RAISE NOTICE 'starter update_trackpoint(%), %', currpoint, clname(currpoint);
69 + RAISE NOTICE 'starter update_trackpoint(%)', currid;
70 -- Sted og dist
71 - UPDATE logg SET sted = clname(coor), dist = cldist(coor)
72 - WHERE ($1 <-> coor) < 0.05;
73 - RAISE NOTICE 'update_trackpoint(%) er ferdig', currpoint;
74 + UPDATE logg SET sted = clname(coor), dist = cldist(coor) WHERE id = currid;
75 + RAISE NOTICE 'update_trackpoint(%) er ferdig', currid;
76 END;
77 $$ LANGUAGE plpgsql;
78 -- }}}
79 Index: create_table.sql
80 ===================================================================
81 --- create_table.sql (revision 2828)
82 +++ create_table.sql (working copy)
83 @@ -6,7 +6,8 @@
84 ele numeric,
85 sted text,
86 dist numeric(8, 5),
87 - description text
88 + description text,
89 + id serial
92 CREATE TABLE wayp (