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

Valid element types? #14

Open
mpickering opened this issue Apr 16, 2020 · 1 comment
Open

Valid element types? #14

mpickering opened this issue Apr 16, 2020 · 1 comment

Comments

@mpickering
Copy link
Contributor

I am observing a SymbolElement where the type is reported to be 165. My understanding is that the type should only be between 1-4 but I am wondering whether this is a problem with the ocad file parsing logic or a problem in my OCAD file. The object in question seems to have quite a few coordinates but the lineWidth field also looks suspicious.

I am also seeing SymbolElement where the type is reported to be 0.

It's coming from an OCAD 11 file.

SymbolElement {
  buffer: <Buffer ad 0c 00 00 0b 00 06 00 9c 27 00 00 80 4c 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 b0 00 00 00 30 00 00 00 80 00 00 00 b9 bf 17 00 43 3a ... 1594922 more bytes>,
  offset: 471782,
  _startOffset: 346838,
  type: 165,
  flags: 9472,
  color: 2,
  lineWidth: -25342,
  diameter: 165,
  numberCoords: 15616,
  coords: [
    TdPoly(2) [ 655360, 7274752, xFlags: 166, yFlags: 2 ],
    TdPoly(2) [ -851968, -7732736, xFlags: 166, yFlags: 1 ],
    TdPoly(2) [ -2031616, -5439488, xFlags: 166, yFlags: 1 ],
    TdPoly(2) [ -4259840, -2686720, xFlags: 166, yFlags: 1 ],
    TdPoly(2) [ 7995392, -2424320, xFlags: 166, yFlags: 1 ],
    TdPoly(2) [ 5046272, 131072, xFlags: 166, yFlags: 1 ],
    TdPoly(2) [ 196608, 524544, xFlags: 167, yFlags: 1 ],
    TdPoly(2) [ -851968, 655872, xFlags: 167, yFlags: 0 ],
    TdPoly(2) [ -1638400, 1507328, xFlags: 167, yFlags: 0 ],
    TdPoly(2) [ -2228224, 4194560, xFlags: 167, yFlags: 0 ],
    TdPoly(2) [ -4390912, 6160896, xFlags: 167, yFlags: 0 ],
    TdPoly(2) [ -5111808, -7274496, xFlags: 167, yFlags: 0 ],
    TdPoly(2) [ -5767168, -4456192, xFlags: 167, yFlags: 0 ],
@perliedman
Copy link
Owner

Hm, yes this definitely looks like the symbol record has been read from the wrong offset, for some reason. As you say, the lineWidth is strange, and also there is no system in the coordinates, also the coordinates flags look weird.

Can't say that I have found anything like this before, at some point I have encountered symbols with negative number of coordinates (

throw new InvalidSymbolElementException(`Symbol element with invalid (${this.numberCoords}) number of coordinates.`, this)
), but the other properties looked more or less sane in that case, IIRC. Still, the fact that you found another case of incorrect symbol element might indicate there is something wrong with how they are read from the file. One idea could be to add some error handling and see if ignoring this error makes the map render incorrectly.

In a few places we currently have code like this:

- IIRC, I never managed to match that offset with the OCAD file format specification, but without it everything breaks.

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

2 participants