branch feature/6944 updated (5f3c48a -> 3996e91)
This is an automated email from the git hooks/post-receive script. New change to branch feature/6944 in repository observe. See http://git.codelutin.com/observe.git from 5f3c48a add french translation fr i18n new f708cab rename functions new 3996e91 add point and fix style The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 3996e91ac30ba9ec8551d17686405fb9132aa5e5 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Thu Apr 16 16:09:54 2015 +0200 add point and fix style commit f708cabdc99b04329fde6eea26d0fd39ef00e2a5 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Thu Apr 16 15:52:51 2015 +0200 rename functions Summary of changes: .../src/main/java/fr/ird/observe/DataService.java | 4 +- .../observe/entities/seine/TripSeineDAOImpl.java | 10 +- observe-swing/pom.xml | 4 + .../open/impl/seine/TripSeineUIHandler.java | 156 +++++++++++++++++---- pom.xml | 5 + 5 files changed, 148 insertions(+), 31 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/6944 in repository observe. See http://git.codelutin.com/observe.git commit f708cabdc99b04329fde6eea26d0fd39ef00e2a5 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Thu Apr 16 15:52:51 2015 +0200 rename functions --- observe-business/src/main/java/fr/ird/observe/DataService.java | 4 ++-- .../java/fr/ird/observe/entities/seine/TripSeineDAOImpl.java | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/observe-business/src/main/java/fr/ird/observe/DataService.java b/observe-business/src/main/java/fr/ird/observe/DataService.java index e35ea06..41739e6 100644 --- a/observe-business/src/main/java/fr/ird/observe/DataService.java +++ b/observe-business/src/main/java/fr/ird/observe/DataService.java @@ -1633,7 +1633,7 @@ public class DataService { } } - public List<TripMapPoint> loadTrip(DataSource source, String id) throws DataSourceException { + public List<TripMapPoint> loadTripMapActivityPoints(DataSource source, String id) throws DataSourceException { if (!source.canReadData()) { if (log.isDebugEnabled()) { log.debug("Can not read data!"); @@ -1646,7 +1646,7 @@ public class DataService { try { TripSeineDAO dao = (TripSeineDAO) source.getDAO(tx, TripSeine.class); - List<TripMapPoint> tripMapPoints = dao.extractTripMap(id); + List<TripMapPoint> tripMapPoints = dao.extractTripMapActivityPoints(id); return tripMapPoints; } catch (Exception e) { 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 21215d9..756d3c1 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 @@ -78,7 +78,7 @@ public class TripSeineDAOImpl<E extends TripSeine> extends TripSeineDAOAbstract< } - public List<TripMapPoint> extractTripMap(String tripId) throws TopiaException { + public List<TripMapPoint> extractTripMapActivityPoints(String tripId) throws TopiaException { TripSeine tripSeine = findByTopiaId(tripId); @@ -95,8 +95,8 @@ public class TripSeineDAOImpl<E extends TripSeine> extends TripSeineDAOAbstract< } // Add Activities - TripMapPointQuery tripMapPointQuery = new TripMapPointQuery(tripId); - tripMapPoints.addAll(tripMapPointQuery.findMultipleResult(context)); + TripMapActivityPointQuery tripMapActivityPointQuery = new TripMapActivityPointQuery(tripId); + tripMapPoints.addAll(tripMapActivityPointQuery.findMultipleResult(context)); // add landing harbours Harbour landingHarbour = tripSeine.getLandingHarbour(); @@ -111,7 +111,7 @@ public class TripSeineDAOImpl<E extends TripSeine> extends TripSeineDAOAbstract< return tripMapPoints; } - private static class TripMapPointQuery extends TopiaSQLQuery<TripMapPoint> { + private static class TripMapActivityPointQuery extends TopiaSQLQuery<TripMapPoint> { private static String SQL = "SELECT" + " r.date, " + @@ -129,7 +129,7 @@ public class TripSeineDAOImpl<E extends TripSeine> extends TripSeineDAOAbstract< protected String tripId; - public TripMapPointQuery(String tripId) { + public TripMapActivityPointQuery(String tripId) { this.tripId = tripId; } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/6944 in repository observe. See http://git.codelutin.com/observe.git commit 3996e91ac30ba9ec8551d17686405fb9132aa5e5 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Thu Apr 16 16:09:54 2015 +0200 add point and fix style --- observe-swing/pom.xml | 4 + .../open/impl/seine/TripSeineUIHandler.java | 156 +++++++++++++++++---- pom.xml | 5 + 3 files changed, 141 insertions(+), 24 deletions(-) diff --git a/observe-swing/pom.xml b/observe-swing/pom.xml index 6f4be94..20155d8 100644 --- a/observe-swing/pom.xml +++ b/observe-swing/pom.xml @@ -258,6 +258,10 @@ <groupId>org.geotools</groupId> <artifactId>gt-render</artifactId> </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt-epsg-hsql</artifactId> + </dependency> <!-- Logging --> <dependency> diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java index 13bf37f..3908feb 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java @@ -22,10 +22,13 @@ package fr.ird.observe.ui.content.open.impl.seine; import com.google.common.base.Function; +import com.google.common.base.Predicate; +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.ObserveDAOHelper; @@ -33,6 +36,7 @@ import fr.ird.observe.db.DataContext; import fr.ird.observe.db.DataSource; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.db.util.TopiaExecutor2; +import fr.ird.observe.entities.constants.seine.SchoolType; import fr.ird.observe.entities.referentiel.Program; import fr.ird.observe.entities.seine.Routes; import fr.ird.observe.entities.seine.TripSeine; @@ -40,12 +44,15 @@ import fr.ird.observe.tripMap.TripMapPoint; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.open.ContentOpenableUIHandler; import fr.ird.observe.ui.content.open.ContentOpenableUIModel; +import org.apache.commons.lang3.time.DateUtils; 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.FeatureCollection; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.geotools.geometry.DirectPosition2D; @@ -54,8 +61,10 @@ 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.SLD; import org.geotools.styling.Style; +import org.geotools.styling.StyleFactory; import org.geotools.swing.JMapPane; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; @@ -63,8 +72,9 @@ import org.nuiton.topia.persistence.TopiaDAO; import org.nuiton.topia.persistence.TopiaEntity; import org.nuiton.topia.persistence.util.TopiaEntityBinder; import org.nuiton.util.DateUtil; -import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.filter.FilterFactory; +import org.opengis.referencing.FactoryException; import javax.swing.JTabbedPane; import javax.swing.event.ChangeEvent; @@ -368,7 +378,6 @@ public class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeine> { mapContent = new MapContent(); mapContent.setTitle("Un titre"); - // add map layers ObserveConfig config = ui.getContextValue(ObserveConfig.class); @@ -380,44 +389,80 @@ public class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeine> { mapContent.addLayer(layer); } - // add trip + // add lines DataService dataService = getDataService(); DataSource source = getDataSource(); String tripId = getSelectedId(); - List<TripMapPoint> tripMapPoints = dataService.loadTrip(source, tripId); + List<TripMapPoint> tripMapPoints = dataService.loadTripMapActivityPoints(source, tripId); GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); - SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); - typeBuilder.setName("a-type-name"); - //typeBuilder.setCRS(CRS.decode("EPSG:4326")); - typeBuilder.add("geom-attr-name", LineString.class); + SimpleFeatureTypeBuilder lineFeatureTypeBuilder = new SimpleFeatureTypeBuilder(); + lineFeatureTypeBuilder.setName("a-type-name"); + lineFeatureTypeBuilder.setCRS(CRS.decode("EPSG:4326", true)); + lineFeatureTypeBuilder.add("geom-attr-name", LineString.class); - SimpleFeatureType type = typeBuilder.buildFeatureType(); - SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); + SimpleFeatureType lineFeatureType = lineFeatureTypeBuilder.buildFeatureType(); + SimpleFeatureBuilder lineBuilder = new SimpleFeatureBuilder(lineFeatureType); + DefaultFeatureCollection featuresDays = new DefaultFeatureCollection(); + DefaultFeatureCollection featuresBetweenTowDays = new DefaultFeatureCollection(); - List <Coordinate> coordinates = Lists.transform(tripMapPoints, new Function<TripMapPoint, Coordinate>() { + List<Coordinate> coordinatesByDay = null; - @Override - public Coordinate apply(TripMapPoint input) { - return new Coordinate(input.getLongitude(), input.getLatitude()); + 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); + featuresDays.add(lineBuilder.buildFeature(null)); + } + + + Coordinate[] coordinates = { + new Coordinate(previousPoint.getLongitude(), previousPoint.getLatitude()), + new Coordinate(point.getLongitude(), point.getLatitude()), + }; + LineString lineBetweenTwoDays = geometryFactory.createLineString(coordinates); + lineBuilder.add(lineBetweenTwoDays); + featuresBetweenTowDays.add(lineBuilder.buildFeature(null)); + + coordinatesByDay = Lists.newLinkedList(); } - }); - LineString line = geometryFactory.createLineString(coordinates.toArray(new Coordinate[0])); + 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); + featuresDays.add(lineBuilder.buildFeature(null)); + } + + Layer layerDays = new FeatureLayer(featuresDays, getStyleLineDay()); + Layer layerBetweenTowDays = new FeatureLayer(featuresBetweenTowDays, getStyleLineBetweenTwoDays()); + mapContent.addLayer(layerDays); + mapContent.addLayer(layerBetweenTowDays); - builder.add(line); + // add Point + FeatureCollection featurePointsLibres = generateFeaturePoints(tripMapPoints, SchoolType.libre); + FeatureCollection featurePointsObjets = generateFeaturePoints(tripMapPoints, SchoolType.objet); - SimpleFeature tripFeature = builder.buildFeature("trip"); + Layer layerPointsLibres = new FeatureLayer(featurePointsLibres, getStylePointLibre()); + Layer layerPointsObjets = new FeatureLayer(featurePointsObjets, getStylePointObjet()); + mapContent.addLayer(layerPointsLibres); + mapContent.addLayer(layerPointsObjets); - DefaultFeatureCollection features = new DefaultFeatureCollection(); - features.add(tripFeature); - Style style = SLD.createLineStyle(Color.green, 1); - Layer layer = new FeatureLayer(features, style); - mapContent.addLayer(layer); // set zoom @@ -436,6 +481,69 @@ public class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeine> { return mapContent; } + private Style getStylePointObjet() { + return SLD.createPointStyle("Triangle", Color.BLACK, Color.ORANGE, 1, 16); + } + + protected Style getStylePointLibre() { + return SLD.createPointStyle("X", Color.BLACK, Color.GREEN, 1, 16); + } + + protected FeatureCollection generateFeaturePoints(List<TripMapPoint> tripMapPoints, final SchoolType schoolType) throws FactoryException { + SimpleFeatureTypeBuilder pointFeatureTypeBuilder = new SimpleFeatureTypeBuilder(); + pointFeatureTypeBuilder.setName("a-type-name"); + pointFeatureTypeBuilder.setCRS(CRS.decode("EPSG:4326", true)); + pointFeatureTypeBuilder.add("geom-attr-name", MultiPoint.class); + + SimpleFeatureType pointFeatureType = pointFeatureTypeBuilder.buildFeatureType(); + SimpleFeatureBuilder pointBuilder = new SimpleFeatureBuilder(pointFeatureType); + + DefaultFeatureCollection featuresPoint = new DefaultFeatureCollection(); + + Iterable<Coordinate> coordinates = Iterables.transform( + Iterables.filter(tripMapPoints, new Predicate<TripMapPoint>() { + @Override + public boolean apply(TripMapPoint input) { + return input.getSchoolType() == schoolType; + } + }), + new Function<TripMapPoint, Coordinate>() { + @Override + public Coordinate apply(TripMapPoint input) { + return new Coordinate(input.getLongitude(), input.getLatitude()); + } + }); + + GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); + + MultiPoint points = geometryFactory.createMultiPoint(Lists.newArrayList(coordinates).toArray(new Coordinate[0])); + pointBuilder.add(points); + featuresPoint.add(pointBuilder.buildFeature(null)); + + return featuresPoint; + } + + protected Style getStyleLineDay() { + return SLD.createLineStyle(Color.BLACK, 1); + } + + protected Style getStyleLineBetweenTwoDays() { + StyleFactory sf = CommonFactoryFinder.getStyleFactory(null); + FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); + float[] dashArray = {5f, 5f}; + org.geotools.styling.Stroke stroke = sf.createStroke(ff.literal(Color.BLACK), + ff.literal(1), + null, + null, + null, + dashArray, + null, + null, + null); + + return SLD.wrapSymbolizers(sf.createLineSymbolizer(stroke, null)); + } + private class MouseMapListener implements MouseWheelListener, MouseListener, MouseMotionListener { @Override @@ -486,7 +594,7 @@ public class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeine> { @Override public void mouseDragged(MouseEvent e) { - endMove(e.getPoint()); +// endMove(e.getPoint()); } @Override diff --git a/pom.xml b/pom.xml index ba64549..d28f7a9 100644 --- a/pom.xml +++ b/pom.xml @@ -511,6 +511,11 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt-epsg-hsql</artifactId> + <version>${geoToolsVersion}</version> + </dependency> <!-- logging --> <dependency> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
participants (1)
-
codelutin.com scm