eatfood 发表于 2019-10-15 13:04:16

osgEarth标注shp字段,出现中文乱码

Style style;

         LineSymbol* ls=style.getOrCreateSymbol<LineSymbol>();
         ls->stroke()->color()=color;
         ls->stroke()->width()=3.0f;

      TextSymbol* text=style.getOrCreateSymbol<TextSymbol>();
      text->content()=StringExpression("");
      text->priority()=NumericExpression("");
      text->removeDuplicateLabels()=true;
      text->size()=16.0f;
      text->alignment()=TextSymbol::ALIGN_CENTER_CENTER;
      text->fill()->color()=Color::White;
      text->halo()->color()=Color::DarkGray;
      text->provider()="annotation";

      OGRFeatureOptions featureOptions;
                std::string featurepath="E:/data/chinashp.shp"
      featureOptions.url()=featurepath;

      FeatureGeomModelOptions geomOptions;
      geomOptions.featureOptions()=featureOptions;
      geomOptions.styles()=new StyleSheet();
      geomOptions.styles()->addStyle(style);
      geomOptions.enableLighting()=false;

      ModelLayerOptions layerOptions(layerName,geomOptions);
      layerOptions.overlay()=true;
      map->addModelLayer(new ModelLayer(layerOptions));

加上text->encoding()=TextSymbol::ENCODING_UTF8;
      text->font()=std::string("E:/simhei.ttf");
这两句也没用,请问各位大佬怎么解决啊?

eatfood 发表于 2019-10-15 13:08:10

出现的结果是这样

TRaymond 发表于 2020-9-21 16:11:16

我比你好一些,有几个文件可以显示,其他的乱码
页: [1]
查看完整版本: osgEarth标注shp字段,出现中文乱码