[gdal-dev] How to get string representation from OGRStyleMgrH

Even Rouault even.rouault at spatialys.com
Sun Aug 10 03:57:19 PDT 2014


Le dimanche 10 août 2014 12:36:02, Nik Sands a écrit :
> Is there a C API equivalent?  

No, from what I can see

> Or some other way of doing this without C++?

Actually I'm not sure OGRStyleMgr::GetStyleString(NULL) is what you want, at 
least not directly. It just returns the m_pszStyleString member of OGRStyleMgr

You didn't explain your use case, but if it is :
1) initialize a style manager with a style string
2) browse through the tools with GetPart()
3) modify some tools with the tool API
4) get the modified style string

then I believe you have to do something cumbersome :
4b) create a new style manager with an empty style string
5) use AddPart(OGRStyleTool *) on the new style manager to add the unmodified 
and modified tools (you need to keep the pointers obtained from 2), not re-call 
GetPart() on the first style manager)
6) call GetStyleString() on the second style manager

When you modify the tools with the tool API it edits the string of the tool, 
but there's no link with the style manager it comes from, so it won't see the 
change.

The working of the style manager is a bit weird...

> 
> I'm using C rather than C++.
> 
> On 10 Aug 2014, at 7:30 pm, Even Rouault <even.rouault at spatialys.com> wrote:
> > Le dimanche 10 août 2014 08:05:48, Nik Sands a écrit :
> >> Hi devs,
> >> 
> >> I've been working with styles using 'OGRStyleMgrH'.  However, I cannot
> >> figure out how to get a string directly from an OGRStyleMgrH.  I'd like
> >> to be able to get the string representation of the style in the same
> >> format as can be used to initialise the OGRStyleMgrH in
> >> OGR_SM_InitStyleString().
> > 
> > Nik,
> > 
> > OGRStyleMgr::GetStyleString(NULL) should do :
> > 
> > /**
> > * \brief Get the style string from the style manager.
> > *
> > * @param poFeature feature object from which to read the style or NULL to
> > *                  get the style string stored in the manager.
> > *
> > * @return the style string stored in the feature or the style string
> > stored *          in the style manager if poFeature is NULL
> > *
> > * NOTE: this method will call OGRStyleMgr::InitFromFeature() if poFeature
> > is *       not NULL and replace the style string stored in the style
> > manager */
> > 
> > Even
> > 
> >> How can I do this?
> >> 
> >> Cheers,
> >> Nik.
> >> 
> >> _______________________________________________
> >> gdal-dev mailing list
> >> gdal-dev at lists.osgeo.org
> >> http://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list