Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSLogic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIPS
VIPSLogic
Commits
b5789191
Commit
b5789191
authored
8 months ago
by
Lene Wasskog
Browse files
Options
Downloads
Patches
Plain Diff
feat: Use organizations default grid weather station data source to get weather data for point
parent
49e27836
Branches
Branches containing commit
No related tags found
1 merge request
!191
Add map module and Open-Meteo support
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/no/nibio/vips/logic/modules/barleynetblotch/BarleyNetBlotchModelService.java
+18
-19
18 additions, 19 deletions
.../modules/barleynetblotch/BarleyNetBlotchModelService.java
with
18 additions
and
19 deletions
src/main/java/no/nibio/vips/logic/modules/barleynetblotch/BarleyNetBlotchModelService.java
+
18
−
19
View file @
b5789191
...
@@ -170,18 +170,24 @@ public class BarleyNetBlotchModelService {
...
@@ -170,18 +170,24 @@ public class BarleyNetBlotchModelService {
Double
preparationDose
=
parseUtil
.
parseDouble
(
preparationDoseStr
);
Double
preparationDose
=
parseUtil
.
parseDouble
(
preparationDoseStr
);
Double
latitudeDouble
=
parseUtil
.
parseDouble
(
latitude
);
Double
latitudeDouble
=
parseUtil
.
parseDouble
(
latitude
);
Double
longitudeDouble
=
parseUtil
.
parseDouble
(
longitude
);
Double
longitudeDouble
=
parseUtil
.
parseDouble
(
longitude
);
if
(
weatherDataSourceType
==
null
)
{
return
Response
.
status
(
Response
.
Status
.
BAD_REQUEST
).
entity
(
"WeatherDataSourceType (grid or weather station) is required"
).
build
();
}
// Must get the VIPSCore user id for this organization
Organization
org
=
em
.
find
(
Organization
.
class
,
organizationId
);
Integer
VIPSCoreUserId
=
org
.
getDefaultVipsCoreUserId
();
// Build model configuration
// Build model configuration
ModelConfiguration
config
=
new
ModelConfiguration
();
ModelConfiguration
config
=
new
ModelConfiguration
();
config
.
setModelId
(
"BARLEYNETB"
);
config
.
setModelId
(
"BARLEYNETB"
);
// Get weather data from weather station
WeatherDataSourceUtil
wsdUtil
=
new
WeatherDataSourceUtil
();
WeatherDataSourceUtil
wsdUtil
=
new
WeatherDataSourceUtil
();
Date
endDateForWeatherData
=
calculateEndDateForWeatherData
(
timeZone
,
sowingDate
);
Date
endDateForWeatherData
=
calculateEndDateForWeatherData
(
timeZone
,
sowingDate
);
List
<
WeatherObservation
>
observations
;
if
(
weatherDataSourceType
!=
null
&&
"weatherstation"
.
equals
(
weatherDataSourceType
.
trim
()))
{
List
<
WeatherObservation
>
observations
=
new
ArrayList
<>();
if
(
"weatherstation"
.
equals
(
weatherDataSourceType
.
trim
()))
{
PointOfInterestWeatherStation
weatherStation
=
PointOfInterestWeatherStation
weatherStation
=
em
.
find
(
PointOfInterestWeatherStation
.
class
,
weatherStationId
);
em
.
find
(
PointOfInterestWeatherStation
.
class
,
weatherStationId
);
LOGGER
.
info
(
"Run model with weatherdata from weatherstation {}"
,
weatherStation
.
getName
());
LOGGER
.
info
(
"Run model with weatherdata from weatherstation {}"
,
weatherStation
.
getName
());
...
@@ -203,14 +209,12 @@ public class BarleyNetBlotchModelService {
...
@@ -203,14 +209,12 @@ public class BarleyNetBlotchModelService {
return
Response
.
status
(
Response
.
Status
.
INTERNAL_SERVER_ERROR
)
return
Response
.
status
(
Response
.
Status
.
INTERNAL_SERVER_ERROR
)
.
entity
(
"Could not find weather data for weather station with id="
+
weatherStationId
).
build
();
.
entity
(
"Could not find weather data for weather station with id="
+
weatherStationId
).
build
();
}
}
}
else
{
}
else
if
(
"grid"
.
equals
(
weatherDataSourceType
.
trim
()))
{
PointOfInterest
coordinates
=
new
PointOfInterest
();
coordinates
.
setLatitude
(
latitudeDouble
);
coordinates
.
setLongitude
(
longitudeDouble
);
LOGGER
.
info
(
"Run model with weatherdata for latitude={} and longitude={}"
,
latitude
,
longitude
);
LOGGER
.
info
(
"Run model with weatherdata for latitude={} and longitude={}"
,
latitude
,
longitude
);
String
datafetchUriExpression
=
org
.
getDefaultGridWeatherStationDataSource
().
getDatafetchUriExpression
();
try
{
try
{
observations
=
wsdUtil
.
getWeatherObservations
(
observations
=
wsdUtil
.
getWeatherObservations
(
String
.
format
(
datafetchUriExpression
,
longitude
+
"_"
+
latitude
),
"https://weather.vips.nibio.no/rest/grid/openmeteo/"
+
coordinates
.
getLongitude
()
+
"_"
+
coordinates
.
getLatitude
(),
WeatherObservation
.
LOG_INTERVAL_ID_1H
,
WeatherObservation
.
LOG_INTERVAL_ID_1H
,
new
String
[]
{
new
String
[]
{
WeatherElements
.
TEMPERATURE_MEAN
,
WeatherElements
.
TEMPERATURE_MEAN
,
...
@@ -223,15 +227,15 @@ public class BarleyNetBlotchModelService {
...
@@ -223,15 +227,15 @@ public class BarleyNetBlotchModelService {
new
HashSet
<>(
Collections
.
singletonList
(
WeatherObservation
.
LOG_INTERVAL_ID_1H
))
new
HashSet
<>(
Collections
.
singletonList
(
WeatherObservation
.
LOG_INTERVAL_ID_1H
))
);
);
}
catch
(
WeatherDataSourceException
ex
)
{
}
catch
(
WeatherDataSourceException
ex
)
{
LOGGER
.
error
(
"Exception while getting observations for lat
itude
={} lon
gitude
={}"
,
latitude
,
longitude
,
ex
);
LOGGER
.
error
(
"Exception while getting observations for lat={} lon={}"
,
latitude
,
longitude
,
ex
);
return
Response
.
status
(
Response
.
Status
.
INTERNAL_SERVER_ERROR
).
entity
(
ex
.
getMessage
()).
build
();
return
Response
.
status
(
Response
.
Status
.
INTERNAL_SERVER_ERROR
).
entity
(
ex
.
getMessage
()).
build
();
}
}
if
(
observations
==
null
||
observations
.
isEmpty
())
{
if
(
observations
==
null
||
observations
.
isEmpty
())
{
return
Response
.
status
(
Response
.
Status
.
INTERNAL_SERVER_ERROR
)
return
Response
.
status
(
Response
.
Status
.
INTERNAL_SERVER_ERROR
)
.
entity
(
"Could not find weather data for
weather station with id="
+
weatherStationId
).
build
();
.
entity
(
String
.
format
(
"Could not find weather data for
lat=%s lon=%s between %s and %s"
,
latitude
,
longitude
,
sowingDate
,
endDateForWeatherData
)
).
build
();
}
}
}
}
// Mandatory parameters
// Mandatory parameters
config
.
setConfigParameter
(
"observations"
,
observations
);
config
.
setConfigParameter
(
"observations"
,
observations
);
config
.
setConfigParameter
(
"timeZone"
,
timeZone
.
getID
());
config
.
setConfigParameter
(
"timeZone"
,
timeZone
.
getID
());
...
@@ -257,11 +261,6 @@ public class BarleyNetBlotchModelService {
...
@@ -257,11 +261,6 @@ public class BarleyNetBlotchModelService {
config
.
setConfigParameter
(
"spraying"
,
spraying
);
config
.
setConfigParameter
(
"spraying"
,
spraying
);
}
}
// Must get the VIPSCore user id for this organization
Organization
org
=
em
.
find
(
Organization
.
class
,
organizationId
);
Integer
VIPSCoreUserId
=
org
.
getDefaultVipsCoreUserId
();
List
<
Result
>
results
;
List
<
Result
>
results
;
try
try
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment