In fact, just breaking the problem down into separate data structures (tables) this way might clarify what the algorithm needs to do, whether or not you actually end up using an RDBMS.
It may be sufficient just to have the set of X,Y points as a unified data structure, with info on which road-chunk(s) each point belongs to; joining the road chunks is now just a matter of determining, for each point, how many road chunks contain it, and whether two (or more?) chunks have a given point as a terminus.
In other words, you started with an array of chunks, with each chunk containing an array of points -- try making a different structure the other way around: an array of points, and each one cites one or more road-chunks that it is a part of. This would be easiest if the point array is actually a hash, keyed by the X,Y coordinates.
None of that is tested, but I hope it might be helpful.my %pointdata; my @chunkends; for ( my $i=0; $i<@data; $i++ ) # road-chunks { for ( my $j=0; $j<@{$data[$i]; $j++ ) # points in a chunk { my $key = join(",",$data[$i][$j]->{X},$data[$i][$j]->{Y}); push @{$pointdata{$key}}, sprintf("%5.5d:%5.5d",$i,$j); $chunkends[$i] = $key if ( $j == 0 ); } $chunkends[$i] .= "-$key"; } # Now the %pointdata array contains all the information # about junctures between chunks (these not necessarily # all end-point junctures -- perhaps some road chunks could # intersect at the mid-points?) Also, the @chunkends array # cites the %pointdata keys for the endpoints of each chunk; # if you only want to find end-point junctures, identify the # %pointdata keys with multi-element entries and grep for # each one among the strings in @chunkends.
In reply to Re: AoA data merging
by graff
in thread AoA data merging
by jasonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |