Skip to content

Commit

Permalink
closes #19; changed result codes into descending
Browse files Browse the repository at this point in the history
order.
  • Loading branch information
mbasa committed Jul 12, 2024
1 parent 8d89e43 commit 6845479
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
12 changes: 5 additions & 7 deletions sql/pgGeocoder.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ DECLARE
gc geores;
output geores;
matching_nomatch integer;
matching_eki integer;
matching_todofuken integer;
matching_shikuchoson integer;
matching_ooaza integer;
Expand All @@ -64,13 +63,12 @@ DECLARE

BEGIN

matching_nomatch := -99;
matching_eki := 30;
matching_todofuken := 5;
matching_shikuchoson := 4;
matching_nomatch := 0;
matching_todofuken := 1;
matching_shikuchoson := 2;
matching_ooaza := 3;
matching_chiban := 2;
matching_pinpnt := 1;
matching_chiban := 4;
matching_pinpnt := 5;

output := searchTodofuken( address );

Expand Down
23 changes: 18 additions & 5 deletions sql/pgReverseGeocoder.sql
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,24 @@ DECLARE
output geores;
s_flag boolean;
s_bdry RECORD;
matching_nomatch integer;
matching_todofuken integer;
matching_shikuchoson integer;
matching_ooaza integer;
matching_chiban integer;
matching_pinpnt integer;
BEGIN

s_flag := FALSE;

output.code := -9;
matching_nomatch := 0;
matching_todofuken := 1;
matching_shikuchoson := 2;
matching_ooaza := 3;
matching_chiban := 4;
matching_pinpnt := 5;

output.code := matching_nomatch;
output.x := -999;
output.y := -999;
output.address := 'なし';
Expand All @@ -84,7 +97,7 @@ BEGIN
ORDER BY st_distance(point,geog) LIMIT 1;

IF FOUND THEN
output.code := 1;
output.code := matching_pinpnt;
output.x := record.lon;
output.y := record.lat;
output.address := record.address;
Expand All @@ -107,7 +120,7 @@ BEGIN
ORDER BY dist LIMIT 1;

IF FOUND THEN
output.code := 2;
output.code := matching_chiban;
output.x := record.lon;
output.y := record.lat;
output.address := record.address;
Expand All @@ -127,7 +140,7 @@ BEGIN
ORDER BY dist LIMIT 1;

IF FOUND THEN
output.code := 3;
output.code := matching_ooaza;
output.x := record.lon;
output.y := record.lat;
output.address := record.address;
Expand All @@ -153,7 +166,7 @@ BEGIN
FROM pggeocoder.address_s AS a
WHERE st_intersects(a.geog, s_bdry.geom::geography);
IF FOUND THEN
output.code := 4;
output.code := matching_shikuchoson;
output.x := record.lon;
output.y := record.lat;
output.address := record.address;
Expand Down

0 comments on commit 6845479

Please sign in to comment.