[Collate Address] when updating address point, do not use the point's address reference if the similarity is below

This commit is contained in:
Julien Fastré 2023-07-15 08:59:07 +02:00
parent 4d7b4500c1
commit 98c2ee3ab2
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 14 additions and 1 deletions

View File

@ -0,0 +1,7 @@
kind: Fixed
body: '[Collate Address] when updating address point, do not use the point''s address
reference if the similarity is below the requirement for associating the address
reference and the address (it uses the postcode''s center instead)'
time: 2023-07-15T08:51:53.293736534+02:00
custom:
Issue: ""

View File

@ -76,11 +76,17 @@ final readonly class CollateAddressWithReferenceOrPostalCode implements CollateA
UPDATE chill_main_address SET addressreference_id = recollate.address_reference_id FROM recollate WHERE chill_main_address.id = recollate.address_id;
SQL;
/**
* Update the point's address with the:
*
* - address reference point, if the address match the reference with sufficient similarity
* - or the postcal code center
*/
private const UPDATE_POINT = <<<'SQL'
WITH address_geom AS (
SELECT cma.id AS address_id, COALESCE(cmar.point, cmpc.center) AS point
FROM chill_main_address cma
LEFT JOIN chill_main_address_reference cmar ON cma.addressreference_id = cmar.id
LEFT JOIN chill_main_address_reference cmar ON cma.addressreference_id = cmar.id AND similarity(cma.street, cmar.street) > 0.6 AND LOWER(cma.streetnumber) = LOWER(cmar.streetnumber)
LEFT JOIN chill_main_postal_code cmpc ON cma.postcode_id = cmpc.id
WHERE cma.id > :since_id
)