com.powsybl.gse.map.BranchGraphicIndex Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powsybl-gse-network-map Show documentation
Show all versions of powsybl-gse-network-map Show documentation
A GSE plugin to draw a network on a map
/**
* Copyright (c) 2018, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.gse.map;
import com.github.davidmoten.rtree.RTree;
import com.github.davidmoten.rtree.geometry.Geometry;
import org.apache.commons.lang3.time.StopWatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Objects;
/**
* @author Geoffroy Jamgotchian
*/
public final class BranchGraphicIndex {
private static final Logger LOGGER = LoggerFactory.getLogger(BranchGraphicIndex.class);
private final RTree tree;
private BranchGraphicIndex(RTree tree) {
this.tree = Objects.requireNonNull(tree);
}
public static BranchGraphicIndex build(Collection segmentGroups) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
RTree tree = RTree.star().maxChildren(6).create();
for (BranchGraphic segmentGroup : segmentGroups) {
tree = tree.add(segmentGroup, segmentGroup.getBoundingBox());
}
LOGGER.info("Line branches R-tree built in {} ms", stopWatch.getTime());
return new BranchGraphicIndex(tree);
}
public RTree getTree() {
return tree;
}
}