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
df069c60
Commit
df069c60
authored
8 months ago
by
Lene Wasskog
Browse files
Options
Downloads
Patches
Plain Diff
feat: Parse coordinates to double
parent
8d598373
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
+13
-5
13 additions, 5 deletions
.../modules/barleynetblotch/BarleyNetBlotchModelService.java
with
13 additions
and
5 deletions
src/main/java/no/nibio/vips/logic/modules/barleynetblotch/BarleyNetBlotchModelService.java
+
13
−
5
View file @
df069c60
...
@@ -44,6 +44,7 @@ import no.nibio.vips.util.ParseRESTParamUtil;
...
@@ -44,6 +44,7 @@ import no.nibio.vips.util.ParseRESTParamUtil;
import
no.nibio.vips.util.WeatherElements
;
import
no.nibio.vips.util.WeatherElements
;
import
no.nibio.vips.util.weather.WeatherDataSourceException
;
import
no.nibio.vips.util.weather.WeatherDataSourceException
;
import
no.nibio.vips.util.weather.WeatherDataSourceUtil
;
import
no.nibio.vips.util.weather.WeatherDataSourceUtil
;
import
org.slf4j.LoggerFactory
;
/**
/**
* @copyright 2015 <a href="http://www.nibio.no/">NIBIO</a>
* @copyright 2015 <a href="http://www.nibio.no/">NIBIO</a>
...
@@ -52,6 +53,8 @@ import no.nibio.vips.util.weather.WeatherDataSourceUtil;
...
@@ -52,6 +53,8 @@ import no.nibio.vips.util.weather.WeatherDataSourceUtil;
@Path
(
"rest/barleynetblotchmodel"
)
@Path
(
"rest/barleynetblotchmodel"
)
@Facet
(
"restricted"
)
@Facet
(
"restricted"
)
public
class
BarleyNetBlotchModelService
{
public
class
BarleyNetBlotchModelService
{
private
static
final
org
.
slf4j
.
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
BarleyNetBlotchModelService
.
class
);
private
final
static
String
VIPSCOREMANAGER_URL
=
System
.
getProperty
(
"no.nibio.vips.logic.VIPSCOREMANAGER_URL"
);
private
final
static
String
VIPSCOREMANAGER_URL
=
System
.
getProperty
(
"no.nibio.vips.logic.VIPSCOREMANAGER_URL"
);
@PersistenceContext
(
unitName
=
"VIPSLogic-PU"
)
@PersistenceContext
(
unitName
=
"VIPSLogic-PU"
)
...
@@ -135,8 +138,8 @@ public class BarleyNetBlotchModelService {
...
@@ -135,8 +138,8 @@ public class BarleyNetBlotchModelService {
@PathParam
(
"organizationId"
)
Integer
organizationId
,
@PathParam
(
"organizationId"
)
Integer
organizationId
,
@QueryParam
(
"timeZone"
)
String
timeZoneStr
,
@QueryParam
(
"timeZone"
)
String
timeZoneStr
,
@QueryParam
(
"weatherdataType"
)
String
weatherdataType
,
@QueryParam
(
"weatherdataType"
)
String
weatherdataType
,
@QueryParam
(
"latitude"
)
Double
latitude
,
@QueryParam
(
"latitude"
)
String
latitude
,
@QueryParam
(
"longitude"
)
Double
longitude
,
@QueryParam
(
"longitude"
)
String
longitude
,
@QueryParam
(
"weatherStationId"
)
Integer
weatherStationId
,
@QueryParam
(
"weatherStationId"
)
Integer
weatherStationId
,
@QueryParam
(
"sowingDate"
)
String
sowingDateStr
,
@QueryParam
(
"sowingDate"
)
String
sowingDateStr
,
@QueryParam
(
"cropId"
)
Integer
cropOrganismId
,
@QueryParam
(
"cropId"
)
Integer
cropOrganismId
,
...
@@ -165,6 +168,8 @@ public class BarleyNetBlotchModelService {
...
@@ -165,6 +168,8 @@ public class BarleyNetBlotchModelService {
Date
sprayingDate
=
parseUtil
.
parseISODate
(
sprayingDateStr
,
timeZone
);
Date
sprayingDate
=
parseUtil
.
parseISODate
(
sprayingDateStr
,
timeZone
);
Integer
preparationId
=
parseUtil
.
parseInteger
(
preparationIdStr
);
Integer
preparationId
=
parseUtil
.
parseInteger
(
preparationIdStr
);
Double
preparationDose
=
parseUtil
.
parseDouble
(
preparationDoseStr
);
Double
preparationDose
=
parseUtil
.
parseDouble
(
preparationDoseStr
);
Double
latitudeDouble
=
parseUtil
.
parseDouble
(
latitude
);
Double
longitudeDouble
=
parseUtil
.
parseDouble
(
longitude
);
// Build model configuration
// Build model configuration
ModelConfiguration
config
=
new
ModelConfiguration
();
ModelConfiguration
config
=
new
ModelConfiguration
();
...
@@ -175,9 +180,11 @@ public class BarleyNetBlotchModelService {
...
@@ -175,9 +180,11 @@ public class BarleyNetBlotchModelService {
Date
endDateForWeatherData
=
calculateEndDateForWeatherData
(
timeZone
,
sowingDate
);
Date
endDateForWeatherData
=
calculateEndDateForWeatherData
(
timeZone
,
sowingDate
);
List
<
WeatherObservation
>
observations
;
List
<
WeatherObservation
>
observations
;
if
(
"weatherstation"
.
equals
(
weatherdataType
))
{
if
(
weatherdataType
!=
null
&&
"weatherstation"
.
equals
(
weatherdataType
.
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
());
try
{
try
{
observations
=
wsdUtil
.
getWeatherObservations
(
observations
=
wsdUtil
.
getWeatherObservations
(
weatherStation
,
weatherStation
,
...
@@ -198,8 +205,9 @@ public class BarleyNetBlotchModelService {
...
@@ -198,8 +205,9 @@ public class BarleyNetBlotchModelService {
}
}
}
else
{
}
else
{
PointOfInterest
coordinates
=
new
PointOfInterest
();
PointOfInterest
coordinates
=
new
PointOfInterest
();
coordinates
.
setLatitude
(
latitude
);
coordinates
.
setLatitude
(
latitudeDouble
);
coordinates
.
setLongitude
(
longitude
);
coordinates
.
setLongitude
(
longitudeDouble
);
LOGGER
.
info
(
"Run model with weatherdata for latitude={} and longitude={}"
,
latitude
,
longitude
);
try
{
try
{
observations
=
wsdUtil
.
getWeatherObservations
(
observations
=
wsdUtil
.
getWeatherObservations
(
"https://weather.vips.nibio.no/rest/grid/openmeteo/"
+
coordinates
.
getLongitude
()
+
"_"
+
coordinates
.
getLatitude
(),
"https://weather.vips.nibio.no/rest/grid/openmeteo/"
+
coordinates
.
getLongitude
()
+
"_"
+
coordinates
.
getLatitude
(),
...
...
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