コード例 #1
0
ファイル: mitab_imapinfofile.cpp プロジェクト: OSGeo/gdal
/**********************************************************************
 *                   IMapInfoFile::ICreateFeature()
 *
 * Standard OGR CreateFeature implementation.  This method is used
 * to create a new feature in current dataset
 **********************************************************************/
OGRErr     IMapInfoFile::ICreateFeature(OGRFeature *poFeature)
{
    TABFeature *poTABFeature = CreateTABFeature(poFeature);
    if( poTABFeature == nullptr ) /* MultiGeometry */
        return OGRERR_NONE;

    OGRErr eErr = CreateFeature(poTABFeature);
    if( eErr == OGRERR_NONE )
        poFeature->SetFID(poTABFeature->GetFID());

    delete poTABFeature;

    return eErr;
}
コード例 #2
0
ファイル: tabdump.cpp プロジェクト: stievie/Martis
/**********************************************************************
 *                          DumpViaSpatialIndex()
 *
 * Open a .TAB file and print all the geogr. objects that match the 
 * specified filter.  Scanes the file via the spatial index.
 **********************************************************************/
static int DumpViaSpatialIndex(const char *pszFname, 
                               double dXMin, double dYMin, 
                               double dXMax, double dYMax)
{
    IMapInfoFile  *poFile;
    TABFeature *poFeature;

    /*---------------------------------------------------------------------
     * Try to open source file
     *--------------------------------------------------------------------*/
    if ((poFile = IMapInfoFile::SmartOpen(pszFname)) == NULL)
    {
        printf("Failed to open %s\n", pszFname);
        return -1;
    }

    poFile->Dump();

    /*---------------------------------------------------------------------
     * Check for indexed fields
     *--------------------------------------------------------------------*/
    for(int iField=0; iField<poFile->GetLayerDefn()->GetFieldCount(); iField++)
    {
        if (poFile->IsFieldIndexed(iField))
            printf("  Field %d is indexed\n", iField);
    }


    /*---------------------------------------------------------------------
     * Set spatial filter
     *--------------------------------------------------------------------*/
    OGRLinearRing oSpatialFilter;

    oSpatialFilter.setNumPoints(5);
    oSpatialFilter.setPoint(0, dXMin, dYMin);
    oSpatialFilter.setPoint(1, dXMax, dYMin);
    oSpatialFilter.setPoint(2, dXMax, dYMax);
    oSpatialFilter.setPoint(3, dXMin, dYMax);
    oSpatialFilter.setPoint(4, dXMin, dYMin);

    poFile->SetSpatialFilter( &oSpatialFilter );

    /*---------------------------------------------------------------------
     * Read/Dump objects until EOF is reached
     *--------------------------------------------------------------------*/
    while ( (poFeature = (TABFeature*)poFile->GetNextFeature()) != NULL )
    {
//        poFeature->DumpReadable(stdout);
        printf("\nFeature %ld:\n", poFeature->GetFID());
        poFeature->DumpMID();
        poFeature->DumpMIF();
    }

    /*---------------------------------------------------------------------
     * Cleanup and exit.
     *--------------------------------------------------------------------*/
    poFile->Close();

    delete poFile;

    return 0;
}