Revision 26563 tmp/trunk/cliente/WorkSpace_WPSClient/extWPSCallejero/src/es/logex/gvsig/gui/dialogs/StreetsMapsPaletteDialog.java

View differences:

StreetsMapsPaletteDialog.java
14 14
import javax.swing.JPanel;
15 15
import javax.swing.JTabbedPane;
16 16

  
17
import org.cresques.cts.ICoordTrans;
18
import org.cresques.cts.IProjection;
19

  
17 20
import com.iver.andami.PluginServices;
18 21
import com.iver.andami.ui.mdiManager.IWindow;
19 22
import com.iver.andami.ui.mdiManager.IWindowListener;
20 23
import com.iver.andami.ui.mdiManager.WindowInfo;
21 24
import com.iver.cit.gvsig.fmap.MapControl;
25
import com.iver.cit.gvsig.fmap.crs.CRSFactory;
22 26
import com.iver.cit.gvsig.project.documents.view.gui.BaseView;
27
import com.iver.cit.gvsig.project.documents.view.gui.View;
23 28

  
24 29
import es.logex.gvsig.streetsmap.core.SMProtocolHandler;
25 30
import es.logex.gvsig.streetsmap.core.SMProtocolHandlerFactory;
......
108 113
		}
109 114
	}
110 115

  
116
	private Rectangle2D getProjectedExtent(Rectangle2D extent) {
117
		IProjection defaultServerProjection = CRSFactory
118
				.getCRS(this.streetsMapProtocolHandler.getCrsDefault());
119
		
120
		IProjection viewProjection = ((View) PluginServices.getMDIManager()
121
				.getActiveWindow()).getProjection();
122
		
123
		Rectangle2D projectedExtent = null;
124
		
125
		projectedExtent = extent;
126
		if (!defaultServerProjection.getAbrev().equals(viewProjection.getAbrev())) {
127
			// projectar.
128
			ICoordTrans ct = defaultServerProjection.getCT(viewProjection);
129
			projectedExtent = ct.convert(extent);
130
		}
131

  
132
		return projectedExtent;
133
	}
111 134
	
112 135
	public void DoExtent(QueryResultData newExtent) {
113 136
		if(getView() != null)
114 137
		{
115 138
			MapControl mapCtrl = getView().getMapControl();		
116 139
			Rectangle2D toExtent = (Rectangle2D)newExtent.getUserData();
117

  
140
		
141
			boolean firstTime = false;
142
			
118 143
			try {
119
				mapCtrl.getMapContext().getViewPort().setExtent(toExtent);
120 144
				
145
				
121 146
				if(this.streetsMapProtocolHandler == null)
122 147
				{
123 148
					this.streetsMapProtocolHandler = SMProtocolHandlerFactory.createVersionHandler("1.0.0");
124 149
					this.streetsMapProtocolHandler.initialize(this.hostURL);
150
					firstTime = true;
151
				}
152
				toExtent = getProjectedExtent(toExtent);
153
				mapCtrl.getMapContext().getViewPort().setExtent(toExtent);
154
				
155
				if (firstTime) {
125 156
					this.streetsMapProtocolHandler.attachToToc();
126 157
				}
158
				
127 159
			} catch (ClassNotFoundException e) {
128 160
				// TODO Auto-generated catch block
129 161
				e.printStackTrace();
......
153 185
			QueryResultData q = new QueryResultDataImpl(s);
154 186
			retList.add(q);
155 187
		}
188
		
156 189
		return retList;
157 190
	}
158 191

  

Also available in: Unified diff