Exemplo n.º 1
0
std::string sosicon::ConverterSosi2psql::
getSrid( ISosiElement* sosiTree ) {

    // Path: .HODE/..TRANSPAR/...KOORDSYS
    ISosiElement* head = 0, * transpar = 0, * coordsys = 0;

    sosi::SosiElementSearch srcHead( sosi::sosi_element_head );
    sosi::SosiElementSearch srcTranspar( sosi::sosi_element_transpar );
    sosi::SosiElementSearch srcCoordsys( sosi::sosi_element_coordsys );

    if( sosiTree->getChild( srcHead ) ) {
        head = srcHead.element();
    }
    if( head && head->getChild( srcTranspar ) ) {
        transpar = srcTranspar.element();
    }
    if( transpar && transpar->getChild( srcCoordsys ) ) {
        coordsys = srcCoordsys.element();
    }

    std::string srid;

    if( coordsys ) {
        std::stringstream ss;
        ss << coordsys->getData();
        int sysCode;
        ss >> sysCode;
        sosi::SosiTranslationTable tt;
        sosi::CoordSys cs = tt.sysCodeToCoordSys( sysCode );
        srid = cs.srid();
        std::cout << "Coordinate system: " << cs.displayString() << "\n";
    }
    else {
Exemplo n.º 2
0
void sosicon::ConverterSosiStat::
run() {
    for( std::vector<std::string>::iterator f = mCmd->mSourceFiles.begin(); f != mCmd->mSourceFiles.end(); f++ ) {
        std::cout << "\nGenerating statistics for " << *f << "\n";
        Parser p;
        char ln[ 1024 ];
        std::ifstream ifs( ( *f ).c_str() );
        int c = 0;
        while( !ifs.eof() ) {
            c++;
            if( mCmd->mIsTtyOut && ( c % 100 ) == 0 ) {
                std::cout << "\rParsing " << c << " lines...";
            }
            memset( ln, 0x00, sizeof ln );
            ifs.getline( ln, sizeof ln );
            p.ragelParseSosiLine( ln );
        }
        std::cout << "\n" << c << " lines in file   \n\n";
        p.complete();
        ifs.close();

        ISosiElement* root = p.getRootElement();
        makeStat( root );

        sosi::SosiElementSearch srcHead( sosi::sosi_element_head );
        if( root->getChild( srcHead ) ) {
            sosi::SosiElementSearch srcHeadItem;
            
            printTableHeader( "SOSI HEADER", "VALUE", 22 );
            printElementData( srcHead.element(), sosi::SosiElementSearch(), 22 );
            std::cout << "\n\n";
            
            sosi::SosiElementSearch srcTranspar( sosi::sosi_element_transpar );
            if( srcHead.element()->getChild( srcTranspar ) ) {
                sosi::SosiElementSearch srcTransparItem;
                printTableHeader( "SOSI HEADER/TRANSPAR", "VALUE", 22 );
                printElementData( srcTranspar.element(), sosi::SosiElementSearch(), 22 );
                std::cout << "\n\n";
            }
        }

        printTableHeader( "SOSI ELEMENT", "COUNT", 30 );
        printListContent( mGeoTypes, 30 );
        std::cout << "\n\n";

        printTableHeader( "OBJTYPE", "COUNT", 30 );
        printListContent( mObjTypes, 30 );
        std::cout << "\n\n";

    }
}
Exemplo n.º 3
0
void sosicon::sosi::SosiNorthEast::
initHeadMember( ISosiHeadMember& headMember, ElementType type ) {
    if( !headMember.initialized() ) {
        SosiElementSearch head( sosi_element_head );
        SosiElementSearch transpar( sosi_element_transpar );
        SosiElementSearch target( type );
        ISosiElement* root = mSosiElement->getRoot();
        if( root->getChild( head ) &&
            head.element()->getChild( transpar ) &&
            transpar.element()->getChild( target ) )
        {
            headMember.init( target.element() );
        }
    }
}