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
494af420
Commit
494af420
authored
9 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Refactored radiation calc service to JSON and CSV formats
parent
3b0ab5d1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/no/nibio/vips/logic/service/LogicService.java
+63
-9
63 additions, 9 deletions
src/main/java/no/nibio/vips/logic/service/LogicService.java
with
63 additions
and
9 deletions
src/main/java/no/nibio/vips/logic/service/LogicService.java
+
63
−
9
View file @
494af420
...
...
@@ -58,6 +58,7 @@ import no.nibio.vips.logic.entity.PointOfInterestWeatherStation;
import
no.nibio.vips.logic.entity.VipsLogicUser
;
import
no.nibio.vips.logic.util.SessionControllerGetter
;
import
no.nibio.vips.logic.util.SystemTime
;
import
no.nibio.vips.util.CSVPrintUtil
;
import
no.nibio.vips.util.ServletUtil
;
import
no.nibio.vips.util.SolarRadiationUtil
;
import
no.nibio.vips.util.weather.ALabDataParser
;
...
...
@@ -330,9 +331,9 @@ public class LogicService {
}
@GET
@Path
(
"weather/calculation/solarradiation"
)
@Path
(
"weather/calculation/solarradiation
/json
"
)
@Produces
(
"application/json;charset=UTF-8"
)
public
Response
getCalculatedSolarRadiationAtLocationAndTime
(
public
Response
getCalculatedSolarRadiationAtLocationAndTime
JSON
(
@QueryParam
(
"latitude"
)
Double
latitude
,
@QueryParam
(
"longitude"
)
Double
longitude
,
@QueryParam
(
"startTime"
)
String
startTimeStr
,
...
...
@@ -343,13 +344,15 @@ public class LogicService {
{
try
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
TimeZone
timeZone
=
TimeZone
.
getTimeZone
(
timeZoneStr
);
Date
startTime
=
format
.
parse
(
startTimeStr
);
Date
endTime
=
format
.
parse
(
endTimeStr
);
logIntervalId
=
logIntervalId
==
null
?
WeatherObservation
.
LOG_INTERVAL_ID_1H
:
logIntervalId
;
SolarRadiationUtil
srUtil
=
new
SolarRadiationUtil
();
List
<
WeatherObservation
>
radiationValues
=
srUtil
.
getCalculatedSolarRadiation
(
latitude
,
longitude
,
startTime
,
endTime
,
timeZone
,
logIntervalId
);
List
<
WeatherObservation
>
radiationValues
=
getCalculatedSolarRadiationAtLocationAndTime
(
latitude
,
longitude
,
startTimeStr
,
endTimeStr
,
timeZoneStr
,
logIntervalId
);
return
Response
.
ok
().
entity
(
radiationValues
).
build
();
}
catch
(
ParseException
ex
)
...
...
@@ -358,6 +361,57 @@ public class LogicService {
}
}
@GET
@Path
(
"weather/calculation/solarradiation/csv"
)
@Produces
(
"text/csv;charset=UTF-8"
)
public
Response
getCalculatedSolarRadiationAtLocationAndTimeCSV
(
@QueryParam
(
"latitude"
)
Double
latitude
,
@QueryParam
(
"longitude"
)
Double
longitude
,
@QueryParam
(
"startTime"
)
String
startTimeStr
,
@QueryParam
(
"endTime"
)
String
endTimeStr
,
@QueryParam
(
"timeZone"
)
String
timeZoneStr
,
@QueryParam
(
"logIntervalId"
)
Integer
logIntervalId
)
{
try
{
List
<
WeatherObservation
>
radiationValues
=
getCalculatedSolarRadiationAtLocationAndTime
(
latitude
,
longitude
,
startTimeStr
,
endTimeStr
,
timeZoneStr
,
logIntervalId
);
//return Response.ok().entity(radiationValues).build();
TimeZone
timeZone
=
TimeZone
.
getTimeZone
(
timeZoneStr
);
return
Response
.
ok
(
new
CSVPrintUtil
().
printWeatherObservations
(
radiationValues
,
timeZone
,
"\t"
)).
build
();
}
catch
(
ParseException
ex
)
{
return
Response
.
serverError
().
entity
(
ex
).
build
();
}
}
private
List
<
WeatherObservation
>
getCalculatedSolarRadiationAtLocationAndTime
(
Double
latitude
,
Double
longitude
,
String
startTimeStr
,
String
endTimeStr
,
String
timeZoneStr
,
Integer
logIntervalId
)
throws
ParseException
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
TimeZone
timeZone
=
TimeZone
.
getTimeZone
(
timeZoneStr
);
Date
startTime
=
format
.
parse
(
startTimeStr
);
Date
endTime
=
format
.
parse
(
endTimeStr
);
logIntervalId
=
logIntervalId
==
null
?
WeatherObservation
.
LOG_INTERVAL_ID_1H
:
logIntervalId
;
SolarRadiationUtil
srUtil
=
new
SolarRadiationUtil
();
return
srUtil
.
getCalculatedSolarRadiation
(
latitude
,
longitude
,
startTime
,
endTime
,
timeZone
,
logIntervalId
);
}
@GET
@POST
...
...
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