Revision 11374

View differences:

trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/TransformationManualPanel.java
369 369
					   tScale.getText() + " ";
370 370
		
371 371
		try {
372
			ICrs crs = new CrsFactory().getCRS(getCode(),
373
					getWKT(),param);
372
			//ICrs crs = new CrsFactory().getCRS(getCode(),getWKT(),param);
373
			ICrs crs = new CrsFactory().getCRS(getCode(),getWKT());
374
			crs.setTransParam(param);
375
			crs.setTransInTarget(false);
374 376
			return crs;
375 377
		} catch (org.gvsig.crs.CrsException e) {
376 378
			e.printStackTrace();
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/TransformationEpsgPanel.java
448 448
		for(int i = 1; i < values.length; i++)
449 449
			params +=","+values[i];
450 450
		try {
451
			ICrs crs = new CrsFactory().getCRS(crs_source_code,
452
					cadWKT,params);
451
			//ICrs crs = new CrsFactory().getCRS(crs_source_code, cadWKT,params);
452
			ICrs crs = new CrsFactory().getCRS(crs_source_code, cadWKT);
453
			crs.setTransParam(params);
454
			crs.setTransInTarget(false);
453 455
			return crs;
454 456
		} catch (org.gvsig.crs.CrsException e) {
455 457
			e.printStackTrace();
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/TransformationRecentsPanel.java
199 199
	public ICrs getProjection() {
200 200
		ICrs crs = null;
201 201
		try {
202
			crs = new CrsFactory().getCRS(getCode(),
203
					getWKT(),getParams());
202
			//crs = new CrsFactory().getCRS(getCode(),getWKT(),getParams());
203
			crs = new CrsFactory().getCRS(getCode(),getWKT());
204
			crs.setTransParam(getParams());
205
			crs.setTransInTarget(false);
204 206
		} catch (CrsException e) {
205 207
			// TODO Auto-generated catch block
206 208
			e.printStackTrace();
......
225 227
				setNad(false);
226 228
				crs = new CrsFactory().getCRS(getCode(),
227 229
						getWKT());
228
				crs.setNadGrid("+nadgrids="+nadFile);//nadFile);
230
				crs.setTransParam("+nadgrids="+nadFile);//nadFile);
229 231
				return crs;
230 232
			} catch (org.gvsig.crs.CrsException e) {
231 233
				e.printStackTrace();
......
237 239
			try {
238 240
				crs = new CrsFactory().getCRS(getCode(),
239 241
						getWKT());
240
				crs.setNadGrid("+nadgrids="+nadFile);//nadFile);
241
				crs.setNadInTarget(true);
242
				crs.setTransParam("+nadgrids="+nadFile);
243
				crs.setTransInTarget(true);
242 244
				
243 245
				return crs;
244 246
			} catch (CrsException e) {				
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/TransformationNadgridsPanel.java
249 249
				setNad(false);
250 250
				crs = new CrsFactory().getCRS(getCode(),
251 251
						getWKT());
252
				crs.setNadGrid("+nadgrids="+getNadFile());//nadFile);
252
				crs.setTransParam("+nadgrids="+getNadFile());
253 253
				return crs;
254 254
			} catch (org.gvsig.crs.CrsException e) {
255 255
				e.printStackTrace();
......
261 261
			try {
262 262
				crs = new CrsFactory().getCRS(getCode(),
263 263
						getWKT());
264
				crs.setNadGrid("+nadgrids="+getNadFile());//nadFile);
265
				crs.setNadInTarget(true);
264
				crs.setTransParam("+nadgrids="+getNadFile());//nadFile);
265
				crs.setTransInTarget(true);
266 266
				
267 267
				return crs;
268 268
			} catch (CrsException e) {				
trunk/libraries/libJCRS/src/org/gvsig/crs/CrsFactory.java
70 70
	 */
71 71
	public ICrs getCRS(String code) throws CrsException {
72 72
		
73
		if (data.containsKey(code))
74
			return (Crs) data.get(code);
75

  
76
		String repoId = code.substring(0, code.indexOf(":"));
77
		String crsCode = code.substring(code.indexOf(":")+1);
73
		/*if (data.containsKey(code))	     // EL CRS no esta identificado univocamente por su c?digo,
74
			return (Crs) data.get(code);*/  // tambien lo caracteriza la informacion sobre transformaciones.
78 75
		
79
		ICrsRepository repo = null;
80 76
		Crs crs = null;
77
		String repoId = "";
78
		String crsCode = "";
79
		String params = "";
81 80
		
82
		if(repoId.equals("EPSG")){
83
			repo = new EpsgRepository();
84
			crs = (Crs)repo.getCrs(crsCode);
85
		}else if (repoId.equals("IAU2000")){
86
			repo = new Iau2000Repository();
87
			crs = (Crs)repo.getCrs(crsCode);
88
		}else if (repoId.equals("ESRI")){
89
			repo = new EsriRepository();
90
			crs = (Crs)repo.getCrs(crsCode);
81
		if(code.indexOf(":", code.indexOf(":")+1)<0){
82
			repoId = code.substring(0, code.indexOf(":"));
83
			crsCode = code.substring(code.indexOf(":")+1);
84
		
85
			ICrsRepository repo = null;
86
			crs = null;
87
			
88
			if(repoId.equals("EPSG")){
89
				repo = new EpsgRepository();
90
				crs = (Crs)repo.getCrs(crsCode);
91
			}else if (repoId.equals("IAU2000")){
92
				repo = new Iau2000Repository();
93
				crs = (Crs)repo.getCrs(crsCode);
94
			}else if (repoId.equals("ESRI")){
95
				repo = new EsriRepository();
96
				crs = (Crs)repo.getCrs(crsCode);
97
			}
91 98
		}
92 99
		
100
		/*
101
		 * En el caso de que code incluya tambi?n par?metros de transformaci?n.
102
		 */
103
		else{ 
104
			crsCode = code.substring(0,code.indexOf(":",code.indexOf(":")+1));
105
			params = code.substring(code.indexOf("@")+1,code.lastIndexOf("@"));
106
			int inTarget = Integer.parseInt(code.substring(code.lastIndexOf("@")+1));
107
			
108
			crs = (Crs)getCRS(crsCode);
109
			crs.setTransParam(params);
110
			if(inTarget == 1)
111
				crs.setTransInTarget(true);
112
			else
113
				crs.setTransInTarget(false);
114
				
115
			//crs = new Crs(Integer.parseInt(crsCode.substring(crsCode.indexOf(":")+1)), crs.getWKT(), params);
116
		}
117
	
93 118
		// LWS Esta l?nea sobra, cuando el cuadro de di?logo est?
94 119
		// mejor hecho.
95
		code = crs.getAbrev();
120
		/*code = crs.getAbrev();
96 121
		
97
		data.put(code, crs);
122
		data.put(code, crs);*/
98 123

  
99 124
		return crs;
100
		
101
		/*if (data.containsKey(code))
102
			return (Crs) data.get(code);
103

  
104
		Crs crs = new Crs(code);
105
		
106
		// LWS Esta l?nea sobra, cuando el cuadro de di?logo est?
107
		// mejor hecho.
108
		code = crs.getAbrev();
109
		
110
		data.put(code, crs);
111

  
112
		return crs;*/
113 125
	}
114 126
	
115 127
	/**
......
120 132
	 * @throws CrsException
121 133
	 */
122 134
	public ICrs getCRS(int epsg_code, String code) throws CrsException {
123
		if (data.containsKey(code))
124
			return (Crs) data.get(code);
135
		
136
		/*if (data.containsKey(code))		 // EL CRS no esta identificado univocamente por su c?digo,
137
			return (Crs) data.get(code);*/	// tambien lo caracteriza la informacion sobre transformaciones.
125 138

  
126 139
		Crs crs = new Crs(epsg_code, code);
127 140
		
128 141
		// LWS Esta l?nea sobra, cuando el cuadro de di?logo est?
129 142
		// mejor hecho.
130
		code = crs.getAbrev();
143
		/*code = crs.getAbrev();
131 144
		
132
		data.put(code, crs);
145
		data.put(code, crs);*/
133 146

  
134 147
		return crs;
135 148
	}
......
143 156
	 * @throws CrsException
144 157
	 */
145 158
	public ICrs getCRS(int epsg_code, String code, String params) throws CrsException {
146
		if (data.containsKey(code))
147
			return (Crs) data.get(code);
148 159
		
160
		/*if (data.containsKey(code))        // EL CRS no esta identificado univocamente por su c?digo,
161
			return (Crs) data.get(code);*/	// tambien lo caracteriza la informacion sobre transformaciones.
162
		
149 163
		Crs crs = new Crs(epsg_code, code,params);
150 164
		
151 165
		// LWS Esta l?nea sobra, cuando el cuadro de di?logo est?
152 166
		// mejor hecho.
153
		code = crs.getAbrev();
167
		/*code = crs.getAbrev();
154 168
		
155
		data.put(code, crs);
169
		data.put(code, crs);*/
156 170

  
157 171
		return crs;
158 172
	}
trunk/libraries/libJCRS/src/org/gvsig/crs/Crs.java
78 78
	private CrsWkt crsWkt;
79 79
	private int epsg_code = 23030;
80 80
	boolean targetNad = false;
81
	String nad = "";
81
	String TransParam = "";
82 82
	String wkt = null;
83 83
	Color gridColor = basicGridColor;
84 84
	CRSDatum datum = null;
......
476 476
	
477 477
	/**
478 478
	 * 
479
	 * @param nad
479
	 * @param param
480 480
	 */
481
	public void setNadGrid(String nad){
482
		this.nad = nad;
481
	public void setTransParam(String param){
482
		this.TransParam = param;
483 483
	}
484 484
	
485 485
	/**
486 486
	 * @return
487 487
	 */
488
	public String getNadGrid(){
489
		return this.nad;
488
	public String getTransParam(){
489
		return this.TransParam;
490 490
	}
491 491
	
492 492
	/**
......
494 494
	 * @return
495 495
	 */
496 496
	public ICOperation getCOp(ICrs target) throws CrsException {		
497
		if (!this.getNadGrid().equals("")) {			
498
			ICrs crs = new Crs(target.getCode(), target.getWKT(), this.getNadGrid());
497
		if (!this.getTransParam().equals("")) {			
498
			ICrs crs = new Crs(target.getCode(), target.getWKT(), this.getTransParam());
499 499
			return new COperation(this, crs);
500 500
		}
501 501
		else return new COperation(this, target);
......
555 555
			e.printStackTrace();
556 556
		}
557 557
		
558
		if (!getNadGrid().equals("")){
559
			if (isTargetNad())
560
				operation.setNadCrsProj(new CrsProj(crsDest.getProj4()+getNadGrid()), true);
558
		if (!getTransParam().equals("")){
559
			if (isTransInTarget())
560
				operation.setNadCrsProj(new CrsProj(crsDest.getProj4()+getTransParam()), true);
561 561
			else
562
				operation.setNadCrsProj(new CrsProj(getProj4()+getNadGrid()), false);
562
				operation.setNadCrsProj(new CrsProj(getProj4()+getTransParam()), false);
563 563
			
564 564
			return operation;
565 565
		}
......
691 691
	/**
692 692
	 * @return
693 693
	 */
694
	public boolean isTargetNad() {
694
	public boolean isTransInTarget() {
695 695
		return targetNad;
696 696
	}
697 697

  
698 698
	/**
699 699
	 * @param targetNad
700 700
	 */
701
	public void setNadInTarget(boolean targetNad) {
701
	public void setTransInTarget(boolean targetNad) {
702 702
		this.targetNad = targetNad;
703 703
	}
704 704

  
......
709 709
	public String getProj4() {
710 710
		return proj4;
711 711
	}
712
	
712

  
713
	public String getFullCode() {
714
		if (!TransParam.equals(""))
715
			if(isTransInTarget())
716
				return getAbrev()+":"+"proj@"+TransParam+"@1";
717
			else
718
				return getAbrev()+":"+"proj@"+TransParam+"@0";
719
		else 
720
			return getAbrev();
721
	}
713 722
}
trunk/libraries/libJCRS/src/org/gvsig/crs/ICrs.java
73 73
	/**
74 74
	 * M?todo para la aplicaci?n de la propiedad de nadgrids
75 75
	 * sobre el CRS destino o fuente 
76
	 * @param nad
76
	 * @param param
77 77
	 */
78
	void setNadGrid(String nad);
78
	void setTransParam(String param);
79 79
	
80 80
	/**
81 81
	 * Cadena nadgrids a utilizar en el crs fuente o destino en una transformacion
82 82
	 * @return
83 83
	 */
84
	String getNadGrid();
84
	String getTransParam();
85 85
	
86 86
	/**
87 87
	 * true si el nadgrid se asocia al crs destino
88 88
	 * @return
89 89
	 */
90
	boolean isTargetNad();
90
	boolean isTransInTarget();
91 91

  
92 92
	/**
93 93
	 * Le indicamos al crs si el nadgrid est? asociado al crs destion al fuente
......
95 95
	 * @param targetNad true si el nadgrid se asocia al crs destino
96 96
	 * @return
97 97
	 */
98
	void setNadInTarget(boolean targetNad);
98
	void setTransInTarget(boolean targetNad);
99 99
	
100 100
	
101 101
	/**

Also available in: Unified diff