xeokit / xeokit-convert

Convert various AEC model formats for efficient viewing in the browser with xeokit.
https://xeokit.github.io/xeokit-convert/docs/
Other
49 stars 52 forks source link

JSON compression for metadata? #83

Open xeolabs opened 2 years ago

xeolabs commented 2 years ago

There are many repeated strings in the metadata JSON. Perhaps compress using: https://coderwall.com/p/mekopw/jsonc-compress-your-json-data-up-to-80

xeolabs commented 2 years ago

An idea - factor strings out into a lookup table within the metadata JSON.

In the snippet below, the integer values for those properties are indexes into the string dictionary. We could also treat the property names in the same way.

{
  "dictionary": [
    "IfcWindow",
    "IfcDoor",
    "1E1QVUnGb7UwbYyT0lPilv",
    "Window",
    "1E1QVUnGb7UwbYyT0lPilv",
    "1E1QVUnGb7UwbYyT0lPilv",
    "Door"
  ],
  "metaObjects": [
    {
      "id": 2,
      "name": 3,
      "type": 0
    },
    {
      "id": 4,
      "name": 6,
      "type": 1,
      "parent": 2
    }
  ]
}
Amoki commented 2 years ago

We do something like the second option at BIMData. It is fast and the complexity of rebuilding usable data from the JSON isn't high.