Revision 39594

View differences:

branches/v2_0_0_prep/libraries/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/impl/AbstractVectorialLegend.java
53 53
import org.gvsig.fmap.geom.GeometryManager;
54 54
import org.gvsig.fmap.geom.aggregate.Aggregate;
55 55
import org.gvsig.fmap.geom.exception.CreateGeometryException;
56
import org.gvsig.fmap.geom.exception.ReprojectionRuntimeException;
56 57
import org.gvsig.fmap.geom.operation.DrawInts;
57 58
import org.gvsig.fmap.geom.operation.DrawOperationContext;
58 59
import org.gvsig.fmap.geom.operation.GeometryOperationException;
......
527 528

  
528 529
        if (coordTrans != null) {
529 530
            geom = geom.cloneGeometry();
530
            geom.reProject(coordTrans);
531
            try {
532
                geom.reProject(coordTrans);
533
            } catch (ReprojectionRuntimeException re) {
534
                /*
535
                 * Library was unable to reproject
536
                 * See reproject method in Point2D (geometry)
537
                 */
538
                throw new CreateGeometryException(
539
                    geom.getGeometryType().getType(),
540
                    geom.getGeometryType().getSubType(),
541
                    re);
542
            }
531 543
        }
532 544

  
533 545
        if (cancel.isCanceled()) {
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/exception/ReprojectionRuntimeException.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2013 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.geom.exception;
24

  
25
import java.awt.geom.Point2D;
26

  
27
import org.cresques.cts.IProjection;
28

  
29

  
30
/**
31
 * 
32
 * This exception is thrown when the reprojection library is unable to
33
 * reproject and we need to notify that there was a problem
34
 * (so far, the reproject method in Geometry API does not
35
 * throw a standard exception)
36
 * 
37
 * @author jldominguez
38
 *
39
 */
40
public class ReprojectionRuntimeException extends RuntimeException {
41
    
42
    public ReprojectionRuntimeException(
43
        IProjection from_p, IProjection to_p,
44
        Point2D from_point, Throwable cause) {
45
        
46
        super("Error while reprojecting point " + from_point.toString()
47
            + " (" + from_p.getAbrev() + " to " + to_p.getAbrev() + ")",
48
            cause);
49
    }
50

  
51
}
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/impl/Point2D.java
32 32

  
33 33
import org.gvsig.fmap.geom.DirectPosition;
34 34
import org.gvsig.fmap.geom.Geometry;
35
import org.gvsig.fmap.geom.exception.ReprojectionRuntimeException;
35 36
import org.gvsig.fmap.geom.handler.AbstractHandler;
36 37
import org.gvsig.fmap.geom.handler.FinalHandler;
37 38
import org.gvsig.fmap.geom.handler.Handler;
......
194 195

  
195 196
    public void reProject(ICoordTrans ct) {
196 197
        java.awt.geom.Point2D p = getPoint2D();
197
        p = ct.convert(p, p);
198
        this.x = p.getX();
199
        this.y = p.getY();
198
        
199
        try {
200
            p = ct.convert(p, p);
201
            this.x = p.getX();
202
            this.y = p.getY();
203
        } catch (Exception exc) {
204
            /*
205
             * This can happen when the reprojection lib is unable
206
             * to reproject (for example the source point
207
             * is out of the valid range and some computing
208
             * problem happens)
209
             */
210
            throw new ReprojectionRuntimeException(
211
                ct.getPOrig(), ct.getPDest(), getPoint2D(), exc);
212
        }
200 213
    }
201 214

  
202 215
    public Handler[] getStretchingHandlers() {

Also available in: Unified diff