/* ---- 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 for Creating Bus network::Network July, 2011 Jianqiu xu [TOC] 1 Overview 2 Defines and includes */ #ifndef Road_Network_H #define Road_Network_H #include "Algebra.h" #include "NestedList.h" #include "QueryProcessor.h" #include "Algebras/RTree/RTreeAlgebra.h" #include "Algebras/BTree/BTreeAlgebra.h" #include "Algebras/Temporal/TemporalAlgebra.h" #include "StandardTypes.h" #include "LogMsg.h" #include "NList.h" #include "Algebras/Relation-C++/RelationAlgebra.h" #include "ListUtils.h" #include "Algebras/Network/NetworkAlgebra.h" #include "Algebras/Spatial/SpatialAlgebra.h" #include #include #include #include #include "Attribute.h" #include "Tools/Flob/DbArray.h" #include "Tools/Flob/Flob.h" #include "WinUnix.h" #include "AvlTree.h" #include "Symbols.h" #include "Partition.h" #include "PaveGraph.h" #include "GeneralType.h" struct GP_Point; ///////////////////////////////////////////////////////////////////////// ///////////////////road network::Network graph/////////////////////////// ///////////////////////////////////////////////////////////////////////// /* a node corresponds to a junction two junctions are connected by (1) the same location on space (2) route segments of one route (the two junctions belong to one route) at this movement (2011.7.26) we assume each road has both up and down directions so that for a network::GPoint it can go either direction along the route. but it is no problem to extend that if network::GPoint has up or down value, then only one direction is available */ class RoadGraph{ public: RoadGraph(); RoadGraph(ListExpr in_xValue,int in_iErrorPos, ListExpr& inout_xErrorInfo, bool& inout_bCorrect); RoadGraph(SmiRecord&, size_t&, const ListExpr); ~RoadGraph(); static std::string RGNodeTypeInfo; static std::string RGBTreeNodeTypeInfo; static std::string RGEdgeTypeInfo1; static std::string RGEdgeTypeInfo2; enum RG_NODE{RG_JUN_ID, RG_JUN_GP, RG_JUN_P, RG_ROAD_ID}; enum RG_EDGE1{RG_JUN1, RG_JUN2}; enum RG_EDGE2{RG_JUN_1, RG_JUN_2, RG_PATHA1, RG_PATH2}; static ListExpr RoadGraphProp(); static bool CheckRoadGraph(ListExpr type, ListExpr& errorInfo); static int SizeOfRoadGraph(); static void* CastRoadGraph(void* addr); static Word CloneRoadGraph(const ListExpr typeInfo, const Word& w); static void CloseRoadGraph(const ListExpr typeInfo, Word& w); static Word CreateRoadGraph(const ListExpr typeInfo); static void DeleteRoadGraph(const ListExpr typeInfo, Word& w); static bool SaveRoadGraph(SmiRecord& valueRecord, size_t& offset, const ListExpr typeInfo, Word& value); bool Save(SmiRecord& in_xValueRecord,size_t& inout_iOffset, const ListExpr in_xTypeInfo); static bool OpenRoadGraph(SmiRecord& valueRecord, size_t& offset, const ListExpr typeInfo, Word& value); static RoadGraph* Open(SmiRecord& valueRecord,size_t& offset, const ListExpr typeInfo); static Word InRoadGraph(ListExpr in_xTypeInfo, ListExpr in_xValue, int in_iErrorPos, ListExpr& inout_xErrorInfo, bool& inout_bCorrect); static ListExpr OutRoadGraph(ListExpr typeInfo, Word value); ListExpr Out(ListExpr typeInfo); unsigned int GetRG_ID(){return rg_id;} void Load(int, Relation*, Relation*, Relation*); void LoadEdge1(Relation* rel); void LoadEdge2(Relation* rel); Relation* GetNode_Rel(){return node_rel;} Relation* GetEdge_Rel1(){return edge_rel1;} Relation* GetEdge_Rel2(){return edge_rel2;} void FindAdj1(int node_id, std::vector& list); void FindAdj2(int node_id, std::vector& list); void GetJunctionsNode(int rid, std::vector& res_list); private: unsigned int rg_id;//road graph id Relation* node_rel;//node relation BTree* btree_node; Relation* edge_rel1; DbArray adj_list1; DbArray entry_adj_list1; Relation* edge_rel2; DbArray adj_list2; DbArray entry_adj_list2; }; /* for shortest path searching in road graph */ struct RNPath_elem:public Path_elem{ double weight; double real_w; network::RouteInterval ri; bool len; //same spatial location or not Point to_loc; RNPath_elem(){} RNPath_elem(int p, int c, int t, double w1, double w2, network::RouteInterval& i, bool b, Point loc):Path_elem(p, c, t), weight(w1), real_w(w2), ri(i), len(b), to_loc(loc){} RNPath_elem(const RNPath_elem& wp):Path_elem(wp), weight(wp.weight),real_w(wp.real_w), ri(wp.ri), len(wp.len), to_loc(wp.to_loc){} RNPath_elem& operator=(const RNPath_elem& wp) { Path_elem::operator=(wp); weight = wp.weight; real_w = wp.real_w; ri = wp.ri; len = wp.len; to_loc = wp.to_loc; return *this; } bool operator<(const RNPath_elem& ip) const { return weight > ip.weight; } void Print() { cout<<" tri_index " < path_list; std::vector gline_list; std::vector jun_list1; std::vector jun_list2; std::vector type_list; unsigned int count; TupleType* resulttype; RoadNav(){count = 0; resulttype = NULL;} ~RoadNav(){if(resulttype != NULL) resulttype->DeleteIfAllowed();} void GenerateRoadLoc(network::Network* rn, int no, std::vector& gp_list, std::vector& gp_loc_list); void ShortestPath(network::GPoint*, network::GPoint*, RoadGraph*, network::Network*, network::GLine* res); void ShortestPathSub(network::GPoint*, network::GPoint*, RoadGraph*, network::Network*, network::GLine* res); void ShortestPath2(network::GPoint*, network::GPoint*, RoadGraph*, network::Network*, network::GLine* res); void ShortestPathSub2(network::GPoint*, network::GPoint*, RoadGraph*, network::Network*, network::GLine* res); void DFTraverse(network::Network* rn, R_Tree<2,TupleId>* rtree, SmiRecordId adr, SimpleLine* line, std::vector& id_list); void ShortestPathSub3(network::GPoint*, network::GPoint*, RoadGraph*, network::Network*, network::GLine* res); void GetAdjNodeRG(RoadGraph* rg, int nodeid); }; #define LOOP_PRINT1(s) for(unsigned int i = 0; i < s.size();i++){ \ cout<