package com.fdkankan.common.util; import java.io.IOException; import java.util.Map; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; public class CreateHouseJsonUtil { /** * 根据用户上传的户型图json文件生成houseType.json * @param filePath * @return */ public static JSONObject createHouseTypeJsonByUser(String filePath) { JSONObject house = init(); JSONArray floors = house.getJSONArray("floors"); JSONArray floorJson = readFloorJson(filePath); for(int i=0;i entry: points.entrySet()) { JSONObject pointValue = (JSONObject)entry.getValue(); JSONObject _pointValue = new JSONObject(); _pointValue.put("x", pointValue.getFloat("x")); _pointValue.put("y", pointValue.getFloat("y")); _pointValue.put("parent", pointValue.getJSONObject("parent")); _pointValue.put("vectorId", pointValue.getString("vectorId")); _points.add(_pointValue); } return _points; } private static JSONArray convertWalls(JSONObject walls) { JSONArray _walls = new JSONArray(); for (Map.Entry entry: walls.entrySet()) { JSONObject wallValue = (JSONObject)entry.getValue(); JSONObject _wallValue = new JSONObject(); _wallValue.put("start", wallValue.getString("start")); _wallValue.put("end", wallValue.getString("end")); _wallValue.put("children", wallValue.getJSONArray("children")); _wallValue.put("vectorId", wallValue.getString("vectorId")); _wallValue.put("width", 0.2); //leftEdgeId //rightEdgeId _walls.add(_wallValue); } return _walls; } //门/窗 private static JSONArray convertSymbols(JSONObject symbols,int floor) { JSONArray _symbols = new JSONArray(); for (Map.Entry entry: symbols.entrySet()) { JSONObject symbolValue = (JSONObject)entry.getValue(); JSONObject _symbolValue = new JSONObject(); _symbolValue.put("start", symbolValue.getJSONObject("startPoint")); _symbolValue.put("end", symbolValue.getJSONObject("endPoint")); _symbolValue.put("parent", symbolValue.getString("parent")); _symbolValue.put("openSide", symbolValue.getString("openSide")); _symbolValue.put("vectorId", symbolValue.getString("vectorId")); _symbolValue.put("points2d", symbolValue.getJSONArray("points2d")); _symbolValue.put("geoType", symbolValue.getString("geoType")); _symbolValue.put("floor", floor); //"groundClearance": -0.7, //"height": 1.3, _symbols.add(_symbolValue); } return _symbols; } private static JSONArray convertRooms(JSONArray rooms,int floor) { JSONArray _rooms = new JSONArray(); for(int i=0;i entry: components.entrySet()) { JSONObject componentValue = (JSONObject)entry.getValue(); JSONObject _componentValue = new JSONObject(); String geoType = componentValue.getString("geoType"); _componentValue.put("center", componentValue.getJSONObject("center")); _componentValue.put("angle", componentValue.getIntValue("angle")); _componentValue.put("vectorId", componentValue.getString("vectorId")); _componentValue.put("points2d", componentValue.getJSONArray("points2d")); _componentValue.put("geoType", componentValue.getString("geoType")); _componentValue.put("sideWidth", componentValue.getFloatValue("sideWidth")); _componentValue.put("sideThickness", componentValue.getFloatValue("sideThickness")); if(geoType.endsWith("Beam")) { beams.add(_componentValue); } else if(geoType.endsWith("Flue")) { flues.add(_componentValue); } } result.put("beams", beams); result.put("flues", flues); return result; } */ //rooms //tags }