Files
secondo/bin/Scripts/Network_CreateObjects.SEC
2026-01-23 17:03:45 +08:00

214 lines
10 KiB
Plaintext

################################################################################
## File: CreateNetwork Objects #################################################
################################################################################
## This file is part of SECONDO. ##
## ##
## Copyright (C) 2010, University in Hagen, Faculty of Mathematics and ##
## Computer Science, Database Systems for New Applications. ##
## ##
## SECONDO is free software; you can redistribute it and/or modify ##
## it under the terms of the GNU General Public License as published by ##
## the Free Software Foundation; either version 2 of the License, or ##
## (at your option) any later version. ##
## ##
## SECONDO is distributed in the hope that it will be useful, ##
## but WITHOUT ANY WARRANTY; without even the implied warranty of ##
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##
## GNU General Public License for more details. ##
## ##
## You should have received a copy of the GNU General Public License ##
## along with SECONDO; if not, write to the Free Software ##
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ##
################################################################################
# This file performs translates the spatial and spatio-temporal data objects #
# of the BerlinMOD benchmark in the Secondo DBMS into their network data #
# model representation and builds the aCCording indexes. #
# #
# It is assumed that there is a database berlinmod with the data objects #
# created by the BerlinMOD_DataGenerator.SEC script. #
# #
################################################################################
# #
# Open Database Berlinmod #
# #
################################################################################
open database berlinmod;
################################################################################
# #
# Build a Network From Streets Data. #
# #
################################################################################
let B_Routes =
streets feed projectextendstream[; GeoData: .GeoData polylines[TRUE]]
addcounter[Id,1]
projectextend [Id; Lengt : size(.GeoData), Geometry: fromline(.GeoData), Dual: TRUE, StartSmaller: TRUE]
consume;
let B_Junctions =
B_Routes feed {r1}
B_Routes feed {r2}
symmjoin [(.Id_r1 < ..Id_r2) and (.Geometry_r1 intersects ..Geometry_r2)]
projectextendstream[Id_r1, Geometry_r1, Id_r2, Geometry_r2; CROSSING_POINT: components(crossings(.Geometry_r1, .Geometry_r2))]
projectextend[; R1Id: .Id_r1, R1meas: atpoint(.Geometry_r1, .CROSSING_POINT, TRUE), R2Id: .Id_r2, R2meas: atpoint(.Geometry_r2, .CROSSING_POINT, TRUE), CC: 65535]
consume;
let B_NETWORK = thenetwork(1, 1.0,B_Routes, B_Junctions);
################################################################################
# #
# Translate Trips into Network Representation #
# #
################################################################################
let dataSNcar = dataScar feed
projectextend[Licence, Model, Type; Trip: mpoint2mgpoint(B_NETWORK, .Trip)]
consume;
let dataMNtrip =
dataMtrip feed
projectextend [Moid; Trip: mpoint2mgpoint(B_NETWORK, .Trip)]
consume;
################################################################################
# #
# Translate QueryPoint Set into Newtork Representation #
# #
################################################################################
let QueryPointsNet =
QueryPoints feed
projectextend[Id; Pos: point2gpoint(B_NETWORK, .Pos)]
projectextendstream[Id; Pos: polygpoints(.Pos, B_NETWORK)]
consume;
let QueryPoints1Net =
QueryPoints feed head[10]
projectextend[Id; Pos: point2gpoint(B_NETWORK, .Pos)]
projectextendstream[Id; Pos: polygpoints(.Pos, B_NETWORK)]
consume;
################################################################################
# #
# Translate QueryRegions into Network Representation #
# #
################################################################################
let routesline =
components(routes(B_NETWORK) feed
projectextend[;Curve: toline(.Curve)]
aggregateB[Curve; fun(L1: line, L2: line) union_new(L1, L2); [const line value()]])
transformstream
extend[NoSeg: no_segments(.Elem)]
sortby [NoSeg desc]
extract [Elem];
let QRlines =
QueryRegions feed
projectextend [Id; Lr: intersection_new(.Region, routesline)]
consume;
let QueryRegionsNet =
QRlines feed
projectextend[Id; Region: line2gline(B_NETWORK, .Lr)]
consume;
################################################################################
# #
# Build Network Indexes #
# #
################################################################################
# #
# B-Tree indexes for licences in dataScar, and dataMtrip, and for moIds in #
# dataMcar and dataMNtrip. #
# #
################################################################################
derive dataSNcar_Licence_btree = dataSNcar createbtree[Licence];
derive dataMcar_Licence_btree = dataMcar createbtree[Licence];
derive dataMcar_Moid_btree = dataMcar createbtree[Moid];
derive dataMNtrip_Moid_btree = dataMNtrip createbtree[Moid];
################################################################################
# #
# Temporal Network Position Indexes (TNPI) and Network Position Indexes (NPI) #
# for dataMNtrip and dataSNcar #
# #
################################################################################
derive dataSNcar_BoxNet_timespace =
dataSNcar feed
extend[TID: tupleid(.)]
projectextendstream[TID; UTrip: units(.Trip)]
extend[Box: unitbox(.UTrip)]
sortby[Box asc]
bulkloadrtree[Box];
derive dataMNtrip_BoxNet_timespace =
dataMNtrip feed
extend[TID: tupleid(.)]
projectextendstream[TID; UTrip: units(.Trip)]
extend[Box: unitbox(.UTrip)]
sortby[Box asc]
bulkloadrtree[Box];
derive dataSNcar_TrajBoxNet =
dataSNcar feed
extend[TID: tupleid(.)]
projectextendstream[TID; Box: routeintervals(trajectory(.Trip))]
sortby [Box asc]
bulkloadrtree[Box];
derive dataMNtrip_TrajBoxNet =
dataMNtrip feed
extend[TID: tupleid(.)]
projectextendstream[TID; Box: routeintervals(trajectory(.Trip))]
sortby [Box asc]
bulkloadrtree[Box];
################################################################################
# #
# Spatio-Temporal Index for dataMNtrip #
# #
################################################################################
derive dataMNtrip_SpatioTemp =
dataMNtrip feed
extend[TID: tupleid(.)]
projectextend[TID; Box: mgpbbox(.Trip)]
sortby [Box asc]
bulkloadrtree[Box];
################################################################################
# #
# Often used Query Object Relations #
# #
################################################################################
let QueryLicences1 = QueryLicences feed head[10] consume;
let QueryLicences2 = QueryLicences feed head[20] filter [.Id > 10] consume;
let QueryPeriods1 = QueryPeriods feed head[10] consume;
let QueryInstant1 = QueryInstants feed head[10] consume;
let QueryRegions1Net = QueryRegionsNet feed head[10] consume;
################################################################################
# #
# Creation Finished Close Database #
# #
################################################################################
close database;