Skip to content

Fix: skip proximity merge when incoming parking has a known source ID#408

Merged
assadriaz merged 2 commits into
entur:masterfrom
tmfg:fix/merge-parking-importer
Jul 16, 2026
Merged

Fix: skip proximity merge when incoming parking has a known source ID#408
assadriaz merged 2 commits into
entur:masterfrom
tmfg:fix/merge-parking-importer

Conversation

@teppope

@teppope teppope commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes a bug in MergingParkingImporter where two distinct parking facilities could be incorrectly merged based on proximity alone when they shared a name and nearby coordinates (e.g., two separate lots at the same station).

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Issue

Motivation: When importing parkings that carry an originalId (i.e., a known source-system ID), the importer first tries to locate an existing parking by that ID. If none is found, it fell through to proximity-based matching. This meant two new parkings with different IDs but the same name and overlapping coordinates (common at large transport hubs) could be collapsed into one record — silently dropping the second facility.

How the code works: MergingParkingImporter.findNearbyOrExistingParking now returns null immediately (signalling "this is a new parking") when the incoming parking has a non-empty ORIGINAL_ID_KEY value list and no existing parking was found by ID. Proximity matching is only attempted for parkings that arrived without any source identifier, preserving the original fallback behaviour for those cases.

Unit tests

A new integration test parkingsWithDifferentImportedIdsMustNotBeMergedByProximity in MergingParkingImporterTest covers the scenario: two parkings with identical names and coordinates but different importedId values are imported sequentially and asserted to produce two distinct Tiamat records (different netexId, both at version 1).

All existing tests continue to pass.

Documentation

The fix and its rationale are documented in a code comment at the insertion point in MergingParkingImporter.

@teppope

teppope commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

Here's an example of two nearby parking elements that get mixed up by the importer


                <Parking changed="2022-08-15T14:39:02.1" version="1" id="FIN:Parking:liipi-550">
                    <keyList>
                        <KeyValue>
                            <Key>imported-id</Key>
                            <Value>FIN:Parking:liipi-550</Value>
                        </KeyValue>
                    </keyList>
                    <Name lang="fi">Pihtisillantie</Name>
                    <Centroid>
                        <Location>
                            <Longitude>24.360944500000002</Longitude>
                            <Latitude>60.30179875</Latitude>
                        </Location>
                    </Centroid>
                    <alternativeNames>
                        <AlternativeName>
                            <Lang>sv</Lang>
                            <NameType>translation</NameType>
                            <Name lang="sv">Pihtisillantie</Name>
                        </AlternativeName>
                        <AlternativeName>
                            <Lang>en</Lang>
                            <NameType>translation</NameType>
                            <Name lang="en">Pihtisillantie</Name>
                        </AlternativeName>
                    </alternativeNames>
                    <ParentSiteRef ref="FSR:StopPlace:3759"/>
                    <ParkingType>parkAndRide</ParkingType>
                    <ParkingVehicleTypes>car</ParkingVehicleTypes>
                    <ParkingLayout>undefined</ParkingLayout>
                    <TotalCapacity>14</TotalCapacity>
                    <parkingProperties>
                        <ParkingProperties version="1">
                            <spaces>
                                <ParkingCapacity version="1" id="FIN:ParkingCapacity:550-CAR">
                                    <ParkingUserType>allUsers</ParkingUserType>
                                    <ParkingVehicleType>car</ParkingVehicleType>
                                    <NumberOfSpaces>14</NumberOfSpaces>
                                </ParkingCapacity>
                            </spaces>
                        </ParkingProperties>
                    </parkingProperties>
                </Parking>

and


                <Parking changed="2022-08-15T14:39:58.608" version="1" id="FIN:Parking:liipi-1103">
                    <keyList>
                        <KeyValue>
                            <Key>imported-id</Key>
                            <Value>FIN:Parking:liipi-1103</Value>
                        </KeyValue>
                    </keyList>
                    <Name lang="fi">Pihtisillantie</Name>
                    <Centroid>
                        <Location>
                            <Longitude>24.361027072046554</Longitude>
                            <Latitude>60.30181328754482</Latitude>
                        </Location>
                    </Centroid>
                    <alternativeNames>
                        <AlternativeName>
                            <Lang>sv</Lang>
                            <NameType>translation</NameType>
                            <Name lang="sv">Pihtisillantie</Name>
                        </AlternativeName>
                        <AlternativeName>
                            <Lang>en</Lang>
                            <NameType>translation</NameType>
                            <Name lang="en">Pihtisillantie</Name>
                        </AlternativeName>
                    </alternativeNames>
                    <ParentSiteRef ref="FSR:StopPlace:3759"/>
                    <ParkingType>parkAndRide</ParkingType>
                    <ParkingVehicleTypes>pedalCycle</ParkingVehicleTypes>
                    <ParkingLayout>undefined</ParkingLayout>
                    <TotalCapacity>16</TotalCapacity>
                    <parkingProperties>
                        <ParkingProperties version="1">
                            <spaces>
                                <ParkingCapacity version="1" id="FIN:ParkingCapacity:1103-BICYCLE">
                                    <ParkingUserType>allUsers</ParkingUserType>
                                    <ParkingVehicleType>pedalCycle</ParkingVehicleType>
                                    <NumberOfSpaces>16</NumberOfSpaces>
                                </ParkingCapacity>
                            </spaces>
                        </ParkingProperties>
                    </parkingProperties>
                </Parking>

@teppope
teppope requested a review from assadriaz June 25, 2026 11:03
@assadriaz
assadriaz merged commit e253850 into entur:master Jul 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants