Files
secondo/Algebras/OSM/Scripts/TuTestNetwork.sec
2026-01-23 17:03:45 +08:00

193 lines
6.2 KiB
Plaintext

################################################################################
### Tests networks from imported OSM data (optional)
################################################################################
### Description:
### - This script tests networks from imported OSM data.
### Please, see tu_osm_import.sh for further details.
###
### Preconditions:
###
### Postconditions:
###
### Author:
### - Thomas Uchdorf, thomas.uchdorf(at)fernuni-hagen.de
################################################################################
# Adding some gpoints for testing purposes
let Spot1 =
point2gpoint(CityNetwork,[const point value(6800.58 51236.37)]);
let Spot2 =
point2gpoint(CityNetwork,[const point value(6775.94 51238.47)]);
#let Spot3 =
# point2gpoint(CityNetwork,[const point value(6783.25 51263.80)]);
# Checking whether the OneWay-Attribute is set correctly
query ExtStreetsRel feed
filter [(.RoadClassRef = 1)
and not(.OneWay = 1)]
consume;
# Testing if any junctions were computed
query (CityJunctions feed count) > 0;
# Checking whether there are duplicate junctions
query ((CityJunctionsTmp feed count) - (CityJunctions feed count)) = 0;
query (CityJunctionsTmp feed
sortby [Road1,Pos1,Road2,Pos2]
groupby [Road1,Pos1,Road2,Pos2; Cnt: group feed count]
filter [.Cnt > 1] count) = 0;
query CityJunctions feed
CityRoads feed {a}
hashjoin[Road1,Road_a,99997]
CityRoads feed {b}
hashjoin[Road2,Road_b,99997]
consume;
# Testing transitions at junctions
# |
# o 8
# |
# o 4
# 5 1 | 3 7
# --o-o--x--o-o--
# |
# o 2
# |
# o 6
# |
delete Spot1;
delete Spot2;
delete Spot3;
delete Spot4;
delete Spot5;
delete Spot6;
delete Spot7;
delete Spot8;
let Spot1 =
point2gpoint(CityNetwork,[const point value(6800.0787 51236.7884)]);
let Spot2 =
point2gpoint(CityNetwork,[const point value(6800.7417 51236.2057)]);
let Spot3 =
point2gpoint(CityNetwork,[const point value(6801.3243 51236.0249)]);
let Spot4 =
point2gpoint(CityNetwork,[const point value(6801.1836 51236.6276)]);
let Spot5 =
point2gpoint(CityNetwork,[const point value(6799.7426 51236.9659)]);
let Spot6 =
point2gpoint(CityNetwork,[const point value(6800.6419 51236.1895)]);
let Spot7 =
point2gpoint(CityNetwork,[const point value(6801.5182 51235.9436)]);
let Spot8 =
point2gpoint(CityNetwork,[const point value(6801.2491 51236.7506)]);
query makearray(
ifthenelse(isdefined(shortest_path(Spot1,Spot3)),1,0),
ifthenelse(isdefined(shortest_path(Spot1,Spot5)),1,0),
ifthenelse(isdefined(shortest_path(Spot1,Spot4)),1,0),
ifthenelse(isdefined(shortest_path(Spot1,Spot2)),1,0),
ifthenelse(isdefined(shortest_path(Spot3,Spot7)),1,0),
ifthenelse(isdefined(shortest_path(Spot3,Spot1)),1,0),
ifthenelse(isdefined(shortest_path(Spot3,Spot4)),1,0),
ifthenelse(isdefined(shortest_path(Spot3,Spot2)),1,0),
ifthenelse(isdefined(shortest_path(Spot2,Spot3)),1,0),
ifthenelse(isdefined(shortest_path(Spot2,Spot1)),1,0),
ifthenelse(isdefined(shortest_path(Spot2,Spot4)),1,0),
ifthenelse(isdefined(shortest_path(Spot2,Spot6)),1,0),
ifthenelse(isdefined(shortest_path(Spot4,Spot3)),1,0),
ifthenelse(isdefined(shortest_path(Spot4,Spot1)),1,0),
ifthenelse(isdefined(shortest_path(Spot4,Spot8)),1,0),
ifthenelse(isdefined(shortest_path(Spot4,Spot2)),1,0));
query CityRoads feed filter [(.Road = 1) or (.Road = 22)] consume
query CityJunctions feed filter [(.Road1 = 1) and (.Road2 = 22)] consume
let CityNetwork = thenetwork(
1,
1.0,
(CityRoads feed filter [(.Road = 1) or (.Road = 22)]
project [Road, Length, Geometry, Dual, StartsSmaller]
consume),
(CityJunctions feed filter [(.Road1 = 1) and (.Road2 = 22)] consume));
# Playing around
let CityNetwork = thenetwork(
1,
1.0,
(CityRoads feed filter [(.Road = 1) or (.Road = 22)]
projectextend [Road, Length, Geometry; Dual: TRUE, StartsSmaller: .StartsSmaller]
consume),
(CityJunctions feed filter [(.Road1 = 1) and (.Road2 = 22)]
remove [NewJunctionType] extend [NewJunctionType: 1911]
consume));
# adjacent sections starting at lower part of A in opposite direction in
# respect to the junction
# (should return nothing - street ends)
query sections(CityNetwork)
feed project [Sid,Curve] {a}
getAdjacentSections(CityNetwork,1,FALSE)
hashjoin [Sid_a,SecID,99997]
consume;
# adjacent sections starting at lower part of A
# (should return
# 1 FALSE [AUP->ADOWN], 2 TRUE [AUP->AUP], 4 TRUE[AUP->BUP])
query sections(CityNetwork)
feed project [Sid,Curve] {a}
getAdjacentSections(CityNetwork,1,TRUE)
hashjoin [Sid_a,SecID,99997]
consume;
# adjacent sections starting at upper part of A
# (should return
# 1 FALSE [ADOWN->ADOWN], 2 TRUE [ADOWN->AUP], 4 TRUE [ADOWN->BUP])
query sections(CityNetwork)
feed project [Sid,Curve] {a}
getAdjacentSections(CityNetwork,2,FALSE)
hashjoin [Sid_a,SecID,99997]
consume;
# adjacent sections starting at upper part of A in opposite direction in
# respect to the junction
# (should return nothing - street ends)
query sections(CityNetwork)
feed project [Sid,Curve] {a}
getAdjacentSections(CityNetwork,2,TRUE)
hashjoin [Sid_a,SecID,99997]
consume;
# adjacent sections starting at lower part of B in opposite direction in
# respect to the junction
# (should return nothing - street ends)
query sections(CityNetwork)
feed project [Sid,Curve] {a}
getAdjacentSections(CityNetwork,3,FALSE)
hashjoin [Sid_a,SecID,99997]
consume;
# adjacent sections starting at lower part of B
# (should return
# 1 FALSE [BUP->ADOWN], 2 TRUE [BUP->AUP], 4 TRUE[BUP->BUP]) WRONG!!!
query sections(CityNetwork)
feed project [Sid,Curve] {a}
getAdjacentSections(CityNetwork,3,TRUE)
hashjoin [Sid_a,SecID,99997]
consume;
# adjacent sections starting at upper part of B
# (should return nothing - oneway-street) WRONG!!!
query sections(CityNetwork)
feed project [Sid,Curve] {a}
getAdjacentSections(CityNetwork,4,FALSE)
hashjoin [Sid_a,SecID,99997]
consume;
# adjacent sections starting at upper part of B in opposite direction in
# respect to the junction
# (should return nothing - street ends)
query sections(CityNetwork)
feed project [Sid,curve] {a}
getAdjacentSections(CityNetwork,4,TRUE)
hashjoin [Sid_a,SecID,99997]
consume;