243 lines
5.6 KiB
C++
243 lines
5.6 KiB
C++
/*
|
|
----
|
|
This file is part of SECONDO.
|
|
|
|
Copyright (C) 2004, University in Hagen, Department of 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
|
|
----
|
|
|
|
//paragraph [1] Title: [{\Large \bf \begin {center}] [\end {center}}]
|
|
//[TOC] [\tableofcontents]
|
|
|
|
[1] Header File of the Transportation Mode Algebra
|
|
|
|
March, 2011 Jianqiu xu
|
|
|
|
[TOC]
|
|
|
|
1 Overview
|
|
|
|
2 Defines and includes
|
|
|
|
*/
|
|
|
|
#include "BusNetwork.h"
|
|
#include "QueryTM.h"
|
|
|
|
using namespace network;
|
|
|
|
/*
|
|
convert a genrange object to a 2D line in space or 3D line in a building
|
|
|
|
*/
|
|
void QueryTM::GetLineOrLine3D(GenRange* gr, Space* sp)
|
|
{
|
|
BusNetwork* bn = sp->LoadBusNetwork(IF_BUSNETWORK);
|
|
|
|
for(int i = 0;i < gr->Size();i++){
|
|
Line l(0);
|
|
GenRangeElem grelem;
|
|
gr->Get( i, grelem, l);
|
|
int infra_type = sp->GetInfraType(grelem.oid);
|
|
|
|
switch(infra_type){
|
|
case IF_LINE:
|
|
// cout<<"road network "<<endl;
|
|
GetLineInRoad(grelem.oid, &l, sp);
|
|
break;
|
|
|
|
case IF_REGION:
|
|
// cout<<"region based outdoor"<<endl;
|
|
GetLineInRegion(grelem.oid, &l, sp);
|
|
break;
|
|
|
|
case IF_FREESPACE:
|
|
// cout<<"free space"<<endl;
|
|
GetLineInFreeSpace(&l);
|
|
break;
|
|
|
|
case IF_BUSNETWORK:
|
|
// cout<<"bus network"<<endl;
|
|
GetLineInBusNetwork(grelem.oid, &l, bn);
|
|
break;
|
|
|
|
case IF_GROOM:
|
|
// cout<<"indoor "<<endl;
|
|
GetLineInGRoom(grelem.oid, &l, sp);
|
|
break;
|
|
|
|
default:
|
|
assert(false);
|
|
break;
|
|
}
|
|
}
|
|
|
|
sp->CloseBusNetwork(bn);
|
|
|
|
}
|
|
|
|
/*
|
|
get the overall line in road network
|
|
|
|
*/
|
|
void QueryTM::GetLineInRoad(int oid, Line* l, Space* sp)
|
|
{
|
|
Network* rn = sp->LoadRoadNetwork(IF_LINE);
|
|
Tuple* route_tuple = rn->GetRoute(oid);
|
|
SimpleLine* sl = (SimpleLine*)route_tuple->GetAttribute(ROUTE_CURVE);
|
|
Rectangle<2> bbox = sl->BoundingBox();
|
|
route_tuple->DeleteIfAllowed();
|
|
sp->CloseRoadNetwork(rn);
|
|
|
|
Line* newl = new Line(0);
|
|
newl->StartBulkLoad();
|
|
|
|
int edgeno = 0;
|
|
for(int i = 0;i < l->Size();i++){
|
|
HalfSegment hs1;
|
|
l->Get(i, hs1);
|
|
if(!hs1.IsLeftDomPoint())continue;
|
|
Point lp = hs1.GetLeftPoint();
|
|
Point rp = hs1.GetRightPoint();
|
|
Point newlp(true, lp.GetX() + bbox.MinD(0), lp.GetY() + bbox.MinD(1));
|
|
Point newrp(true, rp.GetX() + bbox.MinD(0), rp.GetY() + bbox.MinD(1));
|
|
HalfSegment hs2(true, newlp, newrp);
|
|
hs2.attr.edgeno = edgeno++;
|
|
*newl += hs2;
|
|
hs2.SetLeftDomPoint(!hs2.IsLeftDomPoint());
|
|
*newl += hs2;
|
|
}
|
|
|
|
newl->EndBulkLoad();
|
|
|
|
line_list1.push_back(*newl);
|
|
newl->DeleteIfAllowed();
|
|
|
|
/* Line3D* l3d = new Line3D(0);
|
|
line3d_list.push_back(*l3d);
|
|
delete l3d;*/
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
get the overall line in region based outdoor
|
|
|
|
*/
|
|
void QueryTM::GetLineInRegion(int oid, Line* l, Space* sp)
|
|
{
|
|
Pavement* pm = sp->LoadPavement(IF_REGION);
|
|
DualGraph* dg = pm->GetDualGraph();
|
|
Rectangle<2> bbox = dg->rtree_node->BoundingBox();
|
|
pm->CloseDualGraph(dg);
|
|
sp->ClosePavement(pm);
|
|
|
|
Line* newl = new Line(0);
|
|
newl->StartBulkLoad();
|
|
|
|
int edgeno = 0;
|
|
for(int i = 0;i < l->Size();i++){
|
|
HalfSegment hs1;
|
|
l->Get(i, hs1);
|
|
if(!hs1.IsLeftDomPoint())continue;
|
|
Point lp = hs1.GetLeftPoint();
|
|
Point rp = hs1.GetRightPoint();
|
|
Point newlp(true, lp.GetX() + bbox.MinD(0), lp.GetY() + bbox.MinD(1));
|
|
Point newrp(true, rp.GetX() + bbox.MinD(0), rp.GetY() + bbox.MinD(1));
|
|
HalfSegment hs2(true, newlp, newrp);
|
|
hs2.attr.edgeno = edgeno++;
|
|
*newl += hs2;
|
|
hs2.SetLeftDomPoint(!hs2.IsLeftDomPoint());
|
|
*newl += hs2;
|
|
}
|
|
|
|
newl->EndBulkLoad();
|
|
|
|
line_list1.push_back(*newl);
|
|
newl->DeleteIfAllowed();
|
|
|
|
// Line3D* l3d = new Line3D(0);
|
|
// line3d_list.push_back(*l3d);
|
|
// delete l3d;
|
|
|
|
}
|
|
|
|
/*
|
|
get the overall line in free space
|
|
|
|
*/
|
|
void QueryTM::GetLineInFreeSpace(Line* l)
|
|
{
|
|
line_list1.push_back(*l);
|
|
|
|
// Line3D* l3d = new Line3D(0);
|
|
// line3d_list.push_back(*l3d);
|
|
// delete l3d;
|
|
|
|
}
|
|
|
|
/*
|
|
get the overall line in bus network. oid corresponds to a bus route
|
|
|
|
*/
|
|
void QueryTM::GetLineInBusNetwork(int oid, Line* l, BusNetwork* bn)
|
|
{
|
|
SimpleLine br_sl(0);
|
|
bn->GetBusRouteGeoData(oid, br_sl);
|
|
Rectangle<2> bbox = br_sl.BoundingBox();
|
|
Line* newl = new Line(0);
|
|
newl->StartBulkLoad();
|
|
|
|
int edgeno = 0;
|
|
for(int i = 0;i < l->Size();i++){
|
|
HalfSegment hs1;
|
|
l->Get(i, hs1);
|
|
if(!hs1.IsLeftDomPoint())continue;
|
|
Point lp = hs1.GetLeftPoint();
|
|
Point rp = hs1.GetRightPoint();
|
|
Point newlp(true, lp.GetX() + bbox.MinD(0), lp.GetY() + bbox.MinD(1));
|
|
Point newrp(true, rp.GetX() + bbox.MinD(0), rp.GetY() + bbox.MinD(1));
|
|
HalfSegment hs2(true, newlp, newrp);
|
|
hs2.attr.edgeno = edgeno++;
|
|
*newl += hs2;
|
|
hs2.SetLeftDomPoint(!hs2.IsLeftDomPoint());
|
|
*newl += hs2;
|
|
}
|
|
|
|
newl->EndBulkLoad();
|
|
|
|
line_list1.push_back(*newl);
|
|
newl->DeleteIfAllowed();
|
|
|
|
/* Line3D* l3d = new Line3D(0);
|
|
line3d_list.push_back(*l3d);
|
|
delete l3d;*/
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
get the overall line for indoor environment (line3D)
|
|
|
|
*/
|
|
void QueryTM::GetLineInGRoom(int oid, Line* l, Space* sp)
|
|
{
|
|
// cout<<"indoor not implemented"<<endl;
|
|
|
|
}
|
|
|