This is an automated email from the git hooks/post-receive script. New commit to branch feature/7133 in repository observe. See http://git.codelutin.com/observe.git commit d352e5aa390b0093951fd07386a20d627d6bc96b Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Thu May 21 17:49:27 2015 +0200 refs #7132 : ajout des point "Rencontre" et "station océanographique" et modification du style de la carte --- .../entities/longline/TripLonglineDAOImpl.java | 53 ++- .../observe/entities/seine/TripSeineDAOImpl.java | 15 +- .../fr/ird/observe/tripMap/TripMapPointType.java | 8 +- .../i18n/observe-entities_en_GB.properties | 2 + .../i18n/observe-entities_es_ES.properties | 2 + .../i18n/observe-entities_fr_FR.properties | 2 + .../ui/util/tripMap/TripMapContentBuilder.java | 435 +++++++++++++++++++++ .../observe/ui/util/tripMap/TripMapUIHandler.java | 351 ++--------------- observe-swing/src/main/map/style.xml | 153 +++++++- .../resources/i18n/observe-swing_en_GB.properties | 2 + .../resources/i18n/observe-swing_es_ES.properties | 2 + .../resources/i18n/observe-swing_fr_FR.properties | 2 + 12 files changed, 667 insertions(+), 360 deletions(-) diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineDAOImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineDAOImpl.java index f422c34..e804adf 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineDAOImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineDAOImpl.java @@ -43,6 +43,9 @@ import java.util.List; public class TripLonglineDAOImpl<E extends TripLongline> extends TripLonglineDAOAbstract<E> { + public static final String ACTIVITY_INTERACTION_CODE = "INT"; + public static final String ACTIVITY_STATION_CODE = "SAMP"; + public int findPositionByProgramId(String programId, String tripId) throws TopiaException { int result = 0; List<E> list = findAllStubByProgramId(programId, ReferenceLocale.FR); @@ -106,7 +109,7 @@ public class TripLonglineDAOImpl<E extends TripLongline> extends TripLonglineDAO landingPoint.setTime(tripLongline.getEndDate()); landingPoint.setLatitude(landingHarbour.getLatitude()); landingPoint.setLongitude(landingHarbour.getLongitude()); - landingPoint.setType(TripMapPointType.LONGLINE_LANDINGE_HARBOUR); + landingPoint.setType(TripMapPointType.LONGLINE_LANDING_HARBOUR); tripMapPoints.add(landingPoint); } @@ -119,6 +122,7 @@ public class TripLonglineDAOImpl<E extends TripLongline> extends TripLonglineDAO " a.timestamp, " + " a.latitude," + " a.longitude," + + " v.code," + " s.settingStartTimestamp," + " s.settingStartLatitude," + " s.settingStartLongitude," + @@ -132,6 +136,8 @@ public class TripLonglineDAOImpl<E extends TripLongline> extends TripLonglineDAO " s.haulingEndLatitude," + " s.haulingEndLongitude" + " FROM observe_longLine.activity a" + + " LEFT OUTER JOIN observe_longLine.vesselActivity v" + + " ON v.topiaid = a.vesselActivity" + " LEFT OUTER JOIN observe_longLine.set s" + " ON s.topiaId = a.set" + " WHERE a.trip = ?" + @@ -160,45 +166,56 @@ public class TripLonglineDAOImpl<E extends TripLongline> extends TripLonglineDAO activity.setTime(resultSet.getDate(1)); activity.setLatitude(resultSet.getFloat(2)); activity.setLongitude(resultSet.getFloat(3)); - activity.setType(TripMapPointType.LONGLINE_ACTIVITY); + + String vesselActivityCode = resultSet.getString(4); + if (vesselActivityCode == null) { + activity.setType(TripMapPointType.LONGLINE_ACTIVITY); + } else if (vesselActivityCode.equals(ACTIVITY_INTERACTION_CODE)) { + activity.setType(TripMapPointType.LONGLINE_ACTIVITY_WITH_INTERACTION); + } else if (vesselActivityCode.equals(ACTIVITY_STATION_CODE)) { + activity.setType(TripMapPointType.LONGLINE_ACTIVITY_WITH_STATION); + } else { + activity.setType(TripMapPointType.LONGLINE_ACTIVITY); + } + result.add(activity); // settingStart - if (resultSet.getString(4) != null) { + if (resultSet.getString(5) != null) { TripMapPoint settingStart = new TripMapPoint(); - settingStart.setTime(resultSet.getDate(4)); - settingStart.setLatitude(resultSet.getFloat(5)); - settingStart.setLongitude(resultSet.getFloat(6)); + settingStart.setTime(resultSet.getDate(5)); + settingStart.setLatitude(resultSet.getFloat(6)); + settingStart.setLongitude(resultSet.getFloat(7)); settingStart.setType(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_START); result.add(settingStart); } // settingEnd - if (resultSet.getString(7) != null) { + if (resultSet.getString(8) != null) { TripMapPoint settingEnd = new TripMapPoint(); - settingEnd.setTime(resultSet.getDate(7)); - settingEnd.setLatitude(resultSet.getFloat(8)); - settingEnd.setLongitude(resultSet.getFloat(9)); + settingEnd.setTime(resultSet.getDate(8)); + settingEnd.setLatitude(resultSet.getFloat(9)); + settingEnd.setLongitude(resultSet.getFloat(10)); settingEnd.setType(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_END); result.add(settingEnd); } // haulingStart - if (resultSet.getString(10) != null) { + if (resultSet.getString(11) != null) { TripMapPoint haulingStart = new TripMapPoint(); - haulingStart.setTime(resultSet.getDate(10)); - haulingStart.setLatitude(resultSet.getFloat(11)); - haulingStart.setLongitude(resultSet.getFloat(12)); + haulingStart.setTime(resultSet.getDate(11)); + haulingStart.setLatitude(resultSet.getFloat(12)); + haulingStart.setLongitude(resultSet.getFloat(13)); haulingStart.setType(TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_START); result.add(haulingStart); } // haulingEnd - if (resultSet.getString(13) != null) { + if (resultSet.getString(14) != null) { TripMapPoint haulingEnd = new TripMapPoint(); - haulingEnd.setTime(resultSet.getDate(13)); - haulingEnd.setLatitude(resultSet.getFloat(14)); - haulingEnd.setLongitude(resultSet.getFloat(15)); + haulingEnd.setTime(resultSet.getDate(14)); + haulingEnd.setLatitude(resultSet.getFloat(15)); + haulingEnd.setLongitude(resultSet.getFloat(16)); haulingEnd.setType(TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_END); result.add(haulingEnd); } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineDAOImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineDAOImpl.java index 713424d..40ba4f8 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineDAOImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineDAOImpl.java @@ -34,13 +34,13 @@ import fr.ird.observe.tripMap.TripMapPointType; import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaContextImplementor; import org.nuiton.topia.framework.TopiaSQLQuery; +import org.nuiton.util.DateUtil; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.sql.Time; -import java.util.Calendar; +import java.util.Date; import java.util.List; /** @@ -109,7 +109,7 @@ public class TripSeineDAOImpl<E extends TripSeine> extends TripSeineDAOAbstract< landingPoint.setTime(tripSeine.getEndDate()); landingPoint.setLatitude(landingHarbour.getLatitude()); landingPoint.setLongitude(landingHarbour.getLongitude()); - landingPoint.setType(TripMapPointType.SEINE_LANDINGE_HARBOUR); + landingPoint.setType(TripMapPointType.SEINE_LANDING_HARBOUR); tripMapPoints.add(landingPoint); } @@ -152,13 +152,8 @@ public class TripSeineDAOImpl<E extends TripSeine> extends TripSeineDAOAbstract< protected TripMapPoint prepareResult(ResultSet resultSet) throws SQLException { TripMapPoint point = new TripMapPoint(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(resultSet.getDate(1)); - Time time = resultSet.getTime(2); - calendar.set(Calendar.HOUR_OF_DAY, time.getHours()); - calendar.set(Calendar.MINUTE, time.getMinutes()); - calendar.set(Calendar.SECOND, time.getSeconds()); - point.setTime(calendar.getTime()); + Date time = DateUtil.getDateAndTime(resultSet.getDate(1), resultSet.getTime(2), true, false); + point.setTime(time); point.setLatitude(resultSet.getFloat(3)); point.setLongitude(resultSet.getFloat(4)); if (resultSet.getInt(5) == ACTIVITY_HARBOUR_CODE) { diff --git a/observe-entities/src/main/java/fr/ird/observe/tripMap/TripMapPointType.java b/observe-entities/src/main/java/fr/ird/observe/tripMap/TripMapPointType.java index 4380ce4..04fdaa2 100644 --- a/observe-entities/src/main/java/fr/ird/observe/tripMap/TripMapPointType.java +++ b/observe-entities/src/main/java/fr/ird/observe/tripMap/TripMapPointType.java @@ -31,19 +31,21 @@ import static org.nuiton.i18n.I18n.t; public enum TripMapPointType { SEINE_DEPARTURE_HARBOUR(n("observe.map.seine.harbour.departure")), - SEINE_LANDINGE_HARBOUR(n("observe.map.seine.harbour.landing")), + SEINE_LANDING_HARBOUR(n("observe.map.seine.harbour.landing")), SEINE_ACTIVITY(n("observe.map.seine.activity")), SEINE_ACTIVITY_IN_HARBOUR(n("observe.map.seine.activity.inHarbour")), SEINE_ACTIVITY_WITH_FREE_SCHOOL_TYPE(n("observe.map.seine.activity.schollType.free")), SEINE_ACTIVITY_WITH_OBJECT_SCHOOL_TYPE(n("observe.map.seine.activity.schollType.object")), LONGLINE_DEPARTURE_HARBOUR(n("observe.map.longLine.seine.harbour.departure")), - LONGLINE_LANDINGE_HARBOUR(n("observe.map.longLine.seine.harbour.landing")), + LONGLINE_LANDING_HARBOUR(n("observe.map.longLine.seine.harbour.landing")), LONGLINE_ACTIVITY(n("observe.map.longLine.activity")), LONGLINE_ACTIVITY_WITH_SETTING_START(n("observe.map.longLine.activity.setting.start")), LONGLINE_ACTIVITY_WITH_SETTING_END(n("observe.map.longLine.activity.setting.end")), LONGLINE_ACTIVITY_WITH_HAULING_START(n("observe.map.longLine.activity.hauling.start")), - LONGLINE_ACTIVITY_WITH_HAULING_END(n("observe.map.longLine.activity.hauling.end")); + LONGLINE_ACTIVITY_WITH_HAULING_END(n("observe.map.longLine.activity.hauling.end")), + LONGLINE_ACTIVITY_WITH_INTERACTION(n("observe.map.longLine.activity.interaction")), + LONGLINE_ACTIVITY_WITH_STATION(n("observe.map.longLine.activity.station")); String label; diff --git a/observe-entities/src/main/resources/i18n/observe-entities_en_GB.properties b/observe-entities/src/main/resources/i18n/observe-entities_en_GB.properties index b33150c..a4a8c32 100644 --- a/observe-entities/src/main/resources/i18n/observe-entities_en_GB.properties +++ b/observe-entities/src/main/resources/i18n/observe-entities_en_GB.properties @@ -23,8 +23,10 @@ observe.common.schoolType.undefined= observe.map.longLine.activity= observe.map.longLine.activity.hauling.end= observe.map.longLine.activity.hauling.start= +observe.map.longLine.activity.interaction= observe.map.longLine.activity.setting.end= observe.map.longLine.activity.setting.start= +observe.map.longLine.activity.station= observe.map.longLine.seine.harbour.departure= observe.map.longLine.seine.harbour.landing= observe.map.seine.activity= diff --git a/observe-entities/src/main/resources/i18n/observe-entities_es_ES.properties b/observe-entities/src/main/resources/i18n/observe-entities_es_ES.properties index b7b3dde..ebb20b1 100644 --- a/observe-entities/src/main/resources/i18n/observe-entities_es_ES.properties +++ b/observe-entities/src/main/resources/i18n/observe-entities_es_ES.properties @@ -23,8 +23,10 @@ observe.common.schoolType.undefined=Banco indeterminado observe.map.longLine.activity= observe.map.longLine.activity.hauling.end= observe.map.longLine.activity.hauling.start= +observe.map.longLine.activity.interaction= observe.map.longLine.activity.setting.end= observe.map.longLine.activity.setting.start= +observe.map.longLine.activity.station= observe.map.longLine.seine.harbour.departure= observe.map.longLine.seine.harbour.landing= observe.map.seine.activity= diff --git a/observe-entities/src/main/resources/i18n/observe-entities_fr_FR.properties b/observe-entities/src/main/resources/i18n/observe-entities_fr_FR.properties index 858bcda..74354e3 100644 --- a/observe-entities/src/main/resources/i18n/observe-entities_fr_FR.properties +++ b/observe-entities/src/main/resources/i18n/observe-entities_fr_FR.properties @@ -23,8 +23,10 @@ observe.common.schoolType.undefined=Banc indéterminé observe.map.longLine.activity=point d'activité observe.map.longLine.activity.hauling.end=Fin de filage observe.map.longLine.activity.hauling.start=Début de filage +observe.map.longLine.activity.interaction=Rencontre observe.map.longLine.activity.setting.end=Fin de virage observe.map.longLine.activity.setting.start=Début de virage +observe.map.longLine.activity.station=Station océanographique observe.map.longLine.seine.harbour.departure=Port de départ observe.map.longLine.seine.harbour.landing=Port d'arrivée observe.map.seine.activity=point d'activité diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java b/observe-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java new file mode 100644 index 0000000..ad2df49 --- /dev/null +++ b/observe-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java @@ -0,0 +1,435 @@ +package fr.ird.observe.ui.util.tripMap; + +import com.google.common.base.Function; +import com.google.common.base.Optional; +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.GeometryFactory; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.MultiPoint; +import com.vividsolutions.jts.geom.Polygon; +import fr.ird.observe.ObserveTechnicalException; +import fr.ird.observe.tripMap.TripMapPoint; +import fr.ird.observe.tripMap.TripMapPointType; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateUtils; +import org.geotools.data.FileDataStore; +import org.geotools.data.FileDataStoreFinder; +import org.geotools.data.simple.SimpleFeatureSource; +import org.geotools.factory.CommonFactoryFinder; +import org.geotools.feature.DefaultFeatureCollection; +import org.geotools.feature.simple.SimpleFeatureBuilder; +import org.geotools.feature.simple.SimpleFeatureTypeBuilder; +import org.geotools.geometry.jts.JTSFactoryFinder; +import org.geotools.map.FeatureLayer; +import org.geotools.map.Layer; +import org.geotools.map.MapContent; +import org.geotools.referencing.CRS; +import org.geotools.styling.NamedLayer; +import org.geotools.styling.SLD; +import org.geotools.styling.SLDParser; +import org.geotools.styling.Style; +import org.geotools.styling.StyleFactory; +import org.geotools.styling.StyledLayer; +import org.geotools.styling.StyledLayerDescriptor; +import org.geotools.styling.UserLayer; +import org.opengis.feature.simple.SimpleFeature; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.referencing.FactoryException; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import static org.nuiton.i18n.I18n.t; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public class TripMapContentBuilder { + + public static final String TRIP_LINES_LAYER_NAME = "Trip lines"; + public static final String TRIP_LONGLINE_FISHING_ZONE_LAYER_NAME = "Trip longline zone"; + public static final String TRIP_LONGLINE_LINE_LAYER_NAME = "Trip longline line"; + public static final String TRIP_POINTS_LAYER_NAME = "Trip points"; + + protected static final Set<TripMapPointType> TRIP_MAP_POINT_TYPES_IN_LEGEND = ImmutableSet.of( + TripMapPointType.SEINE_ACTIVITY_IN_HARBOUR, + TripMapPointType.SEINE_ACTIVITY_WITH_FREE_SCHOOL_TYPE, + TripMapPointType.SEINE_ACTIVITY_WITH_OBJECT_SCHOOL_TYPE, + TripMapPointType.LONGLINE_DEPARTURE_HARBOUR, + TripMapPointType.LONGLINE_LANDING_HARBOUR, + TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_START, + TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_END, + TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_START, + TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_END, + TripMapPointType.LONGLINE_ACTIVITY_WITH_STATION, + TripMapPointType.LONGLINE_ACTIVITY_WITH_INTERACTION); + + protected StyledLayerDescriptor styledLayerDescriptor; + + protected MapContent mapContent; + protected List<ObserveMapPaneLegendItem> legendItems; + + public TripMapContentBuilder() { + mapContent = new MapContent(); + legendItems = Lists.newArrayList(); + } + + public MapContent getMapContent() { + return mapContent; + } + + public List<ObserveMapPaneLegendItem> getLegendItems() { + return legendItems; + } + + public void setStyledLayerDescriptor(File styleFile) throws FileNotFoundException { + + StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(null); + + SLDParser stylereader = new SLDParser(styleFactory, styleFile); + + styledLayerDescriptor = stylereader.parseSLD(); + } + + public void addLayer(File layerFile) throws IOException { + FileDataStore store = FileDataStoreFinder.getDataStore(layerFile); + SimpleFeatureSource featureSource = store.getFeatureSource(); + Style style = SLD.createSimpleStyle(featureSource.getSchema()); + style = findStyle(styledLayerDescriptor, store.getNames().get(0).getLocalPart(), null, style); + Layer layer = new FeatureLayer(featureSource, style); + mapContent.addLayer(layer); + } + + public void addTripLine(List<TripMapPoint> tripMapPoints) throws FactoryException { + SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM"); + + GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); + + SimpleFeatureTypeBuilder lineFeatureTypeBuilder = new SimpleFeatureTypeBuilder(); + lineFeatureTypeBuilder.setName("lineBuilder"); + lineFeatureTypeBuilder.setCRS(CRS.decode("EPSG:4326", true)); + lineFeatureTypeBuilder.add("line", LineString.class); + lineFeatureTypeBuilder.add("label", String.class); + lineFeatureTypeBuilder.add("type", String.class); + + SimpleFeatureType lineFeatureType = lineFeatureTypeBuilder.buildFeatureType(); + SimpleFeatureBuilder lineBuilder = new SimpleFeatureBuilder(lineFeatureType); + + DefaultFeatureCollection linesFeatures = new DefaultFeatureCollection(); + + List<Coordinate> coordinatesByDay = null; + + TripMapPoint previousPoint = null; + + for (TripMapPoint point : tripMapPoints) { + if (previousPoint == null) { + coordinatesByDay = Lists.newLinkedList(); + } else if (!DateUtils.isSameDay(previousPoint.getTime(), point.getTime())) { + + if (coordinatesByDay.size() > 1) { + LineString line = geometryFactory.createLineString(coordinatesByDay.toArray(new Coordinate[0])); + lineBuilder.add(line); + lineBuilder.add(dateFormat.format(previousPoint.getTime())); + lineBuilder.add("tripDay"); + SimpleFeature feature = lineBuilder.buildFeature(null); + + linesFeatures.add(feature); + } + + + Coordinate[] coordinates = { + new Coordinate(previousPoint.getLongitude(), previousPoint.getLatitude()), + new Coordinate(point.getLongitude(), point.getLatitude()), + }; + LineString lineBetweenTwoDays = geometryFactory.createLineString(coordinates); + lineBuilder.add(lineBetweenTwoDays); + lineBuilder.add(DateFormat.getDateInstance().format(previousPoint.getTime())); + lineBuilder.add("tripBetweenTwoDays"); + linesFeatures.add(lineBuilder.buildFeature(null)); + + coordinatesByDay = Lists.newLinkedList(); + } + + Coordinate coordinate = new Coordinate(point.getLongitude(), point.getLatitude()); + coordinatesByDay.add(coordinate); + + previousPoint = point; + } + + if (coordinatesByDay.size() > 1) { + LineString line = geometryFactory.createLineString(coordinatesByDay.toArray(new Coordinate[0])); + lineBuilder.add(line); + lineBuilder.add(dateFormat.format(previousPoint.getTime())); + lineBuilder.add("tripDay"); + linesFeatures.add(lineBuilder.buildFeature(null)); + } + + Style styleLines = findStyle(styledLayerDescriptor, TRIP_LINES_LAYER_NAME, null); + Layer layerLines = new FeatureLayer(linesFeatures, styleLines); + mapContent.addLayer(layerLines); + + + // add line in legend + LineString line = geometryFactory.createLineString(ObserveMapPaneLegendItem.lineCoordinates()); + lineBuilder.add(line); + lineBuilder.add(""); + lineBuilder.add("tripDay"); + + ObserveMapPaneLegendItem legendTripDay = new ObserveMapPaneLegendItem( + lineBuilder.buildFeature(null), + styleLines, + t("observe.map.legend.tripDay")); + legendItems.add(legendTripDay); + + lineBuilder.add(line); + lineBuilder.add(""); + lineBuilder.add("tripBetweenTwoDays"); + ObserveMapPaneLegendItem legendTripBetweenTwoDays = new ObserveMapPaneLegendItem( + lineBuilder.buildFeature(null), + styleLines, + t("observe.map.legend.tripBetweenTwoDays")); + legendItems.add(legendTripBetweenTwoDays); + + } + + public void addLonglineFishingZone(List<TripMapPoint> tripMapPoints) throws FactoryException { + GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); + + SimpleFeatureTypeBuilder polygonFeatureTypeBuilder = new SimpleFeatureTypeBuilder(); + polygonFeatureTypeBuilder.setName("longlineFishingZoneBuilder"); + polygonFeatureTypeBuilder.setCRS(CRS.decode("EPSG:4326", true)); + polygonFeatureTypeBuilder.add("zone", Polygon.class); + polygonFeatureTypeBuilder.add("type", String.class); + + SimpleFeatureType polygonFeatureType = polygonFeatureTypeBuilder.buildFeatureType(); + SimpleFeatureBuilder polygonBuilder = new SimpleFeatureBuilder(polygonFeatureType); + + DefaultFeatureCollection polygonsFeatures = new DefaultFeatureCollection(); + + for (int indexPoint = 3; indexPoint < tripMapPoints.size(); indexPoint++) { + if (tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_END) + && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_START) + && tripMapPoints.get(indexPoint - 2).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_END) + && tripMapPoints.get(indexPoint - 3).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_START)) { + + Coordinate[] coordinates = { + new Coordinate(tripMapPoints.get(indexPoint - 3).getLongitude(), tripMapPoints.get(indexPoint - 3).getLatitude()), + new Coordinate(tripMapPoints.get(indexPoint - 2).getLongitude(), tripMapPoints.get(indexPoint - 2).getLatitude()), + new Coordinate(tripMapPoints.get(indexPoint - 1).getLongitude(), tripMapPoints.get(indexPoint - 1).getLatitude()), + new Coordinate(tripMapPoints.get(indexPoint).getLongitude(), tripMapPoints.get(indexPoint).getLatitude()), + new Coordinate(tripMapPoints.get(indexPoint - 3).getLongitude(), tripMapPoints.get(indexPoint - 3).getLatitude()) + }; + + + Polygon polygon = geometryFactory.createPolygon(coordinates); + polygonBuilder.add(polygon); + polygonBuilder.add("longlineFishingZone"); + SimpleFeature feature = polygonBuilder.buildFeature(null); + polygonsFeatures.add(feature); + + } + } + + Style styleLines = findStyle(styledLayerDescriptor, TRIP_LONGLINE_FISHING_ZONE_LAYER_NAME, null); + Layer layerLines = new FeatureLayer(polygonsFeatures, styleLines); + mapContent.addLayer(layerLines); + } + + public void addLonglineLine(List<TripMapPoint> tripMapPoints) throws FactoryException { + GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); + + SimpleFeatureTypeBuilder lineFeatureTypeBuilder = new SimpleFeatureTypeBuilder(); + lineFeatureTypeBuilder.setName("longlineSettingBuilder"); + lineFeatureTypeBuilder.setCRS(CRS.decode("EPSG:4326", true)); + lineFeatureTypeBuilder.add("line", LineString.class); + lineFeatureTypeBuilder.add("type", String.class); + + SimpleFeatureType lineFeatureType = lineFeatureTypeBuilder.buildFeatureType(); + SimpleFeatureBuilder lineBuilder = new SimpleFeatureBuilder(lineFeatureType); + + DefaultFeatureCollection linesFeatures = new DefaultFeatureCollection(); + + for (int indexPoint = 1; indexPoint < tripMapPoints.size(); indexPoint++) { + if (tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_END) + && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_START) + || tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_END) + && tripMapPoints.get(indexPoint - 1).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_START)) { + + Coordinate[] coordinates = { + new Coordinate(tripMapPoints.get(indexPoint - 1).getLongitude(), tripMapPoints.get(indexPoint - 1).getLatitude()), + new Coordinate(tripMapPoints.get(indexPoint).getLongitude(), tripMapPoints.get(indexPoint).getLatitude()), + }; + + boolean setting = tripMapPoints.get(indexPoint).getType().equals(TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_END); + LineString lineString = geometryFactory.createLineString(coordinates); + lineBuilder.add(lineString); + lineBuilder.add(setting ? "setting" : "hauling"); + SimpleFeature feature = lineBuilder.buildFeature(null); + linesFeatures.add(feature); + + } + } + + Style styleLines = findStyle(styledLayerDescriptor, TRIP_LONGLINE_LINE_LAYER_NAME, null); + Layer layerLines = new FeatureLayer(linesFeatures, styleLines); + mapContent.addLayer(layerLines); + + // add line in legend + LineString line = geometryFactory.createLineString(ObserveMapPaneLegendItem.lineCoordinates()); + lineBuilder.add(line); + lineBuilder.add("setting"); + + ObserveMapPaneLegendItem legendTripDay = new ObserveMapPaneLegendItem( + lineBuilder.buildFeature(null), + styleLines, + t("observe.map.legend.setting")); + legendItems.add(legendTripDay); + + line = geometryFactory.createLineString(ObserveMapPaneLegendItem.lineCoordinates()); + lineBuilder.add(line); + lineBuilder.add("hauling"); + + legendTripDay = new ObserveMapPaneLegendItem( + lineBuilder.buildFeature(null), + styleLines, + t("observe.map.legend.hauling")); + legendItems.add(legendTripDay); + + + } + + + public void addPoints(List<TripMapPoint> tripMapPoints) throws FactoryException { + + GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); + + SimpleFeatureTypeBuilder pointFeatureTypeBuilder = new SimpleFeatureTypeBuilder(); + pointFeatureTypeBuilder.setName("point Builder"); + pointFeatureTypeBuilder.setCRS(CRS.decode("EPSG:4326", true)); + pointFeatureTypeBuilder.add("points", MultiPoint.class); + pointFeatureTypeBuilder.add("pointType", String.class); + + SimpleFeatureType pointFeatureType = pointFeatureTypeBuilder.buildFeatureType(); + SimpleFeatureBuilder pointBuilder = new SimpleFeatureBuilder(pointFeatureType); + + DefaultFeatureCollection pointsFeatures = new DefaultFeatureCollection(); + + Style stylePoints = findStyle(styledLayerDescriptor, TRIP_POINTS_LAYER_NAME, null); + + + for (final TripMapPointType type : TripMapPointType.values()) { + + Iterable<Coordinate> coordinates = Iterables.transform( + Iterables.filter(tripMapPoints, new Predicate<TripMapPoint>() { + @Override + public boolean apply(TripMapPoint input) { + return type.equals(input.getType()); + } + }), + new Function<TripMapPoint, Coordinate>() { + @Override + public Coordinate apply(TripMapPoint input) { + return new Coordinate(input.getLongitude(), input.getLatitude()); + } + }); + + ArrayList<Coordinate> coordinatesArray = Lists.newArrayList(coordinates); + if (! coordinatesArray.isEmpty()) { + MultiPoint points = geometryFactory.createMultiPoint(coordinatesArray.toArray(new Coordinate[0])); + pointBuilder.add(points); + pointBuilder.add(type.name()); + pointsFeatures.add(pointBuilder.buildFeature(null)); + + + // add point in legend + if (TRIP_MAP_POINT_TYPES_IN_LEGEND.contains(type)) { + points = geometryFactory.createMultiPoint(ObserveMapPaneLegendItem.pointCoordinates()); + pointBuilder.add(points); + pointBuilder.add(type.name()); + + ObserveMapPaneLegendItem legendPoint = new ObserveMapPaneLegendItem( + pointBuilder.buildFeature(null), + stylePoints, + type.getLabel()); + legendItems.add(legendPoint); + } + + } + } + + Layer pointsLayer = new FeatureLayer(pointsFeatures, stylePoints); + mapContent.addLayer(pointsLayer); + + } + + + protected Style findStyle(StyledLayerDescriptor styledLayerDescriptor, final String layerName, String styleName, Style defaultStyle) { + + Optional<StyledLayer> styledLayerOptional = Iterables.tryFind(styledLayerDescriptor.layers(), new Predicate<StyledLayer>() { + @Override + public boolean apply(StyledLayer input) { + return input.getName().equals(layerName); + } + }); + + Style style = defaultStyle; + + if (styledLayerOptional.isPresent()) { + + StyledLayer styledLayer = styledLayerOptional.get(); + + Style[] styles = new Style[0]; + + if (styledLayer instanceof UserLayer) { + + styles = ((UserLayer) styledLayer).getUserStyles(); + + } else if (styledLayer instanceof NamedLayer) { + + styles = ((NamedLayer) styledLayer).getStyles(); + + } + + if (styles.length == 1) { + + style = styles[0]; + + } else { + + for (Style styleTmp : styles) { + + if (StringUtils.isBlank(styleName) && styleTmp.isDefault() + || styleTmp.getName().equals(styleName)) { + + style = styleTmp; + } + } + } + } + + return style; + + } + + protected Style findStyle(StyledLayerDescriptor styledLayerDescriptor, final String layerName, String styleName) { + + Style style = findStyle(styledLayerDescriptor, layerName, styleName, null); + + if (style == null) { + throw new ObserveTechnicalException(String.format("No style found for layer name '%s' and style name '%s'", layerName, styleName)); + } + return style; + + } + +} diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapUIHandler.java index 40994fb..45359a3 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapUIHandler.java @@ -22,57 +22,21 @@ package fr.ird.observe.ui.util.tripMap; * #L% */ -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.GeometryFactory; -import com.vividsolutions.jts.geom.LineString; -import com.vividsolutions.jts.geom.MultiPoint; import fr.ird.observe.DataService; import fr.ird.observe.ObserveConfig; import fr.ird.observe.ObserveContext; import fr.ird.observe.ObserveTechnicalException; import fr.ird.observe.db.DataSource; -import fr.ird.observe.db.DataSourceException; +import fr.ird.observe.entities.Entities; import fr.ird.observe.tripMap.TripMapPoint; -import fr.ird.observe.tripMap.TripMapPointType; import fr.ird.observe.ui.UIHelper; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.time.DateUtils; -import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.geotools.data.FileDataStore; -import org.geotools.data.FileDataStoreFinder; -import org.geotools.data.simple.SimpleFeatureSource; -import org.geotools.factory.CommonFactoryFinder; -import org.geotools.feature.DefaultFeatureCollection; -import org.geotools.feature.simple.SimpleFeatureBuilder; -import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.geotools.geometry.DirectPosition2D; -import org.geotools.geometry.jts.JTSFactoryFinder; import org.geotools.geometry.jts.ReferencedEnvelope; -import org.geotools.map.FeatureLayer; -import org.geotools.map.Layer; -import org.geotools.map.MapContent; -import org.geotools.referencing.CRS; -import org.geotools.styling.NamedLayer; -import org.geotools.styling.SLD; -import org.geotools.styling.SLDParser; -import org.geotools.styling.Style; -import org.geotools.styling.StyleFactory; -import org.geotools.styling.StyledLayer; -import org.geotools.styling.StyledLayerDescriptor; -import org.geotools.styling.UserLayer; import org.geotools.swing.JMapPane; import org.geotools.swing.event.MapPaneEvent; import org.geotools.swing.event.MapPaneListener; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; import javax.imageio.ImageIO; import javax.swing.JOptionPane; @@ -87,13 +51,8 @@ import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; import java.awt.image.BufferedImage; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.List; -import java.util.Set; import static org.nuiton.i18n.I18n.t; @@ -102,19 +61,8 @@ import static org.nuiton.i18n.I18n.t; */ public class TripMapUIHandler { - public static final String TRIP_LINES_LAYER_NAME = "Trip lines"; - public static final String TRIP_POINTS_LAYER_NAME = "Trip points"; public static final double ZOOM_STEP_RATIO = 0.1; - protected static final Set<TripMapPointType> TRIP_MAP_POINT_TYPES_IN_LEGEND = ImmutableSet.of( - TripMapPointType.SEINE_ACTIVITY_IN_HARBOUR, - TripMapPointType.SEINE_ACTIVITY_WITH_FREE_SCHOOL_TYPE, - TripMapPointType.SEINE_ACTIVITY_WITH_OBJECT_SCHOOL_TYPE, - TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_START, - TripMapPointType.LONGLINE_ACTIVITY_WITH_SETTING_END, - TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_START, - TripMapPointType.LONGLINE_ACTIVITY_WITH_HAULING_END); - public static TripMapUIHandler newHandler(TripMapUI view) { return new TripMapUIHandler(view); } @@ -169,11 +117,38 @@ public class TripMapUIHandler { List<TripMapPoint> tripMapPoints = dataService.loadTripMapActivityPoints(dataSource, tripId); ObserveMapPane mapPane = getObserveMapPane(); - Pair<MapContent, List<ObserveMapPaneLegendItem>> buildMapContent = buildMapContent(tripMapPoints); - mapPane.setMapContent(buildMapContent.getKey()); - mapPane.setLegendItems(buildMapContent.getValue()); - } catch (DataSourceException e) { + TripMapContentBuilder mapContentBuilder = new TripMapContentBuilder(); + mapContentBuilder.setStyledLayerDescriptor(config.getMapStyleFile()); + + for (File layerFile : config.getMapLayerFiles()) { + mapContentBuilder.addLayer(layerFile); + } + + if (Entities.isSeineId(tripId)) { + + mapContentBuilder.addTripLine(tripMapPoints); + + } else if (Entities.isLonglineId(tripId)) { + + mapContentBuilder.addLonglineFishingZone(tripMapPoints); + mapContentBuilder.addLonglineLine(tripMapPoints); + + } + + mapContentBuilder.addPoints(tripMapPoints); + + // set zoom + tripArea = new ReferencedEnvelope(); + for (TripMapPoint point : tripMapPoints) { + tripArea.expandToInclude(new DirectPosition2D(point.getLongitude(), point.getLatitude())); + } + tripArea.expandBy(1.1); + + mapPane.setMapContent(mapContentBuilder.getMapContent()); + mapPane.setLegendItems(mapContentBuilder.getLegendItems()); + + } catch (Exception e) { throw new ObserveTechnicalException("Unable to load trip map activity points", e); } finally { ObserveContext.get().getObserveMainUI().setBusy(false); @@ -226,263 +201,6 @@ public class TripMapUIHandler { } } - - - protected Pair<MapContent, List<ObserveMapPaneLegendItem>> buildMapContent(List<TripMapPoint> tripMapPoints) { - - MapContent mapContent = new MapContent(); - List<ObserveMapPaneLegendItem> legendItems = Lists.newArrayList(); - - if (tripMapPoints != null) { - try { - - StyledLayerDescriptor styledLayerDescriptor = importStyledLayerDescriptor(); - - for (File layerFile : config.getMapLayerFiles()) { - FileDataStore store = FileDataStoreFinder.getDataStore(layerFile); - SimpleFeatureSource featureSource = store.getFeatureSource(); - Style style = SLD.createSimpleStyle(featureSource.getSchema()); - style = findStyle(styledLayerDescriptor, store.getNames().get(0).getLocalPart(), null, style); - Layer layer = new FeatureLayer(featureSource, style); - mapContent.addLayer(layer); - } - - SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM"); - - GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); - - SimpleFeatureTypeBuilder lineFeatureTypeBuilder = new SimpleFeatureTypeBuilder(); - lineFeatureTypeBuilder.setName("lineBuilder"); - lineFeatureTypeBuilder.setCRS(CRS.decode("EPSG:4326", true)); - lineFeatureTypeBuilder.add("line", LineString.class); - lineFeatureTypeBuilder.add("label", String.class); - lineFeatureTypeBuilder.add("type", String.class); - - SimpleFeatureType lineFeatureType = lineFeatureTypeBuilder.buildFeatureType(); - SimpleFeatureBuilder lineBuilder = new SimpleFeatureBuilder(lineFeatureType); - - DefaultFeatureCollection linesFeatures = new DefaultFeatureCollection(); - - List<Coordinate> coordinatesByDay = null; - - TripMapPoint previousPoint = null; - - for (TripMapPoint point : tripMapPoints) { - if (previousPoint == null) { - coordinatesByDay = Lists.newLinkedList(); - } else if (!DateUtils.isSameDay(previousPoint.getTime(), point.getTime())) { - - if (coordinatesByDay.size() > 1) { - LineString line = geometryFactory.createLineString(coordinatesByDay.toArray(new Coordinate[0])); - lineBuilder.add(line); - lineBuilder.add(dateFormat.format(previousPoint.getTime())); - lineBuilder.add("tripDay"); - SimpleFeature feature = lineBuilder.buildFeature(null); - - linesFeatures.add(feature); - } - - - Coordinate[] coordinates = { - new Coordinate(previousPoint.getLongitude(), previousPoint.getLatitude()), - new Coordinate(point.getLongitude(), point.getLatitude()), - }; - LineString lineBetweenTwoDays = geometryFactory.createLineString(coordinates); - lineBuilder.add(lineBetweenTwoDays); - lineBuilder.add(DateFormat.getDateInstance().format(previousPoint.getTime())); - lineBuilder.add("tripBetweenTwoDays"); - linesFeatures.add(lineBuilder.buildFeature(null)); - - coordinatesByDay = Lists.newLinkedList(); - } - - Coordinate coordinate = new Coordinate(point.getLongitude(), point.getLatitude()); - coordinatesByDay.add(coordinate); - - previousPoint = point; - } - - if (coordinatesByDay.size() > 1) { - LineString line = geometryFactory.createLineString(coordinatesByDay.toArray(new Coordinate[0])); - lineBuilder.add(line); - lineBuilder.add(dateFormat.format(previousPoint.getTime())); - lineBuilder.add("tripDay"); - linesFeatures.add(lineBuilder.buildFeature(null)); - } - - Style styleLines = findStyle(styledLayerDescriptor, TRIP_LINES_LAYER_NAME, null); - Layer layerLines = new FeatureLayer(linesFeatures, styleLines); - mapContent.addLayer(layerLines); - - - // add line in legend - LineString line = geometryFactory.createLineString(ObserveMapPaneLegendItem.lineCoordinates()); - lineBuilder.add(line); - lineBuilder.add(""); - lineBuilder.add("tripDay"); - - ObserveMapPaneLegendItem legendTripDay = new ObserveMapPaneLegendItem( - lineBuilder.buildFeature(null), - styleLines, - t("observe.map.legend.tripDay")); - legendItems.add(legendTripDay); - - lineBuilder.add(line); - lineBuilder.add(""); - lineBuilder.add("tripBetweenTwoDays"); - ObserveMapPaneLegendItem legendTripBetweenTwoDays = new ObserveMapPaneLegendItem( - lineBuilder.buildFeature(null), - styleLines, - t("observe.map.legend.tripBetweenTwoDays")); - legendItems.add(legendTripBetweenTwoDays); - - - // add Point - SimpleFeatureTypeBuilder pointFeatureTypeBuilder = new SimpleFeatureTypeBuilder(); - pointFeatureTypeBuilder.setName("point Builder"); - pointFeatureTypeBuilder.setCRS(CRS.decode("EPSG:4326", true)); - pointFeatureTypeBuilder.add("points", MultiPoint.class); - pointFeatureTypeBuilder.add("pointType", String.class); - - SimpleFeatureType pointFeatureType = pointFeatureTypeBuilder.buildFeatureType(); - SimpleFeatureBuilder pointBuilder = new SimpleFeatureBuilder(pointFeatureType); - - DefaultFeatureCollection pointsFeatures = new DefaultFeatureCollection(); - - Style stylePoints = findStyle(styledLayerDescriptor, TRIP_POINTS_LAYER_NAME, null); - - - for (final TripMapPointType type : TripMapPointType.values()) { - - Iterable<Coordinate> coordinates = Iterables.transform( - Iterables.filter(tripMapPoints, new Predicate<TripMapPoint>() { - @Override - public boolean apply(TripMapPoint input) { - return type.equals(input.getType()); - } - }), - new Function<TripMapPoint, Coordinate>() { - @Override - public Coordinate apply(TripMapPoint input) { - return new Coordinate(input.getLongitude(), input.getLatitude()); - } - }); - - ArrayList<Coordinate> coordinatesArray = Lists.newArrayList(coordinates); - if (! coordinatesArray.isEmpty()) { - MultiPoint points = geometryFactory.createMultiPoint(coordinatesArray.toArray(new Coordinate[0])); - pointBuilder.add(points); - pointBuilder.add(type.name()); - pointsFeatures.add(pointBuilder.buildFeature(null)); - - - // add point in legend - if (TRIP_MAP_POINT_TYPES_IN_LEGEND.contains(type)) { - points = geometryFactory.createMultiPoint(ObserveMapPaneLegendItem.pointCoordinates()); - pointBuilder.add(points); - pointBuilder.add(type.name()); - - ObserveMapPaneLegendItem legendPoint = new ObserveMapPaneLegendItem( - pointBuilder.buildFeature(null), - stylePoints, - type.getLabel()); - legendItems.add(legendPoint); - } - - } - } - - Layer pointsLayer = new FeatureLayer(pointsFeatures, stylePoints); - mapContent.addLayer(pointsLayer); - // set zoom - - tripArea = new ReferencedEnvelope(); - for (TripMapPoint point : tripMapPoints) { - tripArea.expandToInclude(new DirectPosition2D(point.getLongitude(), point.getLatitude())); - } - tripArea.expandBy(1.1); - - - } catch (Exception e) { - throw new ObserveTechnicalException("Unable to build content map", e); - } - } - - return Pair.of(mapContent, legendItems); - } - - protected StyledLayerDescriptor importStyledLayerDescriptor() throws FileNotFoundException { - - File styleFile = config.getMapStyleFile(); - - StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(null); - - SLDParser stylereader = new SLDParser(styleFactory, styleFile); - - StyledLayerDescriptor styledLayerDescriptor = stylereader.parseSLD(); - - return styledLayerDescriptor; - } - - protected Style findStyle(StyledLayerDescriptor styledLayerDescriptor, final String layerName, String styleName, Style defaultStyle) { - - Optional<StyledLayer> styledLayerOptional = Iterables.tryFind(styledLayerDescriptor.layers(), new Predicate<StyledLayer>() { - @Override - public boolean apply(StyledLayer input) { - return input.getName().equals(layerName); - } - }); - - Style style = defaultStyle; - - if (styledLayerOptional.isPresent()) { - - StyledLayer styledLayer = styledLayerOptional.get(); - - Style[] styles = new Style[0]; - - if (styledLayer instanceof UserLayer) { - - styles = ((UserLayer) styledLayer).getUserStyles(); - - } else if (styledLayer instanceof NamedLayer) { - - styles = ((NamedLayer) styledLayer).getStyles(); - - } - - if (styles.length == 1) { - - style = styles[0]; - - } else { - - for (Style styleTmp : styles) { - - if (StringUtils.isBlank(styleName) && styleTmp.isDefault() - || styleTmp.getName().equals(styleName)) { - - style = styleTmp; - } - } - } - } - - return style; - - } - - protected Style findStyle(StyledLayerDescriptor styledLayerDescriptor, final String layerName, String styleName) { - - Style style = findStyle(styledLayerDescriptor, layerName, styleName, null); - - if (style == null) { - throw new ObserveTechnicalException(String.format("No style found for layer name '%s' and style name '%s'", layerName, styleName)); - } - return style; - - } - protected double zoomRatio = 1; protected Point zoomCenter; @@ -524,15 +242,10 @@ public class TripMapUIHandler { zoomRatio = 1; - } - } - - - private class MouseMapListener implements MouseWheelListener, MouseListener, MouseMotionListener { @Override diff --git a/observe-swing/src/main/map/style.xml b/observe-swing/src/main/map/style.xml index 7305fd4..bcf9aa8 100644 --- a/observe-swing/src/main/map/style.xml +++ b/observe-swing/src/main/map/style.xml @@ -88,18 +88,98 @@ </NamedLayer> <NamedLayer> - <Name>Trip points</Name> + <Name>Trip longline zone</Name> <UserStyle> <IsDefault>true</IsDefault> + <Title>SLD Cook Book: Simple Line</Title> <FeatureTypeStyle> <Rule> - <Name>Point seine activity in harbour</Name> + <Name>Trip day</Name> + <PolygonSymbolizer> + <Fill> + <CssParameter name="fill">#000080</CssParameter> + <CssParameter name="fill-opacity">0.5</CssParameter> + </Fill> + </PolygonSymbolizer> + </Rule> + </FeatureTypeStyle> + </UserStyle> + </NamedLayer> + + <NamedLayer> + <Name>Trip longline line</Name> + <UserStyle> + <IsDefault>true</IsDefault> + <Title>SLD Cook Book: Simple Line</Title> + <FeatureTypeStyle> + <Rule> + <Name>setting</Name> <ogc:Filter> <ogc:PropertyIsEqualTo> - <ogc:PropertyName>pointType</ogc:PropertyName> - <ogc:Literal>SEINE_ACTIVITY_IN_HARBOUR</ogc:Literal> + <ogc:PropertyName>type</ogc:PropertyName> + <ogc:Literal>setting</ogc:Literal> + </ogc:PropertyIsEqualTo> + </ogc:Filter> + <LineSymbolizer> + <Stroke> + <CssParameter name="stroke">#00ff00</CssParameter> + <CssParameter name="stroke-width">2</CssParameter> + </Stroke> + </LineSymbolizer> + </Rule> + </FeatureTypeStyle> + <FeatureTypeStyle> + <Rule> + <Name>hauling</Name> + <ogc:Filter> + <ogc:PropertyIsEqualTo> + <ogc:PropertyName>type</ogc:PropertyName> + <ogc:Literal>hauling</ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:Filter> + <LineSymbolizer> + <Stroke> + <CssParameter name="stroke">#ff0000</CssParameter> + <CssParameter name="stroke-width">2</CssParameter> + </Stroke> + </LineSymbolizer> + </Rule> + </FeatureTypeStyle> + </UserStyle> + </NamedLayer> + + + <NamedLayer> + <Name>Trip points</Name> + <UserStyle> + <IsDefault>true</IsDefault> + <FeatureTypeStyle> + <Rule> + <Name>Point seine activity in harbour</Name> + <ogc:Filter> + <ogc:Or> + <ogc:PropertyIsEqualTo> + <ogc:PropertyName>pointType</ogc:PropertyName> + <ogc:Literal>SEINE_DEPARTURE_HARBOUR</ogc:Literal> + </ogc:PropertyIsEqualTo> + <ogc:PropertyIsEqualTo> + <ogc:PropertyName>pointType</ogc:PropertyName> + <ogc:Literal>SEINE_LANDING_HARBOUR</ogc:Literal> + </ogc:PropertyIsEqualTo> + <ogc:PropertyIsEqualTo> + <ogc:PropertyName>pointType</ogc:PropertyName> + <ogc:Literal>SEINE_ACTIVITY_IN_HARBOUR</ogc:Literal> + </ogc:PropertyIsEqualTo> + <ogc:PropertyIsEqualTo> + <ogc:PropertyName>pointType</ogc:PropertyName> + <ogc:Literal>LONGLINE_DEPARTURE_HARBOUR</ogc:Literal> + </ogc:PropertyIsEqualTo> + <ogc:PropertyIsEqualTo> + <ogc:PropertyName>pointType</ogc:PropertyName> + <ogc:Literal>LONGLINE_LANDING_HARBOUR</ogc:Literal> + </ogc:PropertyIsEqualTo> + </ogc:Or> + </ogc:Filter> <PointSymbolizer> <Graphic> <Mark> @@ -112,7 +192,7 @@ <CssParameter name="stroke-width">1</CssParameter> </Stroke> </Mark> - <Size>16</Size> + <Size>12</Size> </Graphic> </PointSymbolizer> </Rule> @@ -185,7 +265,7 @@ <PointSymbolizer> <Graphic> <Mark> - <WellKnownName>X</WellKnownName> + <WellKnownName>Triangle</WellKnownName> <Fill> <CssParameter name="fill">#00FF00</CssParameter> </Fill> @@ -213,7 +293,7 @@ <PointSymbolizer> <Graphic> <Mark> - <WellKnownName>Circle</WellKnownName> + <WellKnownName>X</WellKnownName> <Fill> <CssParameter name="fill">#00FF00</CssParameter> </Fill> @@ -241,7 +321,7 @@ <PointSymbolizer> <Graphic> <Mark> - <WellKnownName>X</WellKnownName> + <WellKnownName>Triangle</WellKnownName> <Fill> <CssParameter name="fill">#FF0000</CssParameter> </Fill> @@ -256,7 +336,6 @@ </Rule> </FeatureTypeStyle> - <FeatureTypeStyle> <Rule> <Name>Point longline activity with hauling end</Name> @@ -269,7 +348,7 @@ <PointSymbolizer> <Graphic> <Mark> - <WellKnownName>Circle</WellKnownName> + <WellKnownName>X</WellKnownName> <Fill> <CssParameter name="fill">#FF0000</CssParameter> </Fill> @@ -284,6 +363,60 @@ </Rule> </FeatureTypeStyle> + <FeatureTypeStyle> + <Rule> + <Name>Point longline activity with interaction</Name> + <ogc:Filter> + <ogc:PropertyIsEqualTo> + <ogc:PropertyName>pointType</ogc:PropertyName> + <ogc:Literal>LONGLINE_ACTIVITY_WITH_INTERACTION</ogc:Literal> + </ogc:PropertyIsEqualTo> + </ogc:Filter> + <PointSymbolizer> + <Graphic> + <Mark> + <WellKnownName>Circle</WellKnownName> + <Fill> + <CssParameter name="fill">#FFFF00</CssParameter> + </Fill> + <Stroke> + <CssParameter name="stroke">#000000</CssParameter> + <CssParameter name="stroke-width">1</CssParameter> + </Stroke> + </Mark> + <Size>12</Size> + </Graphic> + </PointSymbolizer> + </Rule> + </FeatureTypeStyle> + + <FeatureTypeStyle> + <Rule> + <Name>Point longline activity with station</Name> + <ogc:Filter> + <ogc:PropertyIsEqualTo> + <ogc:PropertyName>pointType</ogc:PropertyName> + <ogc:Literal>LONGLINE_ACTIVITY_WITH_STATION</ogc:Literal> + </ogc:PropertyIsEqualTo> + </ogc:Filter> + <PointSymbolizer> + <Graphic> + <Mark> + <WellKnownName>star</WellKnownName> + <Fill> + <CssParameter name="fill">#FFFF00</CssParameter> + </Fill> + <Stroke> + <CssParameter name="stroke">#000000</CssParameter> + <CssParameter name="stroke-width">1</CssParameter> + </Stroke> + </Mark> + <Size>16</Size> + </Graphic> + </PointSymbolizer> + </Rule> + </FeatureTypeStyle> + </UserStyle> </NamedLayer> diff --git a/observe-swing/src/main/resources/i18n/observe-swing_en_GB.properties b/observe-swing/src/main/resources/i18n/observe-swing_en_GB.properties index 3af012f..978d257 100644 --- a/observe-swing/src/main/resources/i18n/observe-swing_en_GB.properties +++ b/observe-swing/src/main/resources/i18n/observe-swing_en_GB.properties @@ -1281,6 +1281,8 @@ observe.map.export.overwrite.cancel= observe.map.export.overwrite.ok= observe.map.export.overwrite.title= observe.map.export.success= +observe.map.legend.hauling= +observe.map.legend.setting= observe.map.legend.tripBetweenTwoDays= observe.map.legend.tripDay= observe.map.miles= diff --git a/observe-swing/src/main/resources/i18n/observe-swing_es_ES.properties b/observe-swing/src/main/resources/i18n/observe-swing_es_ES.properties index 310858c..09e6ee1 100644 --- a/observe-swing/src/main/resources/i18n/observe-swing_es_ES.properties +++ b/observe-swing/src/main/resources/i18n/observe-swing_es_ES.properties @@ -1283,6 +1283,8 @@ observe.map.export.overwrite.cancel= observe.map.export.overwrite.ok= observe.map.export.overwrite.title= observe.map.export.success= +observe.map.legend.hauling= +observe.map.legend.setting= observe.map.legend.tripBetweenTwoDays= observe.map.legend.tripDay= observe.map.miles= diff --git a/observe-swing/src/main/resources/i18n/observe-swing_fr_FR.properties b/observe-swing/src/main/resources/i18n/observe-swing_fr_FR.properties index 0dad92b..ca23aef 100644 --- a/observe-swing/src/main/resources/i18n/observe-swing_fr_FR.properties +++ b/observe-swing/src/main/resources/i18n/observe-swing_fr_FR.properties @@ -1276,6 +1276,8 @@ observe.map.export.overwrite.cancel=Annuler observe.map.export.overwrite.ok=Remplacer observe.map.export.overwrite.title=Attention observe.map.export.success=Carte exportée (%s) +observe.map.legend.hauling=Filage +observe.map.legend.setting=Virage observe.map.legend.tripBetweenTwoDays=Trajet entre deux jours observe.map.legend.tripDay=Trajet d'une journée observe.map.miles=milles -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.