Revision 42577 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/operation/fromwkt/FromWKT.java

View differences:

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

  
......
38 37
 *
39 38
 */
40 39
public class FromWKT extends GeometryOperation {
40

  
41 41
    public static final String NAME = GeometryManager.OPERATIONS.FROMWKT;
42
	public static final int CODE = GeometryLocator.getGeometryManager().
43
    	getGeometryOperationCode(NAME);
42
    public static final int CODE = GeometryLocator.getGeometryManager().
43
            getGeometryOperationCode(NAME);
44 44

  
45
	private static WKTParser parser = new WKTParser();
46
	/*
47
	 * (non-Javadoc)
48
	 *
49
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex()
50
	 */
51
	public int getOperationIndex() {
45
    private static final WKTParser parser = new WKTParser();
46
    /*
47
     * (non-Javadoc)
48
     *
49
     * @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex()
50
     */
51

  
52
    @Override
53
    public int getOperationIndex() {
52 54
        return CODE;
53
	}
55
    }
54 56

  
55
	/* (non-Javadoc)
56
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext)
57
	 */
58
	public Object invoke(Geometry geom, GeometryOperationContext ctx)
59
			throws GeometryOperationException {
60
		try {
61
			return parser.read( (String) ctx.getAttribute(FromWKTGeometryOperationContext.TEXT));
62
		} catch (ParseException e) {
63
			throw new GeometryOperationException(geom.getType(),CODE,e);
64
		}
65
	}
57
    /* (non-Javadoc)
58
     * @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext)
59
     */
60
    @Override
61
    public Object invoke(Geometry geom, GeometryOperationContext ctx)
62
            throws GeometryOperationException {
63
        try {
64
            return parser.read((String) ctx.getAttribute(FromWKTGeometryOperationContext.TEXT));
65
        } catch (ParseException e) {
66
            throw new GeometryOperationException(geom.getType(), CODE, e);
67
        }
68
    }
66 69

  
67 70
}

Also available in: Unified diff