TGeoBarrierList

Top  Previous  Next

This class is for checking if spatial searches (TSpatialSearch) intersects with geographical barriers, such as rivers. On the map below the river is simplified as the read dotted line and assures the incident snaps to a road on the Eastern side of the water.

 

geobarrier2

 

 

It is an implementation of TBaseList

 

List item: TGeoBarrier

 

Adds 3 methods:

 

1) AddGeoBarrier(GeoBarrier: TGeoBarrier);

Add as many barriers as you need.

 

2) Intersection(A,B: TFloatPoint): boolean;

Main method for checking if the line between A and B intersects with any of the barriers.

 

3) ReadGeoBarrier(filename: string);

Basic function for adding a barrier from a text file.

Starts with one line with number of points and then one point per line, coordinates are space-delimited, x-y sequence.

For adding multiple barriers this way, you need multiple files.

 

 

Sample code:

 

SS:= TSpatialSearch.create(NW);

skiplinks:= TBitArray.create(NW.LinkCount+1);

SS.SkipLinks:= skiplinks;

 

GBL:= TGeoBarrierList.create;

GBL.ReadGeoBarrier('geobarrier.txt');

 

repeat

 SS.NearestLocation(P,loc,side,distance,Pnew);

 intersect:= GBL.Intersection(P,Pnew);

 if intersect then skiplinks[loc.link]:= true;

until not intersect;