当前位置: 首页>>代码示例>>C++>>正文


C++ KmlFactory类代码示例

本文整理汇总了C++中KmlFactory的典型用法代码示例。如果您正苦于以下问题:C++ KmlFactory类的具体用法?C++ KmlFactory怎么用?C++ KmlFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了KmlFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: feat2kml

OGRErr OGRLIBKMLLayer::ISetFeature ( OGRFeature * poOgrFeat )
{
    if( !bUpdate || m_poKmlUpdate == NULL )
        return OGRERR_UNSUPPORTED_OPERATION;
    if( poOgrFeat->GetFID() == OGRNullFID )
        return OGRERR_FAILURE;

    FeaturePtr poKmlFeature =
        feat2kml ( m_poOgrDS, this, poOgrFeat, m_poOgrDS->GetKmlFactory (  ),
                   m_bUseSimpleField );

    KmlFactory *poKmlFactory = m_poOgrDS->GetKmlFactory (  );
    ChangePtr poChange = poKmlFactory->CreateChange();
    poChange->add_object(poKmlFeature);
    m_poKmlUpdate->add_updateoperation(poChange);

    const char* pszId = CPLSPrintf("%s." CPL_FRMT_GIB,
                    OGRLIBKMLGetSanitizedNCName(GetName()).c_str(), poOgrFeat->GetFID());
    poKmlFeature->set_targetid(pszId);

    /***** mark the layer as updated *****/

    bUpdated = TRUE;
    m_poOgrDS->Updated (  );

    return OGRERR_NONE;
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:27,代码来源:ogrlibkmllayer.cpp

示例2: size

  bool UAVFlightPlan::exportToKMLFile(const std::string &f, int begin_, int end_) const {
    bool ret_val = true;
    
    if (end_ < 0 || end_ > size()) {
      end_ = size(); 
    }
  
    if (begin_ < 0 || begin_ > size()) {
      begin_ = 0;
    }
    
    const_iterator it = begin();
    
    // Advance to the first waypoint to save
    int i = 0;
    for (; i < begin_; i++, it++);

    KmlFactory* factory = KmlFactory::GetFactory();
    
    
		kmldom::DocumentPtr doc = factory->CreateDocument();
		
    for (int j = 1; i < end_ && it != end(); j++,i++, it++) {
			ostringstream name_;
			name_ << "Waypoint " << j;
			// Create a <Point> with <coordinates> from the given Vec3.
			kmlbase::Vec3 v(it->getLongitude(), it->getLatitude(), it->getAltitude());
			kmldom::PointPtr point = kmlconvenience::CreatePointFromVec3(v);
			PlacemarkPtr place = factory->CreatePlacemark();
			place->set_geometry(point);
			doc->add_feature(place);
    }
    
    
    
    // Finally create the kml
    KmlPtr kml = factory->CreateKml();
    kml->set_feature(doc);
    
    // Then the file
    KmlFilePtr kmlfile = KmlFile::CreateFromImport(kml);
    if (!kmlfile) {
      cerr << "error: could not create kml file" << endl;
      return false;
    }
    
    // And write it
    std::string kml_data;
    kmlfile->SerializeToString(&kml_data);
    if (!kmlbase::File::WriteStringToFile(kml_data, f.c_str())) {
      cerr << "error: write of " << f << " failed" << endl;
      ret_val = false;
    }
    
    return ret_val;
  }
开发者ID:lrodriguez15,项目名称:resolution,代码行数:56,代码来源:UAVFlightPlan.cpp

示例3: SetLookAt

void OGRLIBKMLLayer::SetLookAt( const char* pszLookatLongitude,
                                const char* pszLookatLatitude,
                                const char* pszLookatAltitude,
                                const char* pszLookatHeading,
                                const char* pszLookatTilt,
                                const char* pszLookatRange,
                                const char* pszLookatAltitudeMode )
{
    KmlFactory *poKmlFactory = m_poOgrDS->GetKmlFactory();
    LookAtPtr lookAt = poKmlFactory->CreateLookAt();
    lookAt->set_latitude(CPLAtof(pszLookatLatitude));
    lookAt->set_longitude(CPLAtof(pszLookatLongitude));
    if( pszLookatAltitude != NULL )
        lookAt->set_altitude(CPLAtof(pszLookatAltitude));
    if( pszLookatHeading != NULL )
        lookAt->set_heading(CPLAtof(pszLookatHeading));
    if( pszLookatTilt != NULL )
    {
        double dfTilt = CPLAtof(pszLookatTilt);
        if( dfTilt >= 0 && dfTilt <= 90 )
            lookAt->set_tilt(dfTilt);
        else
            CPLError(CE_Warning, CPLE_AppDefined, "Invalid value for tilt: %s",
                     pszLookatTilt);
    }
    lookAt->set_range(CPLAtof(pszLookatRange));
    if( pszLookatAltitudeMode != NULL )
    {
        int isGX = FALSE;
        const int iAltitudeMode =
            kmlAltitudeModeFromString(pszLookatAltitudeMode, isGX);
        if( iAltitudeMode != kmldom::ALTITUDEMODE_CLAMPTOGROUND &&
            pszLookatAltitude == NULL )
        {
            CPLError(CE_Warning, CPLE_AppDefined,
                     "Lookat altitude should be present for altitudeMode = %s",
                     pszLookatAltitudeMode);
        }
        else if( isGX )
        {
            lookAt->set_gx_altitudemode(iAltitudeMode);
        }
        else
        {
            lookAt->set_altitudemode(iAltitudeMode);
        }
    }

    m_poKmlLayer->set_abstractview(lookAt);
}
开发者ID:ryandavid,项目名称:rotobox,代码行数:50,代码来源:ogrlibkmllayer.cpp

示例4: LIBKMLSetVec2

void OGRLIBKMLLayer::SetScreenOverlay(const char* pszSOHref,
                                      const char* pszSOName,
                                      const char* pszSODescription,
                                      const char* pszSOOverlayX,
                                      const char* pszSOOverlayY,
                                      const char* pszSOOverlayXUnits,
                                      const char* pszSOOverlayYUnits,
                                      const char* pszSOScreenX,
                                      const char* pszSOScreenY,
                                      const char* pszSOScreenXUnits,
                                      const char* pszSOScreenYUnits,
                                      const char* pszSOSizeX,
                                      const char* pszSOSizeY,
                                      const char* pszSOSizeXUnits,
                                      const char* pszSOSizeYUnits)
{
    KmlFactory *poKmlFactory = m_poOgrDS->GetKmlFactory (  );
    ScreenOverlayPtr so = poKmlFactory->CreateScreenOverlay();

    if( pszSOName != NULL )
        so->set_name(pszSOName);
    if( pszSODescription != NULL )
        so->set_description(pszSODescription);

    IconPtr icon = poKmlFactory->CreateIcon();
    icon->set_href(pszSOHref);
    so->set_icon(icon);

    if( pszSOOverlayX != NULL && pszSOOverlayY != NULL )
    {
        kmldom::OverlayXYPtr overlayxy = poKmlFactory->CreateOverlayXY();
        LIBKMLSetVec2(overlayxy, pszSOOverlayX, pszSOOverlayY,
                      pszSOOverlayXUnits, pszSOOverlayYUnits);
        so->set_overlayxy(overlayxy);
    }

    if( pszSOScreenX != NULL && pszSOScreenY != NULL )
    {
        kmldom::ScreenXYPtr screenxy = poKmlFactory->CreateScreenXY();
        LIBKMLSetVec2(screenxy, pszSOScreenX, pszSOScreenY,
                      pszSOScreenXUnits, pszSOScreenYUnits);
        so->set_screenxy(screenxy);
    }
    else
    {
        kmldom::ScreenXYPtr screenxy = poKmlFactory->CreateScreenXY();
        LIBKMLSetVec2(screenxy, "0.05", "0.05", NULL, NULL);
        so->set_screenxy(screenxy);
    }

    if( pszSOSizeX != NULL && pszSOSizeY != NULL )
    {
        kmldom::SizePtr sizexy = poKmlFactory->CreateSize();
        LIBKMLSetVec2(sizexy, pszSOSizeX, pszSOSizeY,
                      pszSOSizeXUnits, pszSOSizeYUnits);
        so->set_size(sizexy);
    }

    m_poKmlLayer->add_feature(so);
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:60,代码来源:ogrlibkmllayer.cpp

示例5: kmlAltitudeModeFromString

void OGRLIBKMLLayer::SetCamera( const char* pszCameraLongitude,
                                const char* pszCameraLatitude,
                                const char* pszCameraAltitude,
                                const char* pszCameraHeading,
                                const char* pszCameraTilt,
                                const char* pszCameraRoll,
                                const char* pszCameraAltitudeMode )
{
    int isGX = FALSE;
    int iAltitudeMode = kmlAltitudeModeFromString(pszCameraAltitudeMode, isGX);
    if( isGX == FALSE && iAltitudeMode == kmldom::ALTITUDEMODE_CLAMPTOGROUND )
    {
        CPLError(CE_Warning, CPLE_AppDefined,
                 "Camera altitudeMode should be different from %s",
                 pszCameraAltitudeMode);
        return;
    }
    KmlFactory *poKmlFactory = m_poOgrDS->GetKmlFactory();
    CameraPtr camera = poKmlFactory->CreateCamera();
    camera->set_latitude(CPLAtof(pszCameraLatitude));
    camera->set_longitude(CPLAtof(pszCameraLongitude));
    camera->set_altitude(CPLAtof(pszCameraAltitude));
    if( pszCameraHeading != NULL )
        camera->set_heading(CPLAtof(pszCameraHeading));

    if( pszCameraTilt != NULL )
    {
        double dfTilt = CPLAtof(pszCameraTilt);
        if( dfTilt >= 0 && dfTilt <= 90 )
            camera->set_tilt(dfTilt);
        else
            CPLError(CE_Warning, CPLE_AppDefined, "Invalid value for tilt: %s",
                     pszCameraTilt);
    }

    if( pszCameraRoll != NULL )
        camera->set_roll(CPLAtof(pszCameraRoll));
    if( isGX )
        camera->set_gx_altitudemode(iAltitudeMode);
    else
        camera->set_altitudemode(iAltitudeMode);

    m_poKmlLayer->set_abstractview(camera);
}
开发者ID:ryandavid,项目名称:rotobox,代码行数:44,代码来源:ogrlibkmllayer.cpp

示例6: FieldDef2kml

OGRErr OGRLIBKMLLayer::CreateField (
    OGRFieldDefn * poField,
    int bApproxOK )
{

    if ( !bUpdate )
        return OGRERR_UNSUPPORTED_OPERATION;

    if( m_bUseSimpleField )
    {
        SimpleFieldPtr poKmlSimpleField = NULL;

        if ( (poKmlSimpleField =
            FieldDef2kml ( poField, m_poOgrDS->GetKmlFactory (  ) )) != NULL )
        {
            if( m_poKmlSchema == NULL )
            {
                /***** create a new schema *****/

                KmlFactory *poKmlFactory = m_poOgrDS->GetKmlFactory (  );

                m_poKmlSchema = poKmlFactory->CreateSchema (  );

                /***** set the id on the new schema *****/

                std::string oKmlSchemaID = OGRLIBKMLGetSanitizedNCName(m_pszName);
                oKmlSchemaID.append ( ".schema" );
                m_poKmlSchema->set_id ( oKmlSchemaID );
            }

            m_poKmlSchema->add_simplefield ( poKmlSimpleField );
        }
    }

    m_poOgrFeatureDefn->AddFieldDefn ( poField );

    /***** mark the layer as updated *****/

    bUpdated = TRUE;
    m_poOgrDS->Updated (  );

    return OGRERR_NONE;
}
开发者ID:GeospatialDaryl,项目名称:VS2013__00_GDAL_111_x64,代码行数:43,代码来源:ogrlibkmllayer.cpp

示例7: DeleteFeature

OGRErr OGRLIBKMLLayer::DeleteFeature( GIntBig nFIDIn )
{
    if( !bUpdate || !m_poKmlUpdate )
        return OGRERR_UNSUPPORTED_OPERATION;

    KmlFactory *poKmlFactory = m_poOgrDS->GetKmlFactory();
    DeletePtr poDelete = poKmlFactory->CreateDelete();
    m_poKmlUpdate->add_updateoperation(poDelete);
    PlacemarkPtr poKmlPlacemark = poKmlFactory->CreatePlacemark();
    poDelete->add_feature(poKmlPlacemark);

    const char* pszId = CPLSPrintf("%s." CPL_FRMT_GIB,
                    OGRLIBKMLGetSanitizedNCName(GetName()).c_str(), nFIDIn);
    poKmlPlacemark->set_targetid(pszId);

    /***** mark as updated *****/
    m_poOgrDS->Updated();

    return OGRERR_NONE;
}
开发者ID:OSGeo,项目名称:gdal,代码行数:20,代码来源:ogrlibkmllayer.cpp

示例8: createkmlliststyle

void OGRLIBKMLLayer::Finalize(DocumentPtr poKmlDocument)
{
    KmlFactory *poKmlFactory = m_poOgrDS->GetKmlFactory (  );

    if( m_bWriteRegion && m_dfRegionMinX < m_dfRegionMaxX )
    {
        RegionPtr region = poKmlFactory->CreateRegion();

        LatLonAltBoxPtr box = poKmlFactory->CreateLatLonAltBox();
        box->set_west(m_dfRegionMinX);
        box->set_east(m_dfRegionMaxX);
        box->set_south(m_dfRegionMinY);
        box->set_north(m_dfRegionMaxY);
        region->set_latlonaltbox(box);

        LodPtr lod = poKmlFactory->CreateLod();
        lod->set_minlodpixels(m_dfRegionMinLodPixels);
        lod->set_maxlodpixels(m_dfRegionMaxLodPixels);
        if( (m_dfRegionMinFadeExtent != 0 || m_dfRegionMaxFadeExtent != 0) &&
            m_dfRegionMinFadeExtent + m_dfRegionMaxFadeExtent <
                m_dfRegionMaxLodPixels - m_dfRegionMinLodPixels )
        {
            lod->set_minfadeextent(m_dfRegionMinFadeExtent);
            lod->set_maxfadeextent(m_dfRegionMaxFadeExtent);
        }

        region->set_lod(lod);
        m_poKmlLayer->set_region(region);
    }

    createkmlliststyle (poKmlFactory,
                        GetName(),
                        m_poKmlLayer,
                        poKmlDocument,
                        osListStyleType,
                        osListStyleIconHref);
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:37,代码来源:ogrlibkmllayer.cpp

示例9: CPLStrdup


//.........这里部分代码省略.........
        if (m_poKmlSchema == NULL) {

            /***** try to find the correct schema *****/

            FeaturePtr poKmlFeature;

            /***** find the first placemark *****/

            do {
                if ( iFeature >= nFeatures )
                    break;

                poKmlFeature =
                    m_poKmlLayer->get_feature_array_at ( iFeature++ );

            } while ( poKmlFeature->Type (  ) != kmldom::Type_Placemark );

            if ( iFeature <= nFeatures && poKmlFeature &&
                 poKmlFeature->Type (  ) == kmldom::Type_Placemark &&
                 poKmlFeature->has_extendeddata (  ) ) {

                ExtendedDataPtr poKmlExtendedData = poKmlFeature->
                    get_extendeddata (  );

                if ( poKmlExtendedData->get_schemadata_array_size (  ) > 0 ) {
                    SchemaDataPtr poKmlSchemaData = poKmlExtendedData->
                        get_schemadata_array_at ( 0 );

                    if ( poKmlSchemaData->has_schemaurl (  ) ) {

                        std::string oKmlSchemaUrl = poKmlSchemaData->
                            get_schemaurl (  );
                        if ( ( m_poKmlSchema =
                               m_poOgrDS->FindSchema ( oKmlSchemaUrl.
                                                       c_str (  ) ) ) ) {
                            kml2FeatureDef ( m_poKmlSchema,
                                             m_poOgrFeatureDefn );
                        }
                    }
                }
                else if ( poKmlExtendedData->get_data_array_size() > 0 )
                {
                    /* Use the <Data> of the first placemark to build the feature definition */
                    /* If others have different fields, too bad... */
                    int bLaunderFieldNames =
                        CSLTestBoolean(CPLGetConfigOption("LIBKML_LAUNDER_FIELD_NAMES", "YES"));
                    size_t nDataArraySize = poKmlExtendedData->get_data_array_size();
                    for(size_t i=0; i < nDataArraySize; i++)
                    {
                        const DataPtr& data = poKmlExtendedData->get_data_array_at(i);
                        if (data->has_name())
                        {
                            CPLString osName = data->get_name();
                            if (bLaunderFieldNames)
                                osName = LaunderFieldNames(osName);
                            OGRFieldDefn oOgrField ( osName,
                                                    OFTString );
                            m_poOgrFeatureDefn->AddFieldDefn ( &oOgrField );
                        }
                    }
                }
            }

            iFeature = 0;

        }



        /***** check if any features are another layer *****/

        m_poOgrDS->ParseLayers ( m_poKmlLayer, poSpatialRef );

    }

    /***** it was from a DS::CreateLayer *****/

    else {

        /***** mark the layer as updated *****/

        bUpdated = TRUE;

        /***** create a new schema *****/

        KmlFactory *poKmlFactory = m_poOgrDS->GetKmlFactory (  );

        m_poKmlSchema = poKmlFactory->CreateSchema (  );

        /***** set the id on the new schema *****/

        std::string oKmlSchemaID = m_pszName;
        oKmlSchemaID.append ( ".schema" );
        m_poKmlSchema->set_id ( oKmlSchemaID );
    }




}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,代码来源:ogrlibkmllayer.cpp

示例10: MIN

OGRErr OGRLIBKMLLayer::ICreateFeature (
    OGRFeature * poOgrFeat )
{

    if ( !bUpdate )
        return OGRERR_UNSUPPORTED_OPERATION;

    if( m_bRegionBoundsAuto && poOgrFeat->GetGeometryRef() != NULL &&
        !(poOgrFeat->GetGeometryRef()->IsEmpty()) )
    {
        OGREnvelope sEnvelope;
        poOgrFeat->GetGeometryRef()->getEnvelope(&sEnvelope);
        m_dfRegionMinX = MIN(m_dfRegionMinX, sEnvelope.MinX);
        m_dfRegionMinY = MIN(m_dfRegionMinY, sEnvelope.MinY);
        m_dfRegionMaxX = MAX(m_dfRegionMaxX, sEnvelope.MaxX);
        m_dfRegionMaxY = MAX(m_dfRegionMaxY, sEnvelope.MaxY);
    }

    FeaturePtr poKmlFeature =
        feat2kml ( m_poOgrDS, this, poOgrFeat, m_poOgrDS->GetKmlFactory (  ),
                   m_bUseSimpleField );

    if( m_poKmlLayer != NULL )
        m_poKmlLayer->add_feature ( poKmlFeature );
    else
    {
        CPLAssert( m_poKmlUpdate != NULL );
        KmlFactory *poKmlFactory = m_poOgrDS->GetKmlFactory (  );
        CreatePtr poCreate = poKmlFactory->CreateCreate();
        ContainerPtr poContainer;
        if( m_bUpdateIsFolder )
            poContainer = poKmlFactory->CreateFolder();
        else
            poContainer = poKmlFactory->CreateDocument();
        poContainer->set_targetid(OGRLIBKMLGetSanitizedNCName(GetName()));
        poContainer->add_feature ( poKmlFeature );
        poCreate->add_container(poContainer);
        m_poKmlUpdate->add_updateoperation(poCreate);
    }

    /***** update the layer class count of features  *****/

    if( m_poKmlLayer != NULL )
    {
        nFeatures++;

        const char* pszId = CPLSPrintf("%s.%d",
                        OGRLIBKMLGetSanitizedNCName(GetName()).c_str(), nFeatures);
        poOgrFeat->SetFID(nFeatures);
        poKmlFeature->set_id(pszId);
    }
    else
    {
        if( poOgrFeat->GetFID() < 0 )
        {
            static int bAlreadyWarned = FALSE;
            if( !bAlreadyWarned )
            {
                bAlreadyWarned = TRUE;
                CPLError(CE_Warning, CPLE_AppDefined,
                         "It is recommended to define a FID when calling CreateFeature() in a update document");
            }
        }
        else
        {
            const char* pszId = CPLSPrintf("%s." CPL_FRMT_GIB,
                    OGRLIBKMLGetSanitizedNCName(GetName()).c_str(), poOgrFeat->GetFID());
            poOgrFeat->SetFID(nFeatures);
            poKmlFeature->set_id(pszId);
        }
    }

    /***** mark the layer as updated *****/

    bUpdated = TRUE;
    m_poOgrDS->Updated (  );

    return OGRERR_NONE;
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:79,代码来源:ogrlibkmllayer.cpp


注:本文中的KmlFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。