Customizations for the City of Malmo CKAN instance.
- CKAN 2.10+ (tested on 2.11)
This extension exposes a binary preview action at:
/api/3/action/convert_dwg?id=<resource-id>
The preview flow is:
- stage the DWG resource into a temporary file
- convert DWG -> DXF with ODA File Converter
- render DXF -> PNG with
ezdxfandmatplotlib - cache the generated PNG by resource id + file hash
- return the PNG directly from the CKAN endpoint
Important runtime requirements:
- ODA File Converter must be installed and available on
PATH xvfbis used automatically whenxvfb-runis available- Python rendering dependencies must be installed in the CKAN runtime
Python runtime dependencies:
ezdxfmatplotlib
System/runtime dependencies:
- ODA File Converter Linux asset (
.AppImageor.deb) xvfb
The DWG preview pipeline supports these CKAN config settings:
-
ckanext.malmo.dwg_preview_timeoutConversion timeout in seconds. Default:45. -
ckanext.malmo.dwg_preview_download_timeoutDownload timeout in seconds for remote DWG resources. Default:30. -
ckanext.malmo.dwg_preview_max_download_bytesMaximum DWG download size in bytes. Default:104857600. -
ckanext.malmo.dwg_preview_oda_executableAbsolute path or executable name for ODA File Converter. Default:ODAFileConverter. -
ckanext.malmo.dwg_preview_oda_output_versionDXF target version passed to ODA File Converter. Default:ACAD2018. -
ckanext.malmo.dwg_preview_xvfb_screenScreen configuration passed toxvfb-runwhen launching ODA File Converter in headless Docker environments. Default:-screen 0 1600x1200x24. -
ckanext.malmo.dwg_preview_render_marginExtra margin applied around rendered geometry. Default:0.05. -
ckanext.malmo.dwg_preview_image_widthOutput preview width in pixels. Default:1600. -
ckanext.malmo.dwg_preview_image_heightOutput preview height in pixels. Default:1200. -
ckanext.malmo.dwg_preview_min_preview_bytesMinimum byte size for accepting a generated preview. Default:1024. -
ckanext.malmo.dwg_preview_cache_dirDirectory used for cached PNG previews. Default: system temporary directory +ckan-dwg-preview-cache.
In the local development Docker setup:
- ODA File Converter is installed during image build
- the local
src/ckanext-malmoextension is installed at container startup from the mounted workspace xvfbis installed for headless ODA execution
Optional local ODA asset override directory:
ckan/vendor/oda/
Supported local asset formats:
.AppImage.deb
To install ckanext-malmo:
- Install the extension in your environment.
- Install ODA File Converter and make sure
ODAFileConverteris available in the runtime environment. - Add
malmoto theckan.pluginssetting in your CKAN configuration file.