Changeset 19584


Ignore:
Timestamp:
Apr 30, 2010 10:47:59 AM (6 years ago)
Author:
winkey
Message:

when opening a DS store the root kml container for the doc.kml for later.
when writeing a kmz or dir DS reuse the doc.kml root kml container if it exsists, otherwise the pre-existing data will be lost in update mode.

Location:
trunk/gdal/ogr/ogrsf_frmts/libkml
Files:
2 edited

Legend:

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

    r19566 r19584  
    145145    int                       m_isKmz;
    146146    ContainerPtr              m_poKmlDocKml;
     147    ElementPtr                m_poKmlDocKmlRoot;
    147148    ContainerPtr              m_poKmlStyleKml;
    148149    const char               *pszStylePath;
  • trunk/gdal/ogr/ogrsf_frmts/libkml/ogrlibkmldatasource.cpp

    r19573 r19584  
    185185    if ( EQUAL ( pszUseDocKml, "yes" ) && m_poKmlDocKml ) {
    186186
    187         KmlPtr poKmlKml = m_poKmlFactory->CreateKml (  );
    188 
    189         poKmlKml->set_feature ( m_poKmlDocKml );
    190         std::string oKmlOut = kmldom::SerializePretty ( poKmlKml );
     187        /***** if we dont have the doc.kml root *****/
     188        /***** make it and add the container    *****/
     189       
     190        if ( !m_poKmlDocKmlRoot ) {
     191            m_poKmlDocKmlRoot = m_poKmlFactory->CreateKml (  );
     192
     193            AsKml( m_poKmlDocKmlRoot )->set_feature ( m_poKmlDocKml );
     194        }
     195       
     196        std::string oKmlOut = kmldom::SerializePretty ( m_poKmlDocKmlRoot );
    191197
    192198        if ( !poKmlKmzfile->AddFile ( oKmlOut, "doc.kml" ) )
     
    267273    if ( EQUAL ( pszUseDocKml, "yes" ) && m_poKmlDocKml ) {
    268274
    269         KmlPtr poKmlKml = m_poKmlFactory->CreateKml (  );
    270 
    271         poKmlKml->set_feature ( m_poKmlDocKml );
    272 
    273         std::string oKmlOut = kmldom::SerializePretty ( poKmlKml );
     275        /***** if we dont have the doc.kml root *****/
     276        /***** make it and add the container    *****/
     277       
     278        if ( !m_poKmlDocKmlRoot ) {
     279            m_poKmlDocKmlRoot = m_poKmlFactory->CreateKml (  );
     280
     281            AsKml( m_poKmlDocKmlRoot )->set_feature ( m_poKmlDocKml );
     282        }
     283       
     284        std::string oKmlOut = kmldom::SerializePretty ( m_poKmlDocKmlRoot );
    274285
    275286        const char *pszOutfile = CPLFormFilename ( pszName, "doc.kml", NULL );
     
    788799
    789800    std::string oKmlErrors;
    790     ElementPtr poKmlRoot = kmldom::Parse ( oKmlKml, &oKmlErrors );
    791 
    792     if ( !poKmlRoot ) {
     801    m_poKmlDocKmlRoot = kmldom::Parse ( oKmlKml, &oKmlErrors );
     802
     803    if ( !m_poKmlDocKmlRoot ) {
    793804        CPLError ( CE_Failure, CPLE_OpenFailed,
    794805                   "ERROR Parseing kml layer %s from %s :%s",
     
    802813    /***** get the child contianer from root *****/
    803814
    804     ContainerPtr poKmlContainer = GetContainerFromRoot ( poKmlRoot );
     815    ContainerPtr poKmlContainer = GetContainerFromRoot ( m_poKmlDocKmlRoot );
    805816
    806817    /***** loop over the container looking for network links *****/
Note: See TracChangeset for help on using the changeset viewer.