Skip to content

Upgrading PowerSystemUtils dependency #599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `directirradiation` to `directirradiance`
- ICON model:
- `"datum"` to `"time"`
- Force user to provide time stamp pattern to `CouchbaseWeatherSource` to ensure harmonized querying
- Force user to provide time stamp pattern to `CouchbaseWeatherSource` to ensure harmonized querying
- BREAKING: Updating PowerSystemUtils dependency to 2.0-SNAPSHOT [#595](https://github.com/ie3-institute/PowerSystemDataModel/issues/595)

## [2.1.0] - 2022-01-05

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dependencies {
}

// ie³ power system utils
implementation 'com.github.ie3-institute:PowerSystemUtils:1.6'
implementation 'com.github.ie3-institute:PowerSystemUtils:2.0-SNAPSHOT'

implementation 'tech.units:indriya:2.1.3'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected Pair<Integer, Point> buildModel(SimpleFactoryData data) {
int coordinateId = data.getInt(COORDINATE_ID);
double lat = data.getDouble(LAT_GEO);
double lon = data.getDouble(LONG_GEO);
return Pair.of(coordinateId, GeoUtils.xyToPoint(lon, lat));
return Pair.of(coordinateId, GeoUtils.buildPoint(lat, lon));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected Pair<Integer, Point> buildModel(SimpleFactoryData data) {
int coordinateId = data.getInt(COORDINATE_ID);
double lat = data.getDouble(LAT);
double lon = data.getDouble(LONG);
return Pair.of(coordinateId, GeoUtils.xyToPoint(lon, lat));
return Pair.of(coordinateId, GeoUtils.buildPoint(lat, lon));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ default List<CoordinateDistance> getNearestCoordinates(Point coordinate, int n)
default List<CoordinateDistance> getNearestCoordinates(
Point coordinate, int n, Collection<Point> coordinates) {
SortedSet<CoordinateDistance> sortedDistances =
GeoUtils.getCoordinateDistances(
GeoUtils.calcOrderedCoordinateDistances(
coordinate,
(coordinates != null && !coordinates.isEmpty()) ? coordinates : getAllCoordinates());
return sortedDistances.stream().limit(n).toList();
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/edu/ie3/datamodel/models/input/NodeInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.Objects;
import java.util.UUID;
import javax.measure.quantity.Dimensionless;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Point;
import tech.units.indriya.ComparableQuantity;

Expand All @@ -29,8 +28,7 @@ public class NodeInput extends AssetInput {
private final Point geoPosition;

/** Use this default value if geoPosition is unknown */
public static final Point DEFAULT_GEO_POSITION =
GeoUtils.DEFAULT_GEOMETRY_FACTORY.createPoint(new Coordinate(7.4116482, 51.4843281));
public static final Point DEFAULT_GEO_POSITION = GeoUtils.buildPoint(51.4843281, 7.4116482);

/** Voltage level of this node */
private final VoltageLevel voltLvl;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/ie3/datamodel/utils/GridAndGeoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ 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");
throw new IllegalStateException("Utility classes cannot be instantiated.");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,7 @@ private static void lineLengthMatchesDistancesBetweenPointsOfLineString(LineInpu
if ((line.getNodeA().getGeoPosition() != NodeInput.DEFAULT_GEO_POSITION
|| line.getNodeB().getGeoPosition() != NodeInput.DEFAULT_GEO_POSITION)
&& !QuantityUtil.isEquivalentAbs(
line.getLength(),
GeoUtils.totalLengthOfLineString(line.getGeoPosition()),
ALLOWED_LENGTH_ERROR))
line.getLength(), GeoUtils.calcHaversine(line.getGeoPosition()), ALLOWED_LENGTH_ERROR))
throw new InvalidEntityException(
"Line length does not equal calculated distances between points building the line", line);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class CosmoIdCoordinateFactoryTest extends Specification {
"latrot": "-10",
"longrot": "-6.8125"
] as Map<String, String>, Pair)
Pair<Integer, Point> expectedPair = Pair.of(106580, GeoUtils.xyToPoint(1.279336, 39.602772))
Pair<Integer, Point> expectedPair = Pair.of(106580, GeoUtils.buildPoint(39.602772, 1.279336))

when:
def actual = factory.get(validSimpleFactoryData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class IconIdCoordinateFactoryTest extends Specification {
"latitude":"52.312",
"longitude":"12.812",
"coordinatetype":"ICON"] as Map<String, String>, Pair)
Pair<Integer, Point> expectedPair = Pair.of(477295, GeoUtils.xyToPoint(12.812, 52.312))
Pair<Integer, Point> expectedPair = Pair.of(477295, GeoUtils.buildPoint(52.312, 12.812))

when:
def actual = factory.get(validSimpleFactoryData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CsvIdCoordinateSourceCosmoIT extends Specification implements CsvTestDataM
def "The CsvIdCoordinateSource is able to look up a specific point or an empty Optional otherwise" () {
given:
def knownCoordinateId = 106582
def expectedPointA = Optional.of(GeoUtils.xyToPoint(1.438028, 39.617161))
def expectedPointA = Optional.of(GeoUtils.buildPoint(39.617161, 1.438028))
def unknownCoordinateId = 42

when: "looking up a known coordinate id"
Expand All @@ -59,9 +59,9 @@ class CsvIdCoordinateSourceCosmoIT extends Specification implements CsvTestDataM
def "The CsvIdCoordinateSource is able to look up specified points" () {
int[] ids = 106580..106582
def expectedCoordinates = [
GeoUtils.xyToPoint(1.279336, 39.602772),
GeoUtils.xyToPoint(1.358673, 39.610001),
GeoUtils.xyToPoint(1.438028, 39.617161)
GeoUtils.buildPoint(39.602772, 1.279336),
GeoUtils.buildPoint(39.610001, 1.358673),
GeoUtils.buildPoint(39.617161, 1.438028)
].toSet()

when:
Expand All @@ -72,9 +72,9 @@ class CsvIdCoordinateSourceCosmoIT extends Specification implements CsvTestDataM
}

def "The CsvIdCoordinateSource is able to return a specific ID or an empty Optional otherwise" () {
def knownCoordinate = GeoUtils.xyToPoint(1.279336, 39.602772)
def knownCoordinate = GeoUtils.buildPoint(39.602772, 1.279336)
def expectedIdForA = Optional.of(106580)
def unknownCoordinate = GeoUtils.xyToPoint(14.39335, 48.035011)
def unknownCoordinate = GeoUtils.buildPoint(48.035011, 14.39335)

when: "looking up an id of a known coordinate"
def actualIdForA = source.getId(knownCoordinate)
Expand Down Expand Up @@ -103,10 +103,10 @@ class CsvIdCoordinateSourceCosmoIT extends Specification implements CsvTestDataM
def "The CsvIdCoordinateSource is able to return all available coordinates" () {
given:
def expectedCoordinates = [
GeoUtils.xyToPoint(1.279336, 39.602772),
GeoUtils.xyToPoint(1.358673, 39.610001),
GeoUtils.xyToPoint(1.438028, 39.617161),
GeoUtils.xyToPoint(1.5174021, 39.624249)
GeoUtils.buildPoint(39.602772, 1.279336),
GeoUtils.buildPoint(39.610001, 1.358673),
GeoUtils.buildPoint(39.617161, 1.438028),
GeoUtils.buildPoint(39.624249, 1.5174021)
].toSet()

when:
Expand All @@ -119,13 +119,13 @@ class CsvIdCoordinateSourceCosmoIT extends Specification implements CsvTestDataM
def "The CsvIdCoordinateSource is able to return the nearest n coordinates in a collection" () {
given:
def allCoordinates = [
GeoUtils.xyToPoint(1d, 39d),
GeoUtils.xyToPoint(2d, 40d),
GeoUtils.xyToPoint(1d, 40d),
GeoUtils.xyToPoint(2d, 39d)
GeoUtils.buildPoint(39d, 1d),
GeoUtils.buildPoint(40d, 2d),
GeoUtils.buildPoint(40d, 1d),
GeoUtils.buildPoint(39d, 2d)
]

def basePoint = GeoUtils.xyToPoint(1.438029, 39.617162)
def basePoint = GeoUtils.buildPoint(39.617162, 1.438029)
def expectedDistances = [
new CoordinateDistance(basePoint, allCoordinates[2]),
new CoordinateDistance(basePoint, allCoordinates[1])
Expand All @@ -142,7 +142,7 @@ class CsvIdCoordinateSourceCosmoIT extends Specification implements CsvTestDataM
given:
def n = 2
def allCoordinates = source.allCoordinates
def basePoint = GeoUtils.xyToPoint(1.438029, 39.617162)
def basePoint = GeoUtils.buildPoint(39.617162, 1.438029)
def expectedDistances = source.getNearestCoordinates(basePoint, n, allCoordinates)

when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CsvIdCoordinateSourceIconIT extends Specification implements CsvTestDataMe
def "The CsvIdCoordinateSource is able to look up a specific point or an empty Optional otherwise" () {
given:
def knownCoordinateId = 551525
def expectedPointA = Optional.of(GeoUtils.xyToPoint(7.438, 51.438))
def expectedPointA = Optional.of(GeoUtils.buildPoint(51.438, 7.438))
def unknownCoordinateId = 42

when: "looking up a known coordinate id"
Expand All @@ -60,9 +60,9 @@ class CsvIdCoordinateSourceIconIT extends Specification implements CsvTestDataMe
def "The CsvIdCoordinateSource is able to look up specified points" () {
int[] ids = [67775, 551525, 278150]
def expectedCoordinates = [
GeoUtils.xyToPoint(7.438, 51.5),
GeoUtils.xyToPoint(7.438, 51.438),
GeoUtils.xyToPoint(7.375, 51.438)
GeoUtils.buildPoint(51.5, 7.438),
GeoUtils.buildPoint(51.438, 7.438),
GeoUtils.buildPoint(51.438, 7.375)
].toSet()

when:
Expand All @@ -73,9 +73,9 @@ class CsvIdCoordinateSourceIconIT extends Specification implements CsvTestDataMe
}

def "The CsvIdCoordinateSource is able to return a specific ID or an empty Optional otherwise" () {
def knownCoordinate = GeoUtils.xyToPoint(7.438, 51.438)
def knownCoordinate = GeoUtils.buildPoint(51.438, 7.438)
def expectedIdForA = Optional.of(551525)
def unknownCoordinate = GeoUtils.xyToPoint(14.39335, 48.035011)
def unknownCoordinate = GeoUtils.buildPoint(48.035011, 14.39335)

when: "looking up an id of a known coordinate"
def actualIdForA = source.getId(knownCoordinate)
Expand Down Expand Up @@ -104,10 +104,10 @@ class CsvIdCoordinateSourceIconIT extends Specification implements CsvTestDataMe
def "The CsvIdCoordinateSource is able to return all available coordinates" () {
given:
def expectedCoordinates = [
GeoUtils.xyToPoint(7.438, 51.5),
GeoUtils.xyToPoint(7.375, 51.5),
GeoUtils.xyToPoint(7.438, 51.438),
GeoUtils.xyToPoint(7.375, 51.438)
GeoUtils.buildPoint(51.5, 7.438),
GeoUtils.buildPoint(51.5, 7.375),
GeoUtils.buildPoint(51.438, 7.438),
GeoUtils.buildPoint(51.438, 7.375)
].toSet()

when:
Expand All @@ -120,13 +120,13 @@ class CsvIdCoordinateSourceIconIT extends Specification implements CsvTestDataMe
def "The CsvIdCoordinateSource is able to return the nearest n coordinates in a collection" () {
given:
def allCoordinates = [
GeoUtils.xyToPoint(1d, 39d),
GeoUtils.xyToPoint(2d, 40d),
GeoUtils.xyToPoint(1d, 40d),
GeoUtils.xyToPoint(2d, 39d)
GeoUtils.buildPoint(39d, 1d),
GeoUtils.buildPoint(40d, 2d),
GeoUtils.buildPoint(40d, 1d),
GeoUtils.buildPoint(39d, 2d)
]

def basePoint = GeoUtils.xyToPoint(1.438029, 39.617162)
def basePoint = GeoUtils.buildPoint(39.617162, 1.438029)
def expectedDistances = [
new CoordinateDistance(basePoint, allCoordinates[2]),
new CoordinateDistance(basePoint, allCoordinates[1])
Expand All @@ -143,7 +143,7 @@ class CsvIdCoordinateSourceIconIT extends Specification implements CsvTestDataMe
given:
def n = 2
def allCoordinates = source.allCoordinates
def basePoint = GeoUtils.xyToPoint(1.438029, 39.617162)
def basePoint = GeoUtils.buildPoint(39.617162, 1.438029)
def expectedDistances = source.getNearestCoordinates(basePoint, n, allCoordinates)

when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine
def "An InfluxDbWeatherSource will return an equivalent to 'empty' when being unable to map a coordinate to it's ID"() {
given:
def validCoordinate = CosmoWeatherTestData.COORDINATE_193186
def invalidCoordinate = GeoUtils.xyToPoint(48d, 7d)
def invalidCoordinate = GeoUtils.buildPoint(7d, 48d)
def time = CosmoWeatherTestData.TIME_15H
def timeInterval = new ClosedInterval(CosmoWeatherTestData.TIME_15H, CosmoWeatherTestData.TIME_17H)
def emptyTimeSeries = new IndividualTimeSeries(UUID.randomUUID(), Collections.emptySet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class InfluxDbWeatherSourceIconIT extends Specification implements WeatherSource
def "An InfluxDbWeatherSource will return an equivalent to 'empty' when being unable to map a coordinate to it's ID"() {
given:
def validCoordinate = IconWeatherTestData.COORDINATE_67775
def invalidCoordinate = GeoUtils.xyToPoint(48d, 7d)
def invalidCoordinate = GeoUtils.buildPoint(7d, 48d)
def time = IconWeatherTestData.TIME_15H
def timeInterval = new ClosedInterval(IconWeatherTestData.TIME_15H , IconWeatherTestData.TIME_17H)
def emptyTimeSeries = new IndividualTimeSeries(UUID.randomUUID(), Collections.emptySet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelp

def "A SqlWeatherSource returns nothing for an invalid coordinate"() {
when:
def optTimeBasedValue = source.getWeather(CosmoWeatherTestData.TIME_15H, GeoUtils.xyToPoint(88d, 89d))
def optTimeBasedValue = source.getWeather(CosmoWeatherTestData.TIME_15H, GeoUtils.buildPoint(89d, 88d))

then:
optTimeBasedValue.empty
Expand Down Expand Up @@ -97,8 +97,8 @@ class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelp
def "A SqlWeatherSource returns nothing for invalid coordinates"() {
given:
def coordinates = [
GeoUtils.xyToPoint(88d, 89d),
GeoUtils.xyToPoint(89d, 89d)
GeoUtils.buildPoint(89d, 88d),
GeoUtils.buildPoint(89d, 89d)
]
def timeInterval = new ClosedInterval(CosmoWeatherTestData.TIME_16H, CosmoWeatherTestData.TIME_17H)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GridAndGeoUtilsTest extends Specification {

then:
def e = thrown(IllegalStateException)
e.message == "Utility classes cannot be instantiated"
e.message == "Utility classes cannot be instantiated."
}

def "The grid and geo utils should calculate distance between two nodes correctly"() {
Expand Down
20 changes: 10 additions & 10 deletions src/test/groovy/edu/ie3/test/common/WeatherTestData.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ abstract class WeatherTestData {
@Override
Optional<Point> getCoordinate(int id) {
switch (id) {
case 193186: return Optional.of(GeoUtils.xyToPoint(49d, 7d))
case 193187: return Optional.of(GeoUtils.xyToPoint(49d, 8d))
case 193188: return Optional.of(GeoUtils.xyToPoint(50d, 7d))
case 67775: return Optional.of(GeoUtils.xyToPoint(50d, 8d))
case 67776: return Optional.of(GeoUtils.xyToPoint(51d, 7d))
case 193186: return Optional.of(GeoUtils.buildPoint(7d, 49d))
case 193187: return Optional.of(GeoUtils.buildPoint(8d, 49d))
case 193188: return Optional.of(GeoUtils.buildPoint(7d, 50d))
case 67775: return Optional.of(GeoUtils.buildPoint(8d, 50d))
case 67776: return Optional.of(GeoUtils.buildPoint(7d, 51d))
}
return Optional.empty()
}
Expand Down Expand Up @@ -53,11 +53,11 @@ abstract class WeatherTestData {
@Override
Collection<Point> getAllCoordinates() {
return [
GeoUtils.xyToPoint(49d, 7d),
GeoUtils.xyToPoint(49d, 8d),
GeoUtils.xyToPoint(50d, 7d),
GeoUtils.xyToPoint(50d, 8d),
GeoUtils.xyToPoint(51d, 7d)
GeoUtils.buildPoint(7d, 49d),
GeoUtils.buildPoint(8d, 49d),
GeoUtils.buildPoint(7d, 50d),
GeoUtils.buildPoint(8d, 50d),
GeoUtils.buildPoint(7d, 51d)
]
}
}
Expand Down