-
Notifications
You must be signed in to change notification settings - Fork 5
/
GridAndGeoUtils.java
49 lines (44 loc) · 1.76 KB
/
GridAndGeoUtils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.utils;
import edu.ie3.datamodel.models.input.NodeInput;
import edu.ie3.util.geo.GeoUtils;
import javax.measure.quantity.Length;
import org.locationtech.jts.geom.LineString;
import tech.units.indriya.ComparableQuantity;
/** This class offers some useful methods for handling geographical problems related to grids */
public class GridAndGeoUtils extends GeoUtils {
/** Private Constructor as this class is not meant to be instantiated */
private GridAndGeoUtils() {
throw new IllegalStateException("Utility classes cannot be instantiated.");
}
/**
* Builds a straight line string between the both nodes that can be compared safely even if the
* two provided nodes contain exactly equal coordinates
*
* @param a Starting point of the line string
* @param b Ending point of the line string
* @return The equivalent straight line string
*/
public static LineString buildSafeLineStringBetweenNodes(NodeInput a, NodeInput b) {
return buildSafeLineStringBetweenPoints(a.getGeoPosition(), b.getGeoPosition());
}
/**
* Calculates the distance between two {@link NodeInput} entities using {@link
* #calcHaversine(double, double, double, double)}
*
* @param nodeA start node
* @param nodeB end node
* @return distance between start node and end node
*/
public static ComparableQuantity<Length> distanceBetweenNodes(NodeInput nodeA, NodeInput nodeB) {
return calcHaversine(
nodeA.getGeoPosition().getY(),
nodeA.getGeoPosition().getX(),
nodeB.getGeoPosition().getY(),
nodeB.getGeoPosition().getX());
}
}