npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ifc-lbd

v0.3.8

Published

IFC to Linked Building Data (LBD) is built on [IFC.js](https://ifcjs.github.io/info/). It uses the [web-ifc](https://github.com/IFCjs/web-ifc) model loader and parses out triples in [JSON-LD](https://json-ld.org/) format.

Downloads

40

Readme

IFC to LBD

IFC to Linked Building Data (LBD) is built on IFC.js. It uses the web-ifc model loader and parses out triples in JSON-LD format.

demo

Install

npm i ifc-lbd

Why

Working with IFC in the express file format, and therefore the IFC.js project is like sent from the sky. It provides tools that make it a whole lot easier to retrieve properties and traverse the relationships of the IFC file, but even so, it is still a cumbersome job to work with IFC.

The minimal Building Topology Ontology (BOT), however, is quite straightforward to understand, and having a BOT dataset in RDF is cool because it allows you to do sophisticated queries it with SPARQL. The resulting JSON-LD-object can furthermore be re-structured using the cool concepts of compaction, expansion and framing. For example, it might be useful to use framing to build a simple tree structure of the graph as demonstrated below:

const frame = {
  "@context": {
    "bot": "https://w3id.org/bot#",
    "ex": "https://example.com/"
  },
  "@type": "bot:Building",
  "bot:hasStorey": {
    "@type": "bot:Storey",
    "bot:hasSpace": {
      "@type": "bot:Space"
    }
  }
}

const framed = await jsonld.frame(botTriples, frame);

Use

The IFC-LBD parser can be used in a JavaScript project or can be used as a CLI tool.

CLI Tool

Install globally on your machine npm i -g ifc-lbd

Run a subset (BOT, products) ifc-lbd [subset] -i ./myFile.ifc

NB! If used in Node 18, you currently need to set the --no-experimental-fetch flag when executing the command. But how to do this with a globally installed command?

See settings ifc-lbd -h

Run in dev node --no-experimental-fetch ./dist/cli-index.cjs bot -i ./tests/artifacts/Duplex.ifc

Building Topology Ontology (BOT)

Exports triples in compliance with the Building Topology Ontology.

// Init API and load model
const ifcApi = new WebIFC.IfcAPI();
await ifcApi.Init();
const modelID = ifcApi.OpenModel(ifcModelData);

// Init LBD Parser and parse BOT
const lbdParser = new LBDParser();
const botTriples = await lbdParser.parseBOTTriples(ifcApi, modelID);

// Close the model, all memory is freed
ifcApi.CloseModel(modelID);

Flow Systems Ontology (FSO)

Exports triples in compliance with the Flow Systems Ontology. In addition, ports are also exported and the center points of these are exported as OMG geometries. Pipe lengths are calculated from the distance between its two ports.

Coordinates and lengths are normalized to meters.

// Init LBD Parser and parse FSO
const lbdParser = new LBDParser();
const fsoTriples = await lbdParser.parseFSOTriples(ifcApi, modelID);

Flow Systems Ontology (FSO)

Exports triples in compliance with the TUBES System Ontology. This is a Work in Progress and currently only supports few concepts.

// Init LBD Parser and parse FSO
const lbdParser = new LBDParser();
const fsoTriples = await lbdParser.parseFSOTriples(ifcApi, modelID);

IFC Products

// Init LBD Parser and parse products
const lbdParser = new LBDParser();
const products = await lbdParser.parseProductTriples(ifcApi, modelID);

IFC Properties

All measurements (lengths, areas, volumes) are normalized to SI-units (m, m2, m3).

// Init LBD Parser and parse properties
const lbdParser = new LBDParser();
const properties = await lbdParser.parsePropertyTriples(ifcApi, modelID);

Contribute

This library is intended to be expanded, so please go and add your parser or extend one of the existing ones!

Remember to write tests! That's also the preferred approach to developing new functionalities. Run specific test: npm run test -i <path> (eg jest -i tests/fso.spec.ts)

NB! Due to a bug in web-ifc I had to do a hardcoded fix by changing doing a find/replace in node_modules/web-ifc/web-ifc-api-node.js and node_modules/web-ifc/web-ifc-api-browser.js:

Find:

].map((p) => p.value)

Replace:

]?.map((p) => p.value)

Stats

Execute like node ./lib/cli-tool/index.js bot -i ./tests/artifacts/Duplex.ifc

For triple count, copy resulting JSON-LD to JSON-LD Playground and convert to N-Quads + get line count.

|Model|Duplex (2,4MB)|MEP(962KB)|Schependomlaan(49,3MB)|Office MEP(209,1MB)| |---|---|---|---|---| |BOT[ms]|34|13|128|349| |BOT[triples]|1,718|175|12,251|33,087| |FSO[ms]|-|55|-|165| |FSO[triples]|-|2,386|-|32,024| |Products[ms]|9|8|46|174| |Products[triples]|218|85|3,635|16,012| |Properties[ms]|161|48|3,066| | |Properties[triples]|15,506|1,401|266,391| |

Units

In the current setup, all units are as defined in the input model. Will be neutralized to the following in a future release:

|Measure |Unit| |:-------|:--:| |Distance|mm | |Area |m2 | |Volume |m3 |