Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

fix for UDIG-1899 (kml export of feature source with a lot of features) #111

Merged
merged 1 commit into from about 2 years ago

2 participants

Frank Gasdorf Andrea Antonello
Frank Gasdorf
Owner
fgdrf commented

This is the fix for https://jira.codehaus.org/browse/UDIG-1899

It writes directly to the FileOutputStream instead of the detouring with the ByteArrayOutputStream and therefore it can handle larger Feature Sources.

THX to Andrea for Reviewing!

Frank

Andrea Antonello moovida merged commit 8e25a1a into from
Andrea Antonello moovida closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
25 plugins/eu.udig.tools.jgrass/src/eu/udig/tools/jgrass/kml/core/Kmlutils.java
@@ -17,15 +17,9 @@
17 17 */
18 18 package eu.udig.tools.jgrass.kml.core;
19 19
20   -import java.io.BufferedWriter;
21   -import java.io.ByteArrayOutputStream;
22 20 import java.io.File;
23 21 import java.io.FileInputStream;
24   -import java.io.FileWriter;
25   -import java.util.ArrayList;
26   -import java.util.List;
27   -
28   -import net.refractions.udig.project.ui.ApplicationGIS;
  22 +import java.io.FileOutputStream;
29 23
30 24 import org.geotools.data.simple.SimpleFeatureCollection;
31 25 import org.geotools.feature.FeatureCollection;
@@ -33,8 +27,6 @@
33 27 import org.geotools.feature.FeatureIterator;
34 28 import org.geotools.feature.simple.SimpleFeatureBuilder;
35 29 import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
36   -import org.geotools.feature.type.GeometryDescriptorImpl;
37   -import org.geotools.feature.type.GeometryTypeImpl;
38 30 import org.geotools.geometry.jts.JTS;
39 31 import org.geotools.kml.KML;
40 32 import org.geotools.kml.KMLConfiguration;
@@ -44,9 +36,6 @@
44 36 import org.geotools.xml.StreamingParser;
45 37 import org.opengis.feature.simple.SimpleFeature;
46 38 import org.opengis.feature.simple.SimpleFeatureType;
47   -import org.opengis.feature.type.AttributeDescriptor;
48   -import org.opengis.feature.type.GeometryDescriptor;
49   -import org.opengis.feature.type.GeometryType;
50 39 import org.opengis.referencing.crs.CoordinateReferenceSystem;
51 40 import org.opengis.referencing.operation.MathTransform;
52 41
@@ -119,17 +108,13 @@ public static void writeKml( File kmlFile, SimpleFeatureCollection featureCollec
119 108
120 109 Encoder encoder = new Encoder(new KMLConfiguration());
121 110 encoder.setIndenting(true);
122   - ByteArrayOutputStream out = new ByteArrayOutputStream();
123   - encoder.encode(newCollection, KML.kml, out);
124 111
125   - String kmlString = new String(out.toByteArray());
126   - BufferedWriter bW = null;
  112 + FileOutputStream fos = new FileOutputStream(kmlFile);
  113 +
127 114 try {
128   - bW = new BufferedWriter(new FileWriter(kmlFile));
129   - bW.write(kmlString);
  115 + encoder.encode(newCollection, KML.kml, fos);
130 116 } finally {
131   - if (bW != null)
132   - bW.close();
  117 + fos.close();
133 118 }
134 119 }
135 120

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.