Revision 1188
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.gpe.exportto</artifactId> |
|
5 |
<packaging>pom</packaging> |
|
6 |
|
|
7 |
|
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.gpe</artifactId> |
|
11 |
<version>2.1.115</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
|
|
15 |
<modules> |
|
16 |
<module>org.gvsig.gpe.exportto.kml</module> |
|
17 |
<module>org.gvsig.gpe.exportto.generic</module> |
|
18 |
</modules> |
|
19 |
</project> |
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/org.gvsig.gpe.exportto.generic/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.gpe.exportto.generic.ExporttoGPEGenericLibrary |
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/org.gvsig.gpe.exportto.generic/src/main/java/org/gvsig/gpe/exportto/generic/util/GeometryToGPEWriter.java | ||
---|---|---|
1 |
package org.gvsig.gpe.exportto.generic.util; |
|
2 |
|
|
3 |
import java.awt.geom.PathIterator; |
|
4 |
|
|
5 |
import org.slf4j.Logger; |
|
6 |
import org.slf4j.LoggerFactory; |
|
7 |
|
|
8 |
import org.gvsig.fmap.geom.Geometry; |
|
9 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
10 |
import org.gvsig.fmap.geom.aggregate.MultiCurve; |
|
11 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
|
12 |
import org.gvsig.fmap.geom.aggregate.MultiSurface; |
|
13 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
14 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
15 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
16 |
import org.gvsig.fmap.geom.primitive.Point; |
|
17 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
18 |
import org.gvsig.gpe.lib.api.writer.IGPEWriterHandler; |
|
19 |
import org.gvsig.tools.locator.LocatorException; |
|
20 |
|
|
21 |
|
|
22 |
/** |
|
23 |
* |
|
24 |
* Utility class to write gvSIG geometries in a GPE writer. |
|
25 |
* |
|
26 |
* @author jldominguez (I have removed the reprojection methods/fields) |
|
27 |
*/ |
|
28 |
public class GeometryToGPEWriter { |
|
29 |
|
|
30 |
private static Logger logger = LoggerFactory.getLogger(GeometryToGPEWriter.class); |
|
31 |
|
|
32 |
private IGPEWriterHandler writer = null; |
|
33 |
//To know if the geometry is multiple |
|
34 |
// private boolean isMultiple = false; |
|
35 |
//To reproject geometries |
|
36 |
/* |
|
37 |
private IProjection projOrig = null; |
|
38 |
private IProjection projDest = null; |
|
39 |
private ICoordTrans coordTrans = null; |
|
40 |
*/ |
|
41 |
private String srs = null; |
|
42 |
|
|
43 |
public GeometryToGPEWriter(IGPEWriterHandler writer) { |
|
44 |
this.writer = writer; |
|
45 |
} |
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
public String getCrs() { |
|
50 |
return srs; |
|
51 |
} |
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
public void setCrs(String thesrs) { |
|
56 |
this.srs = thesrs; |
|
57 |
} |
|
58 |
|
|
59 |
|
|
60 |
/** |
|
61 |
* It writes a geometry |
|
62 |
* @param geom |
|
63 |
* The geometry to write |
|
64 |
* @param crs |
|
65 |
* The coordinates reference system |
|
66 |
*/ |
|
67 |
public void writeGeometry(Geometry geom, boolean addLabelPoint) { |
|
68 |
|
|
69 |
if (geom == null) { |
|
70 |
logger.error("GPE Writer cannot write geometry.", |
|
71 |
new Exception("Geometry is NULL")); |
|
72 |
return; |
|
73 |
} |
|
74 |
// ==================================================== |
|
75 |
if (geom instanceof MultiPoint) { |
|
76 |
writeMultiPoint((MultiPoint) geom); |
|
77 |
return; |
|
78 |
} |
|
79 |
if (geom instanceof MultiCurve) { |
|
80 |
writeMultiLine((MultiCurve) geom, addLabelPoint); |
|
81 |
return; |
|
82 |
} |
|
83 |
if (geom instanceof MultiSurface) { |
|
84 |
writeMultiPolygon((MultiSurface) geom, addLabelPoint); |
|
85 |
return; |
|
86 |
} |
|
87 |
// ==================================================== |
|
88 |
if (geom instanceof Point) { |
|
89 |
writePoint((Point) geom); |
|
90 |
return; |
|
91 |
} |
|
92 |
if (geom instanceof Curve) { |
|
93 |
writeLine((Curve) geom, addLabelPoint); |
|
94 |
return; |
|
95 |
} |
|
96 |
if (geom instanceof Surface) { |
|
97 |
writePolygon((Surface) geom, addLabelPoint); |
|
98 |
return; |
|
99 |
} |
|
100 |
// ==================================================== |
|
101 |
logger.error("GPE Writer cannot write geometry", |
|
102 |
new Exception("Unexpected geometry: " + geom.getClass().getName())); |
|
103 |
} |
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
/** |
|
109 |
* Writes a point in 2D |
|
110 |
* @param point |
|
111 |
* The point to write |
|
112 |
* @param crs |
|
113 |
* The coordinates reference system |
|
114 |
*/ |
|
115 |
private void writePoint(Point point) { |
|
116 |
writer.startPoint(null, new CoordinatesSequencePoint(point), srs); |
|
117 |
writer.endPoint(); |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* Writes a multipoint in 2D |
|
122 |
* @param point |
|
123 |
* The point to write |
|
124 |
* @param crs |
|
125 |
* The coordinates reference system |
|
126 |
*/ |
|
127 |
private void writeMultiPoint(MultiPoint multi){ |
|
128 |
writer.startMultiPoint(null, srs); |
|
129 |
for (int i=0 ; i<multi.getPrimitivesNumber() ; i++) { |
|
130 |
Point p = multi.getPointAt(i); |
|
131 |
writePoint(p); |
|
132 |
} |
|
133 |
writer.endMultiPoint(); |
|
134 |
} |
|
135 |
|
|
136 |
/** |
|
137 |
* Writes a line in 2D |
|
138 |
* @param line |
|
139 |
* The line to write |
|
140 |
* @param crs |
|
141 |
* The coordinates reference system |
|
142 |
* @param geometries |
|
143 |
* The parsed geometries |
|
144 |
*/ |
|
145 |
private void writeLine(Curve curve, boolean addLabelPoint) { |
|
146 |
|
|
147 |
boolean ismulti = isMultiple(curve.getPathIterator(null)); |
|
148 |
/* |
|
149 |
* Start =================================================== |
|
150 |
*/ |
|
151 |
if (addLabelPoint) { |
|
152 |
Point po = null; |
|
153 |
try { |
|
154 |
po = getLabelPoint(curve.getPathIterator(null), curve.getEnvelope()); |
|
155 |
} catch (Exception ex) { |
|
156 |
logger.info("While getting label point.", ex); |
|
157 |
return; |
|
158 |
} |
|
159 |
writer.startMultiGeometry(null, srs); |
|
160 |
CoordinatesSequencePoint pseq = new CoordinatesSequencePoint(po); |
|
161 |
writer.startPoint(null, pseq, srs); |
|
162 |
writer.endPoint(); |
|
163 |
} else { |
|
164 |
if (ismulti) { |
|
165 |
writer.startMultiLineString(null, srs); |
|
166 |
} |
|
167 |
} |
|
168 |
/* |
|
169 |
* Body =================================================== |
|
170 |
*/ |
|
171 |
CoordinatesSequenceGeneralPath sequence = |
|
172 |
new CoordinatesSequenceGeneralPath(curve.getPathIterator(null)); |
|
173 |
writer.startLineString(null, sequence, srs); |
|
174 |
writer.endLineString(); |
|
175 |
if (ismulti) { |
|
176 |
while (sequence.hasMoreGeometries()){ |
|
177 |
sequence.initialize(); |
|
178 |
writer.startLineString(null, sequence, srs); |
|
179 |
writer.endLineString(); |
|
180 |
} |
|
181 |
} |
|
182 |
/* |
|
183 |
* End =================================================== |
|
184 |
*/ |
|
185 |
if (addLabelPoint) { |
|
186 |
writer.endMultiGeometry(); |
|
187 |
} else { |
|
188 |
if (ismulti) { |
|
189 |
writer.endMultiLineString(); |
|
190 |
} |
|
191 |
} |
|
192 |
} |
|
193 |
|
|
194 |
|
|
195 |
private void writeMultiLine(MultiCurve mcurve, boolean addLabelPoint) { |
|
196 |
|
|
197 |
if (addLabelPoint) { |
|
198 |
Point po = null; |
|
199 |
try { |
|
200 |
po = getLabelPoint(mcurve.getPathIterator(null), mcurve.getEnvelope()); |
|
201 |
} catch (Exception exc) { |
|
202 |
logger.info("While getting label point.", exc); |
|
203 |
return; |
|
204 |
} |
|
205 |
writer.startMultiGeometry(null, srs); |
|
206 |
CoordinatesSequencePoint pseq = new CoordinatesSequencePoint(po); |
|
207 |
writer.startPoint(null, pseq, srs); |
|
208 |
writer.endPoint(); |
|
209 |
} else { |
|
210 |
writer.startMultiLineString(null, srs); |
|
211 |
} |
|
212 |
/* |
|
213 |
* Body ======================================= |
|
214 |
*/ |
|
215 |
CoordinatesSequenceGeneralPath sequence = |
|
216 |
new CoordinatesSequenceGeneralPath(mcurve.getPathIterator(null)); |
|
217 |
|
|
218 |
writer.startLineString(null, sequence, srs); |
|
219 |
writer.endLineString(); |
|
220 |
while (sequence.hasMoreGeometries()){ |
|
221 |
sequence.initialize(); |
|
222 |
writer.startLineString(null, sequence, srs); |
|
223 |
writer.endLineString(); |
|
224 |
} |
|
225 |
/* |
|
226 |
* End ====================================== |
|
227 |
*/ |
|
228 |
if (addLabelPoint) { |
|
229 |
writer.endMultiGeometry(); |
|
230 |
} else { |
|
231 |
writer.endMultiLineString(); |
|
232 |
} |
|
233 |
|
|
234 |
} |
|
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
|
239 |
/** |
|
240 |
* Writes a polygon in 2D |
|
241 |
* @param polygon |
|
242 |
* The polygon to write |
|
243 |
* @param crs |
|
244 |
* The coordinates reference system |
|
245 |
* @param geometries |
|
246 |
* The parsed geometries |
|
247 |
*/ |
|
248 |
private void writePolygon(Surface surface, boolean addLabelPoint) { |
|
249 |
|
|
250 |
boolean ismulti = isMultiple(surface.getPathIterator(null)); |
|
251 |
CoordinatesSequenceGeneralPath sequence = null; |
|
252 |
/* |
|
253 |
* Start =================================================== |
|
254 |
*/ |
|
255 |
if (addLabelPoint) { |
|
256 |
Point po = null; |
|
257 |
try { |
|
258 |
po = surface.getInteriorPoint(); |
|
259 |
} catch (Exception ex) { |
|
260 |
logger.info("While getting label point.", ex); |
|
261 |
return; |
|
262 |
} |
|
263 |
writer.startMultiGeometry(null, srs); |
|
264 |
CoordinatesSequencePoint pseq = new CoordinatesSequencePoint(po); |
|
265 |
writer.startPoint(null, pseq, srs); |
|
266 |
writer.endPoint(); |
|
267 |
} else { |
|
268 |
if (ismulti) { |
|
269 |
writer.startMultiPolygon(null, srs); |
|
270 |
} |
|
271 |
} |
|
272 |
/* |
|
273 |
* Body =================================================== |
|
274 |
*/ |
|
275 |
sequence = new CoordinatesSequenceGeneralPath(surface.getPathIterator(null)); |
|
276 |
writer.startPolygon(null, sequence, srs); |
|
277 |
writer.endPolygon(); |
|
278 |
if (ismulti) { |
|
279 |
while (sequence.hasMoreGeometries()){ |
|
280 |
sequence.initialize(); |
|
281 |
writer.startPolygon(null, sequence, srs); |
|
282 |
writer.endPolygon(); |
|
283 |
} |
|
284 |
} |
|
285 |
/* |
|
286 |
* End =================================================== |
|
287 |
*/ |
|
288 |
if (addLabelPoint) { |
|
289 |
writer.endMultiGeometry(); |
|
290 |
} else { |
|
291 |
if (ismulti) { |
|
292 |
writer.endMultiPolygon(); |
|
293 |
} |
|
294 |
} |
|
295 |
} |
|
296 |
|
|
297 |
|
|
298 |
private Point getLabelPoint(PathIterator pathIterator, Envelope envelope) throws |
|
299 |
Exception { |
|
300 |
|
|
301 |
if (pathIterator == null || envelope == null) { |
|
302 |
throw new Exception("Null iterator or envelope"); |
|
303 |
} |
|
304 |
|
|
305 |
double bestx = 0; |
|
306 |
double besty = 0; |
|
307 |
double cx = envelope.getCenter(0); |
|
308 |
double cy = envelope.getCenter(1); |
|
309 |
double dist = Double.MAX_VALUE; |
|
310 |
double auxdist = 0; |
|
311 |
|
|
312 |
double[] coords = new double[6]; |
|
313 |
while (!pathIterator.isDone()) { |
|
314 |
pathIterator.currentSegment(coords); |
|
315 |
auxdist = getDist2(cx, cy, coords[0], coords[1]); |
|
316 |
if (auxdist < dist) { |
|
317 |
dist = auxdist; |
|
318 |
bestx = coords[0]; |
|
319 |
besty = coords[1]; |
|
320 |
} |
|
321 |
pathIterator.next(); |
|
322 |
} |
|
323 |
Point resp = GeometryLocator.getGeometryManager().createPoint( |
|
324 |
bestx, besty, Geometry.SUBTYPES.GEOM2D); |
|
325 |
return resp; |
|
326 |
} |
|
327 |
|
|
328 |
|
|
329 |
private Point getLabelPoint(MultiSurface msurf) throws Exception { |
|
330 |
|
|
331 |
if (msurf == null) { |
|
332 |
throw new Exception("Surface is Null"); |
|
333 |
} |
|
334 |
|
|
335 |
int n = msurf.getPrimitivesNumber(); |
|
336 |
Surface surf = null; |
|
337 |
Surface bigsurf = null; |
|
338 |
double importance = 0; |
|
339 |
double auximportance = 0; |
|
340 |
Envelope env = null; |
|
341 |
long nverts = 0; |
|
342 |
for (int i=0; i<n; i++) { |
|
343 |
surf = (Surface) msurf.getPrimitiveAt(i); |
|
344 |
nverts = surf.getNumVertices(); |
|
345 |
env = surf.getEnvelope(); |
|
346 |
auximportance = nverts * env.getLength(0) * env.getLength(1); |
|
347 |
if (auximportance >= importance) { |
|
348 |
importance = auximportance; |
|
349 |
bigsurf = surf; |
|
350 |
} |
|
351 |
} |
|
352 |
if (bigsurf != null) { |
|
353 |
return bigsurf.getInteriorPoint(); |
|
354 |
} else { |
|
355 |
return msurf.getInteriorPoint(); |
|
356 |
} |
|
357 |
} |
|
358 |
|
|
359 |
/** |
|
360 |
* Returns (dist ^ 2) between points a and b |
|
361 |
* @param ax |
|
362 |
* @param ay |
|
363 |
* @param bx |
|
364 |
* @param by |
|
365 |
* @return |
|
366 |
*/ |
|
367 |
private double getDist2( |
|
368 |
double ax, double ay, |
|
369 |
double bx, double by) { |
|
370 |
|
|
371 |
double dx = bx - ax; |
|
372 |
double dy = by - ay; |
|
373 |
return (dx * dx) + (dy * dy); |
|
374 |
} |
|
375 |
|
|
376 |
|
|
377 |
|
|
378 |
private void writeMultiPolygon(MultiSurface msurface, boolean addLabelPoint) { |
|
379 |
|
|
380 |
if (addLabelPoint) { |
|
381 |
Point po = null; |
|
382 |
try { |
|
383 |
po = getLabelPoint(msurface); |
|
384 |
} catch (Exception ex) { |
|
385 |
logger.info("While getting label point.", ex); |
|
386 |
return; |
|
387 |
} |
|
388 |
|
|
389 |
writer.startMultiGeometry(null, srs); |
|
390 |
CoordinatesSequencePoint pseq = new CoordinatesSequencePoint(po); |
|
391 |
writer.startPoint(null, pseq, srs); |
|
392 |
writer.endPoint(); |
|
393 |
} else { |
|
394 |
writer.startMultiPolygon(null, srs); |
|
395 |
} |
|
396 |
/* |
|
397 |
* Body ============================================== |
|
398 |
*/ |
|
399 |
CoordinatesSequenceGeneralPath sequence = |
|
400 |
new CoordinatesSequenceGeneralPath(msurface.getPathIterator(null)); |
|
401 |
writer.startPolygon(null, sequence, srs); |
|
402 |
writer.endPolygon(); |
|
403 |
while (sequence.hasMoreGeometries()){ |
|
404 |
sequence.initialize(); |
|
405 |
writer.startPolygon(null, sequence, srs); |
|
406 |
writer.endPolygon(); |
|
407 |
} |
|
408 |
/* |
|
409 |
* End ============================================== |
|
410 |
*/ |
|
411 |
if (addLabelPoint) { |
|
412 |
writer.endMultiGeometry(); |
|
413 |
} else { |
|
414 |
writer.endMultiPolygon(); |
|
415 |
} |
|
416 |
|
|
417 |
} |
|
418 |
|
|
419 |
/** |
|
420 |
* Return if the geometry is multiple |
|
421 |
* @param path |
|
422 |
* @return |
|
423 |
*/ |
|
424 |
public boolean isMultiple(PathIterator path){ |
|
425 |
double[] coords = new double[2]; |
|
426 |
int type = 0; |
|
427 |
int numGeometries = 0; |
|
428 |
while (!path.isDone()){ |
|
429 |
type = path.currentSegment(coords); |
|
430 |
switch (type) { |
|
431 |
case PathIterator.SEG_MOVETO: |
|
432 |
numGeometries++; |
|
433 |
if (numGeometries == 2){ |
|
434 |
return true; |
|
435 |
} |
|
436 |
break; |
|
437 |
default: |
|
438 |
break; |
|
439 |
} |
|
440 |
path.next(); |
|
441 |
} |
|
442 |
return false; |
|
443 |
} |
|
444 |
|
|
445 |
|
|
446 |
|
|
447 |
|
|
448 |
|
|
449 |
|
|
450 |
|
|
451 |
|
|
452 |
|
|
453 |
|
|
454 |
|
|
455 |
|
|
456 |
|
|
457 |
|
|
458 |
|
|
459 |
} |
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/org.gvsig.gpe.exportto.generic/src/main/java/org/gvsig/gpe/exportto/generic/util/CoordinatesSequencePoint.java | ||
---|---|---|
1 |
package org.gvsig.gpe.exportto.generic.util; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import org.gvsig.fmap.geom.primitive.Point; |
|
6 |
import org.gvsig.gpe.lib.api.parser.ICoordinateIterator; |
|
7 |
import org.gvsig.gpe.lib.api.writer.ICoordinateSequence; |
|
8 |
|
|
9 |
public class CoordinatesSequencePoint implements |
|
10 |
ICoordinateSequence, ICoordinateIterator { |
|
11 |
|
|
12 |
double[] points = null; |
|
13 |
int index = 0; |
|
14 |
|
|
15 |
|
|
16 |
public CoordinatesSequencePoint(Point point) { |
|
17 |
|
|
18 |
if (point.getDimension() == 3) { |
|
19 |
// 2dZ |
|
20 |
this.points = new double[3]; |
|
21 |
points[0] = point.getX(); |
|
22 |
points[1] = point.getY(); |
|
23 |
points[2] = point.getCoordinateAt(2); |
|
24 |
index = 3; |
|
25 |
} else { |
|
26 |
// 2d |
|
27 |
this.points = new double[2]; |
|
28 |
points[0] = point.getX(); |
|
29 |
points[1] = point.getY(); |
|
30 |
index = 2; |
|
31 |
} |
|
32 |
|
|
33 |
} |
|
34 |
|
|
35 |
public int getSize() { |
|
36 |
return 1; |
|
37 |
} |
|
38 |
|
|
39 |
public ICoordinateIterator iterator() { |
|
40 |
return this; |
|
41 |
} |
|
42 |
|
|
43 |
public int getDimension() { |
|
44 |
return points.length; |
|
45 |
} |
|
46 |
|
|
47 |
public boolean hasNext() throws IOException { |
|
48 |
return (index > 0); |
|
49 |
} |
|
50 |
|
|
51 |
public void next(double[] buffer) throws IOException { |
|
52 |
buffer[0] = points[0]; |
|
53 |
buffer[1] = points[1]; |
|
54 |
if ((buffer.length == 3) && (points.length == 3)){ |
|
55 |
buffer[2] = points[2]; |
|
56 |
} |
|
57 |
index--; |
|
58 |
} |
|
59 |
|
|
60 |
|
|
61 |
} |
|
62 |
|
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/org.gvsig.gpe.exportto.generic/src/main/java/org/gvsig/gpe/exportto/generic/util/CoordinatesSequenceBbox.java | ||
---|---|---|
1 |
package org.gvsig.gpe.exportto.generic.util; |
|
2 |
|
|
3 |
import java.awt.geom.Rectangle2D; |
|
4 |
import java.io.IOException; |
|
5 |
|
|
6 |
import org.gvsig.gpe.lib.api.parser.ICoordinateIterator; |
|
7 |
import org.gvsig.gpe.lib.api.writer.ICoordinateSequence; |
|
8 |
|
|
9 |
public class CoordinatesSequenceBbox implements |
|
10 |
ICoordinateSequence, ICoordinateIterator { |
|
11 |
|
|
12 |
Rectangle2D bbox = null; |
|
13 |
int index = 0; |
|
14 |
|
|
15 |
public CoordinatesSequenceBbox(Rectangle2D bbox){ |
|
16 |
this.bbox = bbox; |
|
17 |
} |
|
18 |
|
|
19 |
public int getSize() { |
|
20 |
return 2; |
|
21 |
} |
|
22 |
|
|
23 |
public ICoordinateIterator iterator() { |
|
24 |
return this; |
|
25 |
} |
|
26 |
|
|
27 |
public int getDimension() { |
|
28 |
return 2; |
|
29 |
} |
|
30 |
|
|
31 |
public boolean hasNext() throws IOException { |
|
32 |
if (index <=1){ |
|
33 |
return true; |
|
34 |
} |
|
35 |
return false; |
|
36 |
} |
|
37 |
|
|
38 |
public void next(double[] buffer) throws IOException { |
|
39 |
if (index == 0){ |
|
40 |
buffer[0] = bbox.getMinX(); |
|
41 |
buffer[1] = bbox.getMinY(); |
|
42 |
}else if (index == 1){ |
|
43 |
buffer[0] = bbox.getMaxX(); |
|
44 |
buffer[1] = bbox.getMaxY(); |
|
45 |
} |
|
46 |
index++; |
|
47 |
} |
|
48 |
|
|
49 |
} |
|
50 |
|
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/org.gvsig.gpe.exportto.generic/src/main/java/org/gvsig/gpe/exportto/generic/util/CoordinatesSequenceGeneralPath.java | ||
---|---|---|
1 |
package org.gvsig.gpe.exportto.generic.util; |
|
2 |
|
|
3 |
import java.awt.geom.PathIterator; |
|
4 |
import java.io.IOException; |
|
5 |
|
|
6 |
import org.gvsig.gpe.lib.api.parser.ICoordinateIterator; |
|
7 |
import org.gvsig.gpe.lib.api.writer.ICoordinateSequence; |
|
8 |
|
|
9 |
public class CoordinatesSequenceGeneralPath implements |
|
10 |
ICoordinateSequence, ICoordinateIterator { |
|
11 |
|
|
12 |
private PathIterator it = null; |
|
13 |
int size = 0; |
|
14 |
boolean hasMoreGeoemtries = true; |
|
15 |
|
|
16 |
public CoordinatesSequenceGeneralPath(PathIterator it) { |
|
17 |
super(); |
|
18 |
this.it = it; |
|
19 |
} |
|
20 |
|
|
21 |
public int getSize() { |
|
22 |
return size; |
|
23 |
} |
|
24 |
|
|
25 |
public void initialize(){ |
|
26 |
size = 0; |
|
27 |
} |
|
28 |
|
|
29 |
public boolean hasMoreGeometries(){ |
|
30 |
return hasMoreGeoemtries; |
|
31 |
} |
|
32 |
|
|
33 |
public ICoordinateIterator iterator() { |
|
34 |
return this; |
|
35 |
} |
|
36 |
|
|
37 |
public int getDimension() { |
|
38 |
return 2; |
|
39 |
} |
|
40 |
|
|
41 |
public boolean hasNext() throws IOException { |
|
42 |
if (it.isDone()){ |
|
43 |
hasMoreGeoemtries = false; |
|
44 |
return false; |
|
45 |
} |
|
46 |
double[] coords = new double[2]; |
|
47 |
int type = it.currentSegment(coords); |
|
48 |
/* |
|
49 |
if (type == PathIterator.SEG_CLOSE){ |
|
50 |
hasMoreGeoemtries = false; |
|
51 |
} |
|
52 |
*/ |
|
53 |
return ((type != PathIterator.SEG_MOVETO) || (size == 0)); |
|
54 |
} |
|
55 |
|
|
56 |
public void next(double[] buffer) throws IOException { |
|
57 |
it.currentSegment(buffer); |
|
58 |
it.next(); |
|
59 |
size++; |
|
60 |
} |
|
61 |
|
|
62 |
} |
|
63 |
|
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/org.gvsig.gpe.exportto.generic/src/main/java/org/gvsig/gpe/exportto/generic/ExporttoGPEGenericLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.gpe.exportto.generic; |
|
25 |
|
|
26 |
import org.gvsig.gpe.lib.api.GPELibrary; |
|
27 |
import org.gvsig.tools.library.AbstractLibrary; |
|
28 |
import org.gvsig.tools.library.LibraryException; |
|
29 |
|
|
30 |
/** |
|
31 |
* Library with common things to be used by |
|
32 |
* GPE export libraries |
|
33 |
* |
|
34 |
* @author gvSIG Team |
|
35 |
* @version $Id$ |
|
36 |
*/ |
|
37 |
public class ExporttoGPEGenericLibrary extends AbstractLibrary { |
|
38 |
|
|
39 |
public void doRegistration() { |
|
40 |
require(GPELibrary.class); |
|
41 |
} |
|
42 |
|
|
43 |
protected void doInitialize() throws LibraryException { |
|
44 |
// Nothing to do |
|
45 |
} |
|
46 |
|
|
47 |
protected void doPostInitialize() throws LibraryException { |
|
48 |
|
|
49 |
} |
|
50 |
|
|
51 |
} |
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/org.gvsig.gpe.exportto.generic/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.gpe.exportto.generic</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>${project.artifactId}</name> |
|
7 |
|
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.gpe.exportto</artifactId> |
|
11 |
<version>2.1.115</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<dependencies> |
|
15 |
|
|
16 |
<dependency> |
|
17 |
<groupId>org.gvsig</groupId> |
|
18 |
<artifactId>org.gvsig.gpe.lib.api</artifactId> |
|
19 |
<scope>compile</scope> |
|
20 |
</dependency> |
|
21 |
|
|
22 |
<dependency> |
|
23 |
<groupId>org.gvsig</groupId> |
|
24 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
25 |
<scope>compile</scope> |
|
26 |
</dependency> |
|
27 |
|
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
|
|
34 |
</dependencies> |
|
35 |
</project> |
|
36 |
|
|
37 |
|
|
0 | 38 |
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/org.gvsig.gpe.exportto.kml/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<!-- |
|
2 |
|
|
3 |
gvSIG. Desktop Geographic Information System. |
|
4 |
|
|
5 |
Copyright (C) 2007-2013 gvSIG Association. |
|
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
|
8 |
modify it under the terms of the GNU General Public License |
|
9 |
as published by the Free Software Foundation; either version 3 |
|
10 |
of the License, or (at your option) any later version. |
|
11 |
|
|
12 |
This program is distributed in the hope that it will be useful, |
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
GNU General Public License for more details. |
|
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
|
18 |
along with this program; if not, write to the Free Software |
|
19 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
MA 02110-1301, USA. |
|
21 |
|
|
22 |
For any additional information, do not hesitate to contact us |
|
23 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
|
|
25 |
--> |
|
26 |
<assembly> |
|
27 |
<id>gvsig-plugin-package</id> |
|
28 |
<formats> |
|
29 |
<format>zip</format> |
|
30 |
</formats> |
|
31 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
32 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
33 |
<files> |
|
34 |
<file> |
|
35 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
36 |
<outputDirectory>lib</outputDirectory> |
|
37 |
</file> |
|
38 |
<file> |
|
39 |
<source>target/package.info</source> |
|
40 |
</file> |
|
41 |
</files> |
|
42 |
|
|
43 |
<fileSets> |
|
44 |
<fileSet> |
|
45 |
<directory>src/main/resources-plugin</directory> |
|
46 |
<outputDirectory>.</outputDirectory> |
|
47 |
</fileSet> |
|
48 |
</fileSets> |
|
49 |
|
|
50 |
<dependencySets> |
|
51 |
<dependencySet> |
|
52 |
<useProjectArtifact>false</useProjectArtifact> |
|
53 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
54 |
<outputDirectory>lib</outputDirectory> |
|
55 |
<includes> |
|
56 |
<include>org.gvsig:org.gvsig.gpe.exportto.generic</include> |
|
57 |
</includes> |
|
58 |
</dependencySet> |
|
59 |
</dependencySets> |
|
60 |
|
|
61 |
</assembly> |
|
62 |
|
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/org.gvsig.gpe.exportto.kml/src/main/java/org/gvsig/gpe/exportto/kml/swing/ExportKMLPanels.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.gpe.exportto.kml.swing; |
|
7 |
|
|
8 |
import org.gvsig.export.ExportParameters; |
|
9 |
import org.gvsig.export.swing.ExportSwingLocator; |
|
10 |
import org.gvsig.export.swing.JExportProcessPanel; |
|
11 |
import org.gvsig.export.swing.spi.AbstractExportPanels; |
|
12 |
import org.gvsig.export.swing.spi.ExportPanels; |
|
13 |
import org.gvsig.export.swing.spi.ExportPanelsFactory; |
|
14 |
import org.gvsig.export.swing.spi.ExportPanelsManager; |
|
15 |
import org.gvsig.gpe.exportto.kml.swing.panels.KMLPanel; |
|
16 |
|
|
17 |
/** |
|
18 |
* |
|
19 |
* @author osc |
|
20 |
*/ |
|
21 |
public class ExportKMLPanels |
|
22 |
extends AbstractExportPanels |
|
23 |
implements ExportPanels { |
|
24 |
|
|
25 |
ExportKMLPanels( |
|
26 |
ExportPanelsFactory factory, |
|
27 |
JExportProcessPanel processPanel, |
|
28 |
ExportParameters parameters |
|
29 |
) { |
|
30 |
super(factory, processPanel, parameters); |
|
31 |
this.initPanels(); |
|
32 |
} |
|
33 |
|
|
34 |
private void initPanels() { |
|
35 |
ExportPanelsManager manager = ExportSwingLocator.getExportPanelsManager(); |
|
36 |
|
|
37 |
this.add( |
|
38 |
new KMLPanel( |
|
39 |
this.getProcessPanel(), |
|
40 |
this.getParameters() |
|
41 |
) |
|
42 |
); |
|
43 |
this.add(manager.createStandardPanel( |
|
44 |
ExportPanelsManager.PANEL_ATTRIBUTES_SELECTION, |
|
45 |
this.getProcessPanel(), |
|
46 |
this.getParameters() |
|
47 |
) |
|
48 |
); |
|
49 |
|
|
50 |
this.add(manager.createStandardPanel( |
|
51 |
ExportPanelsManager.PANEL_SELECT_OUTPUT_FILE, |
|
52 |
this.getProcessPanel(), |
|
53 |
this.getParameters() |
|
54 |
) |
|
55 |
); |
|
56 |
} |
|
57 |
|
|
58 |
} |
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/org.gvsig.gpe.exportto.kml/src/main/java/org/gvsig/gpe/exportto/kml/swing/ExportKMLPanelsFactory.java | ||
---|---|---|
1 |
package org.gvsig.gpe.exportto.kml.swing; |
|
2 |
|
|
3 |
import org.gvsig.export.ExportParameters; |
|
4 |
import org.gvsig.export.swing.JExportProcessPanel; |
|
5 |
import org.gvsig.export.swing.spi.AbstractExportPanelsFactory; |
|
6 |
import org.gvsig.export.swing.spi.ExportPanels; |
|
7 |
import org.gvsig.export.swing.spi.ExportPanelsFactory; |
|
8 |
import org.gvsig.gpe.exportto.kml.service.ExportKMLServiceFactory; |
|
9 |
|
|
10 |
/** |
|
11 |
* |
|
12 |
* @author jjdelcerro |
|
13 |
*/ |
|
14 |
public class ExportKMLPanelsFactory |
|
15 |
extends AbstractExportPanelsFactory |
|
16 |
implements ExportPanelsFactory { |
|
17 |
|
|
18 |
public ExportKMLPanelsFactory() { |
|
19 |
super(ExportKMLServiceFactory.SERVICE_NAME); |
|
20 |
} |
|
21 |
|
|
22 |
@Override |
|
23 |
public ExportPanels createPanels(JExportProcessPanel processPanel, ExportParameters parameters) { |
|
24 |
return new ExportKMLPanels(this, processPanel, parameters); |
|
25 |
} |
|
26 |
|
|
27 |
} |
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/org.gvsig.gpe.exportto.kml/src/main/java/org/gvsig/gpe/exportto/kml/swing/panels/KMLPanel.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.gpe.exportto.kml.swing.panels; |
|
7 |
|
|
8 |
import javax.swing.JComponent; |
|
9 |
import org.gvsig.export.ExportParameters; |
|
10 |
import org.gvsig.export.swing.JExportProcessPanel; |
|
11 |
import org.gvsig.export.swing.spi.ExportPanel; |
|
12 |
import org.gvsig.export.swing.spi.ExportPanelValidationException; |
|
13 |
import org.gvsig.gpe.exportto.kml.service.ExportKMLParameters; |
|
14 |
import org.gvsig.tools.ToolsLocator; |
|
15 |
import org.gvsig.tools.i18n.I18nManager; |
|
16 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
17 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
18 |
|
|
19 |
/** |
|
20 |
* |
|
21 |
* @author osc |
|
22 |
*/ |
|
23 |
public class KMLPanel |
|
24 |
extends KMLPanelView |
|
25 |
implements ExportPanel |
|
26 |
{ |
|
27 |
|
|
28 |
// private static final Logger LOG = LoggerFactory.getLogger(SelectSimplifiedExport.class); |
|
29 |
|
|
30 |
private final ExportKMLParameters parameters; |
|
31 |
private final JExportProcessPanel processPanel; |
|
32 |
|
|
33 |
public KMLPanel(JExportProcessPanel processPanel, ExportParameters parameters) { |
|
34 |
super(); |
|
35 |
this.processPanel = processPanel; |
|
36 |
this.parameters = (ExportKMLParameters) parameters; |
|
37 |
this.initComponents(); |
|
38 |
} |
|
39 |
|
|
40 |
private void initComponents() { |
|
41 |
//Default value |
|
42 |
//this.chkUseSimplifiedExport.setSelected(parameters.getUseSimplifiedExport()); |
|
43 |
|
|
44 |
this.translate(); |
|
45 |
} |
|
46 |
|
|
47 |
private void translate() { |
|
48 |
ToolsSwingManager i18nc = ToolsSwingLocator.getToolsSwingManager(); |
|
49 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
50 |
// |
|
51 |
// i18nc.translate(this.lblUseSimplifiedExport); |
|
52 |
// String s = i18n.getTranslation(this.lblUseSimplifiedExportDescription.getText()); |
|
53 |
// s = "<html>" + s.replace("\n","<br>\n") + "</html>"; |
|
54 |
// this.lblUseSimplifiedExportDescription.setText(s); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public String getIdPanel() { |
|
59 |
return this.getClass().getSimpleName(); |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public String getTitlePanel() { |
|
64 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
65 |
return i18nManager.getTranslation("kml_Select_KML_Options"); |
|
66 |
} |
|
67 |
|
|
68 |
@Override |
|
69 |
public boolean validatePanel() throws ExportPanelValidationException { |
|
70 |
return true; |
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
74 |
public void enterPanel() { |
|
75 |
|
|
76 |
} |
|
77 |
|
|
78 |
@Override |
|
79 |
public void nextPanel() { |
|
80 |
this.parameters.setMimeType(this.getMimeType()); |
|
81 |
this.parameters.setAttsAsBalloon(this.getAttsAsBalloon()); |
|
82 |
this.parameters.setUseLabels(this.getUseLabels()); |
|
83 |
} |
|
84 |
|
|
85 |
@Override |
|
86 |
public void previousPanel() { |
|
87 |
|
|
88 |
} |
|
89 |
|
|
90 |
@Override |
|
91 |
public JComponent asJComponent() { |
|
92 |
|
|
93 |
return super.asJComponent(); |
|
94 |
} |
|
95 |
|
|
96 |
} |
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/org.gvsig.gpe.exportto.kml/src/main/java/org/gvsig/gpe/exportto/kml/swing/panels/KMLPanelView.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.gpe.exportto.kml.swing.panels; |
|
25 |
|
|
26 |
import java.awt.BorderLayout; |
|
27 |
import java.awt.FlowLayout; |
|
28 |
import java.awt.GridBagConstraints; |
|
29 |
import java.awt.GridBagLayout; |
|
30 |
import java.awt.Insets; |
|
31 |
import java.util.ArrayList; |
|
32 |
|
|
33 |
import javax.swing.JCheckBox; |
|
34 |
import javax.swing.JComboBox; |
|
35 |
import javax.swing.JComponent; |
|
36 |
import javax.swing.JLabel; |
|
37 |
import javax.swing.JPanel; |
|
38 |
|
|
39 |
import org.slf4j.Logger; |
|
40 |
import org.slf4j.LoggerFactory; |
|
41 |
|
|
42 |
//import org.gvsig.exportto.swing.ExporttoSwingLocator; |
|
43 |
//import org.gvsig.exportto.swing.ExporttoSwingManager; |
|
44 |
//import org.gvsig.exportto.swing.spi.ExporttoPanelValidationException; |
|
45 |
//import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel; |
|
46 |
import org.gvsig.gpe.lib.api.writer.IGPEWriterHandler; |
|
47 |
import org.gvsig.gpe.lib.spi.GPEProviderLocator; |
|
48 |
import org.gvsig.tools.ToolsLocator; |
|
49 |
import org.gvsig.tools.i18n.I18nManager; |
|
50 |
|
|
51 |
|
|
52 |
/** |
|
53 |
* |
|
54 |
* This addditional panel lets user choose KML |
|
55 |
* version and other options. |
|
56 |
* |
|
57 |
* @author gvSIG Team |
|
58 |
* @version $Id$ |
|
59 |
* |
|
60 |
*/ |
|
61 |
public class KMLPanelView extends JPanel { |
|
62 |
|
|
63 |
private static final long serialVersionUID = -3278172717881233447L; |
|
64 |
|
|
65 |
private static final Logger LOG = LoggerFactory.getLogger(KMLPanelView.class); |
|
66 |
|
|
67 |
private boolean offerLabels = false; |
|
68 |
private boolean offerReproj = true; |
|
69 |
|
|
70 |
private JCheckBox labelsChk = null; |
|
71 |
private JCheckBox reproChk = null; |
|
72 |
private JCheckBox balloonsChk = null; |
|
73 |
|
|
74 |
private JComboBox versionCombo = null; |
|
75 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
76 |
|
|
77 |
public KMLPanelView() { |
|
78 |
initializePanel(); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* Initializer |
|
83 |
*/ |
|
84 |
protected void initializePanel() { |
|
85 |
setLayout(new BorderLayout()); |
|
86 |
add(createPanel(), BorderLayout.CENTER); |
|
87 |
} |
|
88 |
|
|
89 |
private JPanel createPanel() { |
|
90 |
|
|
91 |
JPanel jpanel1 = new JPanel(); |
|
92 |
jpanel1.setLayout(new BorderLayout()); |
|
93 |
|
|
94 |
FlowLayout fl = new FlowLayout(FlowLayout.LEFT); |
|
95 |
JPanel topPanel = new JPanel(fl); |
|
96 |
// ==================================================== |
|
97 |
JPanel gridPanel = new JPanel(); |
|
98 |
gridPanel.setLayout(new GridBagLayout()); |
|
99 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
100 |
|
|
101 |
gbc.anchor = GridBagConstraints.WEST; |
|
102 |
gbc.insets = new Insets(3, 3, 3, 3); |
|
103 |
|
|
104 |
gbc.gridx = 0; |
|
105 |
gbc.gridy = 0; |
|
106 |
gbc.gridwidth = 3; |
|
107 |
gridPanel.add(new JLabel(i18n.getTranslation("kml_Choose_KML_version")), gbc); |
|
108 |
gbc.gridx = 3; |
|
109 |
gbc.gridwidth = 3; |
|
110 |
gridPanel.add(getVersionsCombo(), gbc); |
|
111 |
// ===================== |
|
112 |
gbc.gridx = 0; |
|
113 |
gbc.gridy = 1; |
|
114 |
gbc.gridwidth = 1; |
|
115 |
gridPanel.add(getBalloonsCheckbox(), gbc); |
|
116 |
gbc.gridx = 1; |
|
117 |
gbc.gridwidth = 5; |
|
118 |
gridPanel.add(new JLabel(i18n.getTranslation( |
|
119 |
"kml_Show_attributes_in_balloon")), gbc); |
|
120 |
// ===================== |
|
121 |
gbc.gridx = 0; |
|
122 |
gbc.gridy = 2; |
|
123 |
gbc.gridwidth = 1; |
|
124 |
getLabelsCheckbox(offerLabels); |
|
125 |
//gridPanel.add(getLabelsCheckbox(offerLabels), gbc); |
|
126 |
gbc.gridx = 1; |
|
127 |
gbc.gridwidth = 5; |
|
128 |
JLabel lbl_lbl = new JLabel(i18n.getTranslation("" + |
|
129 |
"kml_Use_labels_Label_point_will_be_added_to_non_points")); |
|
130 |
lbl_lbl.setEnabled(offerLabels); |
|
131 |
//gridPanel.add(lbl_lbl, gbc); |
|
132 |
// ==================================================== |
|
133 |
// gbc.gridx = 0; |
|
134 |
// gbc.gridy = 2; |
|
135 |
// gbc.gridwidth = 1; |
|
136 |
// gridPanel.add(getReproCheckbox(offerReproj), gbc); |
|
137 |
// gbc.gridx = 1; |
|
138 |
// gbc.gridwidth = 5; |
|
139 |
// JLabel rep_lbl = new JLabel(i18n.getTranslation( |
|
140 |
// "kml_Force_to_EPSG_4326")); |
|
141 |
// rep_lbl.setEnabled(offerReproj); |
|
142 |
// gridPanel.add(rep_lbl, gbc); |
|
143 |
// ==================================================== |
|
144 |
topPanel.add(gridPanel); |
|
145 |
jpanel1.add(topPanel, BorderLayout.NORTH); |
|
146 |
return jpanel1; |
|
147 |
} |
|
148 |
|
|
149 |
// public String getMimeType() { |
|
150 |
// IGPEWriterHandler item = (IGPEWriterHandler) this.versionCombo.getItemAt(0); |
|
151 |
// String longn = item.getFormat(); |
|
152 |
// return longn; |
|
153 |
// } |
|
154 |
|
|
155 |
public String getMimeType() { |
|
156 |
Object obj = this.getVersionsCombo().getSelectedItem(); |
|
157 |
if (obj instanceof FormatListItem) { |
|
158 |
return ((FormatListItem) obj).getLongFormat(); |
|
159 |
} else { |
|
160 |
return null; |
|
161 |
} |
|
162 |
} |
|
163 |
public boolean getUseLabels() { |
|
164 |
return this.labelsChk.isSelected(); |
|
165 |
} |
|
166 |
|
|
167 |
public boolean getAttsAsBalloon() { |
|
168 |
return this.balloonsChk.isSelected(); |
|
169 |
} |
|
170 |
|
|
171 |
public boolean getReprojectTo4326() { |
|
172 |
return this.reproChk.isSelected(); |
|
173 |
} |
|
174 |
|
|
175 |
private JCheckBox getLabelsCheckbox(boolean enabled) { |
|
176 |
|
|
177 |
if (labelsChk == null) { |
|
178 |
labelsChk = new JCheckBox(""); |
|
179 |
labelsChk.setSelected(false); |
|
180 |
labelsChk.setEnabled(enabled); |
|
181 |
} |
|
182 |
return labelsChk; |
|
183 |
} |
|
184 |
|
|
185 |
private JCheckBox getReproCheckbox(boolean enabled) { |
|
186 |
|
|
187 |
if (reproChk == null) { |
|
188 |
reproChk = new JCheckBox(""); |
|
189 |
reproChk.setSelected(true); |
|
190 |
reproChk.setEnabled(enabled); |
|
191 |
} |
|
192 |
return reproChk; |
|
193 |
} |
|
194 |
|
|
195 |
private JCheckBox getBalloonsCheckbox() { |
|
196 |
|
|
197 |
if (balloonsChk == null) { |
|
198 |
balloonsChk = new JCheckBox(""); |
|
199 |
balloonsChk.setSelected(false); |
|
200 |
} |
|
201 |
return balloonsChk; |
|
202 |
} |
|
203 |
|
|
204 |
|
|
205 |
private JComboBox getVersionsCombo() { |
|
206 |
|
|
207 |
if (versionCombo == null) { |
|
208 |
versionCombo = new JComboBox(); |
|
209 |
ArrayList list = GPEProviderLocator.getGPEProviderManager().getWriterHandlerByFormat("kml"); |
|
210 |
IGPEWriterHandler item = null; |
|
211 |
String longn = null; |
|
212 |
String shortn = null; |
|
213 |
for (int i=0; i<list.size(); i++) { |
|
214 |
item = (IGPEWriterHandler) list.get(i); |
|
215 |
longn = item.getFormat(); |
|
216 |
shortn = getShortWithVersion(longn); |
|
217 |
if (longn != null && shortn != null) { |
|
218 |
versionCombo.addItem(new FormatListItem(longn, shortn)); |
|
219 |
} |
|
220 |
} |
|
221 |
} |
|
222 |
return versionCombo; |
|
223 |
} |
|
224 |
|
|
225 |
public String getPanelTitle() { |
|
226 |
return i18n.getTranslation("kml_KML_options"); |
|
227 |
} |
|
228 |
|
|
229 |
public boolean isValidPanel() { |
|
230 |
return getLongFormat() != null; |
|
231 |
} |
|
232 |
|
|
233 |
|
|
234 |
/** |
|
235 |
* Returns null if not valid format |
|
236 |
*/ |
|
237 |
private String getShortWithVersion(String fmt) { |
|
238 |
// Example: "text/xml; subtype=gml/2.1.2" => "gml" |
|
239 |
if (fmt == null) { |
|
240 |
return null; |
|
241 |
} |
|
242 |
String[] parts = fmt.split(";"); |
|
243 |
String aux = ""; |
|
244 |
if (parts.length > 1) { |
|
245 |
aux = parts[1].trim(); |
|
246 |
} else { |
|
247 |
return null; |
|
248 |
} |
|
249 |
parts = aux.split("="); |
|
250 |
if (parts.length > 1) { |
|
251 |
aux = parts[1].trim(); |
|
252 |
// Example: aux = "gml/2.1.2" |
|
253 |
aux = aux.replaceAll("/", " "); |
|
254 |
return aux.toUpperCase(); |
|
255 |
} else { |
|
256 |
return null; |
|
257 |
} |
|
258 |
} |
|
259 |
|
|
260 |
public void enterPanel() { |
|
261 |
|
|
262 |
} |
|
263 |
|
|
264 |
public JComponent asJComponent() { |
|
265 |
return this; |
|
266 |
} |
|
267 |
|
|
268 |
public class FormatListItem { |
|
269 |
|
|
270 |
private String longName = ""; |
|
271 |
private String shortName = ""; |
|
272 |
|
|
273 |
public FormatListItem(String longname, String shortname) { |
|
274 |
longName = longname; |
|
275 |
shortName = shortname; |
|
276 |
} |
|
277 |
|
|
278 |
public String toString() { |
|
279 |
return shortName; |
|
280 |
} |
|
281 |
|
|
282 |
public String getLongFormat() { |
|
283 |
return longName; |
|
284 |
} |
|
285 |
} |
|
286 |
|
|
287 |
// ================================================== |
|
288 |
// ================================================== |
|
289 |
|
|
290 |
public String getLongFormat() { |
|
291 |
Object obj = this.getVersionsCombo().getSelectedItem(); |
|
292 |
if (obj instanceof FormatListItem) { |
|
293 |
return ((FormatListItem) obj).getLongFormat(); |
|
294 |
} else { |
|
295 |
return null; |
|
296 |
} |
|
297 |
} |
|
298 |
|
|
299 |
public boolean useLabels() { |
|
300 |
return this.getLabelsCheckbox(false).isSelected(); |
|
301 |
} |
|
302 |
|
|
303 |
public boolean useBalloons() { |
|
304 |
return this.getBalloonsCheckbox().isSelected(); |
|
305 |
} |
|
306 |
|
|
307 |
public boolean mustReprojectToEpsg4326() { |
|
308 |
return this.getReproCheckbox(true).isSelected(); |
|
309 |
} |
|
310 |
|
|
311 |
|
|
312 |
|
|
313 |
} |
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/org.gvsig.gpe.exportto.kml/src/main/java/org/gvsig/gpe/exportto/kml/ExportKMLLibrary.java | ||
---|---|---|
1 |
package org.gvsig.gpe.exportto.kml; |
|
2 |
|
|
3 |
import org.gvsig.export.ExportLibrary; |
|
4 |
import org.gvsig.export.ExportLocator; |
|
5 |
import org.gvsig.export.spi.ExportServiceManager; |
|
6 |
import org.gvsig.export.swing.ExportSwingLibrary; |
|
7 |
import org.gvsig.export.swing.ExportSwingLocator; |
|
8 |
import org.gvsig.export.swing.spi.ExportPanelsManager; |
|
9 |
import org.gvsig.gpe.exportto.kml.service.ExportKMLServiceFactory; |
|
10 |
import org.gvsig.gpe.exportto.kml.swing.ExportKMLPanelsFactory; |
|
11 |
import org.gvsig.tools.library.AbstractLibrary; |
|
12 |
import org.gvsig.tools.library.LibraryException; |
|
13 |
|
|
14 |
/** |
|
15 |
* |
|
16 |
* @author jjdelcerro |
|
17 |
*/ |
|
18 |
public class ExportKMLLibrary extends AbstractLibrary { |
|
19 |
|
|
20 |
@Override |
|
21 |
public void doRegistration() { |
|
22 |
registerAsServiceOf(ExportSwingLibrary.class); |
|
23 |
registerAsServiceOf(ExportLibrary.class); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
protected void doInitialize() throws LibraryException { |
|
28 |
// Nothing to do |
|
29 |
} |
|
30 |
|
|
31 |
@Override |
|
32 |
protected void doPostInitialize() throws LibraryException { |
|
33 |
ExportServiceManager manager = ExportLocator.getServiceManager(); |
|
34 |
ExportPanelsManager swingManager = ExportSwingLocator.getExportPanelsManager(); |
|
35 |
|
|
36 |
manager.register(new ExportKMLServiceFactory()); |
|
37 |
ExportKMLPanelsFactory panel = new ExportKMLPanelsFactory(); |
|
38 |
swingManager.register(panel); |
|
39 |
} |
|
40 |
|
|
41 |
} |
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.115/org.gvsig.gpe.exportto/org.gvsig.gpe.exportto.kml/src/main/java/org/gvsig/gpe/exportto/kml/service/ExportKMLService.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.gpe.exportto.kml.service; |
|
7 |
|
|
8 |
import java.awt.geom.Rectangle2D; |
|
9 |
import java.io.File; |
|
10 |
import java.io.FileOutputStream; |
|
11 |
import java.io.IOException; |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.Iterator; |
|
14 |
import java.util.List; |
|
15 |
import java.util.Map; |
|
16 |
import org.cresques.cts.ICoordTrans; |
|
17 |
import org.cresques.cts.IProjection; |
|
18 |
import org.gvsig.export.ExportException; |
|
19 |
import org.gvsig.export.ExportParameters; |
|
20 |
import org.gvsig.export.spi.AbstractExportService; |
|
21 |
import org.gvsig.export.spi.ExportService; |
|
22 |
import org.gvsig.export.spi.ExportServiceFactory; |
|
23 |
import org.gvsig.fmap.crs.CRSFactory; |
|
24 |
import org.gvsig.fmap.dal.DALLocator; |
|
25 |
import org.gvsig.fmap.dal.DataManager; |
|
26 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
27 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
28 |
import org.gvsig.fmap.dal.OpenDataStoreParameters; |
|
29 |
import org.gvsig.fmap.dal.exception.DataException; |
|
30 |
import org.gvsig.fmap.dal.feature.Feature; |
|
31 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
32 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
33 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
34 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
35 |
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters; |
|
36 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
|
37 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
|
38 |
import org.gvsig.fmap.geom.DataTypes; |
|
39 |
import org.gvsig.fmap.geom.Geometry; |
|
40 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
41 |
import org.gvsig.fmap.geom.GeometryManager; |
|
42 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
43 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
44 |
import org.gvsig.fmap.mapcontext.MapContextException; |
|
45 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
46 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
47 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
48 |
import org.gvsig.gpe.exportto.generic.util.CoordinatesSequenceBbox; |
|
49 |
import org.gvsig.gpe.exportto.generic.util.GeometryToGPEWriter; |
|
50 |
import org.gvsig.gpe.exportto.kml.style.KmlStyle; |
|
51 |
import org.gvsig.gpe.exportto.kml.style.StyleUtils; |
|
52 |
import org.gvsig.gpe.lib.api.GPELocator; |
|
53 |
import org.gvsig.gpe.lib.api.writer.IGPEWriterHandler; |
|
54 |
import org.gvsig.gpe.lib.api.writer.IGPEWriterHandlerImplementor; |
|
55 |
import org.gvsig.gpe.prov.kml.utils.Kml2_1_Tags; |
|
56 |
import org.gvsig.gpe.prov.kml.writer.GPEKmlWriterHandlerImplementor; |
|
57 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
58 |
import org.gvsig.tools.locator.LocatorException; |
|
59 |
import org.gvsig.tools.util.HasAFile; |
|
60 |
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamWriter; |
|
61 |
import org.slf4j.Logger; |
|
62 |
import org.slf4j.LoggerFactory; |
|
63 |
|
|
64 |
/** |
|
65 |
* |
|
66 |
* @author osc |
|
67 |
*/ |
|
68 |
public class ExportKMLService extends AbstractExportService |
|
69 |
implements ExportService { |
|
70 |
|
|
71 |
private static Logger logger = LoggerFactory.getLogger(ExportKMLService.class); |
|
72 |
|
Also available in: Unified diff