문제

I performed a lot of search around this question, and do not find any answer.

In a Java Program, I have a "SimpleFeatureCollection"(geotools) and a "StyleLayerDescriptor"(geotools) which contain my "SimpleFeatureCollection" style, and I need to generate a KML file using this style.

I actually generate successfully a KML file (without any style) using my "SimpleFeatureCollection" object with the following code:

static public boolean collectionToKMLFile(File iKMLFile, SimpleFeatureCollection iPolygonsCollection, StyledLayerDescriptor iStyle) throws IOException
{
    Encoder lEncoder = new Encoder(new KMLConfiguration());
    FileOutputStream lFileOutputStream = new FileOutputStream(iKMLFile);
    lEncoder.setIndenting(true);
    lEncoder.encode(iPolygonsCollection, KML.kml, lFileOutputStream);
    lFileOutputStream.close();
    return false;
}

I do not find any information on how to add style, I do not think it is impossible, do yo have an idea ?

Thanks.

도움이 되었습니까?

해결책

I finally decided to write a program to generate my own Styled KML File.

In fact, it is not really hard:

  1. Write KML Header
  2. Loop over your geometries and Write them
  3. Write Kml Footer

All information relative to KML elements defined in KML Version 2.2 could be found here :

Enjoy.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top