svn-gvsig-desktop / trunk / libraries / libGeometries / src / com / iver / cit / gvsig / fmap / core / AbstractGeometry.java @ 20086
History | View | Annotate | Download (4.06 KB)
1 |
package com.iver.cit.gvsig.fmap.core; |
---|---|
2 |
|
3 |
import java.awt.Shape; |
4 |
import java.io.Serializable; |
5 |
|
6 |
import org.cresques.cts.ICoordTrans; |
7 |
import org.cresques.cts.IProjection; |
8 |
import org.gvsig.geometries.iso.primitive.Box; |
9 |
import org.gvsig.geometries.operation.GeometryOperation; |
10 |
import org.gvsig.geometries.operation.GeometryOperationException; |
11 |
import org.gvsig.geometries.operation.GeometryOperationsRegistry; |
12 |
import org.gvsig.geometries.operation.GeometryOperationsSet; |
13 |
import org.gvsig.geometries.operation.NotRegisteredOperationSetException; |
14 |
|
15 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
16 |
*
|
17 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
18 |
*
|
19 |
* This program is free software; you can redistribute it and/or
|
20 |
* modify it under the terms of the GNU General Public License
|
21 |
* as published by the Free Software Foundation; either version 2
|
22 |
* of the License, or (at your option) any later version.
|
23 |
*
|
24 |
* This program is distributed in the hope that it will be useful,
|
25 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
26 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
27 |
* GNU General Public License for more details.
|
28 |
*
|
29 |
* You should have received a copy of the GNU General Public License
|
30 |
* along with this program; if not, write to the Free Software
|
31 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
32 |
*
|
33 |
* For more information, contact:
|
34 |
*
|
35 |
* Generalitat Valenciana
|
36 |
* Conselleria d'Infraestructures i Transport
|
37 |
* Av. Blasco Ib??ez, 50
|
38 |
* 46010 VALENCIA
|
39 |
* SPAIN
|
40 |
*
|
41 |
* +34 963862235
|
42 |
* gvsig@gva.es
|
43 |
* www.gvsig.gva.es
|
44 |
*
|
45 |
* or
|
46 |
*
|
47 |
* IVER T.I. S.A
|
48 |
* Salamanca 50
|
49 |
* 46005 Valencia
|
50 |
* Spain
|
51 |
*
|
52 |
* +34 963163400
|
53 |
* dac@iver.es
|
54 |
*/
|
55 |
/* CVS MESSAGES:
|
56 |
*
|
57 |
* $Id: AbstractGeometry.java,v 1.2 2008/03/25 08:47:41 cvs Exp $
|
58 |
* $Log: AbstractGeometry.java,v $
|
59 |
* Revision 1.2 2008/03/25 08:47:41 cvs
|
60 |
* Visitors removed
|
61 |
*
|
62 |
* Revision 1.1 2008/03/12 08:46:20 cvs
|
63 |
* *** empty log message ***
|
64 |
*
|
65 |
*
|
66 |
*/
|
67 |
/**
|
68 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es)
|
69 |
*/
|
70 |
public abstract class AbstractGeometry implements IGeometry, java.awt.Shape, Serializable, org.gvsig.geometries.iso.AbstractGeometry { |
71 |
protected String id = null; |
72 |
protected IProjection projection = null; |
73 |
protected GeometryOperationsSet operationsSet = null; |
74 |
|
75 |
public AbstractGeometry(String id, IProjection projection) { |
76 |
super();
|
77 |
this.id = id;
|
78 |
this.projection = projection;
|
79 |
try {
|
80 |
operationsSet = GeometryOperationsRegistry.getOperationSet(getGeometryType()); |
81 |
} catch (NotRegisteredOperationSetException e) {
|
82 |
//It is not possible to do any operation with this geometry!!!
|
83 |
} |
84 |
} |
85 |
|
86 |
public AbstractGeometry(IProjection projection) {
|
87 |
this(null, projection); |
88 |
} |
89 |
|
90 |
/*
|
91 |
* (non-Javadoc)
|
92 |
* @see org.gvsig.geometries.iso.AbstractGeometry#getOperation(int)
|
93 |
*/
|
94 |
public GeometryOperation getOperation(int opeartionCode){ |
95 |
return operationsSet.getOperation(opeartionCode);
|
96 |
} |
97 |
|
98 |
/*
|
99 |
* (non-Javadoc)
|
100 |
* @see org.gvsig.geometries.iso.AbstractGeometry#doOperation(int)
|
101 |
*/
|
102 |
public Object doOperation(int opeartionCode) throws GeometryOperationException{ |
103 |
return operationsSet.getOperation(opeartionCode).operate(this); |
104 |
} |
105 |
|
106 |
/*
|
107 |
* (non-Javadoc)
|
108 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getInternalShape()
|
109 |
*/
|
110 |
public Shape getInternalShape() { |
111 |
return this; |
112 |
} |
113 |
|
114 |
/*
|
115 |
* (non-Javadoc)
|
116 |
* @see org.gvsig.geometries.iso.AbstractGeometry#getBoundary()
|
117 |
*/
|
118 |
public Box getBoundary() { |
119 |
return new FBox(getBounds2D()); |
120 |
} |
121 |
|
122 |
/* (non-Javadoc)
|
123 |
* @see org.gvsig.geometries.iso.AbstractGeometry#getId()
|
124 |
*/
|
125 |
public String getId() { |
126 |
return id;
|
127 |
} |
128 |
|
129 |
/* (non-Javadoc)
|
130 |
* @see org.gvsig.geometries.iso.AbstractGeometry#getSRS()
|
131 |
*/
|
132 |
public IProjection getSRS() {
|
133 |
return projection;
|
134 |
} |
135 |
|
136 |
/* (non-Javadoc)
|
137 |
* @see org.gvsig.geometries.iso.AbstractGeometry#transform(org.cresques.cts.IProjection)
|
138 |
*/
|
139 |
public AbstractGeometry transform(IProjection newProjection) {
|
140 |
IGeometry newGeom = cloneGeometry(); |
141 |
ICoordTrans coordTrans = projection.getCT(newProjection); |
142 |
newGeom.reProject(coordTrans); |
143 |
return (AbstractGeometry)newGeom;
|
144 |
} |
145 |
} |