
com.conversantmedia.util.collection.spatial.AxialSplitLeaf Maven / Gradle / Ivy
package com.conversantmedia.util.collection.spatial;
/*
* #%L
* Conversant RTree
* ~~
* Conversantmedia.com © 2016, Conversant, Inc. Conversant® is a trademark of Conversant, Inc.
* ~~
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.util.Arrays;
import java.util.Comparator;
/**
* Fast RTree split suggested by Yufei Tao [email protected]
*
* Perform an axial split
*
* Created by jcairns on 5/5/15.
*/
final class AxialSplitLeaf extends Leaf {
protected AxialSplitLeaf(final RectBuilder builder, final int mMin, final int mMax) {
super(builder, mMin, mMax, RTree.Split.AXIAL);
}
@Override
protected Node split(final T t) {
final Branch pNode = new Branch<>(builder, mMin, mMax, splitType);
final Node l1Node = create(builder, mMin, mMax, splitType);
final Node l2Node = create(builder, mMin, mMax, splitType);
final int nD = r[0].getNDim();
final HyperRect[] sortedMbr = new HyperRect[size];
for(int i=0; i rangeD) {
axis = d;
rangeD = dr;
}
}
final int splitDimension = axis;
Arrays.sort(sortedMbr, new Comparator() {
@Override
public int compare(final HyperRect o1, final HyperRect o2) {
final HyperPoint p1 = o1.getCentroid();
final HyperPoint p2 = o2.getCentroid();
return p1.getCoord(splitDimension).compareTo(p2.getCoord(splitDimension));
}
});
for(int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy