diff --git a/src/io/parser/BIMtoOSMParser.java b/src/io/parser/BIMtoOSMParser.java index 7bd11bb..2ad4d54 100644 --- a/src/io/parser/BIMtoOSMParser.java +++ b/src/io/parser/BIMtoOSMParser.java @@ -97,6 +97,12 @@ public boolean parse(String filepath) { // extract important data and put them into internal data structure FilteredRawBIMData filteredRawBIMData = BIMtoOSMUtility.extractMajorBIMData(ifcModel); + // check for IFCSITE element in file + if (!checkForIFCSITE(filteredRawBIMData)) { + showParsingErrorView(filepath, "Could not import IFC file.\nIFC file does not contains IFCSITE element.", true); + return false; + } + // prepare filtered BIM data - find global object coordinates and other attributes like object height, width etc. ArrayList preparedBIMData = new ArrayList<>(); preparedBIMData.addAll(BIMtoOSMUtility.prepareBIMObjects(ifcModel, BIMtoOSMCatalog.BIMObject.IfcSlab, filteredRawBIMData.getAreaObjects())); @@ -214,6 +220,21 @@ else if (data.contains(FLAG_IFC4)) { return schema; } + /** + * Checks if IFCSITE element exists in data + * + * @param data to check + * @return true if exists, else false + */ + private boolean checkForIFCSITE(FilteredRawBIMData data) { + try { + data.getIfcSite().getAttributeValueBNasEntityInstance("ObjectPlacement").getId(); + return true; + } catch (NullPointerException e) { + return false; + } + } + /** * Method packs prepared BIM data into OSM ways and nodes * @@ -356,7 +377,7 @@ private void transformCoordinatesToLatLon(LatLon latlonBuildingOrigin, ArrayList rotationMatrix = ParserMath.getRotationMatrixAboutZAxis(rotationAngle); } - if(rotationMatrix == null) return; + if (rotationMatrix == null) return; for (BIMObject3D object : preparedBIMdata) { ArrayList transformedCoordinates = new ArrayList<>(); diff --git a/src/io/parser/helper/BIMtoOSMUtility.java b/src/io/parser/helper/BIMtoOSMUtility.java index de0ec5c..eba9194 100644 --- a/src/io/parser/helper/BIMtoOSMUtility.java +++ b/src/io/parser/helper/BIMtoOSMUtility.java @@ -106,7 +106,7 @@ public static List prepareBIMObjects(ModelPopulation ifcModel, BIMt // get local points representing shape of object ArrayList shapeDataOfObject = (ArrayList) getShapeDataOfObject(ifcModel, objectEntity); - // create PreparedBIMObject3D and save + // transform and prepare objects if (cartesianOrigin != null && rotMatrix != null && (shapeDataOfObject != null && !shapeDataOfObject.isEmpty())) { // transform points transformPoints(shapeDataOfObject, rotMatrix, cartesianOrigin);