Revision 463
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/MANIFEST.MF | ||
---|---|---|
1 |
Manifest-Version: 1.0 |
|
2 |
Ant-Version: Apache Ant 1.7.1 |
|
3 |
Created-By: 16.0-b13 (Sun Microsystems Inc.) |
|
4 |
Implementation-Version: 0.7 |
|
5 |
Built-Date: 2012-10-04 11:28:17 |
|
6 |
|
|
0 | 7 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.toolbox.core.ToolboxCoreLibrary |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/resources/org/gvsig/toolbox/core/i18n/text.properties | ||
---|---|---|
1 |
[New_model]=[Nuevo modelo] |
|
2 |
|
|
3 |
chart=gr\u00e1fico |
|
4 |
|
|
5 |
raster=raster |
|
6 |
|
|
7 |
text=texto |
|
8 |
|
|
9 |
table=tabla |
|
10 |
|
|
11 |
vector=vectorial |
|
12 |
|
|
13 |
Java_code=C\u00f3digo Java |
|
14 |
|
|
15 |
Toolbox=Caja de herramientas |
|
16 |
|
|
17 |
Toolbox_models=Modelos |
|
0 | 18 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/resources/org/gvsig/toolbox/core/i18n/text_en.properties | ||
---|---|---|
1 |
[New_model]=[New model] |
|
2 |
|
|
3 |
chart=chart |
|
4 |
|
|
5 |
raster=raster |
|
6 |
|
|
7 |
text=text |
|
8 |
|
|
9 |
table=table |
|
10 |
|
|
11 |
vector=vector |
|
12 |
|
|
13 |
Java_code=Java code |
|
14 |
|
|
15 |
Toolbox=Toolbox |
|
16 |
|
|
17 |
Toolbox_models=Models |
|
0 | 18 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/resources/org/gvsig/toolbox/core/i18n/text_fr.properties | ||
---|---|---|
1 |
#Modified by DOKSoft PropEditor. http://www.doksoft.com |
|
2 |
#Fri Feb 18 11:30:32 CET 2011 |
|
3 |
vector=Vectoriel |
|
4 |
raster=Couche matricielle |
|
5 |
[New_model]=[Nouveau mod\u00e8le] |
|
6 |
chart=graphique |
|
7 |
table=table |
|
8 |
text=texte |
|
9 |
Toolbox=Bo\u00eete \u00e0 outils |
|
10 |
Toolbox_models=Mod\u00e8les |
|
0 | 11 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElementString.java | ||
---|---|---|
1 |
package es.unex.sextante.modeler.elements; |
|
2 |
|
|
3 |
|
|
4 |
public class ModelElementString |
|
5 |
implements |
|
6 |
IModelElement { |
|
7 |
|
|
8 |
} |
|
0 | 9 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElementFactory.java | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
package es.unex.sextante.modeler.elements; |
|
4 |
|
|
5 |
import es.unex.sextante.additionalInfo.AdditionalInfoFixedTable; |
|
6 |
import es.unex.sextante.additionalInfo.AdditionalInfoMultipleInput; |
|
7 |
import es.unex.sextante.additionalInfo.AdditionalInfoVectorLayer; |
|
8 |
import es.unex.sextante.exceptions.NullParameterAdditionalInfoException; |
|
9 |
import es.unex.sextante.parameters.Parameter; |
|
10 |
import es.unex.sextante.parameters.ParameterBand; |
|
11 |
import es.unex.sextante.parameters.ParameterBoolean; |
|
12 |
import es.unex.sextante.parameters.ParameterFilepath; |
|
13 |
import es.unex.sextante.parameters.ParameterFixedTable; |
|
14 |
import es.unex.sextante.parameters.ParameterMultipleInput; |
|
15 |
import es.unex.sextante.parameters.ParameterNumericalValue; |
|
16 |
import es.unex.sextante.parameters.ParameterPoint; |
|
17 |
import es.unex.sextante.parameters.ParameterRasterLayer; |
|
18 |
import es.unex.sextante.parameters.Parameter3DRasterLayer; |
|
19 |
import es.unex.sextante.parameters.ParameterSelection; |
|
20 |
import es.unex.sextante.parameters.ParameterString; |
|
21 |
import es.unex.sextante.parameters.ParameterTable; |
|
22 |
import es.unex.sextante.parameters.ParameterTableField; |
|
23 |
import es.unex.sextante.parameters.ParameterVectorLayer; |
|
24 |
|
|
25 |
|
|
26 |
public class ModelElementFactory { |
|
27 |
|
|
28 |
public static IModelElement getParameterAsModelElement(final Parameter param) { |
|
29 |
|
|
30 |
IModelElement element = null; |
|
31 |
|
|
32 |
try { |
|
33 |
if (param instanceof ParameterRasterLayer) { |
|
34 |
element = new ModelElementRasterLayer(); |
|
35 |
((ModelElementRasterLayer) element).setNumberOfBands(ModelElementRasterLayer.NUMBER_OF_BANDS_UNDEFINED); |
|
36 |
} |
|
37 |
if (param instanceof Parameter3DRasterLayer) { |
|
38 |
element = new ModelElement3DRasterLayer(); |
|
39 |
} |
|
40 |
else if (param instanceof ParameterVectorLayer) { |
|
41 |
element = new ModelElementVectorLayer(); |
|
42 |
final AdditionalInfoVectorLayer ai = (AdditionalInfoVectorLayer) param.getParameterAdditionalInfo(); |
|
43 |
((ModelElementVectorLayer) element).setShapeType(ai.getShapeType()); |
|
44 |
} |
|
45 |
else if (param instanceof ParameterTable) { |
|
46 |
element = new ModelElementTable(); |
|
47 |
} |
|
48 |
else if (param instanceof ParameterPoint) { |
|
49 |
element = new ModelElementPoint(); |
|
50 |
} |
|
51 |
else if (param instanceof ParameterNumericalValue) { |
|
52 |
element = new ModelElementNumericalValue(); |
|
53 |
} |
|
54 |
else if (param instanceof ParameterString) { |
|
55 |
element = new ModelElementString(); |
|
56 |
} |
|
57 |
else if (param instanceof ParameterFilepath) { |
|
58 |
element = new ModelElementFilepath(); |
|
59 |
} |
|
60 |
else if (param instanceof ParameterFixedTable) { |
|
61 |
element = new ModelElementFixedTable(); |
|
62 |
final AdditionalInfoFixedTable aift = (AdditionalInfoFixedTable) param.getParameterAdditionalInfo(); |
|
63 |
((ModelElementFixedTable) element).setRowsCount(aift.getRowsCount()); |
|
64 |
((ModelElementFixedTable) element).setColsCount(aift.getColsCount()); |
|
65 |
((ModelElementFixedTable) element).setIsNumberOfRowsFixed(aift.isNumberOfRowsFixed()); |
|
66 |
} |
|
67 |
else if (param instanceof ParameterSelection) { |
|
68 |
element = new ModelElementSelection(); |
|
69 |
} |
|
70 |
else if (param instanceof ParameterMultipleInput) { |
|
71 |
element = new ModelElementInputArray(); |
|
72 |
final AdditionalInfoMultipleInput ai = (AdditionalInfoMultipleInput) param.getParameterAdditionalInfo(); |
|
73 |
((ModelElementInputArray) element).setType(ai.getDataType()); |
|
74 |
} |
|
75 |
else if (param instanceof ParameterBoolean) { |
|
76 |
element = new ModelElementBoolean(); |
|
77 |
} |
|
78 |
else if (param instanceof ParameterMultipleInput) { |
|
79 |
element = new ModelElementInputArray(); |
|
80 |
} |
|
81 |
else if (param instanceof ParameterTableField) { |
|
82 |
element = new ModelElementTableField(); |
|
83 |
} |
|
84 |
else if (param instanceof ParameterBand) { |
|
85 |
element = new ModelElementBand(); |
|
86 |
} |
|
87 |
} |
|
88 |
catch (final NullParameterAdditionalInfoException e) { |
|
89 |
} |
|
90 |
|
|
91 |
return element; |
|
92 |
|
|
93 |
} |
|
94 |
|
|
95 |
} |
|
0 | 96 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElementFixedTable.java | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
package es.unex.sextante.modeler.elements; |
|
4 |
|
|
5 |
|
|
6 |
public class ModelElementFixedTable |
|
7 |
implements |
|
8 |
IModelElement { |
|
9 |
|
|
10 |
private int m_iRowsCount; |
|
11 |
private int m_iColsCount; |
|
12 |
private boolean m_bIsNumberOfRowsFixed; |
|
13 |
|
|
14 |
|
|
15 |
public void setRowsCount(final int rowsCount) { |
|
16 |
|
|
17 |
m_iRowsCount = rowsCount; |
|
18 |
|
|
19 |
} |
|
20 |
|
|
21 |
|
|
22 |
public void setColsCount(final int colsCount) { |
|
23 |
|
|
24 |
m_iColsCount = colsCount; |
|
25 |
|
|
26 |
} |
|
27 |
|
|
28 |
|
|
29 |
public void setIsNumberOfRowsFixed(final boolean isNumberOfRowsFixed) { |
|
30 |
|
|
31 |
m_bIsNumberOfRowsFixed = isNumberOfRowsFixed; |
|
32 |
|
|
33 |
} |
|
34 |
|
|
35 |
|
|
36 |
public int getColsCount() { |
|
37 |
|
|
38 |
return m_iColsCount; |
|
39 |
|
|
40 |
} |
|
41 |
|
|
42 |
|
|
43 |
public int getRowsCount() { |
|
44 |
|
|
45 |
return m_iRowsCount; |
|
46 |
|
|
47 |
} |
|
48 |
|
|
49 |
|
|
50 |
} |
|
0 | 51 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElementNumericalValue.java | ||
---|---|---|
1 |
package es.unex.sextante.modeler.elements; |
|
2 |
|
|
3 |
|
|
4 |
public class ModelElementNumericalValue |
|
5 |
implements |
|
6 |
IModelElement { |
|
7 |
|
|
8 |
@Override |
|
9 |
public String toString() { |
|
10 |
|
|
11 |
return this.getClass().toString(); |
|
12 |
|
|
13 |
} |
|
14 |
|
|
15 |
|
|
16 |
} |
|
0 | 17 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElementBoolean.java | ||
---|---|---|
1 |
package es.unex.sextante.modeler.elements; |
|
2 |
|
|
3 |
|
|
4 |
public class ModelElementBoolean |
|
5 |
implements |
|
6 |
IModelElement { |
|
7 |
|
|
8 |
} |
|
0 | 9 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElement3DRasterLayer.java | ||
---|---|---|
1 |
package es.unex.sextante.modeler.elements; |
|
2 |
|
|
3 |
|
|
4 |
public class ModelElement3DRasterLayer |
|
5 |
implements |
|
6 |
IModelElement { |
|
7 |
|
|
8 |
|
|
9 |
@Override |
|
10 |
public String toString() { |
|
11 |
|
|
12 |
return this.getClass().toString(); |
|
13 |
|
|
14 |
} |
|
15 |
|
|
16 |
} |
|
0 | 17 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElementSelection.java | ||
---|---|---|
1 |
package es.unex.sextante.modeler.elements; |
|
2 |
|
|
3 |
|
|
4 |
public class ModelElementSelection |
|
5 |
implements |
|
6 |
IModelElement { |
|
7 |
|
|
8 |
} |
|
0 | 9 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElementTable.java | ||
---|---|---|
1 |
package es.unex.sextante.modeler.elements; |
|
2 |
|
|
3 |
|
|
4 |
public class ModelElementTable |
|
5 |
implements |
|
6 |
IModelElement { |
|
7 |
|
|
8 |
@Override |
|
9 |
public String toString() { |
|
10 |
|
|
11 |
return this.getClass().toString(); |
|
12 |
|
|
13 |
} |
|
14 |
|
|
15 |
} |
|
0 | 16 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/IModelElement.java | ||
---|---|---|
1 |
package es.unex.sextante.modeler.elements; |
|
2 |
|
|
3 |
public interface IModelElement { |
|
4 |
|
|
5 |
} |
|
0 | 6 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElementPoint.java | ||
---|---|---|
1 |
package es.unex.sextante.modeler.elements; |
|
2 |
|
|
3 |
|
|
4 |
public class ModelElementPoint |
|
5 |
implements |
|
6 |
IModelElement { |
|
7 |
|
|
8 |
} |
|
0 | 9 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElementTableField.java | ||
---|---|---|
1 |
package es.unex.sextante.modeler.elements; |
|
2 |
|
|
3 |
|
|
4 |
public class ModelElementTableField |
|
5 |
implements |
|
6 |
IModelElement { |
|
7 |
|
|
8 |
} |
|
0 | 9 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElementFilepath.java | ||
---|---|---|
1 |
package es.unex.sextante.modeler.elements; |
|
2 |
|
|
3 |
|
|
4 |
public class ModelElementFilepath |
|
5 |
implements |
|
6 |
IModelElement { |
|
7 |
|
|
8 |
@Override |
|
9 |
public String toString() { |
|
10 |
|
|
11 |
return this.getClass().toString(); |
|
12 |
|
|
13 |
} |
|
14 |
|
|
15 |
|
|
16 |
} |
|
0 | 17 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElementRasterLayer.java | ||
---|---|---|
1 |
package es.unex.sextante.modeler.elements; |
|
2 |
|
|
3 |
|
|
4 |
public class ModelElementRasterLayer |
|
5 |
implements |
|
6 |
IModelElement { |
|
7 |
|
|
8 |
public static final int NUMBER_OF_BANDS_UNDEFINED = -1; |
|
9 |
private int m_iNumberOfBands = NUMBER_OF_BANDS_UNDEFINED; |
|
10 |
|
|
11 |
|
|
12 |
public int getNumberOfBands() { |
|
13 |
|
|
14 |
return m_iNumberOfBands; |
|
15 |
|
|
16 |
} |
|
17 |
|
|
18 |
|
|
19 |
public void setNumberOfBands(int numberOfBands) { |
|
20 |
|
|
21 |
if (numberOfBands < 1) { |
|
22 |
numberOfBands = NUMBER_OF_BANDS_UNDEFINED; |
|
23 |
} |
|
24 |
m_iNumberOfBands = numberOfBands; |
|
25 |
|
|
26 |
} |
|
27 |
|
|
28 |
|
|
29 |
@Override |
|
30 |
public String toString() { |
|
31 |
|
|
32 |
return this.getClass().toString() + "," + Integer.toString(m_iNumberOfBands); |
|
33 |
|
|
34 |
} |
|
35 |
|
|
36 |
} |
|
0 | 37 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElementInputArray.java | ||
---|---|---|
1 |
package es.unex.sextante.modeler.elements; |
|
2 |
|
|
3 |
|
|
4 |
public class ModelElementInputArray |
|
5 |
implements |
|
6 |
IModelElement { |
|
7 |
|
|
8 |
private int m_iType; |
|
9 |
|
|
10 |
public static final int DATA_TYPE_RASTER = 1; |
|
11 |
public static final int DATA_TYPE_VECTOR_POINT = 2; |
|
12 |
public static final int DATA_TYPE_VECTOR_LINE = 3; |
|
13 |
public static final int DATA_TYPE_VECTOR_POLYGON = 4; |
|
14 |
public static final int DATA_TYPE_VECTOR_ANY = 5; |
|
15 |
public static final int DATA_TYPE_TABLE = 6; |
|
16 |
public static final int DATA_TYPE_BAND = 7; |
|
17 |
|
|
18 |
|
|
19 |
public int getType() { |
|
20 |
|
|
21 |
return m_iType; |
|
22 |
|
|
23 |
} |
|
24 |
|
|
25 |
|
|
26 |
public void setType(final int type) { |
|
27 |
|
|
28 |
m_iType = type; |
|
29 |
|
|
30 |
} |
|
31 |
|
|
32 |
} |
|
0 | 33 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElementVectorLayer.java | ||
---|---|---|
1 |
package es.unex.sextante.modeler.elements; |
|
2 |
|
|
3 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
4 |
|
|
5 |
public class ModelElementVectorLayer |
|
6 |
implements |
|
7 |
IModelElement { |
|
8 |
|
|
9 |
public static final int SHAPE_TYPE_POLYGON = IVectorLayer.SHAPE_TYPE_POLYGON; |
|
10 |
public static final int SHAPE_TYPE_POINT = IVectorLayer.SHAPE_TYPE_POINT; |
|
11 |
public static final int SHAPE_TYPE_LINE = IVectorLayer.SHAPE_TYPE_LINE; |
|
12 |
public static final int SHAPE_TYPE_UNDEFINED = -1; |
|
13 |
|
|
14 |
private int m_iShapeType; |
|
15 |
|
|
16 |
|
|
17 |
public int getShapeType() { |
|
18 |
|
|
19 |
return m_iShapeType; |
|
20 |
|
|
21 |
} |
|
22 |
|
|
23 |
|
|
24 |
public void setShapeType(final int shapeType) { |
|
25 |
|
|
26 |
m_iShapeType = shapeType; |
|
27 |
|
|
28 |
} |
|
29 |
|
|
30 |
|
|
31 |
@Override |
|
32 |
public String toString() { |
|
33 |
|
|
34 |
return this.getClass().toString() + "," + Integer.toString(m_iShapeType); |
|
35 |
|
|
36 |
} |
|
37 |
|
|
38 |
|
|
39 |
} |
|
0 | 40 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/modeler/elements/ModelElementBand.java | ||
---|---|---|
1 |
package es.unex.sextante.modeler.elements; |
|
2 |
|
|
3 |
|
|
4 |
public class ModelElementBand |
|
5 |
implements |
|
6 |
IModelElement { |
|
7 |
|
|
8 |
} |
|
0 | 9 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/core/IMonitorableTask.java | ||
---|---|---|
1 |
package es.unex.sextante.core; |
|
2 |
|
|
3 |
/** |
|
4 |
* A task that can be monitored |
|
5 |
* |
|
6 |
* @author Victor Olaya volaya@unex.es |
|
7 |
* |
|
8 |
*/ |
|
9 |
public interface IMonitorableTask { |
|
10 |
|
|
11 |
/** |
|
12 |
* Returns true if tha task has been canceled |
|
13 |
* |
|
14 |
* @return true if the task has been canceled |
|
15 |
*/ |
|
16 |
public boolean isCanceled(); |
|
17 |
|
|
18 |
|
|
19 |
/** |
|
20 |
* Returns true is the task is finished and is not running anymore |
|
21 |
* |
|
22 |
* @return true is the task is finished and is not running anymore |
|
23 |
*/ |
|
24 |
public boolean isFinished(); |
|
25 |
|
|
26 |
} |
|
0 | 27 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/core/AbstractInputFactory.java | ||
---|---|---|
1 |
package es.unex.sextante.core; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
|
|
5 |
import es.unex.sextante.additionalInfo.AdditionalInfoVectorLayer; |
|
6 |
import es.unex.sextante.dataObjects.I3DRasterLayer; |
|
7 |
import es.unex.sextante.dataObjects.IDataObject; |
|
8 |
import es.unex.sextante.dataObjects.ILayer; |
|
9 |
import es.unex.sextante.dataObjects.IRasterLayer; |
|
10 |
import es.unex.sextante.dataObjects.ITable; |
|
11 |
import es.unex.sextante.dataObjects.IVectorLayer; |
|
12 |
import es.unex.sextante.parameters.RasterLayerAndBand; |
|
13 |
|
|
14 |
public abstract class AbstractInputFactory |
|
15 |
implements |
|
16 |
IInputFactory { |
|
17 |
|
|
18 |
public static final int SHAPE_TYPE_ANY = AdditionalInfoVectorLayer.SHAPE_TYPE_ANY; |
|
19 |
|
|
20 |
protected IDataObject[] m_Objects; |
|
21 |
|
|
22 |
|
|
23 |
public void clearDataObjects() { |
|
24 |
|
|
25 |
m_Objects = null; |
|
26 |
|
|
27 |
} |
|
28 |
|
|
29 |
|
|
30 |
public void removeDataObject(final String sName) { |
|
31 |
|
|
32 |
final ArrayList<IDataObject> list = new ArrayList<IDataObject>(); |
|
33 |
for (int i = 0; i < m_Objects.length; i++) { |
|
34 |
if (!m_Objects[i].getName().equals(sName)) { |
|
35 |
list.add(m_Objects[i]); |
|
36 |
} |
|
37 |
} |
|
38 |
|
|
39 |
m_Objects = list.toArray(new IDataObject[0]); |
|
40 |
|
|
41 |
} |
|
42 |
|
|
43 |
|
|
44 |
public void addDataObject(final IDataObject obj) { |
|
45 |
|
|
46 |
final IDataObject[] newObjects = new IDataObject[m_Objects.length + 1]; |
|
47 |
System.arraycopy(m_Objects, 0, newObjects, 0, m_Objects.length); |
|
48 |
newObjects[m_Objects.length] = obj; |
|
49 |
m_Objects = newObjects; |
|
50 |
|
|
51 |
} |
|
52 |
|
|
53 |
|
|
54 |
public void removeObject(final IDataObject obj) { |
|
55 |
|
|
56 |
final ArrayList<IDataObject> list = new ArrayList(); |
|
57 |
for (int i = 0; i < m_Objects.length; i++) { |
|
58 |
if (m_Objects[i] != obj) { |
|
59 |
list.add(m_Objects[i]); |
|
60 |
} |
|
61 |
} |
|
62 |
m_Objects = list.toArray(new IDataObject[0]); |
|
63 |
} |
|
64 |
|
|
65 |
|
|
66 |
public RasterLayerAndBand[] getBands() { |
|
67 |
|
|
68 |
final ArrayList list = new ArrayList(); |
|
69 |
|
|
70 |
final IRasterLayer[] layers = getRasterLayers(); |
|
71 |
|
|
72 |
for (int i = 0; i < layers.length; i++) { |
|
73 |
for (int j = 0; j < layers[i].getBandsCount(); j++) { |
|
74 |
final RasterLayerAndBand rab = new RasterLayerAndBand(layers[i], j); |
|
75 |
list.add(rab); |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
final RasterLayerAndBand[] bands = new RasterLayerAndBand[list.size()]; |
|
80 |
for (int i = 0; i < list.size(); i++) { |
|
81 |
bands[i] = (RasterLayerAndBand) list.get(i); |
|
82 |
} |
|
83 |
|
|
84 |
return bands; |
|
85 |
|
|
86 |
} |
|
87 |
|
|
88 |
|
|
89 |
public ILayer[] getLayers() { |
|
90 |
|
|
91 |
final ArrayList list = new ArrayList(); |
|
92 |
|
|
93 |
final Object[] objs = getDataObjects(); |
|
94 |
|
|
95 |
for (int i = 0; i < objs.length; i++) { |
|
96 |
if (objs[i] instanceof ILayer) { |
|
97 |
list.add(objs[i]); |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
final ILayer[] layers = new ILayer[list.size()]; |
|
102 |
for (int i = 0; i < layers.length; i++) { |
|
103 |
layers[i] = (ILayer) list.get(i); |
|
104 |
} |
|
105 |
|
|
106 |
return layers; |
|
107 |
|
|
108 |
} |
|
109 |
|
|
110 |
|
|
111 |
public IRasterLayer[] getRasterLayers() { |
|
112 |
|
|
113 |
final ArrayList list = new ArrayList(); |
|
114 |
|
|
115 |
final Object[] objs = getDataObjects(); |
|
116 |
|
|
117 |
for (int i = 0; i < objs.length; i++) { |
|
118 |
if (objs[i] instanceof IRasterLayer) { |
|
119 |
list.add(objs[i]); |
|
120 |
} |
|
121 |
} |
|
122 |
|
|
123 |
final IRasterLayer[] layers = new IRasterLayer[list.size()]; |
|
124 |
for (int i = 0; i < layers.length; i++) { |
|
125 |
layers[i] = (IRasterLayer) list.get(i); |
|
126 |
} |
|
127 |
|
|
128 |
return layers; |
|
129 |
|
|
130 |
} |
|
131 |
|
|
132 |
|
|
133 |
public I3DRasterLayer[] get3DRasterLayers() { |
|
134 |
|
|
135 |
final ArrayList list = new ArrayList(); |
|
136 |
|
|
137 |
final Object[] objs = getDataObjects(); |
|
138 |
|
|
139 |
for (int i = 0; i < objs.length; i++) { |
|
140 |
if (objs[i] instanceof I3DRasterLayer) { |
|
141 |
list.add(objs[i]); |
|
142 |
} |
|
143 |
} |
|
144 |
|
|
145 |
final I3DRasterLayer[] layers = new I3DRasterLayer[list.size()]; |
|
146 |
for (int i = 0; i < layers.length; i++) { |
|
147 |
layers[i] = (I3DRasterLayer) list.get(i); |
|
148 |
} |
|
149 |
|
|
150 |
return layers; |
|
151 |
|
|
152 |
} |
|
153 |
|
|
154 |
|
|
155 |
public IVectorLayer[] getVectorLayers(final int shapeType) { |
|
156 |
|
|
157 |
final ArrayList list = new ArrayList(); |
|
158 |
|
|
159 |
final Object[] objs = getDataObjects(); |
|
160 |
|
|
161 |
for (int i = 0; i < objs.length; i++) { |
|
162 |
if (objs[i] instanceof IVectorLayer) { |
|
163 |
final IVectorLayer layer = (IVectorLayer) objs[i]; |
|
164 |
if (layer.getShapeType() != IVectorLayer.SHAPE_TYPE_WRONG) { |
|
165 |
if ((layer.getShapeType() == shapeType) || (shapeType == SHAPE_TYPE_ANY)) { |
|
166 |
list.add(objs[i]); |
|
167 |
} |
|
168 |
} |
|
169 |
} |
|
170 |
} |
|
171 |
|
|
172 |
final IVectorLayer[] layers = new IVectorLayer[list.size()]; |
|
173 |
for (int i = 0; i < layers.length; i++) { |
|
174 |
layers[i] = (IVectorLayer) list.get(i); |
|
175 |
} |
|
176 |
|
|
177 |
return layers; |
|
178 |
|
|
179 |
} |
|
180 |
|
|
181 |
|
|
182 |
public ITable[] getTables() { |
|
183 |
|
|
184 |
final ArrayList list = new ArrayList(); |
|
185 |
|
|
186 |
final Object[] objs = getDataObjects(); |
|
187 |
|
|
188 |
for (int i = 0; i < objs.length; i++) { |
|
189 |
if (objs[i] instanceof ITable) { |
|
190 |
list.add(objs[i]); |
|
191 |
} |
|
192 |
} |
|
193 |
|
|
194 |
final ITable[] tables = new ITable[list.size()]; |
|
195 |
for (int i = 0; i < tables.length; i++) { |
|
196 |
tables[i] = (ITable) list.get(i); |
|
197 |
} |
|
198 |
|
|
199 |
return tables; |
|
200 |
|
|
201 |
} |
|
202 |
|
|
203 |
|
|
204 |
public IDataObject[] getDataObjects() { |
|
205 |
|
|
206 |
return m_Objects; |
|
207 |
|
|
208 |
} |
|
209 |
|
|
210 |
|
|
211 |
public IDataObject getInputFromName(final String sName) { |
|
212 |
|
|
213 |
for (int i = 0; i < m_Objects.length; i++) { |
|
214 |
if (m_Objects[i].getName().equals(sName)) { |
|
215 |
return m_Objects[i]; |
|
216 |
} |
|
217 |
} |
|
218 |
|
|
219 |
return null; |
|
220 |
|
|
221 |
} |
|
222 |
|
|
223 |
} |
|
0 | 224 |
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.87/org.gvsig.toolbox.core/src/main/java/es/unex/sextante/core/AnalysisExtent.java | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
package es.unex.sextante.core; |
|
4 |
|
|
5 |
import java.awt.geom.Point2D; |
|
6 |
import java.awt.geom.Rectangle2D; |
|
7 |
|
|
8 |
import com.vividsolutions.jts.geom.Coordinate; |
|
9 |
import com.vividsolutions.jts.geom.Geometry; |
|
10 |
import com.vividsolutions.jts.geom.GeometryFactory; |
|
11 |
|
|
12 |
import es.unex.sextante.dataObjects.I3DRasterLayer; |
|
13 |
import es.unex.sextante.dataObjects.ILayer; |
|
14 |
import es.unex.sextante.dataObjects.IRasterLayer; |
|
15 |
import es.unex.sextante.rasterWrappers.Grid3DCell; |
|
16 |
import es.unex.sextante.rasterWrappers.GridCell; |
|
17 |
|
|
18 |
|
|
19 |
/** |
|
20 |
* This class defines an output region (extent coordinates and cellsize) |
|
21 |
* |
|
22 |
* @author Victor Olaya |
|
23 |
* |
|
24 |
*/ |
|
25 |
public class AnalysisExtent { |
|
26 |
|
|
27 |
//these values are cell border coordinates, not centered ones |
|
28 |
double m_dXMin = 0; |
|
29 |
double m_dYMin = 0; |
|
30 |
double m_dZMin = 0; |
|
31 |
double m_dXMax = 0; |
|
32 |
double m_dYMax = 0; |
|
33 |
double m_dZMax = 0; |
|
34 |
double m_dCellSize = 1; |
|
35 |
double m_dCellSizeZ = 1; |
|
36 |
int m_iNX; |
|
37 |
int m_iNY; |
|
38 |
int m_iNZ; |
|
39 |
|
|
40 |
public AnalysisExtent() { |
|
41 |
} |
|
42 |
|
|
43 |
|
|
44 |
/** |
|
45 |
* Creates a new grid extent using the extent of a layer. If it is a raster layer, it will also use its cellsize. If it is a 3d |
|
46 |
* raster layer, it will use its z values |
|
47 |
* |
|
48 |
* @param layer |
|
49 |
* a layer |
|
50 |
*/ |
|
51 |
public AnalysisExtent(final ILayer layer) { |
|
52 |
|
|
53 |
m_dXMin = layer.getFullExtent().getMinX(); |
|
54 |
m_dXMax = layer.getFullExtent().getMaxX(); |
|
55 |
m_dYMin = layer.getFullExtent().getMinY(); |
|
56 |
m_dYMax = layer.getFullExtent().getMaxY(); |
|
57 |
|
|
58 |
if (layer instanceof IRasterLayer) { |
|
59 |
final IRasterLayer rasterLayer = (IRasterLayer) layer; |
|
60 |
m_dCellSize = rasterLayer.getLayerGridExtent().getCellSize(); |
|
61 |
recalculateNXAndNY(); |
|
62 |
} |
|
63 |
else if (layer instanceof I3DRasterLayer) { |
|
64 |
final I3DRasterLayer raster3DLayer = (I3DRasterLayer) layer; |
|
65 |
m_dZMin = raster3DLayer.getLayerExtent().getZMin(); |
|
66 |
m_dZMax = raster3DLayer.getLayerExtent().getZMax(); |
|
67 |
m_dCellSizeZ = raster3DLayer.getCellSizeZ(); |
|
68 |
recalculateNZ(); |
|
69 |
} |
|
70 |
|
|
71 |
} |
|
72 |
|
|
73 |
|
|
74 |
/** |
|
75 |
* Sets a new range for X coordinates. Coordinates are not center cell ones, but border ones |
|
76 |
* |
|
77 |
* @param dXMin |
|
78 |
* the minimum x coordinate of the extent. |
|
79 |
* @param dXMax |
|
80 |
* the maximum x coordinate of the extent |
|
81 |
* @param bRecalculateWithCellsize |
|
82 |
* if this parameter is true, the range will be adapted to match the cellsize. Use this when you are working |
|
83 |
* with raster layers. Make sure that the cellsize has been set in advance. |
|
84 |
*/ |
|
85 |
public void setXRange(final double dXMin, |
|
86 |
final double dXMax, |
|
87 |
final boolean bRecalculateWithCellsize) { |
|
88 |
|
|
89 |
m_dXMin = Math.min(dXMin, dXMax); |
|
90 |
m_dXMax = Math.max(dXMin, dXMax); |
|
91 |
if (bRecalculateWithCellsize) { |
|
92 |
recalculateNXAndNY(); |
|
93 |
} |
|
94 |
|
|
95 |
} |
|
96 |
|
|
97 |
|
|
98 |
/** |
|
99 |
* Sets a new range for Y coordinates. Coordinates are not center cell ones, but border ones |
|
100 |
* |
|
101 |
* @param dYMin |
|
102 |
* the minimum Y coordinate of the extent. |
|
103 |
* @param dYMax |
|
104 |
* the maximum Y coordinate of the extent |
|
105 |
* @param bRecalculateWithCellsize |
|
106 |
* if this parameter is true, the range will be adapted to match the cellsize. Use this when you are working |
|
107 |
* with raster layers. Make sure that the cellsize has been set in advance. |
|
108 |
*/ |
|
109 |
public void setYRange(final double dYMin, |
|
110 |
final double dYMax, |
|
111 |
final boolean bRecalculateWithCellsize) { |
|
112 |
|
|
113 |
m_dYMin = Math.min(dYMin, dYMax); |
|
114 |
m_dYMax = Math.max(dYMin, dYMax); |
|
115 |
if (bRecalculateWithCellsize) { |
|
116 |
recalculateNXAndNY(); |
|
117 |
} |
|
118 |
|
|
119 |
} |
|
120 |
|
|
121 |
|
|
122 |
/** |
|
123 |
* Sets a new range for Z coordinates. Coordinates are not center cell ones, but border ones |
|
124 |
* |
|
125 |
* @param dZMin |
|
126 |
* the minimum z coordinate of the extent. |
|
127 |
* @param dZMax |
|
128 |
* the maximum z coordinate of the extent |
|
129 |
* @param bRecalculateWithCellsize |
|
130 |
* if this parameter is true, the range will be adapted to match the cellsize. Use this when you are working |
|
131 |
* with raster layers. Make sure that the cellsize has been set in advance. |
|
132 |
*/ |
|
133 |
public void setZRange(final double dZMin, |
|
134 |
final double dZMax, |
|
135 |
final boolean bRecalculateWithCellsize) { |
|
136 |
|
|
137 |
m_dZMin = Math.min(dZMin, dZMax); |
|
138 |
m_dZMax = Math.max(dZMin, dZMax); |
|
139 |
if (bRecalculateWithCellsize) { |
|
140 |
recalculateNZ(); |
|
141 |
} |
|
142 |
|
|
143 |
} |
|
144 |
|
|
145 |
|
|
146 |
/** |
|
147 |
* Returns the cellsize of this extent |
|
148 |
* |
|
149 |
* @return the cellsize of this extent |
|
150 |
*/ |
|
151 |
public double getCellSize() { |
|
152 |
|
|
153 |
return m_dCellSize; |
|
154 |
|
|
155 |
} |
|
156 |
|
|
157 |
|
|
158 |
/** |
|
159 |
* Sets a new cellsize for this extent |
|
160 |
* |
|
161 |
* @param cellSize |
|
162 |
* the new cellsize |
|
163 |
*/ |
|
164 |
public void setCellSize(final double cellSize) { |
|
165 |
if (cellSize <= 0) { |
|
166 |
m_dCellSize = 1; |
|
167 |
} else { |
|
168 |
m_dCellSize = cellSize; |
|
169 |
} |
|
170 |
recalculateNXAndNY(); |
|
171 |
|
|
172 |
} |
|
173 |
|
|
174 |
|
|
175 |
/** |
|
176 |
* Returns the z cellsize of this extent |
|
177 |
* |
|
178 |
* @return the z cellsize of this extent |
|
179 |
*/ |
|
180 |
public double getCellSizeZ() { |
|
181 |
|
|
182 |
return m_dCellSizeZ; |
|
183 |
|
|
184 |
} |
|
185 |
|
|
186 |
|
|
187 |
/** |
|
188 |
* Sets a new z cellsize for this extent |
|
189 |
* |
|
190 |
* @param cellSize |
|
191 |
* the new cellsize |
|
192 |
*/ |
|
193 |
public void setCellSizeZ(final double cellSize) { |
|
194 |
|
|
195 |
m_dCellSizeZ = cellSize; |
|
196 |
recalculateNZ(); |
|
197 |
|
|
198 |
} |
|
199 |
|
|
200 |
|
|
201 |
/** |
|
202 |
* Returns the number of columns in the extent |
|
203 |
* |
|
204 |
* @return the number of columns |
|
205 |
*/ |
|
206 |
public int getNX() { |
|
207 |
|
|
208 |
return m_iNX; |
|
209 |
|
|
210 |
} |
|
211 |
|
|
212 |
|
|
213 |
/** |
|
214 |
* Returns the number of rows in the extent |
|
215 |
* |
|
216 |
* @return the number of rows |
|
217 |
*/ |
|
218 |
public int getNY() { |
|
219 |
|
|
220 |
return m_iNY; |
|
221 |
|
|
222 |
} |
|
223 |
|
|
224 |
|
|
225 |
/** |
|
226 |
* Returns the number of rows in the extent |
|
227 |
* |
|
228 |
* @return the number of rows |
|
229 |
*/ |
|
230 |
public int getNZ() { |
|
231 |
|
|
232 |
return m_iNZ; |
|
233 |
|
|
234 |
} |
|
235 |
|
|
236 |
|
|
237 |
private void recalculateNXAndNY() { |
|
238 |
|
|
239 |
m_iNY = (int) Math.floor((m_dYMax - m_dYMin) / m_dCellSize); |
|
240 |
m_iNX = (int) Math.floor((m_dXMax - m_dXMin) / m_dCellSize); |
|
241 |
m_dXMax = m_dXMin + m_dCellSize * m_iNX; |
|
242 |
m_dYMax = m_dYMin + m_dCellSize * m_iNY; |
|
243 |
|
|
244 |
} |
|
245 |
|
|
246 |
|
|
247 |
private void recalculateNZ() { |
|
248 |
|
|
249 |
m_iNZ = (int) Math.floor((m_dZMax - m_dZMin) / m_dCellSizeZ); |
|
250 |
m_dZMax = m_dZMin + m_dCellSizeZ * m_iNZ; |
|
251 |
|
|
252 |
} |
|
253 |
|
|
254 |
|
|
255 |
/** |
|
256 |
* Return the minimum x coordinate of the extent. For raster layers, this is not the coordinate of the center of the left-most |
|
257 |
* cell, but the the coordinate of its left border |
|
258 |
* |
|
259 |
* @return the minimum x coordinate of the extent |
|
260 |
*/ |
|
261 |
public double getXMin() { |
|
262 |
|
|
263 |
return m_dXMin; |
|
264 |
|
|
265 |
} |
|
266 |
|
|
267 |
|
|
268 |
/** |
|
269 |
* Return the maximum x coordinate of the extent. For raster layers, this is not the coordinate of the center of the right-most |
|
270 |
* cell, but the the coordinate of its right border |
|
271 |
* |
|
272 |
* @return the maximum x coordinate of the extent |
|
273 |
*/ |
|
274 |
public double getXMax() { |
|
275 |
|
|
276 |
return m_dXMax; |
|
277 |
|
|
278 |
} |
|
279 |
|
|
280 |
|
|
281 |
/** |
|
282 |
* Return the minimum x coordinate of the extent. For raster layers, this is not the coordinate of the center of the lower |
|
283 |
* cell, but the the coordinate of its lower border |
|
284 |
* |
|
285 |
* @return the minimum y coordinate of the extent |
|
286 |
*/ |
|
287 |
public double getYMin() { |
|
288 |
|
|
289 |
return m_dYMin; |
|
290 |
|
|
291 |
} |
|
292 |
|
|
293 |
|
|
294 |
/** |
|
295 |
* Return the maximum y coordinate of the extent. For raster layers, this is not the coordinate of the center of the upper |
|
296 |
* cell, but the the coordinate of its upper border |
|
297 |
* |
|
298 |
* @return the maximum y coordinate of the extent |
|
299 |
*/ |
|
300 |
public double getYMax() { |
|
301 |
|
|
302 |
return m_dYMax; |
|
303 |
|
|
304 |
} |
|
305 |
|
|
306 |
|
|
307 |
/** |
|
308 |
* Return the minimum z coordinate of the extent. For raster layers, this is not the coordinate of the center of the lower |
|
309 |
* cell, but the the coordinate of its lower border |
|
310 |
* |
|
311 |
* @return the minimum y coordinate of the extent |
|
312 |
*/ |
|
313 |
public double getZMin() { |
|
314 |
|
|
315 |
return m_dZMin; |
|
316 |
|
|
317 |
} |
|
318 |
|
|
319 |
|
|
320 |
/** |
|
321 |
* Return the maximum z coordinate of the extent. For raster layers, this is not the coordinate of the center of the upper |
|
322 |
* cell, but the the coordinate of its upper border |
|
323 |
* |
|
324 |
* @return the maximum z coordinate of the extent |
|
325 |
*/ |
|
326 |
public double getZMax() { |
|
327 |
|
|
328 |
return m_dZMax; |
|
329 |
|
|
330 |
} |
|
331 |
|
|
332 |
|
|
333 |
/** |
|
334 |
* Returns the real X distance spanned by this extent |
|
335 |
* |
|
336 |
* @return the real X distance spanned by this extent |
|
337 |
*/ |
|
338 |
public double getWidth() { |
|
339 |
|
|
340 |
return m_dXMax - m_dXMin; |
|
341 |
|
|
342 |
} |
|
343 |
|
|
344 |
|
|
345 |
/** |
|
346 |
* Returns the real Y distance spanned by this extent |
|
347 |
* |
|
348 |
* @return the real Y distance spanned by this extent |
|
349 |
*/ |
|
350 |
public double getLength() { |
|
351 |
|
|
352 |
return m_dYMax - m_dYMin; |
|
353 |
|
|
354 |
} |
|
355 |
|
|
356 |
|
|
357 |
/** |
|
358 |
* Returns the real Z distance spanned by this extent |
|
359 |
* |
|
360 |
* @return the real Z distance spanned by this extent |
|
361 |
*/ |
|
362 |
public double getHeight() { |
|
363 |
|
|
364 |
return m_dZMax - m_dZMin; |
|
365 |
|
|
366 |
} |
|
367 |
|
|
368 |
|
|
369 |
/** |
|
370 |
* Returns true if the given point falls within the area covered by this extent |
|
371 |
* |
|
372 |
* @param x |
|
373 |
* the x coordinate of the point |
|
374 |
* @param y |
|
375 |
* the y coordinate of the point |
|
376 |
* @return whether the given point falls within the XY area covered by this extent |
|
377 |
*/ |
|
378 |
public boolean contains(final double x, |
|
379 |
final double y) { |
|
380 |
|
|
381 |
return ((x >= m_dXMin) && (x <= m_dXMax) && (y >= m_dYMin) && (y <= m_dYMax)); |
|
382 |
|
|
383 |
} |
|
384 |
|
|
385 |
|
|
386 |
/** |
|
387 |
* Returns true if the given point falls within the area covered by this extent |
|
388 |
* |
|
389 |
* @param x |
|
390 |
* the x coordinate of the point |
|
391 |
* @param y |
|
392 |
* the y coordinate of the point |
|
393 |
* @param z |
|
394 |
* the z coordinate of the point |
|
395 |
* |
|
396 |
* @return whether the given point falls within the volume covered by this extent |
|
397 |
*/ |
|
398 |
public boolean contains(final double x, |
|
399 |
final double y, |
|
400 |
final double z) { |
|
401 |
|
|
402 |
return ((x >= m_dXMin) && (x <= m_dXMax) && (y >= m_dYMin) && (y <= m_dYMax) && (x >= m_dZMin) && (x <= m_dZMax)); |
|
403 |
|
|
404 |
} |
|
405 |
|
|
406 |
|
|
407 |
/** |
|
408 |
* Returns true if the given extent matches the grid defined by this extent extent (has same size and cell boundaries match) |
|
409 |
* |
|
410 |
* @param extent |
|
411 |
* @return whether the passed extent fits into this extent |
|
412 |
*/ |
|
413 |
public boolean fitsIn(final AnalysisExtent extent) { |
|
414 |
|
|
415 |
boolean bFitsX, bFitsY, bFitsZ; |
|
416 |
double dOffset; |
|
417 |
double dOffsetCols; |
|
418 |
double dOffsetRows; |
|
419 |
double dOffsetZ; |
|
420 |
final double MIN_DIF = 0.00001; |
|
421 |
|
|
422 |
if (extent.getCellSize() != this.getCellSize()) { |
|
423 |
return false; |
|
424 |
} |
|
425 |
dOffset = Math.abs(extent.getXMin() - this.getXMin()); |
|
426 |
dOffsetCols = dOffset / this.getCellSize(); |
|
427 |
bFitsX = (dOffsetCols - Math.floor(dOffsetCols + 0.5) < MIN_DIF); |
|
428 |
|
|
429 |
dOffset = Math.abs(extent.getYMax() - this.getYMax()); |
|
430 |
dOffsetRows = dOffset / this.getCellSize(); |
|
431 |
bFitsY = (Math.abs(dOffsetRows - Math.floor(dOffsetRows + 0.5)) < MIN_DIF); |
|
432 |
|
|
433 |
dOffset = Math.abs(extent.getZMax() - this.getZMax()); |
|
434 |
dOffsetZ = dOffset / this.getCellSizeZ(); |
|
435 |
bFitsZ = (Math.abs(dOffsetZ - Math.floor(dOffsetZ + 0.5)) < MIN_DIF); |
|
436 |
|
|
437 |
return bFitsX && bFitsY && bFitsZ; |
|
438 |
|
|
439 |
} |
|
440 |
|
|
441 |
|
|
442 |
/** |
|
443 |
* Returns true if this extent has the same characteristics as a given one |
|
444 |
* |
|
445 |
* @param extent |
|
446 |
* @return whether this extent equals the given extent |
|
447 |
*/ |
|
448 |
public boolean equals(final AnalysisExtent extent) { |
|
449 |
|
|
450 |
return (m_dXMin == extent.getXMin()) && (m_dXMax == extent.getXMax()) && (m_dYMin == extent.getYMin()) |
|
451 |
&& (m_dYMax == extent.getYMax()) && (m_dCellSize == extent.getCellSize()) && (m_dZMin == extent.getZMin()) |
|
452 |
&& (m_dZMax == extent.getZMax()) && (m_dCellSizeZ == extent.getCellSizeZ()); |
|
453 |
|
|
454 |
} |
|
455 |
|
|
456 |
|
|
457 |
/** |
|
458 |
* Modifies this extent to incorporate another one into its boundaries |
|
459 |
* |
|
460 |
* @param extent |
|
461 |
* the extent to add |
|
462 |
*/ |
|
463 |
public void addExtent(final AnalysisExtent extent) { |
|
464 |
|
|
465 |
m_dXMin = Math.min(extent.getXMin(), m_dXMin); |
|
466 |
m_dXMax = Math.max(extent.getXMax(), m_dXMax); |
|
467 |
m_dYMin = Math.min(extent.getYMin(), m_dYMin); |
|
468 |
m_dYMax = Math.max(extent.getYMax(), m_dYMax); |
|
469 |
m_dZMin = Math.min(extent.getZMin(), m_dZMin); |
|
470 |
m_dZMax = Math.max(extent.getZMax(), m_dZMax); |
|
471 |
m_dCellSize = Math.min(extent.getCellSize(), m_dCellSize); |
|
472 |
m_dCellSizeZ = Math.min(extent.getCellSizeZ(), m_dCellSizeZ); |
|
473 |
recalculateNXAndNY(); |
|
474 |
recalculateNZ(); |
|
475 |
|
|
476 |
} |
|
477 |
|
|
478 |
|
|
479 |
/** |
|
480 |
* Modifies this extent to incorporate another one into its boundaries |
|
481 |
* |
|
482 |
* @param extent |
|
483 |
* the extent to add |
|
484 |
*/ |
|
485 |
public void addExtent(final Rectangle2D extent) { |
|
486 |
|
|
487 |
m_dXMin = Math.min(extent.getMinX(), m_dXMin); |
|
488 |
m_dXMax = Math.max(extent.getMaxX(), m_dXMax); |
|
489 |
m_dYMin = Math.min(extent.getMinY(), m_dYMin); |
|
490 |
m_dYMax = Math.max(extent.getMaxY(), m_dYMax); |
|
491 |
recalculateNXAndNY(); |
|
492 |
|
|
493 |
} |
|
494 |
|
|
495 |
|
|
496 |
/** |
|
497 |
* Converts a world coordinate to grid coordinates |
|
498 |
* |
|
499 |
* @param pt |
|
500 |
* a point in world coordinates |
|
501 |
* @return a grid cell with coordinates of the given point in grid coordinates referred to this grid extent |
|
502 |
*/ |
|
503 |
public GridCell getGridCoordsFromWorldCoords(final Point2D pt) { |
|
504 |
|
|
505 |
final int x = (int) Math.floor((pt.getX() - m_dXMin) / m_dCellSize); |
|
506 |
final int y = (int) Math.floor((m_dYMax - pt.getY()) / m_dCellSize); |
|
507 |
|
|
508 |
final GridCell cell = new GridCell(x, y, 0.0); |
|
509 |
|
|
510 |
return cell; |
|
511 |
|
|
512 |
} |
|
513 |
|
|
514 |
|
|
515 |
/** |
|
516 |
* Converts a world coordinate to grid coordinates |
|
517 |
* |
|
518 |
* @param x |
|
519 |
* the x coordinate of the point |
|
520 |
* @param y |
|
521 |
* the y coordinate of the point |
|
522 |
* @return a grid cell representing the given point in grid coordinates referred to this grid extent |
|
523 |
*/ |
|
524 |
public GridCell getGridCoordsFromWorldCoords(final double x, |
|
525 |
final double y) { |
|
526 |
|
|
527 |
return getGridCoordsFromWorldCoords(new Point2D.Double(x, y)); |
|
528 |
|
|
529 |
} |
|
530 |
|
|
531 |
|
|
532 |
public Grid3DCell getGridCoordsFromWorldCoords(final double x, |
|
533 |
final double y, |
|
534 |
final double z) { |
|
535 |
|
|
536 |
final int iX = (int) Math.floor((x - m_dXMin) / m_dCellSize); |
|
537 |
final int iY = (int) Math.floor((m_dYMax - y) / m_dCellSize); |
|
538 |
final int iZ = (int) Math.floor((z - m_dZMin) / m_dCellSizeZ); |
Also available in: Unified diff