String colors = (String) gft.getFormatOptions().get("COLORS");
String ltypes = (String) gft.getFormatOptions().get("LTYPES");
String layerNames = (String) gft.getFormatOptions().get("LAYERS");
LOGGER.log(Level.FINE,"Format options: "+version+"; "+blocks+"; "+colors+"; "+ltypes+"; "+layerNames);
// get a suitable DXFWriter, for the requested version (null -> get any writer)
DXFWriter dxfWriter = DXFWriterFinder.getWriter(version, w);
if (dxfWriter != null) {
LOGGER.log(Level.INFO,"DXFWriter: "+dxfWriter.getDescription());
String[] layers = null;
if(layerNames!=null)
layers=layerNames.toUpperCase().split(",");
else
layers=getLayerNames(gft.getQuery().iterator());
LOGGER.log(Level.FINE,"Layers names: "+StringUtils.join(layers,","));
dxfWriter.setOption("layers", layers);
if (blocks != null && blocks.toLowerCase().equals("true"))
dxfWriter.setOption("geometryasblock", true);
// set optional colors
if (colors != null) {
try {
String[] sColors = colors.split(",");
int[] icolors = new int[sColors.length];
for (int count = 0; count < sColors.length; count++)
icolors[count] = Integer.parseInt(sColors[count]);
dxfWriter.setOption("colors", icolors);
} catch (Throwable t) {
LOGGER.log(Level.WARNING,"format option colors ignored by DXFOutputFormat due to a wrong format: "+t.getMessage());
}
}
// set optional line types
if (ltypes != null) {
try {
String[] sLTypes = ltypes.split(",");
LineType[] ltypesArr = new LineType[sLTypes.length];
for (int count = 0; count < sLTypes.length; count++)
ltypesArr[count] = LineType.parse(sLTypes[count]);
dxfWriter.setOption("linetypes", ltypesArr);
} catch (Throwable t) {
LOGGER
.warning("format option ltypes ignored by DXFOutputFormat due to a wrong format: "+t.getMessage());
}
}
// do the real job, please
dxfWriter.write(featureCollection.getFeature(),version);
w.flush();
if (zipStream != null) {
zipStream.closeEntry();
zipStream.close();