|
@@ -9,6 +9,8 @@ import java.io.File;
|
|
|
|
|
|
/**
|
|
|
* 四叉树算法
|
|
|
+ *
|
|
|
+ * 返回值是全局, 调用是要new对象使用
|
|
|
*/
|
|
|
public class Solution {
|
|
|
|
|
@@ -16,17 +18,18 @@ public class Solution {
|
|
|
// public static final String path = "F:\\2021\\navvis\\���Ի���\\laserData\\building_1\\map_tiles\\2\\3";
|
|
|
// public static String QUADTREE = "";
|
|
|
//public static int MaxDepth = 0;
|
|
|
-
|
|
|
+
|
|
|
+ // 返回值
|
|
|
private static String quadTree = "";
|
|
|
|
|
|
|
|
|
//val 当前点是否有值
|
|
|
//isLeaf 是否是叶子节点,即:是否有儿子
|
|
|
- public static Node construct(int[][] grid) {
|
|
|
+ public Node construct(int[][] grid) {
|
|
|
return find(grid,0,grid.length-1,0,grid.length-1);
|
|
|
}
|
|
|
|
|
|
- private static Node find(int[][] grid,int startrow,int endrow,int startcol,int endcol) {
|
|
|
+ private Node find(int[][] grid,int startrow,int endrow,int startcol,int endcol) {
|
|
|
boolean val = grid[startrow][startcol] == 0?false:true;
|
|
|
Node root=null;
|
|
|
|
|
@@ -50,7 +53,7 @@ public class Solution {
|
|
|
return root;
|
|
|
}
|
|
|
|
|
|
- private static boolean isLeaf(int[][] grid,int startrow,int endrow,int startcol,int endcol) {
|
|
|
+ private boolean isLeaf(int[][] grid,int startrow,int endrow,int startcol,int endcol) {
|
|
|
//int now=grid[startrow][startcol];
|
|
|
if(startrow == endrow && startcol == endcol) {
|
|
|
//叶子节点
|
|
@@ -72,7 +75,7 @@ public class Solution {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private static File readFiles(String inPath) {
|
|
|
+ private File readFiles(String inPath) {
|
|
|
try {
|
|
|
File f = new File(inPath);
|
|
|
if(f.isDirectory()) {
|
|
@@ -89,7 +92,7 @@ public class Solution {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static String getXYTiles(File f){
|
|
|
+ private void getXYTiles(File f){
|
|
|
File[] files = f.listFiles();
|
|
|
String tiles = "";
|
|
|
|
|
@@ -121,14 +124,14 @@ public class Solution {
|
|
|
|
|
|
Node node = construct(numthree);
|
|
|
String singleScore = getSingleScore(node);
|
|
|
- System.out.println("singleScore: " + singleScore);
|
|
|
+// System.out.println("singleScore: " + singleScore);
|
|
|
ouput(node);
|
|
|
// tiledMap.Quadtree("fccf7fffcff3bf7f") 的值;
|
|
|
- System.out.println(quadTree);
|
|
|
- return quadTree;
|
|
|
+// System.out.println(quadTree);
|
|
|
+// return quadTree;
|
|
|
}
|
|
|
|
|
|
- private static void ouput(Node node) {
|
|
|
+ private void ouput(Node node) {
|
|
|
if(node.isLeaf) {
|
|
|
return;
|
|
|
}
|
|
@@ -152,7 +155,7 @@ public class Solution {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static String getSingleScore(Node node) {
|
|
|
+ private String getSingleScore(Node node) {
|
|
|
int score = 0;
|
|
|
|
|
|
if(node.topLeft!=null&&!node.topLeft.isLeaf) {
|
|
@@ -194,10 +197,12 @@ public class Solution {
|
|
|
|
|
|
public static void main(String args[]) {
|
|
|
String path = "F:\\test\\ngin\\age_laser_data\\w-60\\results\\laserData\\cover\\0";
|
|
|
- File file = readFiles(path);
|
|
|
+ Solution solution = new Solution();
|
|
|
+ File file = solution.readFiles(path);
|
|
|
if(file!=null) {
|
|
|
- String xyTiles = getXYTiles(file);
|
|
|
- System.out.println("quadTree:" + xyTiles);
|
|
|
+ solution.getXYTiles(file);
|
|
|
+ // tiledMap.Quadtree("fccf7fffcff3bf7f") 的值;
|
|
|
+ System.out.println("quadTree:" + quadTree);
|
|
|
}
|
|
|
}
|
|
|
}
|