Developer’s Corner: DXF output format promoted to official extension for GeoServer
as you may already know, GeoServer supports a wide variety of formats as an output of the WFS OGC service, to represent vector feature data. Such formats include the OGC standard GML XML based format (in its various versions), but also more “user friendly” ones such as the shapefile format, GeoJSON, CSV and so on.
Some formats that are not supported by default, but that are used by some people working in the GIS field, are CAD formats. Among them, the most used in absolute (thinking of open formats) is DXF, the standard AutoCad file interchange format.
Many GIS tools, for example GDAL and QGIS already support this format and a weak support has existed in GeoServer for some time, mostly unknown.
- GeoTools includes an unsupported module for DXF file reading and a DXF DataStore
- GeoServer included for a long time a not much supported community module for dxf writing and a WFS output format using it
You can also save bandwidth asking for a zipped dxf file, using the following url:
Some format options are supported to customize the final dxf details:
- version: (number) creates a DXF in the specified version format (only 14 is currently supported); to support other versions developers can implement the DXFWriter interface or extend AbstractDXFWriter
- asblock: (true/false) if true, all geometries are written as blocks and then inserted as entities. If false, simple geometries are directly written as entities.
- colors: (comma delimited list of numbers): colors to be used for the DXF layers, in sequence. If layers are more than the specified colors, they will be reused many times. A set of default colors is used if the option is not used. Colors are AutoCad color numbers (7=white, etc.).
- ltypes: (comma delimited list of line type descriptors): line types to be used for the DXF layers, in sequence.
- If layers are more than the specified line types, they will be reused many times.
- If not specified, all layers will be given a solid, continuous line type.
- A descriptor has the following format:
! [! ], where is the name assigned to the line type (optional) is a real number that tells how long is each part of the line pattern (defaults to 0.125) is a visual description of the repeatable part of the line pattern, as a sequence of – (solid line),* (dot) and _ (empty space). For example a dash-dot pattern would be expressed as –_*_.
- layers: (comma delimited list of strings) names to be assigned to the DXF layers. If specified, must contain a name for each requested layer. By default a standard name will be assigned to layers.
- withattributes: (true/false) enables writing an extra layer with attributes from each feature, the layer has a punctual geometry, with a point in the centroid of the original feature
If you also want to check the WPS PPIO, just use the GeoServer WPS Request builder you can find in the Demos section of the GeoServer Web Admin UI, choose a process that has a feature as an output (for example the gs:Centroid process) and choose application/dxf as the result format.
The GeoSolutions team,