Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / operation / fromwkb / FromWKB.java @ 32924

History | View | Annotate | Download (2.45 KB)

1

    
2
/* gvSIG. Geographic Information System of the Valencian Government
3
*
4
* Copyright (C) 2007-2008 Infrastructures and Transports Department
5
* of the Valencian Government (CIT)
6
*
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
* MA  02110-1301, USA.
21
*
22
*/
23

    
24
/*
25
* AUTHORS (In addition to CIT):
26
* ${year} IVER T.I. S.A.   {{Task}}
27
*/
28

    
29
package org.gvsig.fmap.geom.operation.fromwkb;
30

    
31
import org.gvsig.fmap.geom.Geometry;
32
import org.gvsig.fmap.geom.GeometryLocator;
33
import org.gvsig.fmap.geom.GeometryManager;
34
import org.gvsig.fmap.geom.exception.CreateGeometryException;
35
import org.gvsig.fmap.geom.operation.GeometryOperation;
36
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
37
import org.gvsig.fmap.geom.operation.GeometryOperationException;
38

    
39

    
40
/**
41
 * DOCUMENT ME!
42
 *
43
 * @author Vicente Caballero Navarro
44
 */
45
public class FromWKB extends GeometryOperation {
46
    public static final String NAME = GeometryManager.OPERATIONS.FROMWKB;
47
    
48
        public static final int CODE = GeometryLocator.getGeometryManager().
49
            getGeometryOperationCode(NAME);
50
        private static WKBParser2 wkbParser = new WKBParser2();
51
   
52
        /* (non-Javadoc)
53
     * @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext)
54
     */
55
    public Object invoke(Geometry geom, GeometryOperationContext ctx)
56
        throws GeometryOperationException {
57
        byte[] data = ((FromWKBGeometryOperationContext) ctx).getData();
58

    
59
        try {
60
                        return geom = wkbParser.parse(data);
61
                } catch (CreateGeometryException e) {
62
                        return new GeometryOperationException(e);
63
                }
64
    }
65

    
66
    /* (non-Javadoc)
67
     * @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex()
68
     */
69
    public int getOperationIndex() {
70
        return CODE;
71
    }
72
}