Skip to content
Snippets Groups Projects
Commit 29db1414 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Added infoURI for weather station in KML file

parent 95494dc0
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,9 @@ import com.fasterxml.jackson.databind.JsonNode;
import java.util.Calendar;
import java.util.TimeZone;
import de.micromata.opengis.kml.v_2_2_0.Coordinate;
import de.micromata.opengis.kml.v_2_2_0.Data;
import de.micromata.opengis.kml.v_2_2_0.Document;
import de.micromata.opengis.kml.v_2_2_0.ExtendedData;
import de.micromata.opengis.kml.v_2_2_0.Kml;
import de.micromata.opengis.kml.v_2_2_0.KmlFactory;
import de.micromata.opengis.kml.v_2_2_0.Placemark;
......@@ -640,13 +642,31 @@ public class ForecastBean {
continue;
}
// Adding infoUri (direct link to weather station information) as extra attribute
String infoUriValue = "";
if(poiWithAggregate instanceof PointOfInterestWeatherStation)
{
String infoUriExpression = ((PointOfInterestWeatherStation) poiWithAggregate).getWeatherStationDataSourceId().getInfoUriExpression();
if(!infoUriExpression.isEmpty())
{
infoUriValue = String.format(infoUriExpression, ((PointOfInterestWeatherStation) poiWithAggregate).getWeatherStationRemoteId());
}
}
Data infoUri = new Data(infoUriValue);
infoUri.setName("infoUri");
List<Data> dataList = new ArrayList<>();
dataList.add(infoUri);
ExtendedData extendedData = document.createAndSetExtendedData()
.withData(dataList);
final Placemark placemark = document.createAndAddPlacemark()
.withName(poiWithAggregate.getName())
.withDescription("<![CDATA[Mangler informasjon om varsler for " + poiWithAggregate.getName() + "]]>")
.withStyleUrl("#warning_type_"
+ (poiWithAggregate.getProperties().get("forecastsAggregate") != null ? poiWithAggregate.getProperties().get("forecastsAggregate") : "0")
)
.withId(poiWithAggregate.getPointOfInterestId().toString());
.withId(poiWithAggregate.getPointOfInterestId().toString())
.withExtendedData(extendedData);
final Point point = placemark.createAndSetPoint();
......
......@@ -66,6 +66,9 @@ public class WeatherStationDataSource implements Serializable {
@Size(max = 1024)
@Column(name = "datafetch_uri_expression")
private String datafetchUriExpression;
@Size(max = 1024)
@Column(name = "info_uri_expression")
private String infoUriExpression;
public WeatherStationDataSource() {
}
......@@ -136,6 +139,20 @@ public class WeatherStationDataSource implements Serializable {
return "no.nibio.vips.logic.entity.WeatherStationDataSource[ weatherStationDataSourceId=" + weatherStationDataSourceId + " ]";
}
/**
* @return the infoUriExpression
*/
public String getInfoUriExpression() {
return infoUriExpression;
}
/**
* @param infoUriExpression the infoUriExpression to set
*/
public void setInfoUriExpression(String infoUriExpression) {
this.infoUriExpression = infoUriExpression;
}
}
<#--
Copyright (c) 2014 NIBIO <http://www.nibio.no/>.
This file is part of VIPSLogic.
VIPSLogic is free software: you can redistribute it and/or modify
it under the terms of the NIBIO Open Source License as published by
NIBIO, either version 1 of the License, or (at your option) any
later version.
VIPSLogic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
NIBIO Open Source License for more details.
You should have received a copy of the NIBIO Open Source License
along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>.
-->
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function closeAndReloadParent()
{
window.opener.postMessage("PleaseReload","*");
window.close();
}
</script>
</head>
<body onload="if(window.opener != undefined){closeAndReloadParent();}">
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment