Skip to content

Commit

Permalink
Fix IFCSITE element check
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccasc committed Oct 18, 2020
1 parent 3d32105 commit eca65b2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion src/io/parser/BIMtoOSMParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<BIMObject3D> preparedBIMData = new ArrayList<>();
preparedBIMData.addAll(BIMtoOSMUtility.prepareBIMObjects(ifcModel, BIMtoOSMCatalog.BIMObject.IfcSlab, filteredRawBIMData.getAreaObjects()));
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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<LatLon> transformedCoordinates = new ArrayList<>();
Expand Down
2 changes: 1 addition & 1 deletion src/io/parser/helper/BIMtoOSMUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static List<BIMObject3D> prepareBIMObjects(ModelPopulation ifcModel, BIMt
// get local points representing shape of object
ArrayList<Vector3D> shapeDataOfObject = (ArrayList<Vector3D>) 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);
Expand Down

0 comments on commit eca65b2

Please sign in to comment.