Revision 42531

View differences:

tags/org.gvsig.desktop-2.0.113/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/GeometryLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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.
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.
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.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.fmap.geom;
26

  
27
import org.cresques.ProjectionLibrary;
28

  
29
import org.gvsig.fmap.geom.primitive.Envelope;
30
import org.gvsig.tools.ToolsLibrary;
31
import org.gvsig.tools.ToolsLocator;
32
import org.gvsig.tools.dataTypes.DataTypesManager;
33
import org.gvsig.tools.library.AbstractLibrary;
34
import org.gvsig.tools.library.LibraryException;
35
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
36

  
37
/**
38
 * Registers the default implementation for {@link GeometryManager}.
39
 *
40
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
41
 */
42
public class GeometryLibrary extends AbstractLibrary {
43

  
44
    public void doRegistration() {
45
        registerAsAPI(GeometryLibrary.class);
46
        require(ToolsLibrary.class);
47
        require(ProjectionLibrary.class);
48
    }
49

  
50
    protected void doInitialize() throws LibraryException {
51
    }
52

  
53
    protected void doPostInitialize() throws LibraryException {
54
        // Validate there is any implementation registered.
55
        if(! GeometryLocator.getInstance().exists(GeometryLocator.GEOMETRY_MANAGER_NAME)) {
56
            throw new ReferenceNotRegisteredException(
57
                GeometryLocator.GEOMETRY_MANAGER_NAME,
58
                GeometryLocator.getInstance());
59
        }
60
        DataTypesManager dataTypesManager = ToolsLocator.getDataTypesManager();
61
        dataTypesManager.addtype(DataTypes.GEOMETRY, "Geometry", "Geometry",
62
            Geometry.class, null);
63
        dataTypesManager.addtype(DataTypes.ENVELOPE, "Envelope", "Envelope",
64
            Envelope.class, null);
65

  
66
    }
67
}
0 68

  
tags/org.gvsig.desktop-2.0.113/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/operation/GeometryOperationException.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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.
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.
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.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.operation;
25

  
26
import java.util.HashMap;
27
import java.util.Map;
28

  
29
import org.gvsig.tools.exception.BaseException;
30

  
31
/**
32
 * @author Jorge Piera Llodr? (jorge.piera@iver.es)
33
 */
34
public class GeometryOperationException extends BaseException {
35

  
36
	/**
37
	 * Generated serial version UID
38
	 */
39
	private static final long serialVersionUID = 8230919748601156772L;
40
	private static final String MESSAGE_KEY = "geometry_operation_exception";
41
	private static final String FORMAT_STRING =
42
		"Exception executing the operation with code %(operationCode) for the geometry with type %(geometryType).";
43

  
44
	private int geometryType = -1;
45
	private int operationCode = -1;
46

  
47
	/**
48
	 * Constructor with some context data for cases in which the root cause of
49
	 * <code>this</code> is internal (usually an unsatisfied logic rule).
50
	 * @param geometryType
51
	 * @param operationCode
52
	 */
53
	public GeometryOperationException(int geometryType, int operationCode){
54
		this(geometryType, operationCode, null);
55
	}
56

  
57
	/**
58
	 * Constructor to use when <code>this</code> is caused by another Exception
59
	 * but there is not further context data available.
60
	 * @param e
61
	 */
62
	public GeometryOperationException(Exception e) {
63
		this(-1, -1, e);
64
	}
65

  
66
	/**
67
	 * Main constructor that provides both context data and a cause Exception
68
	 * @param geometryType
69
	 * @param operationCode
70
	 * @param exp
71
	 */
72
	public GeometryOperationException(int geometryType, int operationCode, Exception e) {
73
		super(FORMAT_STRING, e, MESSAGE_KEY, serialVersionUID);
74

  
75
		this.geometryType = geometryType;
76
		this.operationCode = operationCode;
77
	}
78

  
79
	protected Map values() {
80
		HashMap map = new HashMap();
81
		map.put("geometryType", String.valueOf(geometryType));
82
		map.put("operationCode", String.valueOf(operationCode));
83
		return map;
84
	}
85
}
86

  
0 87

  
tags/org.gvsig.desktop-2.0.113/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/operation/GeometryOperation.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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.
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.
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.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.operation;
25

  
26
import org.gvsig.fmap.geom.Geometry;
27
import org.gvsig.fmap.geom.GeometryLocator;
28

  
29
/**
30
 * Every geometry operation that is registered dynamically must extend this class.<br>
31
 *
32
 * The following example shows how to implement and register a custom operation:
33
 *  
34
 * <pre>
35
 * public class MyOperation extends GeometryOperation {
36
 * 
37
 *   // Check GeometryManager for alternative methods to register an operation  
38
 *   public static final int CODE = 
39
 *     GeometryManager.getInstance()
40
 *        .registerGeometryOperation("MyOperation", new MyOperation(), geomType);
41
 *   
42
 *   public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException {
43
 *        // Operation logic goes here
44
 *   }     
45
 *   
46
 *   public int getOperationIndex() {
47
 *      return CODE;
48
 *   }
49
 *   
50
 * }
51
 * </pre>
52
 *
53
 * @author jiyarza
54
 *
55
 */
