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

feat: Add bee icon, variable impactRadius for nurseries

parent 6ad1b015
Branches
No related tags found
No related merge requests found
...@@ -217,7 +217,7 @@ ...@@ -217,7 +217,7 @@
<dependency> <dependency>
<groupId>no.nibio.vips</groupId> <groupId>no.nibio.vips</groupId>
<artifactId>VIPSCommon</artifactId> <artifactId>VIPSCommon</artifactId>
<version>2.0.8-SNAPSHOT</version> <version>2.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax</groupId> <groupId>javax</groupId>
......
...@@ -394,8 +394,6 @@ public class PointOfInterestBean { ...@@ -394,8 +394,6 @@ public class PointOfInterestBean {
if(poi.getGisGeom() != null || (poi.getLongitude() != null && poi.getLatitude() != null)) if(poi.getGisGeom() != null || (poi.getLongitude() != null && poi.getLatitude() != null))
{ {
GISUtil gisUtil = new GISUtil(); GISUtil gisUtil = new GISUtil();
poi.addProperty("pointOfInterestId", poi.getPointOfInterestId());
poi.addProperty("pointOfInterestTypeId", poi.getPointOfInterestTypeId());
if(poi.getGisGeom() != null) if(poi.getGisGeom() != null)
{ {
......
...@@ -269,7 +269,15 @@ public class PointOfInterest implements Serializable, Comparable { ...@@ -269,7 +269,15 @@ public class PointOfInterest implements Serializable, Comparable {
{ {
this.properties = new HashMap<>(); this.properties = new HashMap<>();
} }
return properties; if(this.properties.get("pointOfInterestId") == null)
{
this.properties.put("pointOfInterestId", this.getPointOfInterestId());
}
if(this.properties.get("pointOfInterestTypeId") == null)
{
this.properties.put("pointOfInterestTypeId", this.getPointOfInterestTypeId());
}
return this.properties;
} }
/** /**
...@@ -358,14 +366,16 @@ public class PointOfInterest implements Serializable, Comparable { ...@@ -358,14 +366,16 @@ public class PointOfInterest implements Serializable, Comparable {
@Transient @Transient
public String getGeoJSON() public String getGeoJSON()
{ {
this.addProperty("pointOfInterestId", this.getPointOfInterestId());
this.addProperty("pointOfInterestTypeId", this.getPointOfInterestTypeId());
return this.gisUtil.getGeoJSONFromGeometry(this.getGisGeom(), this.getProperties()); return this.gisUtil.getGeoJSONFromGeometry(this.getGisGeom(), this.getProperties());
} }
public void addProperty(String key, Object value) public void addProperty(String key, Object value)
{ {
this.getProperties().put(key, value); if(this.properties == null)
{
this.properties = new HashMap<>();
}
this.properties.put(key, value);
} }
/** /**
......
...@@ -20,9 +20,12 @@ ...@@ -20,9 +20,12 @@
package no.nibio.vips.logic.entity; package no.nibio.vips.logic.entity;
import java.io.Serializable; import java.io.Serializable;
import java.util.Map;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue; import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient;
/** /**
* @copyright 2023 <a href="http://www.nibio.no/">NIBIO</a> * @copyright 2023 <a href="http://www.nibio.no/">NIBIO</a>
...@@ -32,5 +35,38 @@ import javax.persistence.Table; ...@@ -32,5 +35,38 @@ import javax.persistence.Table;
@DiscriminatorValue("7") @DiscriminatorValue("7")
@Table(name = "point_of_interest_nursery") @Table(name = "point_of_interest_nursery")
public class PointOfInterestTypeNursery extends PointOfInterest implements Serializable { public class PointOfInterestTypeNursery extends PointOfInterest implements Serializable {
private Double impactRadius;
/**
* Radius (in km) of the expected impact (implemented for fire blight)
* of the nursery. Used for map rendering
* @return the impactRadius
*/
@Column(name="impact_radius")
public Double getImpactRadius() {
return impactRadius;
}
/**
* @param impactRadius the impactRadius to set
*/
public void setImpactRadius(Double impactRadius) {
this.impactRadius = impactRadius;
}
@Transient
@Override
public String getGeoJSON()
{
this.addProperty("impactRadius", this.getImpactRadius());
return super.getGeoJSON();
}
@Transient
@Override
public Map<String,Object> getProperties() {
this.addProperty("impactRadius", this.getImpactRadius());
return super.getProperties();
}
} }
/*
* Copyright (c) 2023 NIBIO <http://www.nibio.no/>.
*
* This file is part of VIPSLogic.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* Author: Tor-Einar Skog <tor-einar.skog@nibio.no>
* Created: September 27th, 2023
*/
-- Add property impact_radius to POI type nursery
ALTER TABLE public.point_of_interest_nursery
ADD COLUMN impact_radius DOUBLE PRECISION DEFAULT 0.0;
\ No newline at end of file
src/main/webapp/map_applications/fireblight/icons/bees-icon-25.png

8.41 KiB

...@@ -307,27 +307,37 @@ function getOpenLayersDefaultStyle() ...@@ -307,27 +307,37 @@ function getOpenLayersDefaultStyle()
*/ */
function diseaseSpreadingPoiStyle(feature, resolution) function diseaseSpreadingPoiStyle(feature, resolution)
{ {
if(feature.getGeometry().getType() == "Point") if(feature.getProperties()["pointOfInterestTypeId"] == "7") // Nursery
{ {
const radiusInMeters = feature.getProperties()["pointOfInterestTypeId"] == "6" ? 5000 if(feature.getGeometry().getType() == "Point")
: feature.getProperties()["pointOfInterestTypeId"] == "7" ? 10000 {
: 500; // impactRadius is set in database for nursery POIs
const fillColor = feature.getProperties()["pointOfInterestTypeId"] == "6" ? [255,0, 0, 0.5] const radiusInMeters = feature.getProperties()["impactRadius"] * 1000;
: feature.getProperties()["pointOfInterestTypeId"] == "7" ? [255, 127,127 , 0.5] const viewProjection = map.getView().getProjection();
: [255, 255, 255, 0.0]; const coordsInViewProjection = feature.getGeometry().getCoordinates();
const viewProjection = map.getView().getProjection(); const longLat = ol.proj.toLonLat(coordsInViewProjection, viewProjection);
const coordsInViewProjection = feature.getGeometry().getCoordinates(); const latitude_rad = longLat[1] * Math.PI / 180;
const longLat = ol.proj.toLonLat(coordsInViewProjection, viewProjection); const circle = new ol.style.Style({
const latitude_rad = longLat[1] * Math.PI / 180; image: new ol.style.Circle({
const circle = new ol.style.Style({ fill: new ol.style.Fill({color: [255, 127,127 , 0.5]}),
image: new ol.style.Circle({ stroke: new ol.style.Stroke({color: [0, 0, 0, 1], width: 5, lineDash: [5, 10], lineCap:"square"}),
fill: new ol.style.Fill({color: fillColor}), radius: radiusInMeters / (resolution / viewProjection.getMetersPerUnit() * Math.cos(latitude_rad))
stroke: new ol.style.Stroke({color: [0, 0, 0, 1], width: 5, lineDash: [5, 10], lineCap:"square"}), })
radius: radiusInMeters / (resolution / viewProjection.getMetersPerUnit() * Math.cos(latitude_rad)) });
})
});
return [circle]; return [circle];
}
}
else if(feature.getProperties()["pointOfInterestTypeId"] == "6") // Apiary site
{
return [new ol.style.Style({
image: new ol.style.Icon({
src: 'icons/bees-icon-25.png',
scale: 0.3,
anchor: [0.3,1]
})
})];
} }
return getOpenLayersDefaultStyle(); return getOpenLayersDefaultStyle();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment