Revision 19196 trunk/prototypes/mobile/desktop/extensions/extExportMobile/src/es/prodevelop/gvsig/exportMobile/layerexporters/VectorialExporterTask.java
VectorialExporterTask.java | ||
---|---|---|
47 | 47 |
import es.prodevelop.gvsig.exportMobile.xml.Style; |
48 | 48 |
import es.prodevelop.gvsig.exportMobile.xml.XmlProjectTags; |
49 | 49 |
|
50 |
/** |
|
51 |
* Exportation subtask to export a vectorial layer |
|
52 |
* It supports selecting features by rect, clipping |
|
53 |
* features by rect and exporting all features |
|
54 |
* It splits the input data in polygons, lines and |
|
55 |
* points to save it as shapefiles. |
|
56 |
* |
|
57 |
* @author jcarras |
|
58 |
* |
|
59 |
*/ |
|
50 | 60 |
public class VectorialExporterTask extends ExporterSubTask { |
51 | 61 |
|
52 | 62 |
public static final int CLIPRECT = 1; |
... | ... | |
68 | 78 |
public static final String NOSUFFIX = ""; |
69 | 79 |
public static final String SHAPESUFFIX = ".shp"; |
70 | 80 |
|
81 |
/** |
|
82 |
* Returns the suffix associated wit the input process type |
|
83 |
* @param processType |
|
84 |
* @return the corresponding suffix |
|
85 |
*/ |
|
71 | 86 |
public String getSuffix(int processType){ |
72 | 87 |
if (processType == CLIPRECT) |
73 | 88 |
return CLIPSUFFIX; |
... | ... | |
78 | 93 |
return NOSUFFIX; |
79 | 94 |
} |
80 | 95 |
|
81 |
|
|
96 |
/** |
|
97 |
* Remove the defined suffixes of the input string with the objective |
|
98 |
* of not adding twice the suffixes on several exportations |
|
99 |
* |
|
100 |
* @param name |
|
101 |
* @return the input string without the suffixes |
|
102 |
*/ |
|
82 | 103 |
public String removeSuffixes(String name){ |
83 | 104 |
String res = name; |
84 | 105 |
|
... | ... | |
107 | 128 |
|
108 | 129 |
private Logger logger = Logger.getLogger(this.getClass()); |
109 | 130 |
|
131 |
/** |
|
132 |
* Constructor with all the needed attributes |
|
133 |
* @param parentProcess |
|
134 |
* @param layer |
|
135 |
* @param rect |
|
136 |
* @param destPath |
|
137 |
* @param processType One of those VectorialExporterTask.CLIPRECT, VectorialExporterTask.ALL or VectorialExporterTask.SELECTRECT |
|
138 |
* @param fieldsDescription Description of the fields of the resulting layers |
|
139 |
* @param xml |
|
140 |
*/ |
|
110 | 141 |
public VectorialExporterTask(AbstractMonitorableTask parentProcess, |
111 | 142 |
FLayer layer, Rectangle2D rect, String destPath, int processType, |
112 | 143 |
FieldDescription[] fieldsDescription, XmlBuilder xml) { |
... | ... | |
189 | 220 |
|
190 | 221 |
} |
191 | 222 |
|
192 |
public void clipFeatures(IWriter writer, Driver reader, FBitSet bitSet, ShpSchemaManager schemaManager, ILayerDefinition outputDef, int numStepsToReport){
|
|
223 |
private void clipFeatures(IWriter writer, Driver reader, FBitSet bitSet, ShpSchemaManager schemaManager, ILayerDefinition outputDef, int numStepsToReport){
|
|
193 | 224 |
ClipProcess clip = new ClipProcess( |
194 | 225 |
inLayerVec, |
195 | 226 |
fieldsDescription, bitSet); |
... | ... | |
211 | 242 |
|
212 | 243 |
} |
213 | 244 |
|
245 |
/** |
|
246 |
* Makes the exportation |
|
247 |
*/ |
|
214 | 248 |
public void export() { |
215 | 249 |
setNote(PluginServices.getText(this, "exporting_") + " " + inLayer.getName()); |
216 | 250 |
|
... | ... | |
386 | 420 |
|
387 | 421 |
} |
388 | 422 |
|
423 |
/** |
|
424 |
* It iterates over every feature to return a bitSet with the features of |
|
425 |
* the input type and inside the input rectangle |
|
426 |
* @param rect |
|
427 |
* @param type |
|
428 |
* @return |
|
429 |
* @throws DriverException |
|
430 |
*/ |
|
389 | 431 |
public FBitSet queryByRectAndType(Rectangle2D rect, int type) |
390 | 432 |
throws DriverException { |
391 | 433 |
|
... | ... | |
437 | 479 |
|
438 | 480 |
} |
439 | 481 |
|
440 |
/** |
|
441 |
* @param file |
|
442 |
* @return |
|
443 |
* @throws IOException |
|
444 |
*/ |
|
445 |
public IndexedShpDriver getOpenShpDriver(File file) throws IOException { |
|
482 |
|
|
483 |
private IndexedShpDriver getOpenShpDriver(File file) throws IOException { |
|
446 | 484 |
|
447 | 485 |
IndexedShpDriver drv = new IndexedShpDriver(); |
448 | 486 |
if (!file.exists()) { |
... | ... | |
459 | 497 |
return drv; |
460 | 498 |
} |
461 | 499 |
|
462 |
/** |
|
463 |
* Name agreed with descripExLyr2 |
|
464 |
* |
|
465 |
* @param sds2 |
|
466 |
* @param descripExLyr2 |
|
467 |
* @param i |
|
468 |
* @return |
|
469 |
* @throws com.hardcode.gdbms.engine.data.driver.DriverException |
|
470 |
*/ |
|
471 | 500 |
private Value[] extractValues(SelectableDataSource sds2, |
472 | 501 |
FieldDescription[] descripExLyr2, int i) |
473 | 502 |
throws com.hardcode.gdbms.engine.data.driver.DriverException { |
... | ... | |
528 | 557 |
return index; |
529 | 558 |
} |
530 | 559 |
|
531 |
@Override |
|
560 |
/** |
|
561 |
* Number of steps the Exportation will report |
|
562 |
*/ |
|
532 | 563 |
public int getFinalStep() { |
533 | 564 |
return 100; |
534 | 565 |
} |
535 | 566 |
|
536 |
@Override |
|
567 |
/** |
|
568 |
* Runs the exportation task |
|
569 |
*/ |
|
537 | 570 |
public void run() { |
538 | 571 |
export(); |
539 | 572 |
} |
540 | 573 |
|
574 |
/** |
|
575 |
* Writes the layer attributes to the input xml |
|
576 |
* @param name |
|
577 |
* @param shpType |
|
578 |
* @param path |
|
579 |
*/ |
|
541 | 580 |
private void writeXML(String name, int shpType, String path){ |
542 | 581 |
//xml.openTag(XmlProjectTags.LAYER); |
543 | 582 |
//<Type> |
Also available in: Unified diff