56
public abstract class GeometryOperation {
57
	
58
	
59
	// Constants for well-known operations to avoid dependency between geometry model and
60
	// operations.
61
	public static final String OPERATION_INTERSECTS_NAME = "intersects";
62
	public static final String OPERATION_CONTAINS_NAME = "contains";
63
	
64
	public static int OPERATION_INTERSECTS_CODE = Integer.MIN_VALUE;
65
	public static int OPERATION_CONTAINS_CODE = Integer.MIN_VALUE;
66

  
67
	
68
	
69
	
70
	/**
71
	 * Invokes this operation given the geometry and context 
72
	 * @param geom Geometry to which apply this operation
73
	 * @param ctx Parameter container
74
	 * @return Place-holder object that may contain any specific return value. 
75
	 * @throws GeometryOperationException The implementation is responsible to throw this exception when needed.
76
	 */
77
	public abstract Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException;
78

  
79
	/**
80
	 * Returns the constant value that identifies this operation and that was obtained upon registering it. 
81
	 * @return operation unique index 
82
	 */
83
	public abstract int getOperationIndex();
84
}
0 85

  
tags/org.gvsig.desktop-2.0.113/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/operation/GeometryOperationContext.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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.
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.
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.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.operation;
25

  
26
import java.util.HashMap;
27
import java.util.Map;
28

  
29
/**
30
 * This class is a default parameter container for geometry operation.<br>
31
 * 
32
 * Normally every GeometryOperation will extend this class and identify
33
 * its parameters publicly with getters/setters
34
 *
35
 * For those operations that need high performance, parameters should be declared as class 
36
 * members instead of using the setAttribute/getAttribute mechanism. This way you avoid a hash
37
 * and a cast operation.
38
 * 
39
 * @author jyarza
40
 *
41
 */
42
public class GeometryOperationContext {
43
	
44
	private Map ctx = new HashMap();
45
	
46
	/**
47
	 * Returns an attribute given its name.
48
	 * If it does not exist returns <code>null</code>
49
	 * @param name
50
	 * @return attribute
51
	 */
52
	public Object getAttribute(String name) {
53
		return ctx.get(name.toLowerCase());
54
	}
55
	
56
	/**
57
	 * Sets an attribute
58
	 * @param name
59
	 * @param value
60
	 */
61
	public GeometryOperationContext setAttribute(String name, Object value) {
62
		ctx.put(name.toLowerCase(), value);
63
		return this;
64
	}
65

  
66
}
0 67

  
tags/org.gvsig.desktop-2.0.113/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/operation/GeometryOperationNotSupportedException.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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.
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.
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.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.operation;
25

  
26
import java.util.HashMap;
27
import java.util.Map;
28

  
29
import org.gvsig.fmap.geom.type.GeometryType;
30
import org.gvsig.tools.exception.BaseException;
31

  
32
public class GeometryOperationNotSupportedException extends BaseException {
33

  
34
	/**
35
	 * Generated UID
36
	 */
37
	private static final long serialVersionUID = -8394502194572892834L;
38

  
39
	/**
40
	 * Constants specific to this BaseException subclass
41
	 */
42
	private static final String MESSAGE_KEY = "Operation_opCode_is_not_registered_for_geomTypeName_type";
43
	private static final String FORMAT_STRING = "Operation %(opCode)s is not registered for '%(geomTypeName)s' type.";
44
	
45
	private String geomTypeName = null;
46
	private int opCode = -1;
47
	
48
	/**
49
	 * Constructor with the operation code of a common operation.
50
	 * @param opCode
51
	 */	
52
	public GeometryOperationNotSupportedException(int opCode) {
53
		this(opCode, null);
54
	}
55
	
56
	/**
57
	 * Constructor with the operation code related to a geometry type
58
	 * @param opCode
59
	 * @param geomType
60
	 */
61
	public GeometryOperationNotSupportedException(int opCode, GeometryType geomType) {
62
		this(opCode, geomType, null);
63
	}
64

  
65
	/**
66
	 * Constructor to use when <code>this</code> is caused by another Exception 
67
	 * but there is not further context data available.
68
	 * @param e
69
	 */
70
	public GeometryOperationNotSupportedException(Exception e) {
71
		this(-1, null, e);
72
	}
73
	
74
	/**
75
	 * Main constructor
76
	 * @param opCode
77
	 * @param geomType
78
	 * @param e
79
	 */
80
	public GeometryOperationNotSupportedException(int opCode, GeometryType geomType, Exception e) {
81
		messageKey = MESSAGE_KEY;
82
		formatString = FORMAT_STRING;
83
		code = serialVersionUID;
84

  
85
		if (e != null) {
86
			initCause(e);
87
		}
88
		if (geomType != null) {
89
			geomTypeName = geomType.getName();
90
		} else {
91
			geomTypeName = "ANY";
92
		}
93
		this.opCode = opCode;
94
	}
95
		
96
	protected Map values() {
97
		HashMap map = new HashMap();
98
		map.put("opCode", Integer.toString(opCode));
99
		map.put("geomTypeName", geomTypeName);
100
		return map;
101
	}
102
	
103
}
0 104

  
tags/org.gvsig.desktop-2.0.113/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/SpatialIndex.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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.
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.
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.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom;
25

  
26
import java.util.Iterator;
27
import java.util.List;
28

  
29
import org.gvsig.fmap.geom.primitive.Envelope;
30
import org.gvsig.tools.service.Service;
31
import org.gvsig.tools.visitor.Visitor;
32

  
33
public 	interface SpatialIndex extends Service {
34
    
35
        public SpatialIndexFactory getFactory();
36
        
37
        public void open();
38
        public void close();
39
    
40
	public void query(Envelope envelope, Visitor visitor);
41
	public void query(Geometry geom, Visitor visitor);
42
        
43
	public Iterator query(Envelope envelope, long limit);
44
	public Iterator query(Envelope envelope);
45
	public Iterator query(Geometry geom, long limit);
46
	public Iterator query(Geometry geom);
47

  
48
       	public Iterator queryNearest(Envelope envelope, long limit);
49
        public Iterator queryNearest(Envelope envelope);
50
	public Iterator queryNearest(Geometry geom, long limit);
51
	public Iterator queryNearest(Geometry geom);
52

  
53
        public Iterator queryAll();
54
	
55
        public List queryAsList(Envelope envelope);
56
	public List queryAsList(Geometry geom);
57
	public List queryAllAsList();
58
	
59
	public void insert(Envelope envelope, Object data);
60
	public void insert(Geometry geom, Object data);
61
        public void insert(Geometry geom);
62

  
63
	public boolean remove(Envelope envelope, Object data);
64
	public boolean remove(Geometry geom, Object data);
65
        public boolean remove(Geometry geom);
66

  
67
        public void removeAll();
68

  
69
        public long size();
70
        
71
        public void flush();
72
}
0 73

  
tags/org.gvsig.desktop-2.0.113/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/GeometryManager.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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.
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.
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.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom;
25

  
26
import java.awt.geom.PathIterator;
27
import java.util.List;
28

  
29
import org.gvsig.fmap.geom.aggregate.MultiCurve;
30
import org.gvsig.fmap.geom.aggregate.MultiLine;
31
import org.gvsig.fmap.geom.aggregate.MultiPoint;
32
import org.gvsig.fmap.geom.aggregate.MultiPolygon;
33
import org.gvsig.fmap.geom.aggregate.MultiPrimitive;
34
import org.gvsig.fmap.geom.aggregate.MultiSurface;
35
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
36
import org.gvsig.fmap.geom.exception.CreateGeometryException;
37
import org.gvsig.fmap.geom.operation.GeometryOperation;
38
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
39
import org.gvsig.fmap.geom.operation.GeometryOperationException;
40
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
41
import org.gvsig.fmap.geom.primitive.Curve;
42
import org.gvsig.fmap.geom.primitive.Envelope;
43
import org.gvsig.fmap.geom.primitive.GeneralPathX;
44
import org.gvsig.fmap.geom.primitive.IGeneralPathX;
45
import org.gvsig.fmap.geom.primitive.Line;
46
import org.gvsig.fmap.geom.primitive.NullGeometry;
47
import org.gvsig.fmap.geom.primitive.OrientablePrimitive;
48
import org.gvsig.fmap.geom.primitive.Point;
49
import org.gvsig.fmap.geom.primitive.Polygon;
50
import org.gvsig.fmap.geom.primitive.Surface;
51
import org.gvsig.fmap.geom.type.GeometryType;
52
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException;
53
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException;
54
import org.gvsig.tools.dynobject.DynObject;
55
import org.gvsig.tools.service.Manager;
56
import org.gvsig.tools.service.ServiceException;
57
import org.gvsig.tools.service.spi.ServiceManager;
58

  
59
/**
60
 * This singleton provides a centralized access to gvSIG's Geometry Model.
61
 * Its responsibilities are:<br>
62
 * 
63
 * <ul>
64
 * <li>Offering a set of convenient methods for registering and retrieving
65
 * geometry types.
66
 * <li>Offering a set of convenient methods for registering and retrieving
67
 * geometry operations associated to one or more geometry types.
68
 * <li>Offering a set of convenient methods for registering and retrieving new
69
 * geometries.
70
 * </ul>
71
 * 
72
 * @author jiyarza
73
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
74
 */
