Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / operation / fromwkb / FromWKB.java @ 29097

History | View | Annotate | Download (2.49 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.exception.CreateGeometryException;
34
import org.gvsig.fmap.geom.operation.GeometryOperation;
35
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
36
import org.gvsig.fmap.geom.operation.GeometryOperationException;
37
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
38

    
39

    
40
/**
41
 * DOCUMENT ME!
42
 *
43
 * @author Vicente Caballero Navarro
44
 */
45
public class FromWKB extends GeometryOperation {
46
    private static WKBParser2 wkbParser = new WKBParser2();
47
    public static final int CODE = GeometryLocator.getGeometryManager()
48
                                                  .registerGeometryOperation("fromWKB",
49
            new FromWKB());
50

    
51
    /* (non-Javadoc)
52
     * @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext)
53
     */
54
    public Object invoke(Geometry geom, GeometryOperationContext ctx)
55
        throws GeometryOperationException {
56
        byte[] data = ((FromWKBGeometryOperationContext) ctx).getData();
57

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

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