diff --git a/CHANGELOG.md b/CHANGELOG.md index bedb73618..ec5cb4033 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased/Snapshot] +### Added +- Enhancing `VoltageLevel` with `equals` method [#1063](https://github.com/ie3-institute/PowerSystemDataModel/issues/1063) + +### Fixed + +### Changed +- Improvements to the search for corner points in `IdCoordinateSource` [#1016](https://github.com/ie3-institute/PowerSystemDataModel/issues/1016) + + ## [5.0.1] - 2024-03-07 ### Fixed @@ -23,7 +32,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added test for invalid input data in `CsvRawGridSource` [#1021](https://github.com/ie3-institute/PowerSystemDataModel/issues/1021) - Added `CsvThermalGridSource` [#1009](https://github.com/ie3-institute/PowerSystemDataModel/issues/1009) - Enhance documentation for CSV timeseries [#825](https://github.com/ie3-institute/PowerSystemDataModel/issues/825) -- Enhancing `VoltageLevel` with `equals` method [#1063](https://github.com/ie3-institute/PowerSystemDataModel/issues/1063) ### Fixed - Fixed Couchbase integration tests that randomly failed [#755](https://github.com/ie3-institute/PowerSystemDataModel/issues/755) diff --git a/docs/readthedocs/conf.py b/docs/readthedocs/conf.py index cdf07d375..461dd252f 100644 --- a/docs/readthedocs/conf.py +++ b/docs/readthedocs/conf.py @@ -22,8 +22,8 @@ author = 'Institute of Energy Systems, Energy Efficiency and Energy Economics' # The full version, including alpha/beta/rc tags -version = '3.0' -release = '3.0.0' +version = '5.0' +release = '5.0.1' pygments_style = 'tango' add_function_parentheses = True diff --git a/docs/readthedocs/gettingstarted.md b/docs/readthedocs/gettingstarted.md index 6dd5c1353..2dea1825a 100644 --- a/docs/readthedocs/gettingstarted.md +++ b/docs/readthedocs/gettingstarted.md @@ -20,7 +20,7 @@ On [Maven central](https://search.maven.org/artifact/com.github.ie3-institute/Po com.github.ie3-institute PowerSystemDataModel - 2.1.0 + 5.0.1 ``` @@ -41,7 +41,7 @@ and add the dependency: com.github.ie3-institute PowerSystemDataModel - 3.0-SNAPSHOT + 6.0-SNAPSHOT ``` diff --git a/docs/readthedocs/io/csvfiles.md b/docs/readthedocs/io/csvfiles.md index 398b36cc3..54a6b7369 100644 --- a/docs/readthedocs/io/csvfiles.md +++ b/docs/readthedocs/io/csvfiles.md @@ -81,6 +81,12 @@ You may extend / alter the naming with pre- or suffix by calling `new EntityPers ``` +### Id Coordinate +Csv id coordinate sources can have two different ways to represent their coordinate: +1. ICON: Takes a `latitude` and a `longitude` column +2. COSMO: Takes a `lat_rot`, a `long_rot`, a `lat_geo` and a `long_geo` column + + ### Time Series ```{eval-rst} diff --git a/docs/readthedocs/models/input/additionaldata/idcoordinatesource.md b/docs/readthedocs/models/input/additionaldata/idcoordinatesource.md index 665490477..4196d0736 100644 --- a/docs/readthedocs/models/input/additionaldata/idcoordinatesource.md +++ b/docs/readthedocs/models/input/additionaldata/idcoordinatesource.md @@ -7,11 +7,21 @@ coordinates. ## Information -| Attribute | Remarks | -|:-------------|:---------------------------------------------------------------| -| `Id` | An integer value for identifying the coordinate. | -| `Coordiante` | Geographical information presented as `Lat/long` of a `Point`. | +```{eval-rst} +.. list-table:: + :widths: 33 33 + :header-rows: 1 + + * - Attribute + - Remarks + + * - Id + - An integer value for identifying the coordinate. + + * - Coordinate + - Geographical information presented as `Lat/long` of a `Point`. +``` ## Known implementations: @@ -74,19 +84,17 @@ return less than n coordinates. ## Finding and returning the closest corner coordinates: -In most cases we need four corner coordinates for our given coordinate. Therefor the -IdCoordinateSource contains a method that will use the calculated distances to find the closest -corner coordinates for the given coordinate. +In most cases we need four corner coordinates for our given coordinate. Therefor the IdCoordinateSource contains methods +that tries to return the corner points for a given coordinate. The max. number of corner points is specified by the +implementation of the second method. ``` java - List restrictToBoundingBox( - Point coordinate, - Collection distances, - int numberOfPoints - ) + List findCornerPoints(Point coordinate, ComparableQuantity distance) + List findCornerPoints(Point coordinate, Collection distances) ``` -For a given set of coordinates, the closest four corner coordinates plus more close points if n > 4 -are returned. If n < 4 the method will return the closest n corner coordinates. If the set of -coordinates contains a coordinate that matches the given coordinate, only this one coordinate is -returned. If n > number of coordinates in the set, all coordinates are returned. \ No newline at end of file +1. This method can be used to return the corner points by specifying a maximum search distance. + +2. If a coordinate matches the given coordinate, only this coordinate is returned. If no coordinate matches the given +coordinate, this method tries to return four corner points. + diff --git a/docs/readthedocs/models/input/additionaldata/timeseries.md b/docs/readthedocs/models/input/additionaldata/timeseries.md index 9590a8404..d486f78ca 100644 --- a/docs/readthedocs/models/input/additionaldata/timeseries.md +++ b/docs/readthedocs/models/input/additionaldata/timeseries.md @@ -17,14 +17,39 @@ In addition to actual data, a mapping function has to be known. To be as flexible, as possible, the actual content of the time series is given as children of the `Value` class. The following different values are available: -| Value Class | Purpose | -|:-----------------------|:--------------------------------------------------------------------------------------------------------------| -| `PValue` | Electrical active power | -| `SValue` | Electrical active and reactive power | -| `HeatAndPValue` | Combination of thermal power (e.g. in kW)
and electrical active power (e.g. in kW) | -| `HeatAndSValue` | Combination of thermal power (e.g. in kW)
and electrical active and reactive power (e.g. in kW and kVAr) | -| `EnergyPriceValue` | Wholesale market price (e.g. in € / MWh) | -| `SolarIrradianceValue` | Combination of diffuse and direct solar irradiance | -| `TemperatureValue` | Temperature information | -| `WindValue` | Combination of wind direction and wind velocity | -| `WeatherValue` | Combination of irradiance, temperature and wind information | +```{eval-rst} +.. list-table:: + :widths: 33 33 + :header-rows: 1 + + * - Value Class + - Purpose + + * - `PValue` + - Electrical active power + + * - `SValue` + - Electrical active and reactive power + + * - `HeatAndPValue` + - Combination of thermal power (e.g. in kW)
and electrical active power (e.g. in kW) + + * - `HeatAndSValue` + - Combination of thermal power (e.g. in kW)
and electrical active and reactive power (e.g. in kW and kVAr) + + * - `EnergyPriceValue` + - Wholesale market price (e.g. in € / MWh) + + * - `SolarIrradianceValue` + - Combination of diffuse and direct solar irradiance + + * - `TemperatureValue` + - Temperature information + + * - `WindValue` + - Combination of wind direction and wind velocity + + * - `WeatherValue` + - Combination of irradiance, temperature and wind information + +``` diff --git a/docs/readthedocs/models/input/em.md b/docs/readthedocs/models/input/em.md index 3e842e612..5f9c698c6 100644 --- a/docs/readthedocs/models/input/em.md +++ b/docs/readthedocs/models/input/em.md @@ -10,7 +10,7 @@ Participants are connected to an EM each via their `em` field. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/grid/gridcontainer.md b/docs/readthedocs/models/input/grid/gridcontainer.md index c39ab3386..85cad16a9 100644 --- a/docs/readthedocs/models/input/grid/gridcontainer.md +++ b/docs/readthedocs/models/input/grid/gridcontainer.md @@ -40,7 +40,7 @@ A synoptic overview of both classes' attributes is given here: ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/grid/line.md b/docs/readthedocs/models/input/grid/line.md index 9227d36b7..1f0ebebee 100644 --- a/docs/readthedocs/models/input/grid/line.md +++ b/docs/readthedocs/models/input/grid/line.md @@ -9,7 +9,7 @@ Representation of an AC line. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute - Unit @@ -56,7 +56,7 @@ A list with some standard line types can be found here: [Standard Line Types](#s ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute @@ -129,7 +129,7 @@ Some standard overhead lines. ```{eval-rst} .. list-table:: :widths: 11 11 11 11 11 11 11 11 11 - :header-rows: 0 + :header-rows: 1 * - uuid @@ -312,7 +312,7 @@ Some standard cables. ```{eval-rst} .. list-table:: :widths: 11 11 11 11 11 11 11 11 11 - :header-rows: 0 + :header-rows: 1 * - uuid diff --git a/docs/readthedocs/models/input/grid/linegraphic.md b/docs/readthedocs/models/input/grid/linegraphic.md index d97d695ab..f23fa1b16 100644 --- a/docs/readthedocs/models/input/grid/linegraphic.md +++ b/docs/readthedocs/models/input/grid/linegraphic.md @@ -9,7 +9,7 @@ Schematic drawing information for a line model. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/grid/measurementunit.md b/docs/readthedocs/models/input/grid/measurementunit.md index 0d00d0f3a..aa5a58195 100644 --- a/docs/readthedocs/models/input/grid/measurementunit.md +++ b/docs/readthedocs/models/input/grid/measurementunit.md @@ -11,7 +11,7 @@ The measured information are indicated by boolean fields. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/grid/node.md b/docs/readthedocs/models/input/grid/node.md index f60c0d21a..d409c3141 100644 --- a/docs/readthedocs/models/input/grid/node.md +++ b/docs/readthedocs/models/input/grid/node.md @@ -9,7 +9,7 @@ Representation of an electrical node, with no further distinction into bus bar, ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/grid/nodegraphic.md b/docs/readthedocs/models/input/grid/nodegraphic.md index 6bb73c0ef..07a55a948 100644 --- a/docs/readthedocs/models/input/grid/nodegraphic.md +++ b/docs/readthedocs/models/input/grid/nodegraphic.md @@ -9,7 +9,7 @@ Schematic drawing information for a node model. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/grid/switch.md b/docs/readthedocs/models/input/grid/switch.md index a4ab706cc..6a4ae4db1 100644 --- a/docs/readthedocs/models/input/grid/switch.md +++ b/docs/readthedocs/models/input/grid/switch.md @@ -9,7 +9,7 @@ Model of an ideal switch connecting two node models of the same voltage level ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/grid/transformer2w.md b/docs/readthedocs/models/input/grid/transformer2w.md index 6e4ef7c6f..32be9b754 100644 --- a/docs/readthedocs/models/input/grid/transformer2w.md +++ b/docs/readthedocs/models/input/grid/transformer2w.md @@ -13,7 +13,7 @@ As obvious, the parameter can be used in T- as in 𝜋-equivalent circuit repres ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute - Unit @@ -85,7 +85,7 @@ A list with some standard transformer types can be found here: [Standard Two Win ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute - Unit @@ -145,7 +145,7 @@ The transformers which source is ``simBench`` are from [here](https://simbench.d ```{eval-rst} .. list-table:: :widths: 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 - :header-rows: 0 + :header-rows: 1 * - uuid - bM diff --git a/docs/readthedocs/models/input/grid/transformer3w.md b/docs/readthedocs/models/input/grid/transformer3w.md index 15575c78c..ec2c21b3f 100644 --- a/docs/readthedocs/models/input/grid/transformer3w.md +++ b/docs/readthedocs/models/input/grid/transformer3w.md @@ -25,7 +25,7 @@ All impedances and admittances are given with respect to the higher voltage side ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute @@ -123,7 +123,7 @@ All impedances and admittances are given with respect to the higher voltage side ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/operator.md b/docs/readthedocs/models/input/operator.md index dc560f18d..30d29374c 100644 --- a/docs/readthedocs/models/input/operator.md +++ b/docs/readthedocs/models/input/operator.md @@ -10,7 +10,7 @@ having control over one or more physical entitites. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/participant/bm.md b/docs/readthedocs/models/input/participant/bm.md index ff1854e10..913c0f5a5 100644 --- a/docs/readthedocs/models/input/participant/bm.md +++ b/docs/readthedocs/models/input/participant/bm.md @@ -11,7 +11,7 @@ Model of a biomass power plant. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute @@ -58,7 +58,7 @@ Model of a biomass power plant. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/participant/chp.md b/docs/readthedocs/models/input/participant/chp.md index ad4ff729e..b9012a02a 100644 --- a/docs/readthedocs/models/input/participant/chp.md +++ b/docs/readthedocs/models/input/participant/chp.md @@ -11,7 +11,7 @@ Combined heat and power plant. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute @@ -66,7 +66,7 @@ Combined heat and power plant. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/participant/ev.md b/docs/readthedocs/models/input/participant/ev.md index e70bcb0d2..aeee017ab 100644 --- a/docs/readthedocs/models/input/participant/ev.md +++ b/docs/readthedocs/models/input/participant/ev.md @@ -11,7 +11,7 @@ Model of an electric vehicle, that is occasionally connected to the grid via an ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute @@ -62,7 +62,7 @@ Model of an electric vehicle, that is occasionally connected to the grid via an ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/participant/evcs.md b/docs/readthedocs/models/input/participant/evcs.md index b97def9c3..f4b836ebe 100644 --- a/docs/readthedocs/models/input/participant/evcs.md +++ b/docs/readthedocs/models/input/participant/evcs.md @@ -12,7 +12,7 @@ station and has some limitations outlined below. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute @@ -81,7 +81,7 @@ The actual model definition for charging point types looks as follows: ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute @@ -119,7 +119,7 @@ synonymous ids. All standard types can be found in {code}`edu.ie3.datamodel.mode ```{eval-rst} .. list-table:: :widths: 25 25 25 25 - :header-rows: 0 + :header-rows: 1 * - id @@ -223,7 +223,7 @@ and underscores and minuses are ignored, that means "charginghubtown" is parsed ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - type name diff --git a/docs/readthedocs/models/input/participant/fixedfeedin.md b/docs/readthedocs/models/input/participant/fixedfeedin.md index 2098271de..a6348a7ed 100644 --- a/docs/readthedocs/models/input/participant/fixedfeedin.md +++ b/docs/readthedocs/models/input/participant/fixedfeedin.md @@ -10,7 +10,7 @@ model can be derived. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/participant/hp.md b/docs/readthedocs/models/input/participant/hp.md index 71c8a1608..08a092992 100644 --- a/docs/readthedocs/models/input/participant/hp.md +++ b/docs/readthedocs/models/input/participant/hp.md @@ -11,7 +11,7 @@ Model of a heat pump. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute @@ -54,7 +54,7 @@ Model of a heat pump. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/participant/load.md b/docs/readthedocs/models/input/participant/load.md index c31f71549..a153e8392 100644 --- a/docs/readthedocs/models/input/participant/load.md +++ b/docs/readthedocs/models/input/participant/load.md @@ -9,7 +9,7 @@ Model of (mainly) domestic loads. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/participant/pv.md b/docs/readthedocs/models/input/participant/pv.md index 0746f0023..3e0946fd6 100644 --- a/docs/readthedocs/models/input/participant/pv.md +++ b/docs/readthedocs/models/input/participant/pv.md @@ -7,7 +7,7 @@ Detailed model of a photovoltaic power plant. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/participant/storage.md b/docs/readthedocs/models/input/participant/storage.md index dc4d4857d..6e0f5a313 100644 --- a/docs/readthedocs/models/input/participant/storage.md +++ b/docs/readthedocs/models/input/participant/storage.md @@ -11,7 +11,7 @@ Model of an ideal electrical battery energy storage. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute @@ -86,7 +86,7 @@ Model of an ideal electrical battery energy storage. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/participant/wec.md b/docs/readthedocs/models/input/participant/wec.md index 862cbbdcd..e0330669e 100644 --- a/docs/readthedocs/models/input/participant/wec.md +++ b/docs/readthedocs/models/input/participant/wec.md @@ -11,7 +11,7 @@ Model of a wind energy converter. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute @@ -66,7 +66,7 @@ Model of a wind energy converter. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/thermal/cylindricalstorage.md b/docs/readthedocs/models/input/thermal/cylindricalstorage.md index 5185adb62..553f63d3e 100644 --- a/docs/readthedocs/models/input/thermal/cylindricalstorage.md +++ b/docs/readthedocs/models/input/thermal/cylindricalstorage.md @@ -9,7 +9,7 @@ Model of a cylindrical thermal storage using a fluent to store thermal energy. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/thermal/thermalbus.md b/docs/readthedocs/models/input/thermal/thermalbus.md index 0c193af1a..acffc8379 100644 --- a/docs/readthedocs/models/input/thermal/thermalbus.md +++ b/docs/readthedocs/models/input/thermal/thermalbus.md @@ -10,7 +10,7 @@ A coupling point to thermal system - equivalent to [electrical node](../grid/nod ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/input/thermal/thermalhouse.md b/docs/readthedocs/models/input/thermal/thermalhouse.md index 93ae175b0..d06a1f59c 100644 --- a/docs/readthedocs/models/input/thermal/thermalhouse.md +++ b/docs/readthedocs/models/input/thermal/thermalhouse.md @@ -10,7 +10,7 @@ This reflects a simple shoe box with transmission losses ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/grid/connector.md b/docs/readthedocs/models/result/grid/connector.md index 2b3688fbb..19cd58ec3 100644 --- a/docs/readthedocs/models/result/grid/connector.md +++ b/docs/readthedocs/models/result/grid/connector.md @@ -9,7 +9,7 @@ Representation of all kinds of connectors. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/grid/line.md b/docs/readthedocs/models/result/grid/line.md index 066a74f45..e88f323ab 100644 --- a/docs/readthedocs/models/result/grid/line.md +++ b/docs/readthedocs/models/result/grid/line.md @@ -9,7 +9,7 @@ Representation of an AC line. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/grid/node.md b/docs/readthedocs/models/result/grid/node.md index 0a14d9ef1..b65e739d8 100644 --- a/docs/readthedocs/models/result/grid/node.md +++ b/docs/readthedocs/models/result/grid/node.md @@ -9,7 +9,7 @@ Representation of an electrical node, with no further distinction into bus bar, ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/grid/switch.md b/docs/readthedocs/models/result/grid/switch.md index 4c4ce088b..ae79fb2f0 100644 --- a/docs/readthedocs/models/result/grid/switch.md +++ b/docs/readthedocs/models/result/grid/switch.md @@ -9,7 +9,7 @@ Representation of electrical switches. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/grid/transformer.md b/docs/readthedocs/models/result/grid/transformer.md index a678220e9..8f3784a6a 100644 --- a/docs/readthedocs/models/result/grid/transformer.md +++ b/docs/readthedocs/models/result/grid/transformer.md @@ -9,7 +9,7 @@ Representation of transformers. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/grid/transformer2w.md b/docs/readthedocs/models/result/grid/transformer2w.md index b0630e199..c19550d50 100644 --- a/docs/readthedocs/models/result/grid/transformer2w.md +++ b/docs/readthedocs/models/result/grid/transformer2w.md @@ -9,7 +9,7 @@ Representation of two winding transformers. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/grid/transformer3w.md b/docs/readthedocs/models/result/grid/transformer3w.md index ce753aafd..61b27a789 100644 --- a/docs/readthedocs/models/result/grid/transformer3w.md +++ b/docs/readthedocs/models/result/grid/transformer3w.md @@ -9,7 +9,7 @@ Representation of three winding transformers. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/bm.md b/docs/readthedocs/models/result/participant/bm.md index 72a714b42..b36165809 100644 --- a/docs/readthedocs/models/result/participant/bm.md +++ b/docs/readthedocs/models/result/participant/bm.md @@ -9,7 +9,7 @@ Result of a biomass power plant. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/chp.md b/docs/readthedocs/models/result/participant/chp.md index 43157f6c7..410ff9e55 100644 --- a/docs/readthedocs/models/result/participant/chp.md +++ b/docs/readthedocs/models/result/participant/chp.md @@ -9,7 +9,7 @@ Result of a combined heat and power plant. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/cylindricalstorage.md b/docs/readthedocs/models/result/participant/cylindricalstorage.md index 9f390e2d3..84784f6a8 100644 --- a/docs/readthedocs/models/result/participant/cylindricalstorage.md +++ b/docs/readthedocs/models/result/participant/cylindricalstorage.md @@ -9,7 +9,7 @@ Result of a cylindrical thermal storage using a fluent to store thermal energy. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/em.md b/docs/readthedocs/models/result/participant/em.md index 35ff8f2da..58bf773ba 100644 --- a/docs/readthedocs/models/result/participant/em.md +++ b/docs/readthedocs/models/result/participant/em.md @@ -9,7 +9,7 @@ Result of an energy management entity. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/ev.md b/docs/readthedocs/models/result/participant/ev.md index 473d8e0ee..d8cce0d25 100644 --- a/docs/readthedocs/models/result/participant/ev.md +++ b/docs/readthedocs/models/result/participant/ev.md @@ -9,7 +9,7 @@ Result of an electric vehicle, that is occasionally connected to the grid via an ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/evcs.md b/docs/readthedocs/models/result/participant/evcs.md index f7db10bff..a42c1bd5f 100644 --- a/docs/readthedocs/models/result/participant/evcs.md +++ b/docs/readthedocs/models/result/participant/evcs.md @@ -9,7 +9,7 @@ This model is currently only a dummy implementation of an electric vehicle charg ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/fixedfeedin.md b/docs/readthedocs/models/result/participant/fixedfeedin.md index c27a1ba7e..4dc0ab47f 100644 --- a/docs/readthedocs/models/result/participant/fixedfeedin.md +++ b/docs/readthedocs/models/result/participant/fixedfeedin.md @@ -10,7 +10,7 @@ model can be derived. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/flexoption.md b/docs/readthedocs/models/result/participant/flexoption.md index 83d8f2a4e..4c08755b6 100644 --- a/docs/readthedocs/models/result/participant/flexoption.md +++ b/docs/readthedocs/models/result/participant/flexoption.md @@ -9,7 +9,7 @@ Result of a flexibility option. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/hp.md b/docs/readthedocs/models/result/participant/hp.md index 07931d8ca..233a0b64f 100644 --- a/docs/readthedocs/models/result/participant/hp.md +++ b/docs/readthedocs/models/result/participant/hp.md @@ -9,7 +9,7 @@ Result of a heat pump. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/load.md b/docs/readthedocs/models/result/participant/load.md index c60cbcc00..067795c17 100644 --- a/docs/readthedocs/models/result/participant/load.md +++ b/docs/readthedocs/models/result/participant/load.md @@ -9,7 +9,7 @@ Result of (mainly) domestic loads. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/pv.md b/docs/readthedocs/models/result/participant/pv.md index 61aa92bed..d1378864c 100644 --- a/docs/readthedocs/models/result/participant/pv.md +++ b/docs/readthedocs/models/result/participant/pv.md @@ -9,7 +9,7 @@ Result of a photovoltaic power plant. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/storage.md b/docs/readthedocs/models/result/participant/storage.md index 529cf059f..5c5767dcd 100644 --- a/docs/readthedocs/models/result/participant/storage.md +++ b/docs/readthedocs/models/result/participant/storage.md @@ -9,7 +9,7 @@ Result of an electrochemical storage ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/systemparticipant.md b/docs/readthedocs/models/result/participant/systemparticipant.md index 675c263e5..6b44abe6e 100644 --- a/docs/readthedocs/models/result/participant/systemparticipant.md +++ b/docs/readthedocs/models/result/participant/systemparticipant.md @@ -9,7 +9,7 @@ Groups together all system participants such as PV, Storage etc. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/thermalhouse.md b/docs/readthedocs/models/result/participant/thermalhouse.md index c2ea525d8..942c7e39b 100644 --- a/docs/readthedocs/models/result/participant/thermalhouse.md +++ b/docs/readthedocs/models/result/participant/thermalhouse.md @@ -10,7 +10,7 @@ This reflects a simple shoe box with transmission losses ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/thermalsink.md b/docs/readthedocs/models/result/participant/thermalsink.md index cf40b56de..92d19b9b8 100644 --- a/docs/readthedocs/models/result/participant/thermalsink.md +++ b/docs/readthedocs/models/result/participant/thermalsink.md @@ -9,7 +9,7 @@ Result of a thermal sink. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/thermalstorage.md b/docs/readthedocs/models/result/participant/thermalstorage.md index bb774f775..abbad4e92 100644 --- a/docs/readthedocs/models/result/participant/thermalstorage.md +++ b/docs/readthedocs/models/result/participant/thermalstorage.md @@ -9,7 +9,7 @@ Result of a thermal storage. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/thermalunit.md b/docs/readthedocs/models/result/participant/thermalunit.md index 3fd2b8e78..bedaa368d 100644 --- a/docs/readthedocs/models/result/participant/thermalunit.md +++ b/docs/readthedocs/models/result/participant/thermalunit.md @@ -9,7 +9,7 @@ Result of a thermal unit. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/docs/readthedocs/models/result/participant/wec.md b/docs/readthedocs/models/result/participant/wec.md index 8ba08d097..b4e8e44ce 100644 --- a/docs/readthedocs/models/result/participant/wec.md +++ b/docs/readthedocs/models/result/participant/wec.md @@ -9,7 +9,7 @@ Result of a wind turbine. ```{eval-rst} .. list-table:: :widths: 33 33 33 - :header-rows: 0 + :header-rows: 1 * - Attribute diff --git a/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java b/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java index 33e0daf58..d7d72ffca 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java @@ -84,8 +84,7 @@ List getClosestCoordinates( /** * Calculates and returns the nearest n coordinate distances to the given coordinate from a given - * collection of points. If the set is empty or null an empty list is returned. If n is greater - * than four, this method will try to return the corner points of the bounding box. + * collection of points. If the set is empty or null an empty list is returned. * * @param coordinate the coordinate to look up the nearest neighbours for * @param n how many neighbours to look up @@ -95,81 +94,77 @@ List getClosestCoordinates( default List calculateCoordinateDistances( Point coordinate, int n, Collection coordinates) { if (coordinates != null && !coordinates.isEmpty()) { - List sortedDistances = - GeoUtils.calcOrderedCoordinateDistances(coordinate, coordinates); - return restrictToBoundingBox(coordinate, sortedDistances, n); + return GeoUtils.calcOrderedCoordinateDistances(coordinate, coordinates).stream() + .limit(n) + .toList(); } else { return Collections.emptyList(); } } /** - * Method for evaluating the found points. This method tries to return the four corner points of - * the bounding box of the given coordinate. If one of the found points matches the given - * coordinate, only this point is returned. If the given number of searched points is less than - * four, this method will only return the nearest n corner points. If the given number of searched - * points is greater than four, this method will return the four corner points plus the nearest n - * points to match the number of searched points. + * Method for finding the corner points of a given coordinate within a given distance. + * + *

