Closed aopheim closed 1 month ago
Hi, thanks for the suggestion! It sounds like a very good idea to use the same id (or index) as OCAD uses.
However, looking at the OCAD file format specification (https://www.ocad.com/wiki/ocad/en/index.php?title=OCAD_12_File_Format#Objects), it's not clear to me what property the index is. Just guessing, but it might be that the index is actually the object's index in the Object Index structure. That should be fairly straight forward to use, we only need to figure out what ids to assign to features created for symbol elements.
@aopheim @jmacura continuing the discussion here... since I don't have OCAD (or Windows) myself, can you verify that this "Object Index" in OCAD is indeed stable between different versions of a map? I dug through the spec to figure out what property this might be, but can't really figure it out.
As mentioned in my previous comment, we could just use the object's index within the file, but I'm not sure if that would be stable when the file is changed (I would assume they wouldn't be if objects are removed from the map for example).
As a quick test, I have created f0da7d6609e5ac1e90a16023f349a4fbb417cd44 which stores each object's index and outputs it in the GeoJSON. From a quick test with a map I have, it does unfortunately not look like that index is stable between changes.
Thanks for your effort, @perliedman !
I have made a tiny test with the ocad-tool on branch object-index
.
By comparing the two GeoJSON outputs, it is obvious, that the IDs are not preserved. Other objects' IDs got renumbered after the deletion. Excerpt below.
@jmacura thanks for trying it out, that looks like the results I saw as well. Would it be possible for you to check in OCAD if the object id shown there was stable between those changes?
I wanted to check, but even after long search I haven't found any place where the object ID is exposed in the OCAD's GUI. Creating a new dBase database file from OCAD creates an empty table. So, I do not know how to check otherwise... 😞
Thanks for the update, @jmacura!
I'm going to close this for now since it does not seem possible to find an attribute in the OCAD file that is stable between map edits.
I'm happy to open this again if there's still interest and someone can give a hint that a stable id does exist in the OCAD file!
I see now that all objects are given a numeric id after being parsed into GeoJson. However, we have no guarantee that the same object in the map gets the same id after edits have been made in the map, as the id is just set as 1 -> n when the map has been parsed. After some research I see that OCAD has its own "Object index", briefly explained here. https://www.ocad.com/wiki/ocad/en/index.php?title=Select#Select_Object_by_Object_Index I have made some small tests, and it seems like this is a numeric id given in the order objects are added to the map. Meaning it will remain the same and make it possible to identify the same object across different versions of the map. Would it be possible to expose the object id as a property of a GeoJson Feature?
It may be that this is already available, as I see the OcadFile object has a property objIndex. However, I see no properties in that object that gives me the id.
If the object index is not easily available, do you maybe have suggestions of other ways to identify the same map object between different versions? I have tried using a combination of type and creationDate, but that is not unique, as the creation date will be the same across objects if you import objects (importing contours for example).