Ejemplo n.º 1
0
OGRErr TigerPolygon::CreateFeature( OGRFeature *poFeature )

{
    char        szRecord[OGR_TIGER_RECBUF_LEN];

/* -------------------------------------------------------------------- */
/*      Write basic data record ("RTA")                                 */
/* -------------------------------------------------------------------- */

    if( !SetWriteModule( "A", psRTAInfo->nRecordLength+2, poFeature ) )
        return OGRERR_FAILURE;

    memset( szRecord, ' ', psRTAInfo->nRecordLength );

    WriteFields( psRTAInfo, poFeature, szRecord );
    WriteRecord( szRecord, psRTAInfo->nRecordLength, "A" );

/* -------------------------------------------------------------------- */
/*      Prepare S record.                                               */
/* -------------------------------------------------------------------- */

    memset( szRecord, ' ', psRTSInfo->nRecordLength );

    WriteFields( psRTSInfo, poFeature, szRecord );
    WriteRecord( szRecord, psRTSInfo->nRecordLength, "S", fpRTS );


    return OGRERR_NONE;
}
Ejemplo n.º 2
0
OGRErr TigerPoint::CreateFeature( OGRFeature *poFeature,
                                  int pointIndex)

{
    char        szRecord[OGR_TIGER_RECBUF_LEN];
    OGRPoint    *poPoint = poFeature->GetGeometryRef()->toPoint();

    if( !SetWriteModule( m_pszFileCode, psRTInfo->nRecordLength+2, poFeature ) )
        return OGRERR_FAILURE;

    memset( szRecord, ' ', psRTInfo->nRecordLength );

    WriteFields( psRTInfo, poFeature, szRecord );

    if( poPoint != nullptr
        && (poPoint->getGeometryType() == wkbPoint
            || poPoint->getGeometryType() == wkbPoint25D) ) {
        WritePoint( szRecord, pointIndex, poPoint->getX(), poPoint->getY() );
    } else {
        if (bRequireGeom) {
            return OGRERR_FAILURE;
        }
    }

    WriteRecord( szRecord, psRTInfo->nRecordLength, m_pszFileCode );

    return OGRERR_NONE;
}
Ejemplo n.º 3
0
OGRErr TigerAltName::CreateFeature( OGRFeature *poFeature )

{
  char        szRecord[OGR_TIGER_RECBUF_LEN];
    const int   *panValue;
    int         nValueCount = 0;

    if( !SetWriteModule( FILE_CODE, psRTInfo->nRecordLength+2, poFeature ) )
        return OGRERR_FAILURE;

    memset( szRecord, ' ', psRTInfo->nRecordLength );

    WriteFields( psRTInfo, poFeature, szRecord );

    panValue = poFeature->GetFieldAsIntegerList( "FEAT", &nValueCount );
    for( int i = 0; i < nValueCount; i++ )
    {
        char    szWork[9];
        
        sprintf( szWork, "%8d", panValue[i] );
        strncpy( szRecord + 18 + 8 * i, szWork, 8 );
    }

    WriteRecord( szRecord, psRTInfo->nRecordLength, FILE_CODE );

    return OGRERR_NONE;
}
OGRErr TigerPolygonCorrections::CreateFeature( OGRFeature *poFeature )

{
    char        szRecord[OGR_TIGER_RECBUF_LEN];

    if( !SetWriteModule( FILE_CODE, psRTBInfo->nRecordLength+2, poFeature ) )
        return OGRERR_FAILURE;

    memset( szRecord, ' ', psRTBInfo->nRecordLength );

    WriteFields( psRTBInfo, poFeature, szRecord);

    WriteRecord( szRecord, psRTBInfo->nRecordLength, FILE_CODE );

    return OGRERR_NONE;
}
Ejemplo n.º 5
0
OGRErr TigerFileBase::CreateFeature( OGRFeature *poFeature )

{
    char        szRecord[OGR_TIGER_RECBUF_LEN];

    if (psRTInfo == NULL)
        return OGRERR_FAILURE;

    if( !SetWriteModule( m_pszFileCode, psRTInfo->nRecordLength+2, poFeature ) )
        return OGRERR_FAILURE;

    memset( szRecord, ' ', psRTInfo->nRecordLength );

    WriteFields( psRTInfo, poFeature, szRecord );

    WriteRecord( szRecord, psRTInfo->nRecordLength, m_pszFileCode );

    return OGRERR_NONE;
}
Ejemplo n.º 6
0
OGRErr TigerCompleteChain::CreateFeature( OGRFeature *poFeature )

{
    char        szRecord[OGR_TIGER_RECBUF_LEN];
    OGRLineString *poLine = (OGRLineString *) poFeature->GetGeometryRef();

    if( poLine == NULL 
        || (poLine->getGeometryType() != wkbLineString
            && poLine->getGeometryType() != wkbLineString25D) )
        return OGRERR_FAILURE;

    /* -------------------------------------------------------------------- */
    /*      Write basic data record ("RT1")                                 */
    /* -------------------------------------------------------------------- */
    if( !SetWriteModule( "1", psRT1Info->nRecordLength+2, poFeature ) )
        return OGRERR_FAILURE;
    memset( szRecord, ' ', psRT1Info->nRecordLength );
    WriteFields( psRT1Info, poFeature, szRecord );
    WritePoint( szRecord, 191, poLine->getX(0), poLine->getY(0) );
    WritePoint( szRecord, 210, 
                poLine->getX(poLine->getNumPoints()-1), 
                poLine->getY(poLine->getNumPoints()-1) );
    WriteRecord( szRecord, psRT1Info->nRecordLength, "1" );

    /* -------------------------------------------------------------------- */
    /*      Write geographic entity codes (RT3)                             */
    /* -------------------------------------------------------------------- */
    if (bUsingRT3) {
      memset( szRecord, ' ', psRT3Info->nRecordLength );
      WriteFields( psRT3Info, poFeature, szRecord );
      WriteRecord( szRecord, psRT3Info->nRecordLength, "3", fpRT3 );
    }

    /* -------------------------------------------------------------------- */
    /*      Write shapes sections (RT2)                                     */
    /* -------------------------------------------------------------------- */
    if( poLine->getNumPoints() > 2 )
    {
        int     nPoints = poLine->getNumPoints();
        int     iPoint, nRTSQ = 1;

        for( iPoint = 1; iPoint < nPoints-1; )
        {
            int         i;
            char        szTemp[5];

            memset( szRecord, ' ', psRT2Info->nRecordLength );

            WriteField( poFeature, "TLID", szRecord, 6, 15, 'R', 'N' );
            
            sprintf( szTemp, "%3d", nRTSQ );
            strncpy( ((char *)szRecord) + 15, szTemp, 4 );

            for( i = 0; i < 10; i++ )
            {
                if( iPoint < nPoints-1 )
                    WritePoint( szRecord, 19+19*i, 
                                poLine->getX(iPoint), poLine->getY(iPoint) );
                else
                    WritePoint( szRecord, 19+19*i, 0.0, 0.0 );

                iPoint++;
            }
            
            WriteRecord( szRecord, psRT2Info->nRecordLength, "2", fpShape );

            nRTSQ++;
        }
    }

    return OGRERR_NONE;
}