Revision 964
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/pom.xml | ||
---|---|---|
11 | 11 |
<parent> |
12 | 12 |
<groupId>org.gvsig</groupId> |
13 | 13 |
<artifactId>org.gvsig.desktop</artifactId> |
14 |
<version>2.0.195-SNAPSHOT</version>
|
|
14 |
<version>2.0.195</version> |
|
15 | 15 |
</parent> |
16 | 16 |
|
17 | 17 |
<properties> |
... | ... | |
165 | 165 |
<artifactId>org.japura</artifactId> |
166 | 166 |
<version>1.14.0</version> |
167 | 167 |
</dependency> |
168 |
<dependency> |
|
169 |
<groupId>org.mapdb</groupId> |
|
170 |
<artifactId>mapdb</artifactId> |
|
171 |
<version>3.0.5</version> |
|
172 |
</dependency> |
|
173 |
|
|
174 |
|
|
175 |
<dependency> |
|
176 |
<groupId>org.jetbrains.kotlin</groupId> |
|
177 |
<artifactId>kotlin-stdlib</artifactId> |
|
178 |
<version>1.0.7</version> |
|
179 |
</dependency> |
|
180 |
|
|
181 |
<dependency> |
|
182 |
<groupId>org.jetbrains.kotlin</groupId> |
|
183 |
<artifactId>kotlin-runtime</artifactId> |
|
184 |
<version>1.0.7</version> |
|
185 |
</dependency> |
|
186 |
|
|
187 |
<dependency> |
|
188 |
<groupId>org.eclipse.collections</groupId> |
|
189 |
<artifactId>eclipse-collections-api</artifactId> |
|
190 |
<version>7.1.1</version> |
|
191 |
</dependency> |
|
192 |
|
|
193 |
<dependency> |
|
194 |
<groupId>net.jcip</groupId> |
|
195 |
<artifactId>jcip-annotations</artifactId> |
|
196 |
<version>1.0</version> |
|
197 |
</dependency> |
|
198 |
|
|
199 |
<dependency> |
|
200 |
<groupId>org.eclipse.collections</groupId> |
|
201 |
<artifactId>eclipse-collections</artifactId> |
|
202 |
<version>7.1.1</version> |
|
203 |
</dependency> |
|
204 |
|
|
205 |
<dependency> |
|
206 |
<groupId>org.eclipse.collections</groupId> |
|
207 |
<artifactId>eclipse-collections-forkjoin</artifactId> |
|
208 |
<version>7.1.1</version> |
|
209 |
</dependency> |
|
210 |
|
|
211 |
<dependency> |
|
212 |
<groupId>com.google.guava</groupId> |
|
213 |
<artifactId>guava</artifactId> |
|
214 |
<version>19.0</version> |
|
215 |
</dependency> |
|
216 |
|
|
217 |
<dependency> |
|
218 |
<groupId>net.jpountz.lz4</groupId> |
|
219 |
<artifactId>lz4</artifactId> |
|
220 |
<version>1.3.0</version> |
|
221 |
</dependency> |
|
222 |
|
|
223 |
<dependency> |
|
224 |
<groupId>org.mapdb</groupId> |
|
225 |
<artifactId>elsa</artifactId> |
|
226 |
<version>3.0.0-M5</version> |
|
227 |
</dependency> |
|
228 |
|
|
168 | 229 |
</dependencies> |
169 | 230 |
</dependencyManagement> |
170 | 231 |
|
... | ... | |
190 | 251 |
</configuration> |
191 | 252 |
</plugin> |
192 | 253 |
|
193 |
<plugin> |
|
254 |
<!-- <plugin>
|
|
194 | 255 |
<groupId>org.codehaus.mojo</groupId> |
195 | 256 |
<artifactId>animal-sniffer-maven-plugin</artifactId> |
196 | 257 |
<executions> |
... | ... | |
210 | 271 |
</configuration> |
211 | 272 |
</execution> |
212 | 273 |
</executions> |
213 |
</plugin> |
|
274 |
</plugin> -->
|
|
214 | 275 |
|
215 | 276 |
</plugins> |
216 | 277 |
</build> |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.app/org.gvsig.geoprocess.app.algorithm/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
47 | 47 |
<include>org.gvsig:org.gvsig.geoprocess.algorithm.lateralbuffer</include> |
48 | 48 |
<include>org.gvsig:org.gvsig.geoprocess.algorithm.splitlines</include> |
49 | 49 |
<include>org.gvsig:org.gvsig.geoprocess.algorithm.dispersepoints</include> |
50 |
<include>org.mapdb:mapdb</include> |
|
51 |
|
|
52 |
<include>org.mapdb:mapdb</include> |
|
53 |
<include>org.jetbrains.kotlin:kotlin-stdlib</include> |
|
54 |
<include>org.jetbrains.kotlin:kotlin-runtime</include> |
|
55 |
<include>org.eclipse.collections:eclipse-collections-api</include> |
|
56 |
<include>net.jcip:jcip-annotations</include> |
|
57 |
<include>org.eclipse.collections:eclipse-collections</include> |
|
58 |
<include>org.eclipse.collections:eclipse-collections-forkjoin</include> |
|
59 |
<include>com.google.guava:guava</include> |
|
60 |
<include>net.jpountz.lz4:lz4</include> |
|
61 |
<include>org.mapdb:elsa</include> |
|
62 |
|
|
50 | 63 |
</includes> |
51 | 64 |
</dependencySet> |
52 | 65 |
</dependencySets> |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.app/org.gvsig.geoprocess.app.algorithm/pom.xml | ||
---|---|---|
128 | 128 |
<artifactId>org.gvsig.fmap.mapcontext.operation</artifactId> |
129 | 129 |
<scope>runtime</scope> |
130 | 130 |
</dependency> |
131 |
<dependency> |
|
132 |
<groupId>org.mapdb</groupId> |
|
133 |
<artifactId>mapdb</artifactId> |
|
134 |
<scope>runtime</scope> |
|
135 |
</dependency> |
|
136 |
|
|
137 |
<dependency> |
|
138 |
<groupId>org.jetbrains.kotlin</groupId> |
|
139 |
<artifactId>kotlin-stdlib</artifactId> |
|
140 |
<scope>runtime</scope> |
|
141 |
</dependency> |
|
142 |
|
|
143 |
<dependency> |
|
144 |
<groupId>org.jetbrains.kotlin</groupId> |
|
145 |
<artifactId>kotlin-runtime</artifactId> |
|
146 |
<scope>runtime</scope> |
|
147 |
</dependency> |
|
148 |
|
|
149 |
<dependency> |
|
150 |
<groupId>org.eclipse.collections</groupId> |
|
151 |
<artifactId>eclipse-collections-api</artifactId> |
|
152 |
<scope>runtime</scope> |
|
153 |
</dependency> |
|
154 |
|
|
155 |
<dependency> |
|
156 |
<groupId>net.jcip</groupId> |
|
157 |
<artifactId>jcip-annotations</artifactId> |
|
158 |
<scope>runtime</scope> |
|
159 |
</dependency> |
|
160 |
|
|
161 |
<dependency> |
|
162 |
<groupId>org.eclipse.collections</groupId> |
|
163 |
<artifactId>eclipse-collections</artifactId> |
|
164 |
<scope>runtime</scope> |
|
165 |
</dependency> |
|
166 |
|
|
167 |
<dependency> |
|
168 |
<groupId>org.eclipse.collections</groupId> |
|
169 |
<artifactId>eclipse-collections-forkjoin</artifactId> |
|
170 |
<scope>runtime</scope> |
|
171 |
</dependency> |
|
172 |
|
|
173 |
<dependency> |
|
174 |
<groupId>com.google.guava</groupId> |
|
175 |
<artifactId>guava</artifactId> |
|
176 |
<scope>runtime</scope> |
|
177 |
</dependency> |
|
178 |
|
|
179 |
<dependency> |
|
180 |
<groupId>net.jpountz.lz4</groupId> |
|
181 |
<artifactId>lz4</artifactId> |
|
182 |
<scope>runtime</scope> |
|
183 |
</dependency> |
|
184 |
|
|
185 |
<dependency> |
|
186 |
<groupId>org.mapdb</groupId> |
|
187 |
<artifactId>elsa</artifactId> |
|
188 |
<scope>runtime</scope> |
|
189 |
</dependency> |
|
131 | 190 |
</dependencies> |
132 | 191 |
|
133 | 192 |
<properties> |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/resources/org/gvsig/geoprocess/algorithm/dispersepoints/dispersepoints_en.properties | ||
---|---|---|
23 | 23 |
# |
24 | 24 |
|
25 | 25 |
basic_vect_algorithms=Vector layers tools |
26 |
Input_layer=Input cover
|
|
26 |
input_layer=Input cover
|
|
27 | 27 |
_disperse_points=Disperse points |
28 | 28 |
_scatter_radius=Scatter radius |
29 | 29 |
_match_distance=Match distance |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/resources/help/DispersePointsAlgorithm.xml | ||
---|---|---|
27 | 27 |
--> |
28 | 28 |
<help> |
29 | 29 |
<element name="DESCRIPTION" text="Este geoproceso, permite dispersar los puntos de una capa que se superponen alrededor de un punto central. Dada una capa de puntos, una distancia de concordancia y un radio de dispersi?n, este algoritmo se recorre la capa de origen buscando grupos de puntos cuya distancia sea menor o igual a la distancia de concordancia y los dispersa, seg?n el radio de dispersi?n, alrededor del centro de dicho grupo, generando una nueva capa de puntos con el resultado." description="Descripción" type="0"> |
30 |
<!-- <image description="" file="spatialjoindesc.png">
|
|
31 |
</image> -->
|
|
30 |
<image description="" file="dispersepoints.png">
|
|
31 |
</image> |
|
32 | 32 |
</element> |
33 | 33 |
<element name="ADDITIONAL_INFO" text="" description="Información adicional" type="0"> |
34 | 34 |
</element> |
35 | 35 |
<element name="EXTENSION_AUTHOR" text="Francisco D?az" description="Algoritmo creado por" type="0"> |
36 | 36 |
</element> |
37 |
<element name="HELP_AUTHOR" text="" description="Ayuda creada por" type="0"> |
|
37 |
<element name="HELP_AUTHOR" text="Francisco D?az" description="Ayuda creada por" type="0">
|
|
38 | 38 |
</element> |
39 | 39 |
<element name="USER_NOTES" text="" description="Notas de usuario" type="0"> |
40 | 40 |
</element> |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/resources/help/DispersePointsAlgorithm_en.xml | ||
---|---|---|
27 | 27 |
--> |
28 | 28 |
<help> |
29 | 29 |
<element name="DESCRIPTION" text="This geoprocess allows to scatter around a central point the points of a layer that are overlapped. From a point layer, a match distance and a scatter radius, this algorithm acts on the input layer looking for groups of points whose distance is less than or equal to the match distance. It scatters them, according to the scatter radius, around the centre of that group, creating a new point layer with the results." description="Description" type="0"> |
30 |
<!-- <image description="" file="spatialjoindesc.png">
|
|
31 |
</image> -->
|
|
30 |
<image description="" file="dispersepoints.png">
|
|
31 |
</image>
|
|
32 | 32 |
</element> |
33 | 33 |
<element name="ADDITIONAL_INFO" text="" description="Additional information" type="0"> |
34 | 34 |
</element> |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/java/org/gvsig/geoprocess/algorithm/dispersepoints/DispersePointsOperation.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.geoprocess.algorithm.dispersepoints; |
24 | 24 |
|
25 |
import java.io.File; |
|
25 | 26 |
import java.util.ArrayList; |
26 | 27 |
import java.util.Collection; |
27 | 28 |
import java.util.HashSet; |
28 | 29 |
import java.util.Iterator; |
29 | 30 |
import java.util.List; |
30 | 31 |
import java.util.ListIterator; |
32 |
import java.util.NavigableSet; |
|
31 | 33 |
import java.util.Set; |
32 | 34 |
|
35 |
import org.mapdb.DB; |
|
36 |
import org.mapdb.DBMaker; |
|
37 |
|
|
33 | 38 |
import es.unex.sextante.core.Sextante; |
34 | 39 |
|
35 | 40 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
45 | 50 |
import org.gvsig.fmap.geom.primitive.Point; |
46 | 51 |
import org.gvsig.geoprocess.algorithm.base.core.GeometryOperation; |
47 | 52 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
53 |
import org.gvsig.tools.ToolsLocator; |
|
54 |
import org.gvsig.tools.folders.FoldersManager; |
|
48 | 55 |
|
49 | 56 |
/** |
50 | 57 |
* Disperse points operation |
... | ... | |
56 | 63 |
private SpatialIndex index; |
57 | 64 |
private double scatterRadius; |
58 | 65 |
private double matchDistance; |
59 |
private List<Set<FeatureReference>> groups;
|
|
66 |
NavigableSet<Integer> processed;
|
|
60 | 67 |
|
61 | 68 |
/** |
62 | 69 |
* Builds an instance of this operation. |
... | ... | |
73 | 80 |
this.index = index; |
74 | 81 |
this.scatterRadius = scatterRadius; |
75 | 82 |
this.matchDistance = matchDistance; |
76 |
this.groups = new ArrayList<Set<FeatureReference>>(); |
|
77 | 83 |
|
84 |
FoldersManager folderManager = ToolsLocator.getFoldersManager(); |
|
85 |
File dbfile = folderManager.getUniqueTemporaryFile("dispersepoints.mapdb"); |
|
86 |
|
|
87 |
// Creariamos la BBDD |
|
88 |
DB db = DBMaker.fileDB(dbfile).fileMmapEnable().make(); |
|
89 |
// Y dentro de ella una tabla "processed" para nuestro set. |
|
90 |
processed = (NavigableSet<Integer>) db.treeSet("processed").create(); |
|
91 |
|
|
78 | 92 |
} |
79 | 93 |
|
80 | 94 |
public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g, Feature feature) { |
81 |
// final MutableObject<Feature> foundFeature = new |
|
82 |
// MutableObject<Feature>(null); |
|
83 | 95 |
boolean addedFeature = false; |
84 | 96 |
if (g == null) |
85 | 97 |
return lastEditFeature; |
... | ... | |
87 | 99 |
try { |
88 | 100 |
|
89 | 101 |
FeatureReference reference = feature.getReference(); |
90 |
if (!isVisited(reference)) { |
|
91 |
Set<FeatureReference> group = new HashSet<FeatureReference>(); |
|
92 |
// Iterator<?> iterator = index.queryNearest(g); |
|
102 |
if (!processed.contains(reference.hashCode())) { |
|
103 |
final List<FeatureReference> group = new ArrayList<FeatureReference>(); |
|
93 | 104 |
Iterator<?> iterator = index.query(g.buffer(matchDistance)); |
94 | 105 |
while (iterator.hasNext()) { |
95 | 106 |
FeatureReference ref = (FeatureReference) iterator.next(); |
96 |
if (!isVisited(ref)) {
|
|
107 |
if (!processed.contains(ref.hashCode())) {
|
|
97 | 108 |
Feature feat = ref.getFeature().getCopy(); |
98 | 109 |
Geometry g2 = feat.getDefaultGeometry(); |
99 | 110 |
double dist = g.distance(g2); |
100 | 111 |
if (dist <= matchDistance) { |
101 | 112 |
group.add(ref); |
113 |
processed.add(ref.hashCode()); |
|
102 | 114 |
} |
103 | 115 |
} |
104 | 116 |
} |
105 |
groups.add(group); |
|
106 | 117 |
if (group.size() == 1) { |
107 | 118 |
buildFeature(feature, g); |
108 | 119 |
} else { |
109 |
buildFeatures(group); |
|
120 |
buildFeatures(group, (Point) g);
|
|
110 | 121 |
} |
111 | 122 |
} |
112 | 123 |
|
... | ... | |
122 | 133 |
* @throws DataException |
123 | 134 |
* @throws CreateGeometryException |
124 | 135 |
*/ |
125 |
private void buildFeatures(Set<FeatureReference> group) throws CreateGeometryException, DataException {
|
|
136 |
private void buildFeatures(List<FeatureReference> group, Point center) throws CreateGeometryException, DataException {
|
|
126 | 137 |
if (group.isEmpty()) { |
127 | 138 |
return; |
128 | 139 |
} |
... | ... | |
130 | 141 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
131 | 142 |
|
132 | 143 |
int points = group.size(); |
133 |
Point center = getCenter(group); |
|
134 | 144 |
|
135 | 145 |
double step = 2 * Math.PI / points; |
136 | 146 |
int i = 0; |
... | ... | |
147 | 157 |
} |
148 | 158 |
} |
149 | 159 |
|
150 |
/** |
|
151 |
* @param group |
|
152 |
* @return |
|
153 |
* @throws DataException |
|
154 |
* @throws CreateGeometryException |
|
155 |
*/ |
|
156 |
private Point getCenter(Set<FeatureReference> group) throws DataException, CreateGeometryException { |
|
157 |
double x = 0; |
|
158 |
double y = 0; |
|
159 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
160 |
for (FeatureReference ref : group) { |
|
161 |
Point point = (Point) ref.getFeature().getDefaultGeometry(); |
|
162 |
x += point.getX(); |
|
163 |
y += point.getY(); |
|
164 |
} |
|
165 |
int size = group.size(); |
|
166 |
return geomManager.createPoint(x / size, y / size, SUBTYPES.GEOM2D); |
|
167 |
} |
|
168 |
|
|
169 | 160 |
/* |
170 | 161 |
* (non-Javadoc) |
171 | 162 |
* |
... | ... | |
198 | 189 |
Sextante.addErrorToLog(e); |
199 | 190 |
} |
200 | 191 |
} |
201 |
|
|
202 |
private boolean isVisited(FeatureReference ref) { |
|
203 |
for (Set<FeatureReference> group : groups) { |
|
204 |
if (group.contains(ref)) { |
|
205 |
return true; |
|
206 |
} |
|
207 |
} |
|
208 |
return false; |
|
209 |
} |
|
210 | 192 |
} |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/pom.xml | ||
---|---|---|
59 | 59 |
<artifactId>org.gvsig.fmap.dal.spi</artifactId> |
60 | 60 |
<scope>compile</scope> |
61 | 61 |
</dependency> |
62 |
<dependency> |
|
63 |
<groupId>org.mapdb</groupId> |
|
64 |
<artifactId>mapdb</artifactId> |
|
65 |
<scope>compile</scope> |
|
66 |
</dependency> |
|
62 | 67 |
</dependencies> |
63 | 68 |
</project> |
Also available in: Unified diff