Skip to content
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

Suggestion: Expose Object index from OCAD as GeoJson property #25

Open
aopheim opened this issue Dec 22, 2023 · 6 comments
Open

Suggestion: Expose Object index from OCAD as GeoJson property #25

aopheim opened this issue Dec 22, 2023 · 6 comments

Comments

@aopheim
Copy link
Contributor

aopheim commented Dec 22, 2023

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.
image

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).

@perliedman
Copy link
Owner

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.

@perliedman
Copy link
Owner

@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).

perliedman added a commit that referenced this issue Aug 14, 2024
@perliedman
Copy link
Owner

As a quick test, I have created f0da7d6 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.

@jmacura
Copy link

jmacura commented Aug 16, 2024

Thanks for your effort, @perliedman !
I have made a tiny test with the ocad-tool on branch object-index.

  1. export an OCAD map into GeoJSON.
  2. delete one object from the OCAD file.
  3. export the edited map into GeoJSON again.

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.
image

@perliedman
Copy link
Owner

@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?

@jmacura
Copy link

jmacura commented Aug 29, 2024

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... 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants