Class IFCtoLBDConverter


  • public class IFCtoLBDConverter
    extends java.lang.Object

    • Constructor Summary

      Constructors 
      Constructor Description
      IFCtoLBDConverter​(java.lang.String ifc_filename, java.lang.String uriBase, java.lang.String target_file, int props_level, boolean hasBuildingElements, boolean hasSeparateBuildingElementsModel, boolean hasBuildingProperties, boolean hasSeparatePropertiesModel, boolean hasPropertiesBlankNodes, boolean hasGeolocation)
      The construction method for the converter process.
    • Method Summary

      Modifier and Type Method Description
      private void addAttrributes​(org.apache.jena.rdf.model.Model output_model, org.apache.jena.rdf.model.Resource r, org.apache.jena.rdf.model.Resource bot_r)
      Creates and adds the literal triples from the original ifcOWL resource under the new LBD resource.
      private void addGeolocation2BOT()
      Adds Geolocation triples to the RDF model.
      private void addNamespaces​(java.lang.String uriBase, int props_level, boolean hasBuildingElements, boolean hasBuildingProperties)
      Adds the used RDF namespaces for the Jena Models
      private void connectElement​(org.apache.jena.rdf.model.Resource bot_resource, org.apache.jena.rdf.model.Property bot_property, org.apache.jena.rdf.model.Resource ifcowl_element)
      For a RDF LBD resource, creates the targetted object for the given property and adds a triple that connects them with the property.
      private void connectElement​(org.apache.jena.rdf.model.Resource bot_resource, org.apache.jena.rdf.model.Resource ifc_element)  
      private void conversion​(java.lang.String target_file, boolean hasBuildingElements, boolean hasSeparateBuildingElementsModel, boolean hasBuildingProperties, boolean hasSeparatePropertiesModel, boolean hasGeolocation)  
      private org.apache.jena.rdf.model.Resource createformattedURI​(org.apache.jena.rdf.model.Resource r, org.apache.jena.rdf.model.Model m, java.lang.String product_type)
      Creates URIs for the elements in the output graph.
      private void createIfcLBDProductMapping()
      Fills in the ifcowl_product_map map using the seealso ontology statemets at the Apache Jena RDF ontology model on the memory.
      private org.apache.jena.rdf.model.Resource getformattedURI​(org.apache.jena.rdf.model.Resource r, org.apache.jena.rdf.model.Model m, java.lang.String product_type)  
      java.util.Optional<org.apache.jena.rdf.model.Resource> getLBDProductType​(java.lang.String ifcType)
      This used the ifcowl_product_map map and returns one mapped class in a Linked Building Data ontology, if specified.
      private void handlePropertySetData​(int props_level, boolean hasPropertiesBlankNodes)
      Collects the PropertySet data from the ifcOWL model and creates a separate Apache Jena Model that contains the converted representation of the property set content.
      private java.util.List<org.apache.jena.rdf.model.Resource> listElements()
      Returns list of all RDF nodes that have an matching element type returned by getLBDProductType(String ifcType) on the RDF graph.
      static void main​(java.lang.String[] args)  
      org.apache.jena.rdf.model.Model readAndConvertIFC​(java.lang.String ifc_file, java.lang.String uriBase)
      The method converts an IFC STEP formatted file and returns an Apache Jena RDF memory storage model that contains the generated RDF triples.
      private void readInOntologies​(java.lang.String ifc_file)
      This internal method reads in all the associated ontologies so that ontology inference can ne used during the conversion.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • eventBus

        private final com.google.common.eventbus.EventBus eventBus
      • ifcowl_model

        private org.apache.jena.rdf.model.Model ifcowl_model
      • ontology_model

        private org.apache.jena.rdf.model.Model ontology_model
      • ifcowl_product_map

        private java.util.Map<java.lang.String,​java.util.List<org.apache.jena.rdf.model.Resource>> ifcowl_product_map
      • uriBase

        private final java.lang.String uriBase
      • ontURI

        private java.util.Optional<java.lang.String> ontURI
      • ifcOWL

        private org.lbd.ifc2lbd.ns.IfcOWLNameSpace ifcOWL
      • propertysets

        private java.util.Map<java.lang.String,​org.lbd.ifc2lbd.PropertySet> propertysets
      • props_level

        private final int props_level
      • hasPropertiesBlankNodes

        private final boolean hasPropertiesBlankNodes
      • lbd_general_output_model

        private final org.apache.jena.rdf.model.Model lbd_general_output_model
      • lbd_product_output_model

        private final org.apache.jena.rdf.model.Model lbd_product_output_model
      • lbd_property_output_model

        private final org.apache.jena.rdf.model.Model lbd_property_output_model
      • handledSttributes4resource

        java.util.Set<org.apache.jena.rdf.model.Resource> handledSttributes4resource
    • Constructor Detail

      • IFCtoLBDConverter

        public IFCtoLBDConverter​(java.lang.String ifc_filename,
                                 java.lang.String uriBase,
                                 java.lang.String target_file,
                                 int props_level,
                                 boolean hasBuildingElements,
                                 boolean hasSeparateBuildingElementsModel,
                                 boolean hasBuildingProperties,
                                 boolean hasSeparatePropertiesModel,
                                 boolean hasPropertiesBlankNodes,
                                 boolean hasGeolocation)
        The construction method for the converter process. This does the whole process.
        Parameters:
        ifc_filename - The absolute path for the IFC file that will be converted
        uriBase - The URI base for all the elemenents that will be created
        target_file - The main file name for the output. If there are many, they will be sharing the same beginning
        props_level - The levels described in https://github.com/w3c-lbd-cg/lbd/blob/gh-pages/presentations/props/presentation_LBDcall_20180312_final.pdf
        hasBuildingElements - The Building Elements will be created in the output
        hasSeparateBuildingElementsModel - The Building elements will have a separate file
        hasBuildingProperties - The properties will ne added into the output
        hasSeparatePropertiesModel - The properties will be written in a separate file
        hasPropertiesBlankNodes - Blank nodes are used
        hasGeolocation - Geolocation, i.e., the latitude and longitude are added.
    • Method Detail

      • conversion

        private void conversion​(java.lang.String target_file,
                                boolean hasBuildingElements,
                                boolean hasSeparateBuildingElementsModel,
                                boolean hasBuildingProperties,
                                boolean hasSeparatePropertiesModel,
                                boolean hasGeolocation)
      • handlePropertySetData

        private void handlePropertySetData​(int props_level,
                                           boolean hasPropertiesBlankNodes)
        Collects the PropertySet data from the ifcOWL model and creates a separate Apache Jena Model that contains the converted representation of the property set content.
        Parameters:
        props_level - The levels described in https://github.com/w3c-lbd-cg/lbd/blob/gh-pages/presentations/props/presentation_LBDcall_20180312_final.pdf
        hasPropertiesBlankNodes - If the nameless nodes are used.
      • addNamespaces

        private void addNamespaces​(java.lang.String uriBase,
                                   int props_level,
                                   boolean hasBuildingElements,
                                   boolean hasBuildingProperties)
        Adds the used RDF namespaces for the Jena Models
        Parameters:
        uriBase -
        props_level -
        hasBuildingElements -
        hasBuildingProperties -
      • connectElement

        private void connectElement​(org.apache.jena.rdf.model.Resource bot_resource,
                                    org.apache.jena.rdf.model.Resource ifc_element)
      • connectElement

        private void connectElement​(org.apache.jena.rdf.model.Resource bot_resource,
                                    org.apache.jena.rdf.model.Property bot_property,
                                    org.apache.jena.rdf.model.Resource ifcowl_element)
        For a RDF LBD resource, creates the targetted object for the given property and adds a triple that connects them with the property. The literals of the elements and and the hosted elements are added as well.
        Parameters:
        bot_resource - The Jena Resource in the LBD output model in the Apacje model
        bot_property - The LBD ontology property
        ifcowl_element - The corresponding ifcOWL elemeny
      • addAttrributes

        private void addAttrributes​(org.apache.jena.rdf.model.Model output_model,
                                    org.apache.jena.rdf.model.Resource r,
                                    org.apache.jena.rdf.model.Resource bot_r)
        Creates and adds the literal triples from the original ifcOWL resource under the new LBD resource.
        Parameters:
        output_model - The Apache Jena model where the conversion output is written
        r - The oroginal ifcOWL resource
        bot_r - The correspoinding resource in the output model. The LBD resource.
      • createformattedURI

        private org.apache.jena.rdf.model.Resource createformattedURI​(org.apache.jena.rdf.model.Resource r,
                                                                      org.apache.jena.rdf.model.Model m,
                                                                      java.lang.String product_type)
        Creates URIs for the elements in the output graph. The IfcRoot elements (that have a GUID) are given URI that contais the guid in the standard uncompressed format. The uncompressed GUID form is created using the implementation by Tulke & Co. (The OPEN IFC JAVA TOOLBOX)
        Parameters:
        r - A ifcOWL RDF node in a Apache Jena RDF store.
        m - The Apache Jena RDF Store for the output.
        product_type - The LBD product type to be shown on the URI
        Returns:
      • getformattedURI

        private org.apache.jena.rdf.model.Resource getformattedURI​(org.apache.jena.rdf.model.Resource r,
                                                                   org.apache.jena.rdf.model.Model m,
                                                                   java.lang.String product_type)
      • listElements

        private java.util.List<org.apache.jena.rdf.model.Resource> listElements()
        Returns list of all RDF nodes that have an matching element type returned by getLBDProductType(String ifcType) on the RDF graph.
        Returns:
        the list of the matching nodes
      • getLBDProductType

        public java.util.Optional<org.apache.jena.rdf.model.Resource> getLBDProductType​(java.lang.String ifcType)
        This used the ifcowl_product_map map and returns one mapped class in a Linked Building Data ontology, if specified.
        Parameters:
        ifcType - The IFC entity class
        Returns:
        The corresponding class Resource in a LBD ontology
      • createIfcLBDProductMapping

        private void createIfcLBDProductMapping()
        Fills in the ifcowl_product_map map using the seealso ontology statemets at the Apache Jena RDF ontology model on the memory. Uses also RDFS.subClassOf so that subclasses are included.
      • readAndConvertIFC

        public org.apache.jena.rdf.model.Model readAndConvertIFC​(java.lang.String ifc_file,
                                                                 java.lang.String uriBase)
        The method converts an IFC STEP formatted file and returns an Apache Jena RDF memory storage model that contains the generated RDF triples. Apache Jena: https://jena.apache.org/index.html The generated temporsary file is used to reduce the temporary memory need and make it possible to convert larger models. Sets the this.ontURI class variable. That is used to create the right ifcOWL version based ontology base URI that is used to create the ifcOWL version based peroperties and class URIs-
        Parameters:
        ifc_file - the absolute path (For example: c:\ifcfiles\ifc_file.ifc) for the IFC file
        uriBase - the URL beginning for the elements in the ifcOWL TTL output
        Returns:
        the Jena Model that contains the ifcOWL attribute value (Abox) output.
      • readInOntologies

        private void readInOntologies​(java.lang.String ifc_file)
        This internal method reads in all the associated ontologies so that ontology inference can ne used during the conversion.
        Parameters:
        ifc_file - the absolute path (For example: c:\ifcfiles\ifc_file.ifc) for the IFC file
      • addGeolocation2BOT

        private void addGeolocation2BOT()
        Adds Geolocation triples to the RDF model. Ontology: http://www.opengis.net
      • main

        public static void main​(java.lang.String[] args)