Revision 29798

View differences:

branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/towkb/ToWKBNative.java
7 7
import org.gvsig.fmap.geom.operation.GeometryOperationException;
8 8

  
9 9
public class ToWKBNative extends GeometryOperation {
10

  
11

  
12
	public static final int CODE = GeometryLocator.getGeometryManager()
13
			.registerGeometryOperation("toWKBNative", new ToWKBNative());
14

  
10
    public static final String NAME = "toWKBNative";
11
	public static final int CODE = GeometryLocator.getGeometryManager().
12
    	getGeometryOperationCode(NAME);
13
	
15 14
	private static WKBEncoder encoder = new WKBEncoder();
16 15

  
17 16
	public Object invoke(Geometry geom, GeometryOperationContext ctx)
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/towkb/ToWKB.java
9 9
import com.vividsolutions.jts.io.WKBWriter;
10 10

  
11 11
public class ToWKB extends GeometryOperation {
12

  
12
    public static final String NAME = "toWKB";
13
	public static final int CODE = GeometryLocator.getGeometryManager().
14
    	getGeometryOperationCode(NAME);
15
	
13 16
	private static WKBWriter writer = new WKBWriter();
14 17

  
15
	public static final int CODE = GeometryLocator.getGeometryManager()
16
			.registerGeometryOperation("toWKB", new ToWKB());
17

  
18 18
	public Object invoke(Geometry geom, GeometryOperationContext ctx) {
19 19
		if (ctx == null){
20 20
			return writer.write(Converter.geometryToJts(geom));
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/fromwkt/FromWKT.java
43 43
 *
44 44
 */
45 45
public class FromWKT extends GeometryOperation {
46
	public static final int CODE = GeometryLocator.getGeometryManager()
47
			.registerGeometryOperation("fromWKT", new FromWKT());
48

  
46
    public static final String NAME = "fromWKT";
47
	public static final int CODE = GeometryLocator.getGeometryManager().
48
    	getGeometryOperationCode(NAME);	
49
	
49 50
	private static WKTParser parser = new WKTParser();
50 51
	/*
51 52
	 * (non-Javadoc)
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/distance/PointDistance.java
42 42
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
43 43
 */
44 44
public class PointDistance extends GeometryOperation{
45
	public static final int CODE = GeometryLocator.getGeometryManager().registerGeometryOperation("distance", new PointDistance(), TYPES.POINT);
45
    public static final String NAME = "distance";
46
	public static final int CODE = GeometryLocator.getGeometryManager().
47
    	getGeometryOperationCode(NAME);
46 48
	
47 49
	/* (non-Javadoc)
48 50
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex()
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/flip/Flip.java
22 22
 * @author Carlos S?nchez Peri??n <a href = "mailto:csanchez@prodevelop.es"> e-mail </a>
23 23
 */
24 24
public class Flip extends GeometryOperation{
25
   
25
    public static final String NAME = "flip";
26
	public static final int CODE = GeometryLocator.getGeometryManager().
27
    	getGeometryOperationCode(NAME);
28
	
26 29
	private GeneralPathX generalPathX = null;
27 30
    
28
	public static final int CODE = GeometryLocator.getGeometryManager().registerGeometryOperation("flip", new Flip());
29
	
30 31
	public int getOperationIndex() {
31 32
		return CODE;
32 33
	}
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/utils/PointGetAngle.java
44 44
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
45 45
 */
46 46
public class PointGetAngle extends GeometryOperation{
47
	public static final int CODE = GeometryLocator.getGeometryManager().registerGeometryOperation("getAngle", new PointGetAngle());
47
    public static final String NAME = "getAngle";
48
	public static final int CODE = GeometryLocator.getGeometryManager().
49
    	getGeometryOperationCode(NAME);	
48 50

  
49 51
	/* (non-Javadoc)
50 52
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex()
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/impl/DefaultGeometryOperationLibrary.java
48 48
import org.gvsig.fmap.geom.operation.relationship.Disjoint;
49 49
import org.gvsig.fmap.geom.operation.relationship.Equals;
50 50
import org.gvsig.fmap.geom.operation.relationship.Intersects;
51
import org.gvsig.fmap.geom.operation.relationship.Out;
51 52
import org.gvsig.fmap.geom.operation.relationship.Overlaps;
52 53
import org.gvsig.fmap.geom.operation.relationship.Touches;
53 54
import org.gvsig.fmap.geom.operation.relationship.Within;
......
105 106
					GeometryLocator.GEOMETRY_MANAGER_NAME, GeometryLocator.getInstance());
106 107
		}	
107 108
		
108
		geometryManager.registerGeometryOperation("contains", new Contains());
109
		geometryManager.registerGeometryOperation("crosses", new Crosses());
110
		geometryManager.registerGeometryOperation("disjoint", new Disjoint());
111
		geometryManager.registerGeometryOperation("equals", new Equals());
112
		geometryManager.registerGeometryOperation("intersects", new Intersects());
113
		geometryManager.registerGeometryOperation("overlaps", new Overlaps());
114
		geometryManager.registerGeometryOperation("touches", new Touches());
115
		geometryManager.registerGeometryOperation("within", new Within());
116
		geometryManager.registerGeometryOperation("isCCW", new IsCCW());
117
		geometryManager.registerGeometryOperation("fromWKT", new FromWKT());
118
		geometryManager.registerGeometryOperation("fromWKB", new FromWKB());
119
		geometryManager.registerGeometryOperation("flip", new Flip());	
120
		geometryManager.registerGeometryOperation("ensureOrientation",  new EnsureOrientation());		
121
		geometryManager.registerGeometryOperation("toWKB",  new ToWKB());
122
		geometryManager.registerGeometryOperation("toWKBNative",  new ToWKBNative());
123
		geometryManager.registerGeometryOperation("toWKT", new ToWKT());
124
		geometryManager.registerGeometryOperation("distance",  new PointDistance(), TYPES.POINT);
125
		geometryManager.registerGeometryOperation("toJTS", new ToJTS());
126
		geometryManager.registerGeometryOperation("getAngle", new PointGetAngle());
109
		geometryManager.registerGeometryOperation(Contains.NAME, new Contains());
110
		geometryManager.registerGeometryOperation(Crosses.NAME, new Crosses());
111
		geometryManager.registerGeometryOperation(Disjoint.NAME, new Disjoint());
112
		geometryManager.registerGeometryOperation(Equals.NAME, new Equals());
113
		geometryManager.registerGeometryOperation(Intersects.NAME, new Intersects());
114
		geometryManager.registerGeometryOperation(Overlaps.NAME, new Overlaps());
115
		geometryManager.registerGeometryOperation(Touches.NAME, new Touches());
116
		geometryManager.registerGeometryOperation(Within.NAME, new Within());
117
		geometryManager.registerGeometryOperation(IsCCW.NAME, new IsCCW());
118
		geometryManager.registerGeometryOperation(FromWKT.NAME, new FromWKT());
119
		geometryManager.registerGeometryOperation(FromWKB.NAME, new FromWKB());
120
		geometryManager.registerGeometryOperation(Flip.NAME, new Flip());	
121
		geometryManager.registerGeometryOperation(EnsureOrientation.NAME,  new EnsureOrientation());		
122
		geometryManager.registerGeometryOperation(ToWKB.NAME,  new ToWKB());
123
		geometryManager.registerGeometryOperation(ToWKBNative.NAME,  new ToWKBNative());
124
		geometryManager.registerGeometryOperation(ToWKT.NAME, new ToWKT());
125
		geometryManager.registerGeometryOperation(PointDistance.NAME,  new PointDistance(), TYPES.POINT);
126
		geometryManager.registerGeometryOperation(ToJTS.NAME, new ToJTS());
127
		geometryManager.registerGeometryOperation(PointGetAngle.NAME, new PointGetAngle());
128
		geometryManager.registerGeometryOperation(Out.NAME, new Out());
127 129
	}	
128 130
}
129 131

  
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/relationship/Out.java
45 45
 *
46 46
 */
47 47
public class Out extends GeometryOperation {
48
    public static final int CODE = GeometryLocator.getGeometryManager()
49
            .registerGeometryOperation("out", new Out());
50

  
48
    public static final String NAME = "out";
49
	public static final int CODE = GeometryLocator.getGeometryManager().
50
    	getGeometryOperationCode(NAME);
51
	
51 52
    /*
52 53
     * (non-Javadoc)
53 54
     *
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/relationship/Equals.java
45 45
 *
46 46
 */
47 47
public class Equals extends GeometryOperation {
48
    public static final int CODE = GeometryLocator.getGeometryManager()
49
            .registerGeometryOperation("equals", new Equals());
48
    public static final String NAME = "equals";
49
	public static final int CODE = GeometryLocator.getGeometryManager().
50
    	getGeometryOperationCode(NAME);
50 51

  
51 52
    /*
52 53
     * (non-Javadoc)
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/relationship/Touches.java
45 45
 *
46 46
 */
47 47
public class Touches extends GeometryOperation {
48
    public static final int CODE = GeometryLocator.getGeometryManager()
49
            .registerGeometryOperation("touches", new Touches());
48
    public static final String NAME = "touches";
49
	public static final int CODE = GeometryLocator.getGeometryManager().
50
    	getGeometryOperationCode(NAME);
50 51

  
51 52
    /*
52 53
     * (non-Javadoc)
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/relationship/Overlaps.java
43 43
 * 
44 44
 */
45 45
public class Overlaps extends GeometryOperation {
46
	public static final int CODE = GeometryLocator.getGeometryManager()
47
			.registerGeometryOperation("overlaps", new Overlaps());
46
    public static final String NAME = "overlaps";
47
	public static final int CODE = GeometryLocator.getGeometryManager().
48
    	getGeometryOperationCode(NAME);
48 49

  
49 50
	/*
50 51
	 * (non-Javadoc)
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/relationship/Contains.java
45 45
 *
46 46
 */
47 47
public class Contains extends GeometryOperation {
48
    public static final int CODE = GeometryLocator.getGeometryManager()
49
            .registerGeometryOperation("contains", new Contains());
50

  
48
    public static final String NAME = "contains";
49
	public static final int CODE = GeometryLocator.getGeometryManager().
50
    	getGeometryOperationCode(NAME);
51
     
51 52
    /*
52 53
     * (non-Javadoc)
53 54
     *
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/relationship/Crosses.java
45 45
 *
46 46
 */
47 47
public class Crosses extends GeometryOperation {
48
    public static final int CODE = GeometryLocator.getGeometryManager()
49
            .registerGeometryOperation("crosses", new Crosses());
48
	public static final String NAME = "crosses";
49
	public static final int CODE = GeometryLocator.getGeometryManager().
50
		getGeometryOperationCode(NAME);
50 51

  
51
    /*
52
     * (non-Javadoc)
53
     *
54
     * @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex()
55
     */
56
    public int getOperationIndex() {
57
        return CODE;
58
    }
59 52

  
60
    /*
61
     * (non-Javadoc)
62
     *
63
     * @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry,
64
     *      org.gvsig.fmap.geom.operation.GeometryOperationContext)
65
     */
66
    public Object invoke(Geometry geom, GeometryOperationContext ctx)
67
            throws GeometryOperationException {
68
        DefaultRelationshipGeometryOperationContext myCtx = null;
69
        myCtx = (DefaultRelationshipGeometryOperationContext) ctx;
53
	/*
54
	 * (non-Javadoc)
55
	 *
56
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex()
57
	 */
58
	public int getOperationIndex() {
59
		return CODE;
60
	}
70 61

  
71
        Geometry otherGeom = myCtx.getGeom();
72
        if (otherGeom instanceof DefaultNullGeometry || geom instanceof DefaultNullGeometry){
73
            return new Boolean(false);
74
        }
75
        // TODO optimizar esto para los rectangulos (envelope)
76
        com.vividsolutions.jts.geom.Geometry jtsGeom = null;
77
        com.vividsolutions.jts.geom.Geometry otherJtsGeom = null;
78
        try {
79
            jtsGeom = (com.vividsolutions.jts.geom.Geometry) geom
80
                    .invokeOperation(ToJTS.CODE, null);
81
        } catch (GeometryOperationNotSupportedException e) {
82
            throw new GeometryOperationException(geom.getType(), CODE, e);
83
        }
84
        try {
62
	/*
63
	 * (non-Javadoc)
64
	 *
65
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry,
66
	 *      org.gvsig.fmap.geom.operation.GeometryOperationContext)
67
	 */
68
	public Object invoke(Geometry geom, GeometryOperationContext ctx)
69
	throws GeometryOperationException {
70
		DefaultRelationshipGeometryOperationContext myCtx = null;
71
		myCtx = (DefaultRelationshipGeometryOperationContext) ctx;
85 72

  
86
            otherJtsGeom = (com.vividsolutions.jts.geom.Geometry) otherGeom
87
                    .invokeOperation(ToJTS.CODE, null);
88
        } catch (GeometryOperationNotSupportedException e) {
89
            throw new GeometryOperationException(otherGeom.getType(), CODE, e);
90
        }
91
        if (jtsGeom!=null && otherJtsGeom!=null)
92
            return new Boolean(jtsGeom.crosses(otherJtsGeom));
93
        return new Boolean(false);
94
    }
73
		Geometry otherGeom = myCtx.getGeom();
74
		if (otherGeom instanceof DefaultNullGeometry || geom instanceof DefaultNullGeometry){
75
			return new Boolean(false);
76
		}
77
		// TODO optimizar esto para los rectangulos (envelope)
78
		com.vividsolutions.jts.geom.Geometry jtsGeom = null;
79
		com.vividsolutions.jts.geom.Geometry otherJtsGeom = null;
80
		try {
81
			jtsGeom = (com.vividsolutions.jts.geom.Geometry) geom
82
			.invokeOperation(ToJTS.CODE, null);
83
		} catch (GeometryOperationNotSupportedException e) {
84
			throw new GeometryOperationException(geom.getType(), CODE, e);
85
		}
86
		try {
95 87

  
88
			otherJtsGeom = (com.vividsolutions.jts.geom.Geometry) otherGeom
89
			.invokeOperation(ToJTS.CODE, null);
90
		} catch (GeometryOperationNotSupportedException e) {
91
			throw new GeometryOperationException(otherGeom.getType(), CODE, e);
92
		}
93
		if (jtsGeom!=null && otherJtsGeom!=null)
94
			return new Boolean(jtsGeom.crosses(otherJtsGeom));
95
		return new Boolean(false);
96
	}
97

  
96 98
}
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/relationship/Within.java
45 45
 *
46 46
 */
47 47
public class Within extends GeometryOperation {
48
    public static final int CODE = GeometryLocator.getGeometryManager()
49
            .registerGeometryOperation("within", new Within());
48
    public static final String NAME = "within";
49
	public static final int CODE = GeometryLocator.getGeometryManager().
50
    	getGeometryOperationCode(NAME);
50 51

  
51 52
    /*
52 53
     * (non-Javadoc)
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/relationship/Disjoint.java
45 45
 *
46 46
 */
47 47
public class Disjoint extends GeometryOperation {
48
    public static final int CODE = GeometryLocator.getGeometryManager()
49
            .registerGeometryOperation("disjoint", new Disjoint());
48
    public static final String NAME = "disjoint";
49
	public static final int CODE = GeometryLocator.getGeometryManager().
50
    	getGeometryOperationCode(NAME);
50 51

  
51 52
    /*
52 53
     * (non-Javadoc)
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/relationship/Intersects.java
44 44
 *
45 45
 */
46 46
public class Intersects extends GeometryOperation {
47
    public static final int CODE = GeometryLocator.getGeometryManager()
48
            .registerGeometryOperation("intersects", new Intersects());
47
    public static final String NAME = "intersects";
48
	public static final int CODE = GeometryLocator.getGeometryManager().
49
    	getGeometryOperationCode(NAME);
49 50

  
50 51
    /*
51 52
     * (non-Javadoc)
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/tojts/ToJTS.java
7 7
import org.gvsig.fmap.geom.util.Converter;
8 8

  
9 9
public class ToJTS extends GeometryOperation {
10

  
11
	public static final int CODE = GeometryLocator.getGeometryManager()
12
			.registerGeometryOperation("toJTS", new ToJTS());
13

  
10
    public static final String NAME = "toJTS";
11
	public static final int CODE = GeometryLocator.getGeometryManager().
12
    	getGeometryOperationCode(NAME);	
13
	
14 14
	public Object invoke(Geometry geom, GeometryOperationContext ctx) {
15 15
		return Converter.geometryToJts(geom);
16 16
	}
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/fromwkb/FromWKB.java
43 43
 * @author Vicente Caballero Navarro
44 44
 */
45 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)
46
    public static final String NAME = "fromWKB";
47
	public static final int CODE = GeometryLocator.getGeometryManager().
48
    	getGeometryOperationCode(NAME);
49
	private static WKBParser2 wkbParser = new WKBParser2();
50
   
51
	/* (non-Javadoc)
52 52
     * @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext)
53 53
     */
54 54
    public Object invoke(Geometry geom, GeometryOperationContext ctx)
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/isCCW/IsCCW.java
50 50
 * @author Carlos S?nchez Peri??n <a href = "mailto:csanchez@prodevelop.es"> e-mail </a>
51 51
 */
52 52
public class IsCCW extends GeometryOperation{
53

  
54
	private GeneralPathX generalPathX = null;
53
    public static final String NAME = "isCCW";
54
	public static final int CODE = GeometryLocator.getGeometryManager().
55
    	getGeometryOperationCode(NAME);
55 56
	
56
	public static final int CODE = GeometryLocator.getGeometryManager().registerGeometryOperation("isCCW", new IsCCW());
57
	private GeneralPathX generalPathX = null;	
57 58
	
58 59
	public int getOperationIndex() {
59 60
		return CODE;
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/towkt/ToWKT.java
9 9
import com.vividsolutions.jts.io.WKTWriter;
10 10

  
11 11
public class ToWKT extends GeometryOperation {
12

  
12
    public static final String NAME = "toWKT";
13
	public static final int CODE = GeometryLocator.getGeometryManager().
14
    	getGeometryOperationCode(NAME);
15
	
13 16
	private static WKTWriter writer = new WKTWriter();
14 17

  
15
	public static final int CODE = GeometryLocator.getGeometryManager()
16
			.registerGeometryOperation("toWKT", new ToWKT());
17

  
18 18
	public Object invoke(Geometry geom, GeometryOperationContext ctx) {
19 19
		return writer.write(Converter.geometryToJts(geom));
20 20
	}
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/ensureOrientation/EnsureOrientation.java
56 56
 * @author Carlos S?nchez Peri??n <a href = "mailto:csanchez@prodevelop.es"> e-mail </a>
57 57
 */
58 58
public class EnsureOrientation extends GeometryOperation{
59

  
59
    public static final String NAME = "ensureOrientation";
60
	public static final int CODE = GeometryLocator.getGeometryManager().
61
    	getGeometryOperationCode(NAME);
62
	
60 63
	private GeneralPathX generalPathX = null;
61 64
	
62 65
	private Boolean bCCW;
63
	
64
	public static final int CODE = GeometryLocator.getGeometryManager().registerGeometryOperation("ensureOrientation", new EnsureOrientation());
65
	
66
		
66 67
	public int getOperationIndex() {
67 68
		return CODE;
68 69
	}
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/impl/DefaultGeometryManager.java
134 134
		return factory;
135 135
	}
136 136

  
137
	/**
138
	 * Registers the unique name of one operation. If it already exists then this method does nothing but returning
139
	 * the name's corresponding index.
140
	 * @param geomOpName Name used to register the geometry operation
141
	 * @return index assigned to the operation name passed as parameter
142
	 */
143
	private int registerGeometryOperationName(String geomOpName) {
144
		if (geomOpName == null) {
145
			throw new IllegalArgumentException("geomOpName cannot be null.");
146
		}
147

  
148
		int index = geometryOperations.indexOf(geomOpName);
149
		if (index == -1) {
150
			geometryOperations.add(geomOpName);
151
			index = geometryOperations.indexOf(geomOpName);
152
		}
153
		return index;
154
	}
155

  
156

  
157
	//	/**
158
	//	 * Sets a common operation into the common operations map.
159
	//	 * @param index index in which to set the operation
160
	//	 * @param geomOp operation to be set
161
	//	 */
162
	//	private void setCommonOperation(int index, GeometryOperation geomOp) {
163
	//
164
	//		while (index > commonOperations.size()) {
165
	//			commonOperations.add(null);
166
	//		}
167
	//
168
	//		if (index == commonOperations.size()) {
169
	//			commonOperations.add(geomOp);
170
	//		} else {
171
	//			commonOperations.set(index, geomOp);
172
	//		}
173
	//	}
174

  
175 137
	/*
176 138
	 * (non-Javadoc)
177 139
	 * @see org.gvsig.fmap.geom.GeometryManager#registerGeometryOperation(java.lang.String, org.gvsig.fmap.geom.operation.GeometryOperation, org.gvsig.fmap.geom.type.GeometryType)
......
185 147
			throw new IllegalArgumentException("geomType cannot be null.");
186 148
		}
187 149

  
188
		int index = registerGeometryOperationName(geomOpName);
150
		int index = getGeometryOperationCode(geomOpName);
189 151

  
190 152
		geomType.setGeometryOperation(index, geomOp);
191 153

  
......
205 167
			throw new IllegalArgumentException("geomOp cannot be null.");
206 168
		}
207 169

  
208
		int index = registerGeometryOperationName(geomOpName);
170
		int index = getGeometryOperationCode(geomOpName);
209 171

  
210 172
		Iterator it = geometryTypeName.keySet().iterator();
211 173
		while (it.hasNext()){
......
795 757
		return multiSurface;
796 758

  
797 759
	}
760

  
761
	/* (non-Javadoc)
762
	 * @see org.gvsig.fmap.geom.GeometryManager#getGeometryOperationCode(java.lang.String)
763
	 */
764
	public int getGeometryOperationCode(String geomOpName) {
765
		if (geomOpName == null) {
766
			throw new IllegalArgumentException("geomOpName cannot be null.");
767
		}
768

  
769
		int index = geometryOperations.indexOf(geomOpName);
770
		if (index == -1) {
771
			geometryOperations.add(geomOpName);
772
			index = geometryOperations.indexOf(geomOpName);
773
		}
774
		return index;
775
	}
776

  
777
	/* (non-Javadoc)
778
	 * @see org.gvsig.fmap.geom.GeometryManager#getGeometryOperationNames()
779
	 */
780
	public List getGeometryOperationNames() {
781
		ArrayList operations = new ArrayList();
782
		for (int i=0 ; i<operations.size() ; i++){
783
			operations.add(geometryOperations.get(i));
784
		}
785
		return operations;
786
	}
798 787
}
799 788

  
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/GeometryManager.java
40 40
 */
41 41
package org.gvsig.fmap.geom;
42 42

  
43
import java.util.List;
44

  
43 45
import org.gvsig.fmap.geom.aggregate.MultiCurve;
44 46
import org.gvsig.fmap.geom.aggregate.MultiSurface;
45 47
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
......
79 81
	 * Returns an unique index that is used later to identify and invoke the operation.
80 82
	 * </p>
81 83
	 * <p>
82
	 * By convention, the return value should be stored in a public constant within the class implementing
83
	 * the operation:<BR>
84
	 * By convention this index should be in a final and static variable in the 
85
	 * class that implements the operation. The value of this variable must be set 
86
	 * using the method {@link GeometryManager#getGeometryOperationCode(String)}:<BR>	
84 87
	 * <pre>
85 88
	 * public class MyOperation extends GeometryOperation {
86 89
	 *   public static final int CODE =
87 90
	 *     GeometryLocator.getGeometryManager()
88
	 *        .registerGeometryOperation("MyOperation", new MyOperation(), geomType);
91
	 *        .getGeometryOperationCode("MyOperation");
89 92
	 * }
90 93
	 * </pre>
91 94
	 * </p>
......
104 107
	 * Returns an unique index that is used later to identify and invoke the operation.
105 108
	 * </p>
106 109
	 * <p>
107
	 * By convention, the return value should be stored in a public constant within the class implementing
108
	 * the operation:<BR>
110
	 * By convention this index should be in a final and static variable in the 
111
	 * class that implements the operation. The value of this variable must be set 
112
	 * using the method {@link GeometryManager#getGeometryOperationCode(String)}:<BR>	
109 113
	 * <pre>
110 114
	 * public class MyOperation extends GeometryOperation {
111 115
	 *   public static final int CODE =
112 116
	 *     GeometryLocator.getGeometryManager()
113
	 *        .registerGeometryOperation("MyOperation", new MyOperation());
117
	 *        .getGeometryOperationCode("MyOperation");
114 118
	 * }
115 119
	 * </pre>
116 120
	 * </p>
......
128 132
	 * Returns an unique index that is used later to identify and invoke the operation.
129 133
	 * </p>
130 134
	 * <p>
131
	 * By convention, the return value should be stored in a public constant within the class implementing
132
	 * the operation:<BR>
135
	 * By convention this index should be in a final and static variable in the 
136
	 * class that implements the operation. The value of this variable must be set 
137
	 * using the method {@link GeometryManager#getGeometryOperationCode(String)}:<BR>	
133 138
	 * <pre>
134 139
	 * public class MyOperation extends GeometryOperation {
135 140
	 *   public static final int CODE =
136 141
	 *     GeometryLocator.getGeometryManager()
137
	 *        .registerGeometryOperation("MyOperation", new MyOperation(), TYPES.POINT, SUBTYPES.GEOM2D);
142
	 *        .getGeometryOperationCode("MyOperation");
138 143
	 * }
139 144
	 * </pre>
140 145
	 * </p>
......
165 170
	 * Returns an unique index that is used later to identify and invoke the operation.<br>
166 171
	 * </p>
167 172
	 * <p>
168
	 * By convention, the return value should be stored in a public constant within the class implementing
169
	 * the operation:<BR>
173
	 * By convention this index should be in a final and static variable in the 
174
	 * class that implements the operation. The value of this variable must be set 
175
	 * using the method {@link GeometryManager#getGeometryOperationCode(String)}:<BR>	
170 176
	 * <pre>
171 177
	 * public class MyOperation extends GeometryOperation {
172 178
	 *   public static final int CODE =
173 179
	 *     GeometryLocator.getGeometryManager()
174
	 *        .registerGeometryOperation("MyOperation", new MyOperation(), TYPES.POINT);
180
	 *        .getGeometryOperationCode("MyOperation");
175 181
	 * }
176 182
	 * </pre>
177 183
	 * </p>
......
191 197
	 * Returns an unique index that is used later to identify and invoke the operation.<br>
192 198
	 * </p>
193 199
	 * <p>
194
	 * By convention, the return value should be stored in a public constant within the class implementing
195
	 * the operation:<BR>
200
	 * By convention this index should be in a final and static variable in the 
201
	 * class that implements the operation. The value of this variable must be set 
202
	 * using the method {@link GeometryManager#getGeometryOperationCode(String)}:<BR>	
196 203
	 * <pre>
197 204
	 * public class MyOperation extends GeometryOperation {
198 205
	 *   public static final int CODE =
199 206
	 *     GeometryLocator.getGeometryManager()
200
	 *        .registerGeometryOperation("MyOperation", new MyOperation(), SUBTYPES.GEOM2D);
207
	 *        .getGeometryOperationCode("MyOperation");
201 208
	 * }
202 209
	 * </pre>
203 210
	 * </p>
......
362 369
	 * <pre>
363 370
	 * Point point = (Point)GeometryLocator
364 371
	 * 		.getGeometryManager().create("Point2D");
365
	 * 	point.setX(1);
366
	 * 	point.setY(1);
372
	 * point.setX(1);
373
	 * point.setY(1);
367 374
	 * </pre>
368 375
	 *
369 376
	 * @param name
......
590 597
	 * The object returned by an operation, depends on each operation.
591 598
	 */
592 599
	public Object invokeOperation(String geomOpName, Geometry geom, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException;
600
	
601
	/**
602
	 * <p>
603
	 * Registers the unique name of one operation. If it already exists 
604
	 * then this method does nothing but returning the name's corresponding 
605
	 * index.
606
	 * </p>
607
	 * <p>
608
	 * By convention this method is used to set the value of the final and static 
609
	 * variable that is located in the classes that implements the operation:<BR>	
610
	 * <pre>
611
	 * public class MyOperation extends GeometryOperation {
612
	 *   public static final int CODE =
613
	 *     GeometryLocator.getGeometryManager()
614
	 *        .getGeometryOperationCode("MyOperation");
615
	 * }
616
	 * </pre>
617
	 * </p>
618
	 * @param geomOpName
619
	 * Name used to register the geometry operation
620
	 * @return
621
	 * Index assigned to the operation name passed as parameter
622
	 */
623
	public int getGeometryOperationCode(String geomOpName);
624
	
625
	/**
626
	 * Returns a list with the name of the operations that have been
627
	 * registered.
628
	 * @return
629
	 * A list of the registered operations.
630
	 */
631
	public List getGeometryOperationNames();
593 632
}

Also available in: Unified diff