pgRouting

Changeset 210

Show
Ignore:
Timestamp:
09/01/08 17:13:20 (3 months ago)
Author:
anton
Message:

osm2pgrouting: onewaystreets support added

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/osm2pgrouting/trunk/src/Export2DB.cpp

    r207 r210  
    7070        PGresult *result = PQexec(mycon, "CREATE TABLE nodes (ID integer PRIMARY KEY,  lon decimal(11,8), lat decimal(11,8), numOfUse smallint);"); 
    7171        std::cout << "Nodes table created" << std::endl; 
    72         result = PQexec(mycon, "CREATE TABLE ways (gid integer, class_id integer, cost double precision, name char(200), x1 double precision, y1 double precision, x2 double precision,y2 double precision, PRIMARY KEY(gid)); SELECT AddGeometryColumn('ways','the_geom',4326,'MULTILINESTRING',2);"); 
     72        result = PQexec(mycon, "CREATE TABLE ways (gid integer, class_id integer, length double precision, name char(200), x1 double precision, y1 double precision, x2 double precision,y2 double precision, reverse_cost double precision,rule text, to_cost double precision, PRIMARY KEY(gid)); SELECT AddGeometryColumn('ways','the_geom',4326,'MULTILINESTRING',2);"); 
    7373        std::cout << "Ways table created" << std::endl; 
    7474        result = PQexec(mycon, "CREATE TABLE types (id integer, name char(200));"); 
     
    106106void Export2DB::exportWay(Way* way) 
    107107{ 
    108         std::string query = "INSERT into ways(gid, class_id, cost, x1, y1, x2, y2, the_geom"; 
     108        std::string query = "INSERT into ways(gid, class_id, length, x1, y1, x2, y2, the_geom, reverse_cost"; 
    109109        if(!way->name.empty()) 
    110110                query+=", name"; 
     
    115115                 + boost::lexical_cast<std::string>(way->m_NodeRefs.back()->lon)  + ","+ boost::lexical_cast<std::string>(way->m_NodeRefs.back()->lat) + ","; 
    116116        query+="GeometryFromText('" + way->geom +"', 4326)"; 
     117 
     118        if(way->oneway) 
     119        { 
     120            query+=", "+ boost::lexical_cast<std::string>(way->length*1000000); 
     121        } 
     122        else 
     123        { 
     124            query+=", "+ boost::lexical_cast<std::string>(way->length); 
     125        }        
     126 
    117127        if(!way->name.empty()) 
    118128                query+=",$$"+ way->name +"$$"; 
    119129        query+=");"; 
    120 //             std::cout << query <<std::endl; 
     130               //std::cout << query <<std::endl; 
    121131        PGresult *result = PQexec(mycon, query.c_str()); 
    122132} 
  • tools/osm2pgrouting/trunk/src/OSMDocument.cpp

    r206 r210  
    8888                        splitted_way->type=currentWay->type; 
    8989                        splitted_way->clss=currentWay->clss; 
     90                        splitted_way->oneway=currentWay->oneway; 
    9091 
    9192        //GeometryFromText('MULTILINESTRING(('||x1||' '||y1||','||x2||' '||y2||'))',4326); 
  • tools/osm2pgrouting/trunk/src/OSMDocumentParserCallback.cpp

    r198 r210  
    107107                                        m_pActWay->name = v; 
    108108                                } 
     109                                else if( m_pActWay && k.compare("oneway")==0 ) 
     110                                { 
     111                                        m_pActWay->oneway = true;                                        
     112                                        std::cout<<"Edge "<<m_pActWay->id<<" is oneway"<<std::endl; 
     113 
     114                                } 
     115                                 
    109116                                //else if( m_pActWay && k.compare("highway")==0 ) 
    110117                                else if( m_pActWay && m_rDocument.m_rConfig.m_Types.count(k) ) 
  • tools/osm2pgrouting/trunk/src/Way.cpp

    r189 r210  
    3030        id(id), 
    3131        visible(visible), 
    32         length(0) 
     32        length(0), 
     33        oneway(false) 
    3334{ 
    3435} 
  • tools/osm2pgrouting/trunk/src/Way.h

    r198 r210  
    6868        std::string geom; 
    6969        //! length of the street 
     70 
    7071        double length; 
     72        bool oneway; 
     73 
    7174public: 
    7275        /**