/** * Parse roof model from way. * * @param primitive * @param perspective * @return roof model */ public static RoofModel parse(OsmPrimitive primitive, Perspective perspective) { if (hasRoofLines(primitive)) { return RoofLinesParser.parse(primitive, perspective); } return parseDormerRoof(primitive, perspective); }
private static boolean hasRoofLines(OsmPrimitive primitive) { if (!StringUtil.isBlankOrNull(parseRoofShape(primitive))) { return false; } // not tagged flat roofs should be resolved as regular flat roofs! return RoofLinesParser.hasRoofLines(primitive); }
/** * @param perspective * @param roofHeightMap * @param way */ private static void setNodesAsMinHeight(Perspective perspective, Map<Point2d, Double> roofHeightMap, Way way) { Point2d [] points = transform(way, perspective); for (Point2d point2d : points) { if (roofHeightMap.get(point2d) == null) { roofHeightMap.put(point2d, MIN_HEIGHT); } } }
public static BuildingModel parseBuilding(OsmPrimitive primitive, Perspective perspective) { if (primitive instanceof Way) { return BuildingParser.parseBuildingWay((Way) primitive, perspective); } else if (primitive instanceof Node) { return BuildingParser.parseBuildingNode((Node) primitive, perspective); } else if (primitive instanceof Relation) { Relation relation = (Relation) primitive; if (relation.isMultipolygon()) { // simple building from multipolygon return BuildingParser.parseBuildingMultiPolygon(relation, perspective); } else { // complex building return BuildingParser.parseBuildingRelation(relation, perspective); } } throw new IllegalArgumentException("unknown type of building"); }
private static List<BuildingPart> parseBuildingPart(Way primitive, Perspective pPerspective) { if (!primitive.isClosed()) { throw new RuntimeException("Way is not closed: " + primitive); } OsmPrimitive p = primitive; BuildingPart bp = parseBuildingPartAttributes(p); bp.setWall(parseWall((Way) p, pPerspective)); bp.setInlineWalls(null); bp.setRoof(RoofParser.parse(primitive, pPerspective)); List<BuildingPart> bpList = new ArrayList<BuildingPart>(); bpList.add(bp); bpList.addAll(parseRelationClone(primitive, bp)); return bpList; }
private static RoofFrontDirection findDirection(OsmPrimitive pWay, Perspective pPerspective) { Vector2d direction = null; boolean soft = false; direction = findDirectionByRelation(pWay, pPerspective); if (direction != null) { return new RoofFrontDirection(direction, false); } if (pWay instanceof Way) { direction = findDirectionByPoints((Way) pWay, pPerspective); if (direction != null) { return new RoofFrontDirection(direction, soft); } } else { // TODO } return findDirectionByDirectionTag(pWay); }
/** * Parse building model from way. * * @param way * @param perspective * @return */ public static BuildingModel parseBuildingWay(Way way, Perspective perspective) { BuildingModel bm = new BuildingModel(); bm.setParts(parseBuildingPart(way, perspective)); return bm; }
private static boolean isNodeBuildingPart(Node node) { if (isPrimitiveBuildingPart(node) && OsmAttributeKeys.BUILDING_SHAPE.primitiveKeyHaveValue(node, OsmAttributeValues.SPHERE)) { return true; } return false; }
/** * Parse number of roof levels. * * @param osmPrimitive osm primitive * @return number of roof levels */ public static Integer parseRoofLevels(OsmPrimitive osmPrimitive) { Integer level = roundToInteger(ModelUtil.getNumberAttribute(osmPrimitive, OsmAttributeKeys.ROOF_LEVELS.getKey(), null)); return level; }
private static Wall parseWall(List<ReversableWay> rwList, Perspective pPerspective) { Wall wall = new Wall(); List<WallPart> wp = new ArrayList<WallPart>(); for (ReversableWay rw : rwList) { wp.add(parseWallPart(rw, pPerspective)); } wall.setWallParts(wp); return wall; }
private static List<BuildingWallElement> parseBuildingAttributeWallElement(Way w) { List<BuildingWallElement> ret = new ArrayList<BuildingWallElement>(); WindowGridBuildingElement wgbe = BuildingAttributeParser.parseWallWindowsColumns(w); if (wgbe != null) { ret.add(wgbe); } return ret; }
public static List<List<DormerType>> parseMultipleDormers(String key) { List<List<DormerType>> ret = new ArrayList<List<DormerType>>(); if (key == null) { return ret; } String[] split = key.split("\\."); for (String sideKeys : split) { List<DormerType> site = dormers(sideKeys); ret.add(site); } return ret; }
/** * @param sideKeys * @return */ public static List<DormerType> dormers(String sideKeys) { List<DormerType> site = new ArrayList<DormerType>(); for (int i = 0; i < sideKeys.length(); i++) { String dormerKey = sideKeys.substring(i, i + 1); site.add(parseDormer(dormerKey)); } return site; }
private static List<BuildingPart> parseRelationClone(Way primitive, BuildingPart bp) { List<RelationCloneHeight> buildHeightClone = RelationCloneHeight.buildHeightClone(primitive); List<BuildingPart> bpList = new ArrayList<BuildingPart>(); for (RelationCloneHeight relationCloneHeight : buildHeightClone) { for (Double height : relationCloneHeight) { bpList.add(cloneBuildingPart(bp, height)); } } return bpList; }
/** * Find roof direction saved in tag. * * @param pWay * way * @return roof direction */ private static RoofFrontDirection findDirectionByDirectionTag(OsmPrimitive pWay) { RoofFrontDirection roofDirection = parseDirectionStr(OsmAttributeKeys.ROOF_DIRECTION.primitiveValue(pWay), Ortagonal.NONE); if (roofDirection != null) { return roofDirection; } roofDirection = parseDirectionStr(OsmAttributeKeys.DIRECTION.primitiveValue(pWay), Ortagonal.NONE); if (roofDirection != null) { return roofDirection; } roofDirection = parseDirectionStr(OsmAttributeKeys.ROOF_RIDGE_DIRECTION.primitiveValue(pWay), Ortagonal.LEFT); if (roofDirection != null) { return roofDirection; } roofDirection = parseDirectionStr(OsmAttributeKeys.ROOF_SLOPE_DIRECTION.primitiveValue(pWay), Ortagonal.NONE); return roofDirection; }
/** * @param apexNode * @param roofLine */ private static void findApexNodes(List<Node> apexNode, Way roofLine) { for (int i = 0; i < roofLine.getNodesCount(); i++) { Node node = roofLine.getNode(i); if (isApex(node)) { apexNode.add(node); } } }
/** * Parse building model from node. * * @param node * @param perspective * @return */ public static BuildingModel parseBuildingNode(Node node, Perspective perspective) { BuildingModel bm = new BuildingModel(); bm.setNodeParts(parseBuildingPart(node, perspective)); return bm; }
private static boolean isRelationHaveBuildingParts(Relation pRelation) { boolean haveParts = false; for (int i = 0; i < pRelation.getMembersCount(); i++) { RelationMember member = pRelation.getMember(i); if (isPrimitiveBuildingPart(member.getMember())) { haveParts = true; break; } } return haveParts; }
/** * Parse minimal number of levels. * * @param osmPrimitive osm primitive * @return minimal number of levels */ public static Integer parseMinLevel(OsmPrimitive osmPrimitive) { Integer level = roundToInteger(ModelUtil.getNumberAttribute(osmPrimitive, OsmAttributeKeys.BUILDING_MIN_LEVEL.getKey(), null)); if (level == null) { level = roundToInteger(ModelUtil.getNumberAttribute(osmPrimitive, OsmAttributeKeys.BUILDING_LEVELS_UNDERGROUND.getKey(), null)); if (level != null) { level = -level; } } return level; }
private static Wall parseWall(Way way, Perspective pPerspective) { Wall wall = new Wall(); WallPart wp = parseWallPart(new ReversableWay(way, false), pPerspective); wall.setWallParts(Arrays.asList(wp)); return wall; }