package index.alg; import index.entity.Point; import index.entity.WholeIndex; import index.file.OperateFile; import java.io.FileNotFoundException; import java.util.ArrayList; public class BuildInitialWholeIndex { // public WholeIndex build(ArrayList pointsList,Integer numOfGapsX,Integer numOfGapsY){ pointsList.add(pointsList.get(0)); Point point0 = pointsList.get(0); double minX = point0.getColX(); double minY = point0.getColY(); double maxX = point0.getColX(); double maxY = point0.getColY(); for (int i = 0 ; i < pointsList.size();i++){ Point point = pointsList.get(i); double corX = point.getColX(); double corY = point.getColY(); if (corX < minX){ minX = corX; } if (corX > maxX){ maxX = corX; } if (corY < minY){ minY = corY; } if (corY > maxY){ maxY = corY; } } double xGap = (maxX - minX) / numOfGapsX; double yGap = (maxY - minY) / numOfGapsY; WholeIndex wholeIndex = new WholeIndex(); wholeIndex.setMinX(minX); wholeIndex.setMinY(minY); wholeIndex.setNumOfGapsX(numOfGapsX); wholeIndex.setNumOfGapsY(numOfGapsY); wholeIndex.setxGap(xGap); wholeIndex.setyGap(yGap); return wholeIndex; } }