|
From: <de...@us...> - 2013-01-14 08:29:18
|
Revision: 8202
http://fudaa.svn.sourceforge.net/fudaa/?rev=8202&view=rev
Author: deniger
Date: 2013-01-14 08:29:05 +0000 (Mon, 14 Jan 2013)
Log Message:
-----------
Ajout support filtre de points
Added Paths:
-----------
trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/process/
trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/process/GisZoneCollectionPointDoublonRemover.java
trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/process/GisZonePointCollectionPointFiltered.java
Added: trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/process/GisZoneCollectionPointDoublonRemover.java
===================================================================
--- trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/process/GisZoneCollectionPointDoublonRemover.java (rev 0)
+++ trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/process/GisZoneCollectionPointDoublonRemover.java 2013-01-14 08:29:05 UTC (rev 8202)
@@ -0,0 +1,61 @@
+/*
+ GPL 2
+ */
+package org.fudaa.ctulu.gis.process;
+
+import com.vividsolutions.jts.geom.Coordinate;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+import org.fudaa.ctulu.CtuluLib;
+import org.fudaa.ctulu.ProgressionInterface;
+import org.fudaa.ctulu.ProgressionUpdater;
+import org.fudaa.ctulu.gis.comparator.CoordinateComparator;
+import org.fudaa.ctulu.interpolation.SupportLocationI;
+
+/**
+ *
+ * Permet de construire une liste de points en s'assurant qu'il n'y ait pas de doublons dans les points.
+ *
+ * @author Frederic Deniger
+ */
+public class GisZoneCollectionPointDoublonRemover {
+
+ private double eps = 1e-3;
+ private final SupportLocationI in;
+
+ public GisZoneCollectionPointDoublonRemover(SupportLocationI in) {
+ this.in = in;
+ }
+
+ public GisZoneCollectionPointDoublonRemover(SupportLocationI in, double eps) {
+ this.in = in;
+ this.eps = eps;
+ }
+
+ public GisZonePointCollectionPointFiltered createFiltered(ProgressionInterface prog) {
+ ProgressionUpdater updater = new ProgressionUpdater(prog);
+ updater.majProgessionStateOnly(CtuluLib.getS("Indexation des points"));
+ TreeMap<Coordinate, Integer> indexs = new TreeMap<Coordinate, Integer>(new CoordinateComparator(eps));
+ updater.setValue(10, in.getPtsNb());
+ for (int i = 0; i < in.getPtsNb(); i++) {
+ Coordinate c = new Coordinate(in.getPtX(i), in.getPtY(i));
+ Integer index = indexs.get(c);
+ //le point n'existe pas
+ if (index == null) {
+ indexs.put(c, i);
+ }
+ updater.majAvancement();
+ }
+ Coordinate[] coordinate = new Coordinate[indexs.size()];
+ int[] correspondance = new int[coordinate.length];
+ int idx = 0;
+ updater.majProgessionStateOnly(CtuluLib.getS("Construction filtre"));
+ updater.setValue(10, coordinate.length);
+ for (Entry<Coordinate, Integer> entry : indexs.entrySet()) {
+ coordinate[idx] = entry.getKey();
+ correspondance[idx++] = entry.getValue();
+ updater.majAvancement();
+ }
+ return new GisZonePointCollectionPointFiltered(correspondance, in);
+ }
+}
Added: trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/process/GisZonePointCollectionPointFiltered.java
===================================================================
--- trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/process/GisZonePointCollectionPointFiltered.java (rev 0)
+++ trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/process/GisZonePointCollectionPointFiltered.java 2013-01-14 08:29:05 UTC (rev 8202)
@@ -0,0 +1,41 @@
+/*
+ GPL 2
+ */
+package org.fudaa.ctulu.gis.process;
+
+import org.fudaa.ctulu.interpolation.SupportLocationI;
+
+/**
+ * Le r\xE9sultat d'un filtre de points.
+ *
+ * @author Frederic Deniger
+ */
+public class GisZonePointCollectionPointFiltered implements SupportLocationI {
+
+ private int[] correspondance;
+ SupportLocationI init;
+
+ public GisZonePointCollectionPointFiltered(int[] correspondance, SupportLocationI init) {
+ this.correspondance = correspondance;
+ this.init = init;
+ }
+
+ @Override
+ public int getPtsNb() {
+ return correspondance.length;
+ }
+
+ public int getInitialIdx(int _i) {
+ return correspondance[_i];
+ }
+
+ @Override
+ public double getPtX(int _i) {
+ return init.getPtX(correspondance[_i]);
+ }
+
+ @Override
+ public double getPtY(int _i) {
+ return init.getPtY(correspondance[_i]);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|