Hi Bruno,

The lml format is not very active these days, I am trying to determine why
others have not run into this problem - does your PostGIS table have a
generic "Geometry" type (rather thank Point, or Polygon, or
MultiLineString?)

You would be implementing a new feature, so it would be good to confirm the
abilities of the KML standard, and be sure to include a test case :D
--
Jody Garnett


On Apr 26, 2024 at 6:47:09 AM, Bruno Lombardi <bruno.lomba...@live.it>
wrote:

> Hi,
>
> I've found some difficulty exporting Feature to KML.
>
> Here's my piece of code:
>
> Encoder encoder = new Encoder(new FCKMLConfiguration());
> encoder.setIndenting(true);
> PipedInputStream in = new PipedInputStream();
> try {
> PipedOutputStream out = new PipedOutputStream(in);
> new Thread(new Runnable() {
> public void run() {
> try {
> encoder.encode(polyFeatures, KML.kml, out);
> } catch (IOException e) {
> log.error("", e);
> } finally {
> try {
> out.close();
> } catch (IOException e) {
> log.error("", e);
> }
> after.run();
> }
> }
> }).start();
> } catch (IOException e) {
> log.error("Problem generating export", e);
> }
> return in;
>
> All works correctly but, if feature contains a "multigeometry" retrieved
> from PostGIS data base, the KML entry is empy:
>
> <kml:MultiGeometry/>
>
> I've changed the MultiGeometryTypeBinding in this way:
>
> @Override
>
> public Object getProperty(Object object, QName name) throws Exception {
> GeometryCollection gc = (GeometryCollection) object;
> if ("AbstractGeometryGroup".equals(name.getLocalPart()) ||
> KML.Geometry.getLocalPart().equals(name.getLocalPart())) {
> Geometry[] g = new Geometry[gc.getNumGeometries()];
> for (int i = 0; i < g.length; i++) {
> g[i] = gc.getGeometryN(i);
> }
> return g;
> }
> return super.getProperty(object, name);
> }
>
> It works! I don't know if the change is correct since I do not know so
> deeply the code but, if it make sense I would do a pull_request for the
> change.
>
> Thanks for you fantastic works!
>
> _______________________________________________
> GeoTools-Devel mailing list
> GeoTools-Devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to