MetodosCambiados.java

Fichero con las soluciones a los errores detectados - Leticia Riestra, 03/04/2013 09:42 AM

Download (3.76 KB)

 
1
//-- Clase EditVertexCADTool.java -- //
2
private Geometry removeVertexGC(MultiPrimitive gc, Handler handler)
3
        throws GeometryOperationNotSupportedException,
4
        GeometryOperationException, CreateGeometryException {
5

    
6
        Primitive prim = null;
7
        int np = gc.getPrimitivesNumber();
8
        
9
        for (int i = 0; i < np; i++) {
10
            prim = gc.getPrimitiveAt(i);
11
            Handler[] hh = prim.getHandlers(Geometry.SELECTHANDLER);
12
            int nh = hh.length;
13
            for (int j=0; j<nh; j++) {
14
                if (hh[j].equalsPoint(handler)) {
15
                    /*
16
                     * Find the first primitive which has a handler
17
                     * matching received handler
18
                     */
19
                    Geometry resp = this.removeVertex(prim, handler);
20
                    for (int k=0; k<np; k++) {
21
                        if (k != i) {
22
                            resp = resp.union(gc.getPrimitiveAt(k));
23
                        }
24
                    }
25
                    if (resp.getType() == Geometry.TYPES.SURFACE){
26
                            MultiSurface geom = createMultiSurface();
27
                            geom.addSurface((Surface)resp);
28
                            return geom;
29
                    }else if (resp.getType() == Geometry.TYPES.POINT){
30
                            MultiPoint geom = createMultiPoint();
31
                            geom.addPoint((Point)resp);
32
                            return geom;
33
                    }else if (resp.getType() == Geometry.TYPES.CURVE){
34
                            MultiCurve geom = createMultiCurve();
35
                            geom.addCurve((Curve)resp);
36
                            return geom;
37
                        }
38
                    return resp;
39
                }
40
            }
41
        }
42
        throw new CreateGeometryException(
43
            new Exception("Unable to remove vertex"));
44
    }
45
        
46
        
47
//-- Clase WKBParser2.java -- //        
48
private MultiSurface parseMultiPolygon(ByteBuffer data)
49
        throws CreateGeometryException {
50
        int count = data.getInt();
51
        
52
        int subType = getSubType(gHaveZ, gHaveM);
53
        MultiSurface multiSurface = (MultiSurface)geomManager.create(TYPES.MULTISURFACE, subType);
54
        
55
        Point point;
56
        for (int i = 0; i < count; i++) {
57
            parseTypeAndSRID(data);
58
            int countRings = data.getInt();
59
            Surface surface = (Surface)geomManager.create(TYPES.SURFACE, subType);
60
            for (int j = 0; j < countRings; j++) {
61
                double[][] points =
62
                    parsePointsAsDoubleArray(data, gHaveZ, gHaveM);
63
                
64
                //Add the initial point
65
                surface.addMoveToVertex(geomManager.createPoint(points[0][0], points[0][1], subType));
66
                
67
                //Add the other points
68
                int lastPoint = points.length - 1;
69
                for (int k=1 ; k<lastPoint ; k++){                    
70
                    point = geomManager.createPoint(points[k][0], points[k][1], subType);
71
                    for (int l=2 ; l<points[k].length ; i++){
72
                        point.setCoordinateAt(l, points[k][l]);
73
                    }
74
                    surface.addVertex(point);
75
                }   
76
                surface.closePrimitive();
77
            }
78
            multiSurface.addSurface(surface);
79
        }        
80
        return multiSurface;
81
}
82
        
83
        
84
private MultiCurve parseMultiLineString(ByteBuffer data) throws CreateGeometryException {
85
                MultiCurve multiCurve = (MultiCurve) geomManager.create(TYPES.MULTICURVE, getSubType(gHaveZ, gHaveM));
86
        Curve curve = (Curve) geomManager.create(TYPES.CURVE, getSubType(gHaveZ, gHaveM));
87
        fillOrientablePrimitive(data, curve);
88
                multiCurve.addCurve(curve);
89
        return multiCurve;
90
}