75
public interface GeometryManager extends Manager, ServiceManager {
76

  
77
    public interface OPERATIONS {
78

  
79
        public final static String FROMWKT = "FromWKT";
80
        public final static String FROMWKB = "FromWKB";
81
    }
82

  
83
    /**
84
     * <p>
85
     * Registers a GeometryOperation associated to a GeometryType. Returns an
86
     * unique index that is used later to identify and invoke the operation.
87
     * </p>
88
     * <p>
89
     * By convention this index should be in a final and static variable in the
90
     * class that implements the operation. The value of this variable must be
91
     * set using the method
92
     * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
93
     * 
94
     * <pre>
95
     * 
96
     * public class MyOperation extends GeometryOperation {
97
     * 
98
     *     public static final int CODE = GeometryLocator.getGeometryManager()
99
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
100
     * }
101
     * </pre>
102
     * 
103
     * </p>
104
     * 
105
     * @param geomOpName
106
     *            Operation's unique name
107
     * @param geomOp
108
     *            Specific GeometryOperation's instance implementing this
109
     *            operation
110
     * @param geomType
111
     *            GeometryType instance to which this operation should be
112
     *            associated
113
     * @return Index assigned to this operation. This index is used later to
114
     *         access the operation.
115
     * 
116
     */
117
    public int registerGeometryOperation(String geomOpName,
118
        GeometryOperation geomOp, GeometryType geomType);
119

  
120
    /**
121
     * <p>
122
     * Registers a GeometryOperation that is common for all GeometryType
123
     * (registered yet or not). Returns an unique index that is used later to
124
     * identify and invoke the operation.
125
     * </p>
126
     * <p>
127
     * By convention this index should be in a final and static variable in the
128
     * class that implements the operation. The value of this variable must be
129
     * set using the method
130
     * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
131
     * 
132
     * <pre>
133
     * 
134
     * public class MyOperation extends GeometryOperation {
135
     * 
136
     *     public static final int CODE = GeometryLocator.getGeometryManager()
137
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
138
     * }
139
     * </pre>
140
     * 
141
     * </p>
142
     * 
143
     * @param geomOpName
144
     *            Operation's unique name
145
     * @param geomOp
146
     *            Specific GeometryOperation's instance implementing this
147
     *            operation
148
     * @return Index assigned to this operation. This index is used later to
149
     *         access the operation.
150
     */
151
    public int registerGeometryOperation(String geomOpName,
152
        GeometryOperation geomOp);
153

  
154
    /**
155
     * <p>
156
     * Registers a GeometryOperation associated to a GeometryType, that has been
157
     * specified using the type code and the subtype code. Returns an unique
158
     * index that is used later to identify and invoke the operation.
159
     * </p>
160
     * <p>
161
     * By convention this index should be in a final and static variable in the
162
     * class that implements the operation. The value of this variable must be
163
     * set using the method
164
     * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
165
     * 
166
     * <pre>
167
     * 
168
     * public class MyOperation extends GeometryOperation {
169
     * 
170
     *     public static final int CODE = GeometryLocator.getGeometryManager()
171
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
172
     * }
173
     * </pre>
174
     * 
175
     * </p>
176
     * <p>
177
     * This method is only used if you have not a reference to the GeometryType
178
     * associated to the geometry class. If you have such reference then it is
179
     * slightly faster to use the method that receives the GeometryType.<br>
180
     * </p>
181
     * 
182
     * @param geomOpName
183
     *            Operation's unique name
184
     * @param geomOp
185
     *            Specific GeometryOperation's instance implementing this
186
     *            operation
187
     * @param type
188
     *            Type of geometry. Must be a value defined in
189
     *            {@link Geometry.TYPES}
190
     * @param subType
191
     *            SubType of geometry. Must be a value defined in
192
     *            {@link Geometry.SUBTYPES}
193
     * @return Index assigned to this operation. This index is used later to
194
     *         access the operation.
195
     * @throws GeometryTypeNotSupportedException
196
     *             Returns this exception if there is not a registered geometry
197
     *             with
198
     *             these type and subtype
199
     * @throws GeometryTypeNotValidException
200
     *             Returns if the type and subtype are not valid
201
     */
202
    public int registerGeometryOperation(String geomOpName,
203
        GeometryOperation geomOp, int type, int subType)
204
        throws GeometryTypeNotSupportedException, GeometryTypeNotValidException;
205

  
206
    /**
207
     * <p>
208
     * Registers a GeometryOperation associated to all the geometries with a
209
     * concrete type. Returns an unique index that is used later to identify and
210
     * invoke the operation.<br>
211
     * </p>
212
     * <p>
213
     * By convention this index should be in a final and static variable in the
214
     * class that implements the operation. The value of this variable must be
215
     * set using the method
216
     * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
217
     * 
218
     * <pre>
219
     * 
220
     * public class MyOperation extends GeometryOperation {
221
     * 
222
     *     public static final int CODE = GeometryLocator.getGeometryManager()
223
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
224
     * }
225
     * </pre>
226
     * 
227
     * </p>
228
     * 
229
     * @param geomOpName
230
     *            Operation's unique name
231
     * @param geomOp
232
     *            Specific GeometryOperation's instance implementing this
233
     *            operation
234
     * @param type
235
     *            Type of geometry. Must be a value defined in
236
     *            {@link Geometry.TYPES}
237
     * @return Index assigned to this operation. This index is used later to
238
     *         access the operation.
239
     */
240
    public int registerGeometryOperation(String geomOpName,
241
        GeometryOperation geomOp, int type);
242
    
243
    /**
244
     * <p>
245
     * Registers a GeometryOperation associated to all the geometries which
246
     * super type matches with a concrete type. Returns an unique index that 
247
     * is used later to identify and invoke the operation.<br>
248
     * </p>
249
     * <p>
250
     * By convention this index should be in a final and static variable in the
251
     * class that implements the operation. The value of this variable must be
252
     * set using the method
253
     * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
254
     * 
255
     * <pre>
256
     * 
257
     * public class MyOperation extends GeometryOperation {
258
     * 
259
     *     public static final int CODE = GeometryLocator.getGeometryManager()
260
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
261
     * }
262
     * </pre>
263
     * 
264
     * </p>
265
     * 
266
     * @param geomOpName
267
     *            Operation's unique name
268
     * @param geomOp
269
     *            Specific GeometryOperation's instance implementing this
270
     *            operation
271
     * @param superType
272
     *            super type of geometries that is used to register
273
     *            the operation. Must be a value defined in
274
     *            {@link Geometry.TYPES}
275
     * @return Index assigned to this operation. This index is used later to
276
     *         access the operation.
277
     */
278
    public int registerGeometryOperationBySuperType(String geomOpName,
279
        GeometryOperation geomOp, int superType);
280
    
281
    /**
282
     * <p>
283
     * Registers a GeometryOperation associated to all the geometries which
284
     * super subType matches with a concrete subType. Returns an unique index that 
285
     * is used later to identify and invoke the operation.<br>
286
     * </p>
287
     * <p>
288
     * By convention this index should be in a final and static variable in the
289
     * class that implements the operation. The value of this variable must be
290
     * set using the method
291
     * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
292
     * 
293
     * <pre>
294
     * 
295
     * public class MyOperation extends GeometryOperation {
296
     * 
297
     *     public static final int CODE = GeometryLocator.getGeometryManager()
298
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
299
     * }
300
     * </pre>
301
     * 
302
     * </p>
303
     * 
304
     * @param geomOpName
305
     *            Operation's unique name
306
     * @param geomOp
307
     *            Specific GeometryOperation's instance implementing this
308
     *            operation
309
     * @param superSubType
310
     *            super subType of geometries that is used to register
311
     *            the operation. Must be a value defined in
312
     *            {@link Geometry.SUBTYPES}
313
     * @return Index assigned to this operation. This index is used later to
314
     *         access the operation.
315
     */
316
    public int registerGeometryOperationBySuperSubType(String geomOpName,
317
        GeometryOperation geomOp, int superSubType);
318

  
319
    /**
320
     * <p>
321
     * Registers a GeometryOperation associated to all the geometries with a
322
     * concrete subtype. Returns an unique index that is used later to identify
323
     * and invoke the operation.<br>
324
     * </p>
325
     * <p>
326
     * By convention this index should be in a final and static variable in the
327
     * class that implements the operation. The value of this variable must be
328
     * set using the method
329
     * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
330
     * 
331
     * <pre>
332
     * 
333
     * public class MyOperation extends GeometryOperation {
334
     * 
335
     *     public static final int CODE = GeometryLocator.getGeometryManager()
336
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
337
     * }
338
     * </pre>
339
     * 
340
     * </p>
341
     * 
342
     * @param geomOpName
343
     *            Operation's unique name
344
     * @param geomOp
345
     *            Specific GeometryOperation's instance implementing this
346
     *            operation
347
     * @param subType
348
     *            SubType of geometry. Must be a value defined in
349
     *            {@link Geometry.SUBTYPES}
350
     * @return Index assigned to this operation. This index is used later to
351
     *         access the operation.
352
     */
353
    public int registerGeometryOperationBySubtype(String geomOpName,
354
        GeometryOperation geomOp, int subType);
355

  
356
    /**
357
     * <p>
358
     * Registers a GeometryType instance. 
359
     * </p>
360
     * 
361
     * @param geometryType
362
     *            A {@link GeometryType} instance to create {@link Geometry} objects
363
     */
364
    public void registerGeometryType(GeometryType geometryType);
365
    
366
    /**
367
     * <p>
368
     * Registers a Geometry implementation class with a predefined geometry type
369
     * and returns the associated GeometryType instance. Available predefined
370
     * types are defined in {@link Geometry.TYPES} and the subtypes are defined
371
     * in {@link Geometry.SUBTYPES}.
372
     * </p>
373
     * <p>
374
     * How to register a geometry class with a predefined type:
375
     * 
376
     * <pre>
377
     * 
378
     * GeometryType geomType = GeometryLocator.getGeometryManager()
379
     *     .registerBasicGeometryType(Point2D.class, &quot;Point2D&quot;, Geometry.TYPES.POINT,
380
     *         Geometry.SYBTYPES.GEOM2D);
381
     * </pre>
382
     * 
383
     * </p>
384
     * 
385
     * @param geomClass
386
     *            Geometry subclass. It must not be null and must implement
387
     *            Geometry, otherwise an exception
388
     *            is raised.
389
     * @param name
390
     *            Symbolic name for the geometry type, it can be null. If it is
391
     *            null then the symbolic name
392
     *            will be the simple class name.
393
     * @param type
394
     *            Type of geometry. Must be a value defined in
395
     *            {@link Geometry.TYPES}
396
     * @param subType
397
     *            SubType of geometry. Must be a value defined in
398
     *            {@link Geometry.SUBTYPES}
399
     * @return Instance of GeometryType associated to the Geometry
400
     *         implementation class
401
     *         geomClass
402
     * @throws IllegalArgumentException
403
     *             If geomClass is null or does not implement Geometry
404
     */
405
    public GeometryType registerGeometryType(Class geomClass, String name,
406
        int type, int subType);
407
    
408
    /**
409
     * <p>
410
     * Registers a Geometry implementation class with a predefined geometry type
411
     * and returns the associated GeometryType instance. Available predefined
412
     * types are defined in {@link Geometry.TYPES} and the subtypes are defined
413
     * in {@link Geometry.SUBTYPES}.    
414
     * </p>
415
     * <p>
416
     * It adds also the super type and the super subType of the geometry, that
417
     * can be used to check if the type (or the subtype) inherits of other 
418
     * type (or subType)
419
     * </p>
420
     * <p>
421
     * How to register a geometry class with a predefined type:
422
     * 
423
     * <pre>
424
     * 
425
     * GeometryType geomType = GeometryLocator.getGeometryManager()
426
     *     .registerBasicGeometryType(Arc3D.class, &quot;Arc3D&quot;, Geometry.TYPES.ARC,
427
     *         Geometry.SYBTYPES.GEOM3D, Geometry.TYPES.CURVE, Geometry.SYBTYPES.GEOM2D);
428
     * </pre>
429
     * 
430
     * </p>
431
     * 
432
     * @param geomClass
433
     *            Geometry subclass. It must not be null and must implement
434
     *            Geometry, otherwise an exception
435
     *            is raised.
436
     * @param name
437
     *            Symbolic name for the geometry type, it can be null. If it is
438
     *            null then the symbolic name
439
     *            will be the simple class name.
440
     * @param type
441
     *            Type of geometry. Must be a value defined in
442
     *            {@link Geometry.TYPES}
443
     * @param subType
444
     *            SubType of geometry. Must be a value defined in
445
     *            {@link Geometry.SUBTYPES}
446
     * @param superType
447
     *              Super type of a geometry. Must be a value defined in
448
     *            {@link Geometry.TYPES}
449
     * @param superSubType
450
     *             Super subType of a geometry. Must be a value defined in
451
     *            {@link Geometry.SUBTYPES}
452
     * @return Instance of GeometryType associated to the Geometry
453
     *         implementation class
454
     *         geomClass
455
     * @throws IllegalArgumentException
456
     *             If geomClass is null or does not implement Geometry
457
     */
458
    public GeometryType registerGeometryType(Class geomClass, String name,
459
        int type, int subType, int superType, int superSubType);
460
    
461
    /**
462
     * <p>
463
     * Registers a Geometry implementation class with a predefined geometry type
464
     * and returns the associated GeometryType instance. Available predefined
465
     * types are defined in {@link Geometry.TYPES} and the subtypes are defined
466
     * in {@link Geometry.SUBTYPES}.    
467
     * </p>
468
     * <p>
469
     * It adds also the super type of the geometry, that can be used to 
470
     * check if the type inherits of other type.
471
     * </p>
472
     * <p>
473
     * How to register a geometry class with a predefined type:
474
     * 
475
     * <pre>
476
     * 
477
     * GeometryType geomType = GeometryLocator.getGeometryManager()
478
     *     .registerBasicGeometryType(Arc3D.class, &quot;Arc3D&quot;, Geometry.TYPES.ARC,
479
     *         Geometry.SYBTYPES.GEOM3D, Geometry.TYPES.CURVE);
480
     * </pre>
481
     * 
482
     * </p>
483
     * 
484
     * @param geomClass
485
     *            Geometry subclass. It must not be null and must implement
486
     *            Geometry, otherwise an exception
487
     *            is raised.
488
     * @param name
489
     *            Symbolic name for the geometry type, it can be null. If it is
490
     *            null then the symbolic name
491
     *            will be the simple class name.
492
     * @param type
493
     *            Type of geometry. Must be a value defined in
494
     *            {@link Geometry.TYPES}
495
     * @param subType
496
     *            SubType of geometry. Must be a value defined in
497
     *            {@link Geometry.SUBTYPES}
498
     * @param superType
499
     *              Super type of a geometry. Must be a value defined in
500
     *            {@link Geometry.TYPES}   
501
     * @return Instance of GeometryType associated to the Geometry
502
     *         implementation class
503
     *         geomClass
504
     * @throws IllegalArgumentException
505
     *             If geomClass is null or does not implement Geometry
506
     */
507
    public GeometryType registerGeometryType(Class geomClass, String name,
508
        int type, int subType, int superType);
509
    
510
    /**
511
     * <p>
512
     * Registers a Geometry implementation class with a predefined geometry type
513
     * and returns the associated GeometryType instance. Available predefined
514
     * types are defined in {@link Geometry.TYPES} and the subtypes are defined
515
     * in {@link Geometry.SUBTYPES}.    
516
     * </p>
517
     * <p>
518
     * It adds also the super types and the super subTypes of the geometry, that
519
     * can be used to check if the type (or the subtype) inherits of other 
520
     * types (or subTypes)
521
     * </p>
522
     * <p>
523
     * How to register a geometry class with a predefined type:
524
     * 
525
     * <pre>
526
     * 
527
     * GeometryType geomType = GeometryLocator.getGeometryManager()
528
     *     .registerBasicGeometryType(Circle3DM.class, &quot;Circle3DM&quot;, Geometry.TYPES.CIRCLE,
529
     *         Geometry.SYBTYPES.GEOM3DM,
530
     *         new int[]{Geometry.TYPES.CURVE, Geometry.TYPES.GEOMETRY},
531
     *         new int[]{Geometry.SYBTYPES.GEOM2D, Geometry.SYBTYPES.GEOM3D});
532
     * </pre>
533
     * 
534
     * </p>
535
     * 
536
     * @param geomClass
537
     *            Geometry subclass. It must not be null and must implement
538
     *            Geometry, otherwise an exception
539
     *            is raised.
540
     * @param name
541
     *            Symbolic name for the geometry type, it can be null. If it is
542
     *            null then the symbolic name
543
     *            will be the simple class name.
544
     * @param type
545
     *            Type of geometry. Must be a value defined in
546
     *            {@link Geometry.TYPES}
547
     * @param subType
548
     *            SubType of geometry. Must be a value defined in
549
     *            {@link Geometry.SUBTYPES}
550
     * @param superTypes
551
     *              List of the super types of a geometry. Must be a value defined in
552
     *            {@link Geometry.TYPES}
553
     * @param superSubTypes
554
     *             List of the super subType of a geometry. Must be a value defined in
555
     *            {@link Geometry.SUBTYPES}
556
     * @return Instance of GeometryType associated to the Geometry
557
     *         implementation class
558
     *         geomClass
559
     * @throws IllegalArgumentException
560
     *             If geomClass is null or does not implement Geometry
561
     */
562
    public GeometryType registerGeometryType(Class geomClass, String name,
563
        int type, int subType, int[] superTypes, int superSubTypes[]);
564
    
565
    /**
566
     * <p>
567
     * Registers a Geometry implementation class with a predefined geometry type
568
     * and returns the associated GeometryType instance. Available predefined
569
     * types are defined in {@link Geometry.TYPES} and the subtypes are defined
570
     * in {@link Geometry.SUBTYPES}.    
571
     * </p>
572
     * <p>
573
     * It adds also the super types and the super subTypes of the geometry, that
574
     * can be used to check if the type inherits of other types.
575
     * </p>
576
     * <p>
577
     * How to register a geometry class with a predefined type:
578
     * 
579
     * <pre>
580
     * 
581
     * GeometryType geomType = GeometryLocator.getGeometryManager()
582
     *     .registerBasicGeometryType(Circle2D.class, &quot;Circle2DM&quot;, Geometry.TYPES.CIRCLE,
583
     *         Geometry.SYBTYPES.GEOM2D,
584
     *         new int[]{Geometry.TYPES.CURVE, Geometry.TYPES.SURFACE});        
585
     * </pre>
586
     * 
587
     * </p>
588
     * 
589
     * @param geomClass
590
     *            Geometry subclass. It must not be null and must implement
591
     *            Geometry, otherwise an exception
592
     *            is raised.
593
     * @param name
594
     *            Symbolic name for the geometry type, it can be null. If it is
595
     *            null then the symbolic name
596
     *            will be the simple class name.
597
     * @param type
598
     *            Type of geometry. Must be a value defined in
599
     *            {@link Geometry.TYPES}
600
     * @param subType
601
     *            SubType of geometry. Must be a value defined in
602
     *            {@link Geometry.SUBTYPES}
603
     * @param superTypes
604
     *              List of the super types of a geometry. Must be a value defined in
605
     *            {@link Geometry.TYPES}
606
     * @return Instance of GeometryType associated to the Geometry
607
     *         implementation class
608
     *         geomClass
609
     * @throws IllegalArgumentException
610
     *             If geomClass is null or does not implement Geometry
611
     */
612
    public GeometryType registerGeometryType(Class geomClass, String name,
613
        int type, int subType, int[] superTypes);
614

  
615
    /**
616
     * <p>
617
     * Registers a Geometry implementation class with a predefined geometry type
618
     * and returns the associated GeometryType instance. Available predefined
619
     * types are defined in {@link Geometry.TYPES} and the subtypes are defined
620
     * in {@link Geometry.SUBTYPES}.
621
     * </p>
622
     * <p>
623
     * In this case the symbolic name will be the geometry's simple class name
624
     * </p>
625
     * How to register a new geometry type:
626
     * 
627
     * <pre>
628
     * 
629
     * GeometryType geomType = GeometryLocator.getGeometryManager()
630
     *     .registerBasicGeometryType(Point2D.class, Geometry.TYPES.POINT,
631
     *         Geometry.SYBTYPES.GEOM2D);
632
     * </pre>
633
     * 
634
     * @param geomClass
635
     *            Geometry implementation class. It must not be null and must
636
     *            implement Geometry,
637
     *            otherwise an exception is thrown.
638
     * @param type
639
     *            Type of geometry. Must be a value defined in
640
     *            {@link Geometry.TYPES}
641
     * @param subType
642
     *            SubType of geometry. Must be a value defined in
643
     *            {@link Geometry.SUBTYPES}
644
     * @return Instance of GeometryType associated to the Geometry
645
     *         implementation class
646
     * @throws IllegalArgumentException
647
     *             If geomClass is null or does not implement Geometry
648
     */
649
    public GeometryType registerGeometryType(Class geomClass, int type,
650
        int subType);
651

  
652
    /**
653
     * <p>
654
     * Returns an instance of GeometryType given the Geometry type and the
655
     * subtype.
656
     * </p>
657
     * 
658
     * @param type
659
     *            Type of geometry. Must be a value defined in
660
     *            {@link Geometry.TYPES}
661
     * @param subType
662
     *            SubType of geometry. Must be a value defined in
663
     *            {@link Geometry.SUBTYPES}
664
     * @return Instance of GeometryType associated to the type and the subtype
665
     * @throws GeometryTypeNotSupportedException
666
     *             Returns this exception if there is not a registered geometry
667
     *             with
668
     *             these type and subtype
669
     * @throws GeometryTypeNotValidException
670
     *             Returns if the type and subtype are not valid
671
     */
672
    public GeometryType getGeometryType(int type, int subType)
673
        throws GeometryTypeNotSupportedException, GeometryTypeNotValidException;
674

  
675
    /**
676
     * <p>
677
     * This method creates a {@link Geometry} with the type specified by this
678
     * GeometryType. The geometry is empty, and all the internal attributes must
679
     * be assigned to a value when the geometry has been created.
680
     * </p>
681
     * <p>
682
     * This example creates a point2D and sets the coordinates to 1,1:
683
     * 
684
     * <pre>
685
     * Point point =
686
     *     (Point) GeometryLocator.getGeometryManager().create(GEOMETRY.TYPES.POINT,
687
     *         GEOMETRY.SUBTYPES.GEOM2D);
688
     * point.setX(1);
689
     * point.setY(1);
690
     * </pre>
691
     * 
692
     * </p>
693
     * 
694
     * @param geomType
695
     *            The geometry type
696
     * @return
697
     *         A instance of a geometry.
698
     * @throws CreateGeometryException
699
     *             This exception is thrown when the manager can not create
700
     *             the geometry.
701
     */
702
    public Geometry create(GeometryType geomType)
703
        throws CreateGeometryException;
704

  
705
    /**
706
     * <p>
707
     * Creates a Envelope with a concrete subtype. The envelope is empty and it
708
     * have to be filled with the corners once has been created.
709
     * </p>
710
     * 
711
     * @param subType
712
     *            SubType of envelope. Must be a value defined in
713
     *            {@link Geometry.SUBTYPES}
714
     * @return
715
     *         A Envelope
716
     * @throws CreateEnvelopeException
717
     *             If it is not possible to create the envelope.
718
     */
719
    public Envelope createEnvelope(int subType) throws CreateEnvelopeException;
720

  
721
    /**
722
     * <p>
723
     * Creates a Envelope with a concrete subtype. It sets the values for the
724
     * lower corner and the upper corner (in 2D) using the method parameters.
725
     * </p>
726
     * 
727
     * @param minX
728
     *            The minimum value for the X coordinate.
729
     * @param minY
730
     *            The minimum value for the Y coordinate.
731
     * @param maxX
732
     *            The maximum value for the X coordinate.
733
     * @param maxY
734
     *            The maximum value for the Y coordinate.
735
     * @param subType
736
     *            SubType of envelope. Must be a value defined in
737
     *            {@link Geometry.SUBTYPES}
738
     * @return
739
     * @throws CreateEnvelopeException
740
     */
741
    public Envelope createEnvelope(double minX, double minY, double maxX,
742
        double maxY, int subType) throws CreateEnvelopeException;
743

  
744
    /**
745
     * <p>
746
     * This method creates a {@link Geometry} with the type specified by this
747
     * name. If a geometry with this name doesn't exist, a
748
     * {@link IllegalArgumentException} is thrown. The geometry is empty, and
749
     * all the internal attributes must be assigned to a value when the geometry
750
     * has been created.
751
     * </p>
752
     * <p>
753
     * This example creates a point2D and sets the coordinates to 1,1: It
754
     * supposes that there is a Point2D class with name "Point2D".
755
     * </p>
756
     * 
757
     * <pre>
758
     * Point point = (Point) GeometryLocator.getGeometryManager().create(&quot;Point2D&quot;);
759
     * point.setX(1);
760
     * point.setY(1);
761
     * </pre>
762
     * 
763
     * @param name
764
     *            The name of the geometry type
765
     * @return
766
     *         A instance of a geometry.
767
     * @throws CreateGeometryException
768
     *             This exception is thrown when the manager can not create
769
     *             the geometry.
770
     */
771
    public Geometry create(String name) throws CreateGeometryException;
772

  
773
    /**
774
     * Create a geometry from a WKT definition.
775
     * 
776
     * This is a utility method to wrap the invocation to the operation
777
     * {@link OPERATIONS#FROMWKT}.
778
     * 
779
     * @param wkt
780
     *            geometry in Well-known text format
781
     * 
782
     * @return the geometry as a Geometry
783
     * 
784
     * @throws CreateGeometryException
785
     * @throws GeometryException
786
     */
787
    public Geometry createFrom(String wkt, String srs)
788
        throws CreateGeometryException, GeometryException;
789

  
790
    public Geometry createFrom(String wkt) throws CreateGeometryException,
791
        GeometryException;
792

  
793
    /**
794
     * Create a geometry from a WKB definition.
795
     * 
796
     * This is a utility method to wrap the invocation to the operation
797
     * {@link OPERATIONS#FROMWKB}.
798
     * 
799
     * @param wkb
800
     *            geometry in well-known binary format
801
     * 
802
     * @return the geometry as a Geometry
803
     * 
804
     * @throws CreateGeometryException
805
     * @throws GeometryException
806
     */
807
    public Geometry createFrom(byte[] wkb) throws CreateGeometryException,
808
        GeometryException;
809

  
810
    /**
811
     * <p>
812
     * This method creates a {@link Geometry} with a concrete type and subtype.
813
     * The geometry is empty, and all the internal attributes must be assigned
814
     * to a value when the geometry has been created.
815
     * </p>
816
     * <p>
817
     * This example creates a point2D and sets the coordinates to 1,1. It
818
     * supposes that there is a Point2D class with the id 1.
819
     * </p>
820
     * 
821
     * <pre>
822
     * Point point =
823
     *     (Point) GeometryLocator.getGeometryManager().create(Geometry.TYPES.POINT,
824
     *         Geometry.SYBTYPES.GEOM2D);
825
     * point.setX(1);
826
     * point.setY(1);
827
     * </pre>
828
     * 
829
     * @param type
830
     *            Type of geometry. Must be a value defined in
831
     *            {@link Geometry.TYPES}
832
     * @param subType
833
     *            SubType of geometry. Must be a value defined in
834
     *            {@link Geometry.SUBTYPES}
835
     * @return
836
     *         A instance of a geometry.
837
     * @throws CreateGeometryException
838
     *             This exception is thrown when the manager can not create
839
     *             the geometry.
840
     */
841
    public Geometry create(int type, int subType)
842
        throws CreateGeometryException;
843

  
844
    /**
845
     * <p>
846
     * It creates a null geometry with a concrete subtype.
847
     * <p>
848
     * 
849
     * @param subType
850
     *            SubType of geometry. Must be a value defined in
851
     *            {@link Geometry.SUBTYPES}
852
     * @return
853
     *         A NullGeometry
854
     * @throws CreateGeometryException
855
     *             This exception is thrown when the manager can not create
856
     *             the geometry.
857
     * @deprecated use null instead. This method can be removed in next revisions
858
     */
859
    public NullGeometry createNullGeometry(int subType)
860
        throws CreateGeometryException;
861

  
862
    /**
863
     * <p>
864
     * Create a new point with a concrete type and sets the value for the X and
865
     * the Y.
866
     * </p>
867
     * 
868
     * @param x
869
     *            The X coordinate
870
     * @param y
871
     *            The y coordinate
872
     * @param subType
873
     *            SubType of geometry. Must be a value defined in
874
     *            {@link Geometry.SUBTYPES}
875
     * @throws CreateGeometryException
876
     *             This exception is thrown when the manager can not create
877
     *             the geometry.
878
     * @return
879
     *         The Point
880
     */
881
    public Point createPoint(double x, double y, int subType)
882
        throws CreateGeometryException;
883

  
884
    /**
885
     * Create a new line with a concrete type. Use later addVertex to add
886
     * vertex to te line. 
887
     * 
888
     * @param subType SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
889
     * @return a line
890
     * @throws CreateGeometryException
891
     *             This exception is thrown when the manager can not create
892
     *             the geometry.
893
     */
894
    public Line createLine(int subType) throws CreateGeometryException;
895

  
896
    /**
897
     * @deprecated use createLine
898
     */
899
    public Curve createCurve(int subType) throws CreateGeometryException;
900

  
901
    /**
902
     * Create a new polygon with a concrete type.
903
     * Use later addVertex to add vertex to te polygon.
904
     * 
905
     * @param subType
906
     *            SubType of geometry. Must be a value defined in
907
     *            {@link Geometry.SUBTYPES}
908
     * @return
909
     *         A polygon
910
     * @throws CreateGeometryException
911
     *             This exception is thrown when the manager can not create
912
     *             the geometry.
913
     */
914
    public Polygon createPolygon(int subType)
915
        throws CreateGeometryException;
916

  
917
    /**
918
     * @deprecated use createPolygon
919
     */
920
    public Surface createSurface(int subType)
921
        throws CreateGeometryException;
922

  
923
    /**
924
     * Create a new multipoint with a concrete subtype.
925
     * Use addPrimitive to populate the multipoint.
926
     * 
927
     * @param subType
928
     *            SubType of geometry. Must be a value defined in
929
     *            {@link Geometry.SUBTYPES}
930
     * @return A multipoint
931
     * @throws CreateGeometryException
932
     *             This exception is thrown when the manager can not create the
933
     *             geometry.
934
     */
935
    public MultiPoint createMultiPoint(int subType)
936
        throws CreateGeometryException;
937
    
938
    /**
939
     * Create a new multicurve with a concrete subtype.
940
     * Use addPrimitive to populate the multicurve.
941
     * 
942
     * @param subType
943
     *            SubType of geometry. Must be a value defined in
944
     *            {@link Geometry.SUBTYPES}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff