-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make DXF writing layers more developer-friendly #11657
Comments
What other drivers than DXF do you know that require something more than just CreateLayer? |
@jratike80, My intention is more general: to have one way (algorithm) to write several layers to a dataset, regardless of the driver. |
Isn't DXF rather different from the GIS formats anyway? I understand that you want to do something more advanced than what ogr2ogr or gdal.VectorTranslate can do, but I fear that
|
Please, imagine that you have 3 layers: "roads", "buildings" and "parcels". You want to share your GIS project someone out-of-the GIS world, so your choice is DXF, but for other reasons you also want to store this layers in GPKG file. By default DXF writer uses "0" layer for entities, but you can manage DXF entities localization by manually assigning "Layer" internal field. Thanks to this the DXF will contain your data organized in CAD layers similar to GIS approach. But now... it requires 2 approaches for writing GPKG and DXF. GDAL could introduce automatically filling "Layer" field when you invoke Dataset.CreateLayer function, and this simple change let make much simpler and unified method of writing to both formats. In the above case, but thinking more general to any driver that supports multiple vector layers. Remember: I'm writing about GDAL API, not the console utils. |
This problem also can be omitted using smart approach (unified code, without if-else exceptions) ;-) |
If you exclude DXF, how much if-else exceptions do you need to use? I believe that unified code cannot resolve DXF conversion but special tools are needed for that purpose. QGIS seems to have one and I tested it a bit by opening my two-layer test gpkg with QGIS and using an option "Export Project to DXF". It created a DXF file where ogrinfo finds one layer, "entities". The result does not have a Layer field but the layers ("tieviiva" and "rakennus") are separated this way:
For some reason QGIS developers have selected to do this instead of "filling in the built-in "Layer" field to easily create a multi-layer DXF file". For me the connection between GIS layers and DXF layers is not clear, and https://ezdxf.readthedocs.io/en/stable/tables/layer_table_entry.html does not help much. I fear I do not have anything else to add into this issue. Let's hope some CAD experts appears. |
Even I still fear I don't have anything to add, I am curious to see a sample of such data. |
Did you open this file in AutoCAD or other CAD viewer...? And the same can be easily done when you set "Layer" field for each feature written to DXF layer on the GDAL site (tested).
Maybe I'm not the expert, but I have worked with CAD systems for several years and I know how data is organized by CAD users. I would just like to suggest that introducing two small changes to the GDAL source code (this issue #11657 and this) will enable more flexible and universal use of the DXF driver. I'm not a C++ programmer, so I can't do it. |
AutoCAD is too expensive for me and and for my employer, but I had a try with FreeCAD. Unfortunately it failed, but I think that it is not due to the data but due to a missing feature in that other fine Open Source project.
It is nice that you have two workarounds, to use the QGIS "export project" tool, or to add and populate a new "layer" field into the source data. Because the task is so well defined, it may be that some of the few GDAL developers who have experience on DXF start working on it some day. Or you can try to do it yourself, or use another developer-friendly method and hire one. Disclaimer: I am not a developer, I am just a GDAL user. |
Feature description
Creating a new layer in a DXF dataset should automatically fill in the built-in "Layer" field to easily create a multi-layer DXF file.
Creating multi-layer datasets for all GDAL vector drivers should be unified as much as possible. This will allow you to create multi-layer datasets regardless of the driver (GPKG, DXF, GML, etc.).
What do you think?
Additional context
No response
The text was updated successfully, but these errors were encountered: