diff --git a/pom.xml b/pom.xml index 3b94a9fa789761f9d86d14c8a5923dffbf9ed5c4..481a18f4c0a0909aac1f29afc41afb1d4138f062 100755 --- a/pom.xml +++ b/pom.xml @@ -217,7 +217,7 @@ <dependency> <groupId>no.nibio.vips</groupId> <artifactId>VIPSCommon</artifactId> - <version>2.0.8-SNAPSHOT</version> + <version>2.0.1</version> </dependency> <dependency> <groupId>javax</groupId> diff --git a/src/main/java/no/nibio/vips/logic/controller/session/PointOfInterestBean.java b/src/main/java/no/nibio/vips/logic/controller/session/PointOfInterestBean.java index fbe1d3e7648d0e6b2e7a56f2a6136b38ae2860ae..99893bbf532f08626b7f957d2f1fbc9a0d1682da 100755 --- a/src/main/java/no/nibio/vips/logic/controller/session/PointOfInterestBean.java +++ b/src/main/java/no/nibio/vips/logic/controller/session/PointOfInterestBean.java @@ -394,8 +394,6 @@ public class PointOfInterestBean { if(poi.getGisGeom() != null || (poi.getLongitude() != null && poi.getLatitude() != null)) { GISUtil gisUtil = new GISUtil(); - poi.addProperty("pointOfInterestId", poi.getPointOfInterestId()); - poi.addProperty("pointOfInterestTypeId", poi.getPointOfInterestTypeId()); if(poi.getGisGeom() != null) { diff --git a/src/main/java/no/nibio/vips/logic/entity/PointOfInterest.java b/src/main/java/no/nibio/vips/logic/entity/PointOfInterest.java index 796d78165d690f40984f940c057f7f8bd734d680..c6f1eb588af0113aa788b5dac4f536cbcab2c71f 100755 --- a/src/main/java/no/nibio/vips/logic/entity/PointOfInterest.java +++ b/src/main/java/no/nibio/vips/logic/entity/PointOfInterest.java @@ -269,7 +269,15 @@ public class PointOfInterest implements Serializable, Comparable { { 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 { @Transient public String getGeoJSON() { - this.addProperty("pointOfInterestId", this.getPointOfInterestId()); - this.addProperty("pointOfInterestTypeId", this.getPointOfInterestTypeId()); return this.gisUtil.getGeoJSONFromGeometry(this.getGisGeom(), this.getProperties()); } 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); } /** diff --git a/src/main/java/no/nibio/vips/logic/entity/PointOfInterestTypeNursery.java b/src/main/java/no/nibio/vips/logic/entity/PointOfInterestTypeNursery.java index 18565569dcf89a3660d21d44b65d799745a15b49..0a1c0f2df162f720252af7fa767f32587fb87a99 100644 --- a/src/main/java/no/nibio/vips/logic/entity/PointOfInterestTypeNursery.java +++ b/src/main/java/no/nibio/vips/logic/entity/PointOfInterestTypeNursery.java @@ -20,9 +20,12 @@ package no.nibio.vips.logic.entity; import java.io.Serializable; +import java.util.Map; +import javax.persistence.Column; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.Table; +import javax.persistence.Transient; /** * @copyright 2023 <a href="http://www.nibio.no/">NIBIO</a> @@ -32,5 +35,38 @@ import javax.persistence.Table; @DiscriminatorValue("7") @Table(name = "point_of_interest_nursery") 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(); + } } diff --git a/src/main/resources/db/migration/V15__POI_type_nursery_altered.sql b/src/main/resources/db/migration/V15__POI_type_nursery_altered.sql new file mode 100644 index 0000000000000000000000000000000000000000..2b7cba02c8bbd8645419f202c5b74be11d91363d --- /dev/null +++ b/src/main/resources/db/migration/V15__POI_type_nursery_altered.sql @@ -0,0 +1,28 @@ +/* + * 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 diff --git a/src/main/webapp/map_applications/fireblight/icons/bees-icon-25.png b/src/main/webapp/map_applications/fireblight/icons/bees-icon-25.png new file mode 100644 index 0000000000000000000000000000000000000000..4ff07995a3a5358964d713d9c0384d83e25c90ef Binary files /dev/null and b/src/main/webapp/map_applications/fireblight/icons/bees-icon-25.png differ diff --git a/src/main/webapp/map_applications/fireblight/js/map.js b/src/main/webapp/map_applications/fireblight/js/map.js index b9671d4538eec4bbbc24a333b25ecd71e287f86a..50b991438dbe1f0ecb34351915519c8a2fe8cc37 100755 --- a/src/main/webapp/map_applications/fireblight/js/map.js +++ b/src/main/webapp/map_applications/fireblight/js/map.js @@ -307,27 +307,37 @@ function getOpenLayersDefaultStyle() */ function diseaseSpreadingPoiStyle(feature, resolution) { - if(feature.getGeometry().getType() == "Point") - { - const radiusInMeters = feature.getProperties()["pointOfInterestTypeId"] == "6" ? 5000 - : feature.getProperties()["pointOfInterestTypeId"] == "7" ? 10000 - : 500; - const fillColor = feature.getProperties()["pointOfInterestTypeId"] == "6" ? [255,0, 0, 0.5] - : feature.getProperties()["pointOfInterestTypeId"] == "7" ? [255, 127,127 , 0.5] - : [255, 255, 255, 0.0]; - const viewProjection = map.getView().getProjection(); - const coordsInViewProjection = feature.getGeometry().getCoordinates(); - const longLat = ol.proj.toLonLat(coordsInViewProjection, viewProjection); - const latitude_rad = longLat[1] * Math.PI / 180; - const circle = new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({color: fillColor}), - 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)) - }) - }); + if(feature.getProperties()["pointOfInterestTypeId"] == "7") // Nursery + { + if(feature.getGeometry().getType() == "Point") + { + // impactRadius is set in database for nursery POIs + const radiusInMeters = feature.getProperties()["impactRadius"] * 1000; + const viewProjection = map.getView().getProjection(); + const coordsInViewProjection = feature.getGeometry().getCoordinates(); + const longLat = ol.proj.toLonLat(coordsInViewProjection, viewProjection); + const latitude_rad = longLat[1] * Math.PI / 180; + const circle = new ol.style.Style({ + image: new ol.style.Circle({ + fill: new ol.style.Fill({color: [255, 127,127 , 0.5]}), + 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();