Changeset 19434


Ignore:
Timestamp:
Apr 16, 2010 10:00:30 PM (6 years ago)
Author:
winkey
Message:

remove random read/write methods on laers and alter testcapability to reflect the change
make synctodisk do nothing

Location:
sandbox/winkey/libkml/gdal/ogr/ogrsf_frmts/libkml
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sandbox/winkey/libkml/gdal/ogr/ogrsf_frmts/libkml/ogr_libkml.h

    r19424 r19434  
    9191    OGRFeatureDefn           *GetLayerDefn (  ) { return m_poOgrFeatureDefn; };
    9292    //OGRErr                    SetAttributeFilter (const char * );
    93     OGRErr                    SetNextByIndex ( long nIndex );
    94     OGRFeature               *GetFeature ( long nFID );
    95     OGRErr                    SetFeature ( OGRFeature * poFeature );
    9693    OGRErr                    CreateFeature ( OGRFeature * poOgrFeat );
    97     OGRErr                    DeleteFeature ( long nFID );
    9894
    9995    OGRSpatialReference      *GetSpatialRef (  ) { return m_poOgrSRS; };
  • sandbox/winkey/libkml/gdal/ogr/ogrsf_frmts/libkml/ogrlibkmllayer.cpp

    r19424 r19434  
    285285    OGRFeature *poOgrFeature = NULL;
    286286
    287 #warning perhaps we need an array of idexes that contain actual placemarks
    288 
    289287    do {
    290288        if ( iFeature >= nFeatures )
     
    301299            kml2feat ( AsPlacemark ( poKmlFeature ), m_poOgrDS, this,
    302300                       m_poOgrFeatureDefn );
    303         poOgrFeature->SetFID ( iFeature );
    304301    }
    305302
     
    308305
    309306/******************************************************************************
    310  SetNextByIndex
    311 
    312  Args:          nIndex      the inex to set the next feature to
    313  
    314  Returns:       OGRERR_NONE
    315                
    316 ******************************************************************************/
    317 
    318 OGRErr OGRLIBKMLLayer::SetNextByIndex (
    319     long nIndex )
    320 {
    321     iFeature = nIndex;
    322 
    323     return OGRERR_NONE;
    324 }
    325 
    326 /******************************************************************************
    327  method to get a feature on a layer by its FID
    328 
    329  Args:          nFID    the FID of the feature to get
    330  
    331  Returns:       pointer to the feature, or NULL if it does not exist
    332                
    333 ******************************************************************************/
    334 
    335 OGRFeature *OGRLIBKMLLayer::GetFeature (
    336     long nFID )
    337 {
    338 
    339     SetNextByIndex ( nFID );
    340 
    341     OGRFeature *poOgrFeature = GetNextFeature (  );
    342 
    343     return poOgrFeature;
    344 }
    345 
    346 /******************************************************************************
    347  method to rewrite a feature on a layer
    348 
    349  Args:          poFeature   the feature to rewrite
    350  
    351  Returns:       OGRERR_UNSUPPORTED_OPERATION
    352                
    353 ******************************************************************************/
    354 
    355 OGRErr OGRLIBKMLLayer::SetFeature (
    356     OGRFeature * poFeature )
    357 {
     307 method to add a feature to a layer
     308
     309 Args:          poOgrFeat   pointer to the feature to add
     310 
     311 Returns:       OGRERR_NONE, or OGRERR_UNSUPPORTED_OPERATION of the layer is
     312                not writeable
     313               
     314******************************************************************************/
     315
     316OGRErr OGRLIBKMLLayer::CreateFeature (
     317    OGRFeature * poOgrFeat )
     318{
     319
    358320    if ( !bUpdate )
    359321        return OGRERR_UNSUPPORTED_OPERATION;
    360322
    361 
    362 #warning we need to figure this out
     323    PlacemarkPtr poKmlPlacemark =
     324        feat2kml ( m_poOgrDS, this, poOgrFeat, m_poOgrDS->GetKmlFactory (  ) );
     325
     326    m_poKmlLayer->add_feature ( poKmlPlacemark );
    363327
    364328    /***** mark the layer as updated *****/
     
    367331    m_poOgrDS->Updated (  );
    368332
    369     return OGRERR_UNSUPPORTED_OPERATION;
    370 }
    371 
    372 /******************************************************************************
    373  method to add a feature to a layer
    374 
    375  Args:          poOgrFeat   pointer to the feature to add
    376  
    377  Returns:       OGRERR_NONE, or OGRERR_UNSUPPORTED_OPERATION of the layer is
    378                 not writeable
    379                
    380 ******************************************************************************/
    381 
    382 OGRErr OGRLIBKMLLayer::CreateFeature (
    383     OGRFeature * poOgrFeat )
    384 {
    385 
    386     if ( !bUpdate )
    387         return OGRERR_UNSUPPORTED_OPERATION;
    388 
    389     PlacemarkPtr poKmlPlacemark =
    390         feat2kml ( m_poOgrDS, this, poOgrFeat, m_poOgrDS->GetKmlFactory (  ) );
    391 
    392     m_poKmlLayer->add_feature ( poKmlPlacemark );
    393 
    394     /***** mark the layer as updated *****/
    395 
    396     bUpdated = TRUE;
    397     m_poOgrDS->Updated (  );
    398 
    399333    return OGRERR_NONE;
    400334}
    401 
    402 /******************************************************************************
    403  method to delete a feature
    404 
    405  Args:          nFID
    406  
    407  Returns:       OGRERR_UNSUPPORTED_OPERATION;
    408                
    409 ******************************************************************************/
    410 
    411 OGRErr OGRLIBKMLLayer::DeleteFeature (
    412     long nFID )
    413 {
    414     if ( !bUpdate )
    415         return OGRERR_UNSUPPORTED_OPERATION;
    416 
    417 #warning we need to figure this out
    418 
    419     /***** mark the layer as updated *****/
    420 
    421     bUpdated = TRUE;
    422     m_poOgrDS->Updated (  );
    423 
    424     return OGRERR_UNSUPPORTED_OPERATION;
    425 }
    426 
    427335
    428336/******************************************************************************
     
    442350{
    443351
    444 #warning this return value can be wrong, kml features could be a folder
    445 
    446     return nFeatures;
     352    int i = 0;
     353    size_t iKmlFeature;
     354   
     355    for ( iKmlFeature = 0; iKmlFeature < (size_t) nFeatures; iKmlFeature++ ) {
     356        if (m_poKmlLayer->get_feature_array_at ( iFeature++ )->IsA( kmldom::Type_Placemark ) ) {
     357            i++;
     358        }
     359    }
     360   
     361    return i;
    447362}
    448363
     
    528443{
    529444
    530     KmlFactory *poKmlFactory = m_poOgrDS->GetKmlFactory (  );
    531     KmzFile *poKmlKmzfile;      //= m_poOgrDS->GetKmz (  );
    532 
    533     KmlPtr poKmlKml = poKmlFactory->CreateKml (  );
    534 
    535     poKmlKml->set_feature ( m_poKmlDocument );
    536 
    537     std::string strKmlOut = kmldom::SerializePretty ( poKmlKml );
    538 #warning this file name still might not be correct
    539 
    540     if ( poKmlKmzfile->
    541          AddFile ( strKmlOut,
    542                    CPLString (  ).Printf ( "%s.kml", m_pszFileName ) ) )
    543         return OGRERR_NONE;
    544 
    545     return OGRERR_FAILURE;
     445    return OGRERR_NONE;
    546446}
    547447
     
    654554
    655555    if ( EQUAL ( pszCap, OLCRandomRead ) )
    656         result = TRUE;
     556        result = FALSE;
    657557    if ( EQUAL ( pszCap, OLCSequentialWrite ) )
    658558        result = bUpdate;
    659 #warning todo random write
    660559    if ( EQUAL ( pszCap, OLCRandomWrite ) )
    661         result = FALSE;         //bUpdate
    662     if ( EQUAL ( pszCap, OLCFastFeatureCount ) && !GetSpatialFilter (  ) )
    663         result = TRUE;
     560        result = FALSE;
     561    if ( EQUAL ( pszCap, OLCFastFeatureCount ) )
     562        result = FALSE;
    664563    if ( EQUAL ( pszCap, OLCFastSetNextByIndex ) )
    665         result = TRUE;
     564        result = FALSE;
    666565    if ( EQUAL ( pszCap, OLCCreateField ) )
    667566        result = bUpdate;
    668 #warning todo DeleteFeature
    669567    if ( EQUAL ( pszCap, OLCDeleteFeature ) )
    670         result = FALSE;         //bUpdate
     568        result = FALSE;
    671569
    672570    return result;
Note: See TracChangeset for help on using the changeset viewer.