The max. number of returned corner points is set by the implementation (default: 4). + * + * @param coordinate at the center + * @param distance list of fount points with their distances + * @return either a list with one exact match or a list of corner points (default implementation: + * max. 4 points) + */ + List findCornerPoints(Point coordinate, ComparableQuantity distance); + + /** + * Method for finding the corner points of a given coordinate. If a point matches the given + * coordinate, only this point is returned. + * + *

The max. number of returned corner points is set by the implementation (default: 4). * *

To work properly, the given collection of {@link CoordinateDistance}'s should already be * sorted by distance. * - * @param coordinate at the center of the bounding box - * @param distances list of found points with their distances - * @param numberOfPoints that should be returned - * @return list of distances + * @param coordinate at the center + * @param coordinateDistances list of fount points with their distances + * @return either a list with one exact match or a list of corner points (default implementation: + * max. 4 points) */ - default List restrictToBoundingBox( - Point coordinate, Collection distances, int numberOfPoints) { + default List findCornerPoints( + Point coordinate, Collection coordinateDistances) { boolean topLeft = false; boolean topRight = false; boolean bottomLeft = false; boolean bottomRight = false; List resultingDistances = new ArrayList<>(); - List other = new ArrayList<>(); // search for smallest bounding box - for (CoordinateDistance distance : distances) { + for (CoordinateDistance distance : coordinateDistances) { Point point = distance.getCoordinateB(); // check for bounding box if (coordinate.equalsExact(point, 1e-6)) { // if current point is matching the given coordinate, we need to return only the current // point - resultingDistances.clear(); - resultingDistances.add(distance); - return resultingDistances; + return List.of(distance); } else if (!topLeft - && (point.getX() < coordinate.getX() && point.getY() > coordinate.getY())) { + && (point.getX() <= coordinate.getX() && point.getY() >= coordinate.getY())) { resultingDistances.add(distance); topLeft = true; } else if (!topRight - && (point.getX() > coordinate.getX() && point.getY() > coordinate.getY())) { + && (point.getX() >= coordinate.getX() && point.getY() >= coordinate.getY())) { resultingDistances.add(distance); topRight = true; } else if (!bottomLeft - && (point.getX() < coordinate.getX() && point.getY() < coordinate.getY())) { + && (point.getX() <= coordinate.getX() && point.getY() <= coordinate.getY())) { resultingDistances.add(distance); bottomLeft = true; } else if (!bottomRight - && (point.getX() > coordinate.getX() && point.getY() < coordinate.getY())) { + && (point.getX() >= coordinate.getX() && point.getY() <= coordinate.getY())) { resultingDistances.add(distance); bottomRight = true; - } else { - other.add(distance); } } - // check if n distances are found - int diff = numberOfPoints - resultingDistances.size(); - - if (diff > 0) { - resultingDistances.addAll(other.stream().limit(diff).toList()); - } else if (diff < 0) { - return resultingDistances.stream().limit(numberOfPoints).toList(); - } - return resultingDistances; } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSource.java b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSource.java index 7868c809e..04a1b08d9 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSource.java @@ -161,20 +161,31 @@ public List getNearestCoordinates(Point coordinate, int n) { @Override public List getClosestCoordinates( Point coordinate, int n, ComparableQuantity distance) { - Set points = coordinateToId.keySet(); - - Envelope envelope = GeoUtils.calculateBoundingBox(coordinate, distance); - Set reducedPoints = - points.stream() - .filter(point -> envelope.contains(point.getCoordinate())) - .collect(Collectors.toSet()); + Collection reducedPoints = getCoordinatesInBoundingBox(coordinate, distance); return calculateCoordinateDistances(coordinate, n, reducedPoints); } + @Override + public List findCornerPoints( + Point coordinate, ComparableQuantity distance) { + Collection points = getCoordinatesInBoundingBox(coordinate, distance); + return findCornerPoints( + coordinate, GeoUtils.calcOrderedCoordinateDistances(coordinate, points)); + } + public int getCoordinateCount() { return idToCoordinate.keySet().size(); } + private Collection getCoordinatesInBoundingBox( + Point coordinate, ComparableQuantity distance) { + Set points = coordinateToId.keySet(); + Envelope envelope = GeoUtils.calculateBoundingBox(coordinate, distance); + return points.stream() + .filter(point -> envelope.contains(point.getCoordinate())) + .collect(Collectors.toSet()); + } + /** * Build a stream with mappings from field identifiers to attributes * diff --git a/src/main/java/edu/ie3/datamodel/io/source/sql/SqlIdCoordinateSource.java b/src/main/java/edu/ie3/datamodel/io/source/sql/SqlIdCoordinateSource.java index 387039266..4424d3adf 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/sql/SqlIdCoordinateSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/sql/SqlIdCoordinateSource.java @@ -178,25 +178,37 @@ public List getNearestCoordinates(Point coordinate, int n) { @Override public List getClosestCoordinates( Point coordinate, int n, ComparableQuantity distance) { + List points = getCoordinatesInBoundingBox(coordinate, distance); + return calculateCoordinateDistances(coordinate, n, points); + } + + @Override + public List findCornerPoints( + Point coordinate, ComparableQuantity distance) { + List points = getCoordinatesInBoundingBox(coordinate, distance); + return findCornerPoints( + coordinate, GeoUtils.calcOrderedCoordinateDistances(coordinate, points)); + } + + // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + + private List getCoordinatesInBoundingBox( + Point coordinate, ComparableQuantity distance) { Envelope envelope = GeoUtils.calculateBoundingBox(coordinate, distance); - List values = - executeQueryToList( + return executeQueryToList( queryForBoundingBox, ps -> { ps.setDouble(1, envelope.getMinX()); ps.setDouble(2, envelope.getMinY()); ps.setDouble(3, envelope.getMaxX()); ps.setDouble(4, envelope.getMaxY()); - }); - - List points = values.stream().map(value -> value.coordinate).toList(); - - return calculateCoordinateDistances(coordinate, n, points); + }) + .stream() + .map(value -> value.coordinate) + .toList(); } - // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - private CoordinateValue createCoordinateValue(Map fieldToValues) { fieldToValues.remove("distance"); diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/IdCoordinateSourceMock.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/IdCoordinateSourceMock.groovy index bdbe1fea6..b6e2a909a 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/IdCoordinateSourceMock.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/IdCoordinateSourceMock.groovy @@ -48,4 +48,9 @@ class IdCoordinateSourceMock implements IdCoordinateSource { List getClosestCoordinates(Point coordinate, int n, ComparableQuantity distance) { return Collections.emptyList() } + + @Override + List findCornerPoints(Point coordinate, ComparableQuantity distance) { + return Collections.emptyList() + } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/IdCoordinateSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/IdCoordinateSourceTest.groovy index 833a47c48..ce336adf2 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/IdCoordinateSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/IdCoordinateSourceTest.groovy @@ -14,15 +14,15 @@ class IdCoordinateSourceTest extends Specification { private final IdCoordinateSourceMock coordinateSourceMock = new IdCoordinateSourceMock() private final Point point0 = GeoUtils.buildPoint(52.5, 7.5) - private final Point point1 = GeoUtils.buildPoint(53, 8) + private final Point point1 = GeoUtils.buildPoint(53, 7.9) private final Point point2 = GeoUtils.buildPoint(53, 7) - private final Point point3 = GeoUtils.buildPoint(53, 6) - private final Point point4 = GeoUtils.buildPoint(52, 8) + private final Point point3 = GeoUtils.buildPoint(53, 6.2) + private final Point point4 = GeoUtils.buildPoint(52, 7.9) private final Point point5 = GeoUtils.buildPoint(52, 7) - private final Point point6 = GeoUtils.buildPoint(52, 6) - private final Point point7 = GeoUtils.buildPoint(51, 8) + private final Point point6 = GeoUtils.buildPoint(52, 6.2) + private final Point point7 = GeoUtils.buildPoint(51, 7.9) private final Point point8 = GeoUtils.buildPoint(51, 7) - private final Point point9 = GeoUtils.buildPoint(51, 6) + private final Point point9 = GeoUtils.buildPoint(51, 6.2) private final List points = [ point1, @@ -36,27 +36,25 @@ class IdCoordinateSourceTest extends Specification { point9 ] - def "IdCoordinateSource should return correct number of corner points restricted to the bounding box"() { + def "IdCoordinateSource should return only the corner points of a collection of coordinate distances"() { given: List expectedPoints = [ + point1, point2, point4, - point5, - point6, - point8 + point5 ] when: - List distances = coordinateSourceMock.calculateCoordinateDistances(point0, 9, points) - List result = coordinateSourceMock.restrictToBoundingBox(point0, distances, 4) + List distances = GeoUtils.calcOrderedCoordinateDistances(point0, points) + List result = coordinateSourceMock.findCornerPoints(point0, distances) then: - for (CoordinateDistance value: result) { - expectedPoints.contains(value.coordinateB) - } + result.size() == expectedPoints.size() + result*.coordinateB.containsAll(expectedPoints) } - def "IdCoordinateSource should return only one point of the bounding box if the starting coordinate exactly matched the found coordinate"() { + def "IdCoordinateSource should return only one point if the starting coordinate exactly matched the found coordinate"() { given: Point matchingPoint = GeoUtils.buildPoint(52.5, 7.5) @@ -64,8 +62,8 @@ class IdCoordinateSourceTest extends Specification { List withExactMatch = new ArrayList<>(points) withExactMatch.addAll(matchingPoint) - List distances = coordinateSourceMock.calculateCoordinateDistances(point0, 9, withExactMatch) - List result = coordinateSourceMock.restrictToBoundingBox(point0, distances, 4) + List distances = GeoUtils.calcOrderedCoordinateDistances(point0, withExactMatch) + List result = coordinateSourceMock.findCornerPoints(point0, distances) then: result.size() == 1 diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceCosmoIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceCosmoIT.groovy index b878d2b28..d45e457e6 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceCosmoIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceCosmoIT.groovy @@ -206,4 +206,28 @@ class CsvIdCoordinateSourceCosmoIT extends Specification implements CsvTestDataM then: actualDistances.size() == 1 } + + def "The CsvCoordinateSource will return less than four corner points if not enough points are within the given distance"() { + given: + def basePoint = GeoUtils.buildPoint(39.61, 1.38) + def distance = Quantities.getQuantity(10000, Units.METRE) + + when: + def actualDistances = source.findCornerPoints(basePoint, distance) + + then: + actualDistances.size() == 3 + } + + def "The CsvCoordinateSource will return one point if there is an exact match"() { + given: + def basePoint = GeoUtils.buildPoint(39.617162, 1.438029) + def distance = Quantities.getQuantity(100, Units.METRE) + + when: + def actualDistances = source.findCornerPoints(basePoint, distance) + + then: + actualDistances.size() == 1 + } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceIconIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceIconIT.groovy index 869c9d882..8a9105b00 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceIconIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceIconIT.groovy @@ -191,4 +191,40 @@ class CsvIdCoordinateSourceIconIT extends Specification implements CsvTestDataMe then: actualDistances.size() == 1 } + + def "The CsvCoordinateSource will return the four corner points if enough points are within the given distance"() { + given: + def basePoint = GeoUtils.buildPoint(51.45, 7.4) + def distance = Quantities.getQuantity(10000, Units.METRE) + + when: + def actualDistances = source.findCornerPoints(basePoint, distance) + + then: + actualDistances.size() == 4 + } + + def "The CsvCoordinateSource will return less than four corner points if not enough points are within the given distance"() { + given: + def basePoint = GeoUtils.buildPoint(51.45, 7.38) + def distance = Quantities.getQuantity(5000, Units.METRE) + + when: + def actualDistances = source.findCornerPoints(basePoint, distance) + + then: + actualDistances.size() == 2 + } + + def "The CsvCoordinateSource will return one point if there is an exact match"() { + given: + def basePoint = GeoUtils.buildPoint(51.5, 7.438) + def distance = Quantities.getQuantity(100, Units.METRE) + + when: + def actualDistances = source.findCornerPoints(basePoint, distance) + + then: + actualDistances.size() == 1 + } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlIdCoordinateSourceIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlIdCoordinateSourceIT.groovy index 39be186ff..9678012b8 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlIdCoordinateSourceIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlIdCoordinateSourceIT.groovy @@ -187,4 +187,40 @@ class SqlIdCoordinateSourceIT extends Specification implements TestContainerHelp expectedValues.contains(coordinateDistance.coordinateB) } } + + def "The CsvCoordinateSource will return the four corner points if enough points are within the given distance"() { + given: + def basePoint = GeoUtils.buildPoint(51.45, 7.4) + def distance = Quantities.getQuantity(10000, Units.METRE) + + when: + def actualDistances = source.findCornerPoints(basePoint, distance) + + then: + actualDistances.size() == 4 + } + + def "The CsvCoordinateSource will return less than four corner points if not enough points are within the given distance"() { + given: + def basePoint = GeoUtils.buildPoint(51.45, 7.38) + def distance = Quantities.getQuantity(5000, Units.METRE) + + when: + def actualDistances = source.findCornerPoints(basePoint, distance) + + then: + actualDistances.size() == 2 + } + + def "The CsvCoordinateSource will return one point if there is an exact match"() { + given: + def basePoint = GeoUtils.buildPoint(51.5, 7.438) + def distance = Quantities.getQuantity(100, Units.METRE) + + when: + def actualDistances = source.findCornerPoints(basePoint, distance) + + then: + actualDistances.size() == 1 + } } diff --git a/src/test/groovy/edu/ie3/test/common/WeatherTestData.groovy b/src/test/groovy/edu/ie3/test/common/WeatherTestData.groovy index 343af527a..2eed3c090 100644 --- a/src/test/groovy/edu/ie3/test/common/WeatherTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/WeatherTestData.groovy @@ -80,6 +80,11 @@ abstract class WeatherTestData { List getClosestCoordinates(Point coordinate, int n, ComparableQuantity distance) { throw new UnsupportedOperationException("This method is not supported!") } + + @Override + List findCornerPoints(Point coordinate, ComparableQuantity distance) { + throw new UnsupportedOperationException("This method is not supported!") + } } public static final IdCoordinateSource coordinateSource = new DummyIdCoordinateSource()