Revision 5472
org.gvsig.raster.tools/branches/org.gvsig.raster.tools_proyeccion_al_vuelo/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/RasterExtension.java | ||
---|---|---|
51 | 51 |
import org.gvsig.raster.tools.app.basic.raster.gui.preference.RasterPreferences; |
52 | 52 |
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareDataStoreParametersRaw; |
53 | 53 |
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareDataStoreParametersVTR; |
54 |
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareLayerAskCoordinates; |
|
55 | 54 |
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareLayerAskWritableDirectory; |
56 | 55 |
import org.gvsig.raster.tools.app.basic.raster.process.ClippingProcess; |
57 | 56 |
import org.gvsig.raster.tools.app.basic.tool.analysisview.ViewRasterAnalysisTocMenuEntry; |
... | ... | |
102 | 101 |
*/ |
103 | 102 |
public static boolean autoRefreshView = true; |
104 | 103 |
|
105 |
/** |
|
106 |
* Indica si se debe preguntar las coordenadas al cargar una capa que no las |
|
107 |
* tenga |
|
108 |
*/ |
|
109 |
public static boolean askCoordinates = false; |
|
110 | 104 |
private ExtensionPoint genericToolBarMenuExtensionPoint = null; |
111 | 105 |
|
112 | 106 |
public void execute(String actionCommand) { |
... | ... | |
175 | 169 |
appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareDataStoreParametersRaw()); |
176 | 170 |
appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareDataStoreParametersVTR()); |
177 | 171 |
|
178 |
appGvSigMan.registerPrepareOpenLayer(new PrepareLayerAskCoordinates()); |
|
179 |
|
|
180 | 172 |
appGvSigMan.registerColorTablesFactory(new RasterColorTablesFactory()); |
181 | 173 |
|
182 | 174 |
registerMenuElements(); |
... | ... | |
358 | 350 |
*/ |
359 | 351 |
private void loadConfigurationValues() { |
360 | 352 |
autoRefreshView = Configuration.getValue("general_auto_preview", Boolean.TRUE).booleanValue(); |
361 |
askCoordinates = Configuration.getValue("general_ask_coordinates", Boolean.FALSE).booleanValue(); |
|
362 | 353 |
RasterLibrary.defaultNumberOfClasses = Configuration.getValue("general_defaultNumberOfClasses", Integer.valueOf(RasterLibrary.defaultNumberOfClasses)).intValue(); |
363 | 354 |
RasterLibrary.cacheSize = Configuration.getValue("cache_size", Long.valueOf(RasterLibrary.cacheSize)).longValue(); |
364 | 355 |
RasterLibrary.pageSize = Configuration.getValue("cache_pagesize", Double.valueOf(RasterLibrary.pageSize)).doubleValue(); |
... | ... | |
398 | 389 |
return; |
399 | 390 |
} |
400 | 391 |
|
401 |
if (e.getKey().equals("general_ask_coordinates")) { |
|
402 |
if(e.getValue() instanceof String) |
|
403 |
askCoordinates = new Boolean((String) e.getValue()).booleanValue(); |
|
404 |
if(e.getValue() instanceof Boolean) |
|
405 |
askCoordinates = ((Boolean) e.getValue()).booleanValue(); |
|
406 |
return; |
|
407 |
} |
|
408 |
|
|
409 | 392 |
if (e.getKey().equals("general_defaultNumberOfClasses")) { |
410 | 393 |
if(e.getValue() instanceof String) |
411 | 394 |
try { |
org.gvsig.raster.tools/branches/org.gvsig.raster.tools_proyeccion_al_vuelo/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/layerdatatype/ProcessEndActions.java | ||
---|---|---|
42 | 42 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
43 | 43 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
44 | 44 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
45 |
import org.gvsig.fmap.mapcontext.layers.FLyrDefault; |
|
45 | 46 |
import org.gvsig.raster.algorithm.process.IProcessActions; |
46 | 47 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
47 | 48 |
import org.gvsig.raster.swing.RasterSwingLocator; |
... | ... | |
136 | 137 |
|
137 | 138 |
ProviderServices provServ = RasterLocator.getManager().getProviderServices(); |
138 | 139 |
RasterDataParameters storeParameters = provServ.createParameters(fileName); |
139 |
URI uri; |
|
140 |
try { |
|
141 |
uri = new URI(fileName); |
|
142 |
} catch (URISyntaxException e1) { |
|
143 |
throw new RasterNotLoadException("Can't create URI from "+fileName, e1); |
|
144 |
} |
|
145 |
storeParameters.setURI(uri); |
|
140 |
File file = new File(fileName); |
|
141 |
storeParameters.setURI(file.toURI()); |
|
146 | 142 |
|
147 | 143 |
MapContextManager mcm = MapContextLocator.getMapContextManager(); |
148 | 144 |
|
org.gvsig.raster.tools/branches/org.gvsig.raster.tools_proyeccion_al_vuelo/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/clip/ui/listener/ClippingPanelListener.java | ||
---|---|---|
45 | 45 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
46 | 46 |
import org.gvsig.fmap.dal.coverage.exception.ROIException; |
47 | 47 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
48 |
import org.gvsig.fmap.geom.Geometry; |
|
49 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
50 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
51 |
import org.gvsig.fmap.geom.GeometryManager; |
|
52 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
53 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
54 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
48 | 55 |
import org.gvsig.fmap.geom.primitive.Envelope; |
49 | 56 |
import org.gvsig.fmap.mapcontrol.MapControl; |
50 | 57 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
... | ... | |
76 | 83 |
import org.gvsig.raster.tools.app.basic.tool.clip.ui.panel.ClippingOptionsPanel; |
77 | 84 |
import org.gvsig.raster.tools.app.basic.tool.clip.ui.panel.ClippingResolutionPanel; |
78 | 85 |
import org.gvsig.raster.tools.app.basic.tool.clip.ui.panel.ClippingSelectionPanel; |
86 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
87 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
88 |
import org.slf4j.Logger; |
|
89 |
import org.slf4j.LoggerFactory; |
|
79 | 90 |
|
80 | 91 |
/** |
81 | 92 |
* <code>ClippingPanelListener</code> es una clase donde se recoger?n y |
... | ... | |
84 | 95 |
* @author BorSanZa - Borja S?nchez Zamorano |
85 | 96 |
*/ |
86 | 97 |
public class ClippingPanelListener implements ActionListener, RectangleListener, ButtonsPanelListener, CoordinatesListener, DataInputContainerListener, IProcessActions { |
98 |
|
|
99 |
private static final Logger LOG = LoggerFactory.getLogger(ClippingPanelListener.class); |
|
100 |
|
|
87 | 101 |
private Dimension dim = new Dimension(); |
88 | 102 |
private AffineTransform at = null; |
89 | 103 |
private ClippingPanel clippingPanel = null; |
... | ... | |
558 | 572 |
return; |
559 | 573 |
} |
560 | 574 |
|
561 |
double[] wcValues = data.getWcCoordinatesToClip(); |
|
562 |
double[] pxValues = data.getPxCoordinatesToClip(); |
|
563 |
boolean pxRound = arePixelsRound(pxValues); |
|
564 |
|
|
565 | 575 |
// Seleccionamos las bandas que se usaran en el recorte a partir de la tabla |
566 | 576 |
int countBands = 0; |
567 | 577 |
int rowCount = ((CheckBoxModel) getSelectionPanel().getTableContainer().getModel()).getRowCount(); |
... | ... | |
608 | 618 |
/** |
609 | 619 |
* Preparacion para la generacion del proceso del recorte |
610 | 620 |
*/ |
611 |
if (getFLayer() == null) |
|
612 |
return; |
|
621 |
if (getFLayer() == null){ |
|
622 |
return; |
|
623 |
} |
|
624 |
|
|
625 |
double[] pxValues = data.getPxCoordinatesToClip(); |
|
626 |
boolean pxRound = arePixelsRound(pxValues); |
|
627 |
double[] wcValues = data.getWcCoordinatesToClip(); |
|
628 |
|
|
629 |
if (getFLayer().getCoordTrans() != null) { |
|
613 | 630 |
|
631 |
GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
|
632 |
Envelope envelope = null; |
|
633 |
Envelope storeEnvelope = null; |
|
634 |
Envelope projectedEnvelope = null; |
|
635 |
Extent extent = getFLayer().getDataStore().getExtent(); |
|
636 |
|
|
637 |
try { |
|
638 |
// Create envelope with coordinates of clip area |
|
639 |
envelope = |
|
640 |
geometryManager.createEnvelope(wcValues[0], wcValues[3], wcValues[2], |
|
641 |
wcValues[1], SUBTYPES.GEOM2D); |
|
642 |
|
|
643 |
} catch (CreateEnvelopeException e) { |
|
644 |
String errorMessage = |
|
645 |
String.format("Can not create envelope with [%1d,%1d,%1d,%1d,%1s] parameters", |
|
646 |
wcValues[0], wcValues[3], wcValues[2], wcValues[1], SUBTYPES.GEOM2D); |
|
647 |
LOG.error(errorMessage, e); |
|
648 |
|
|
649 |
ThreadSafeDialogsManager tsdm = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
650 |
tsdm.messageDialog("error_cutting", "_error", |
|
651 |
JOptionPane.ERROR_MESSAGE); |
|
652 |
return; |
|
653 |
} |
|
654 |
|
|
655 |
// Get envelope of raster store |
|
656 |
try { |
|
657 |
storeEnvelope = |
|
658 |
geometryManager.createEnvelope(extent.getMin().getX(), extent.getMin().getY(), |
|
659 |
extent.getMax().getX(), extent.getMax().getY(), SUBTYPES.GEOM2D); |
|
660 |
} catch (CreateEnvelopeException e) { |
|
661 |
String errorMessage = |
|
662 |
String.format("Can not create envelope with [%1d,%1d,%1d,%1d,%1s] parameters", |
|
663 |
extent.getMin().getX(), extent.getMin().getY(), extent.getMax().getX(), |
|
664 |
extent.getMax().getY(), SUBTYPES.GEOM2D); |
|
665 |
LOG.error(errorMessage, e); |
|
666 |
|
|
667 |
ThreadSafeDialogsManager tsdm = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
668 |
tsdm.messageDialog("error_cutting", "_error", |
|
669 |
JOptionPane.ERROR_MESSAGE); |
|
670 |
return; |
|
671 |
} |
|
672 |
|
|
673 |
// Reproject to store projection using layer coordinate transform |
|
674 |
projectedEnvelope = envelope.convert(getFLayer().getCoordTrans().getInverted()); |
|
675 |
try { |
|
676 |
// Get instersection to fix projected envelope |
|
677 |
Geometry intersection = |
|
678 |
projectedEnvelope.getGeometry().intersection(storeEnvelope.getGeometry()); |
|
679 |
projectedEnvelope = geometryManager.createEnvelope(SUBTYPES.GEOM2D); |
|
680 |
projectedEnvelope.add(intersection); |
|
681 |
} catch (GeometryOperationNotSupportedException | GeometryOperationException e) { |
|
682 |
String errorMessage = |
|
683 |
String.format( |
|
684 |
"Can not intersects [%1s] projected envelope with [%1s] store envelope", |
|
685 |
projectedEnvelope, storeEnvelope); |
|
686 |
LOG.error(errorMessage, e); |
|
687 |
|
|
688 |
ThreadSafeDialogsManager tsdm = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
689 |
tsdm.messageDialog("error_cutting", "_error", |
|
690 |
JOptionPane.ERROR_MESSAGE); |
|
691 |
return; |
|
692 |
} catch (CreateEnvelopeException e) { |
|
693 |
String errorMessage = |
|
694 |
String.format("Can not create envelope with [%1s] parameters", SUBTYPES.GEOM2D); |
|
695 |
LOG.error(errorMessage, e); |
|
696 |
|
|
697 |
ThreadSafeDialogsManager tsdm = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
698 |
tsdm.messageDialog("error_cutting", "_error", |
|
699 |
JOptionPane.ERROR_MESSAGE); |
|
700 |
return; |
|
701 |
} |
|
702 |
|
|
703 |
wcValues[0] = projectedEnvelope.getLowerCorner().getX(); |
|
704 |
wcValues[3] = projectedEnvelope.getLowerCorner().getY(); |
|
705 |
wcValues[2] = projectedEnvelope.getUpperCorner().getX(); |
|
706 |
wcValues[1] = projectedEnvelope.getUpperCorner().getY(); |
|
707 |
} |
|
708 |
|
|
614 | 709 |
AffineTransform transf = null; |
615 | 710 |
if(pxRound && |
616 | 711 |
((pxValues[2] - pxValues[0]) == data.getPxWidth()) && |
org.gvsig.raster.tools/branches/org.gvsig.raster.tools_proyeccion_al_vuelo/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/infobypoint/viewtool/InfoByPixelPointViewTool.java | ||
---|---|---|
101 | 101 |
FLayer lyr = layers.getLayer(i); |
102 | 102 |
if(lyr instanceof FLyrRaster) { |
103 | 103 |
FLyrRaster raster = (FLyrRaster)lyr; |
104 |
if(raster.isInside(mapPoint)) {
|
|
105 |
list.add(raster.getName()); |
|
106 |
if(raster.isActive())
|
|
107 |
selected = raster;
|
|
104 |
Point2D tmpPoint = mapPoint;
|
|
105 |
|
|
106 |
if(raster.getCoordTrans() != null){
|
|
107 |
tmpPoint = raster.getCoordTrans().getInverted().convert(mapPoint, null);
|
|
108 | 108 |
} |
109 |
|
|
110 |
if(raster.isInside(tmpPoint)) { |
|
111 |
list.add(raster.getName()); |
|
112 |
if(raster.isActive()) |
|
113 |
selected = raster; |
|
114 |
} |
|
109 | 115 |
} |
110 | 116 |
} |
111 | 117 |
|
112 | 118 |
if(selected != null) { |
119 |
|
|
120 |
if(selected.getCoordTrans() != null){ |
|
121 |
mapPoint = selected.getCoordTrans().getInverted().convert(mapPoint, null); |
|
122 |
} |
|
123 |
|
|
113 | 124 |
Point2D rasterPoint = selected.getDataStore().worldToRaster(mapPoint); |
114 | 125 |
model.setNumberOfBands(selected.getDataStore().getBandCount()); |
115 | 126 |
model.setBandValues(getBandValues(selected.getDataStore(), rasterPoint)); |
org.gvsig.raster.tools/branches/org.gvsig.raster.tools_proyeccion_al_vuelo/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/raster/gui/preference/panel/PreferenceGeneral.java | ||
---|---|---|
44 | 44 |
public class PreferenceGeneral extends BasePanel { |
45 | 45 |
private static final long serialVersionUID = 1L; |
46 | 46 |
private JCheckBox checkBoxPreview = null; |
47 |
private JCheckBox checkBoxCoordinates = null; |
|
48 | 47 |
private JLabel labelNumClases = null; |
49 | 48 |
private JComboBox comboBoxNumClases = null; |
50 |
private JCheckBox checkBoxProjection = null; |
|
51 | 49 |
|
52 | 50 |
/** |
53 | 51 |
*Inicializa componentes gr?ficos y traduce |
... | ... | |
65 | 63 |
getCheckBoxPreview().setText(getText(this, "previsualizar_automaticamente_raster")); |
66 | 64 |
getCheckBoxPreview().setToolTipText(getCheckBoxPreview().getText()); |
67 | 65 |
getLabelNumClases().setText(getText(this, "num_clases") + ":"); |
68 |
getCheckBoxCoordinates().setText(getText(this, "pedir_coordenadas_georreferenciacion")); |
|
69 |
getCheckBoxProjection().setText(getText(this, "ask_for_projection")); |
|
70 | 66 |
} |
71 | 67 |
|
72 | 68 |
protected void init() { |
... | ... | |
98 | 94 |
gridBagConstraints.weightx = 1.0; |
99 | 95 |
gridBagConstraints.insets = new Insets(2, 2, 2, 5); |
100 | 96 |
add(getComboBoxNumClases(), gridBagConstraints); |
101 |
|
|
102 |
gridBagConstraints = new GridBagConstraints(); |
|
103 |
gridBagConstraints.gridx = 0; |
|
104 |
gridBagConstraints.gridy = 2; |
|
105 |
gridBagConstraints.gridwidth = 2; |
|
106 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
|
107 |
gridBagConstraints.anchor = GridBagConstraints.WEST; |
|
108 |
gridBagConstraints.weighty = 1.0; |
|
109 |
gridBagConstraints.insets = new Insets(2, 5, 5, 5); |
|
110 |
add(getCheckBoxCoordinates(), gridBagConstraints); |
|
111 |
|
|
112 |
gridBagConstraints = new GridBagConstraints(); |
|
113 |
gridBagConstraints.gridx = 0; |
|
114 |
gridBagConstraints.gridy = 3; |
|
115 |
gridBagConstraints.gridwidth = 2; |
|
116 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
|
117 |
gridBagConstraints.anchor = GridBagConstraints.WEST; |
|
118 |
gridBagConstraints.insets = new Insets(2, 5, 5, 5); |
|
119 |
add(getCheckBoxProjection(), gridBagConstraints); |
|
120 | 97 |
} |
121 | 98 |
|
122 | 99 |
private JCheckBox getCheckBoxPreview() { |
... | ... | |
142 | 119 |
return comboBoxNumClases; |
143 | 120 |
} |
144 | 121 |
|
145 |
private JCheckBox getCheckBoxCoordinates() { |
|
146 |
if (checkBoxCoordinates == null) { |
|
147 |
checkBoxCoordinates = new JCheckBox(); |
|
148 |
checkBoxCoordinates.setMargin(new Insets(0, 0, 0, 0)); |
|
149 |
} |
|
150 |
return checkBoxCoordinates; |
|
151 |
} |
|
152 |
|
|
153 | 122 |
/** |
154 |
* Obtiene el checkbox que indica si se se muestran las opciones de proyecci?n |
|
155 |
* en la carga de un raster o no. Si se marca no, se aplicar?n siempre las opciones |
|
156 |
* por defecto. |
|
157 |
* @return JCheckBox |
|
158 |
*/ |
|
159 |
private JCheckBox getCheckBoxProjection() { |
|
160 |
if (checkBoxProjection == null) { |
|
161 |
checkBoxProjection = new JCheckBox(); |
|
162 |
checkBoxProjection.setMargin(new Insets(0, 0, 0, 0)); |
|
163 |
} |
|
164 |
return checkBoxProjection; |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 | 123 |
* Establece los valodres por defecto |
169 | 124 |
*/ |
170 | 125 |
public void initializeDefaults() { |
171 |
getCheckBoxCoordinates().setSelected(((Boolean) Configuration.getDefaultValue("general_ask_coordinates")).booleanValue()); |
|
172 |
getCheckBoxProjection().setSelected(((Boolean) Configuration.getDefaultValue("general_ask_projection")).booleanValue()); |
|
173 | 126 |
getCheckBoxPreview().setSelected(((Boolean)Configuration.getDefaultValue("general_auto_preview")).booleanValue()); |
174 | 127 |
Integer defaultNumberOfClasses = (Integer) Configuration.getDefaultValue("general_defaultNumberOfClasses"); |
175 | 128 |
for (int i = 0; i < getComboBoxNumClases().getItemCount(); i++) { |
... | ... | |
184 | 137 |
* Establece los valores que han sido definidas por el usuario |
185 | 138 |
*/ |
186 | 139 |
public void initializeValues() { |
187 |
getCheckBoxCoordinates().setSelected(Configuration.getValue("general_ask_coordinates", Boolean.valueOf(false)).booleanValue()); |
|
188 |
getCheckBoxProjection().setSelected(Configuration.getValue("general_ask_projection", Boolean.valueOf(true)).booleanValue()); |
|
189 | 140 |
getCheckBoxPreview().setSelected(Configuration.getValue("general_auto_preview", Boolean.valueOf(true)).booleanValue()); |
190 | 141 |
Integer defaultNumberOfClasses = Configuration.getValue("general_defaultNumberOfClasses", Integer.valueOf(RasterLibrary.defaultNumberOfClasses)); |
191 | 142 |
for (int i = 0; i < getComboBoxNumClases().getItemCount(); i++) { |
... | ... | |
200 | 151 |
* Guarda los valores que han sido definidas por el usuario |
201 | 152 |
*/ |
202 | 153 |
public void storeValues() { |
203 |
Configuration.setValue("general_ask_coordinates", Boolean.valueOf(getCheckBoxCoordinates().isSelected())); |
|
204 | 154 |
Configuration.setValue("general_auto_preview", Boolean.valueOf(getCheckBoxPreview().isSelected())); |
205 | 155 |
int nClasses = Integer.valueOf(getComboBoxNumClases().getSelectedItem().toString()); |
206 | 156 |
Configuration.setValue("general_defaultNumberOfClasses", nClasses); |
207 | 157 |
RasterLibrary.defaultNumberOfClasses = nClasses; |
208 |
Configuration.setValue("general_ask_projection", Boolean.valueOf(getCheckBoxProjection().isSelected())); |
|
209 | 158 |
} |
210 | 159 |
} |
org.gvsig.raster.tools/branches/org.gvsig.raster.tools_proyeccion_al_vuelo/org.gvsig.raster.tools.algorithm/org.gvsig.raster.tools.algorithm.layerdatatype/src/main/java/org/gvsig/raster/tools/algorithm/layerdatatype/LayerDatatypeProcess.java | ||
---|---|---|
170 | 170 |
break; |
171 | 171 |
} |
172 | 172 |
|
173 |
super.exportRaster(filename, |
|
174 |
buf, |
|
175 |
sourceBuffer.getStore().getCellSize(), |
|
176 |
sourceBuffer.getStore().getExtent().getULX(), |
|
177 |
sourceBuffer.getStore().getExtent().getULY()); |
|
173 |
super.exportRaster(filename, buf, sourceBuffer.getStore().getCellSize(), sourceBuffer |
|
174 |
.getStore().getExtent().getULX(), sourceBuffer.getStore().getExtent().getULY(), |
|
175 |
store.getProjection()); |
|
178 | 176 |
|
179 | 177 |
addOutputValue(FILENAME, filename); |
180 | 178 |
} catch (LayerDatatypeException e) { |
Also available in: Unified diff