001: /*
002: * This file is part of the GeOxygene project source files.
003: *
004: * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for
005: * the development and deployment of geographic (GIS) applications. It is a open source
006: * contribution of the COGIT laboratory at the Institut Géographique National (the French
007: * National Mapping Agency).
008: *
009: * See: http://oxygene-project.sourceforge.net
010: *
011: * Copyright (C) 2005 Institut Géographique National
012: *
013: * This library is free software; you can redistribute it and/or modify it under the terms
014: * of the GNU Lesser General Public License as published by the Free Software Foundation;
015: * either version 2.1 of the License, or any later version.
016: *
017: * This library is distributed in the hope that it will be useful, but WITHOUT ANY
018: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
019: * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
020: *
021: * You should have received a copy of the GNU Lesser General Public License along with
022: * this library (see file LICENSE if present); if not, write to the Free Software
023: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024: *
025: */
026:
027: package fr.ign.cogit.geoxygene.util.algo;
028:
029: import fr.ign.cogit.geoxygene.spatial.coordgeom.DirectPositionList;
030: import fr.ign.cogit.geoxygene.spatial.coordgeom.GM_Envelope;
031: import fr.ign.cogit.geoxygene.spatial.geomroot.GM_Object;
032: import fr.ign.cogit.geoxygene.util.conversion.WktGeOxygene;
033:
034: /**
035: * Appel des methodes GEOS sur des GM_Object.
036: * Non finalisé.
037: *
038: * @author Thierry Badard, Arnaud Braun & Christophe Pele
039: * @version 1.0
040: *
041: */
042:
043: public class GeosAlgorithms implements GeomAlgorithms {
044:
045: public GeosAlgorithms() {
046: System.loadLibrary("GeosAlgorithms");
047: }
048:
049: private native String intersection(String wkt1, String wkt2);
050:
051: public GM_Object intersection(GM_Object geom1, GM_Object geom2) {
052: try {
053: String wkt1 = WktGeOxygene.makeWkt(geom1);
054: String wkt2 = WktGeOxygene.makeWkt(geom2);
055: String wktResult = intersection(wkt1, wkt2);
056: return WktGeOxygene.makeGeOxygene(wktResult);
057: } catch (Exception e) {
058: e.printStackTrace();
059: return null;
060: }
061: }
062:
063: private native String union(String wkt1, String wkt2);
064:
065: public GM_Object union(GM_Object geom1, GM_Object geom2) {
066: try {
067: String wkt1 = WktGeOxygene.makeWkt(geom1);
068: String wkt2 = WktGeOxygene.makeWkt(geom2);
069: String wktResult = union(wkt1, wkt2);
070: return WktGeOxygene.makeGeOxygene(wktResult);
071: } catch (Exception e) {
072: e.printStackTrace();
073: return null;
074: }
075: }
076:
077: private native String difference(String wkt1, String wkt2);
078:
079: public GM_Object difference(GM_Object geom1, GM_Object geom2) {
080: try {
081: String wkt1 = WktGeOxygene.makeWkt(geom1);
082: String wkt2 = WktGeOxygene.makeWkt(geom2);
083: String wktResult = difference(wkt1, wkt2);
084: return WktGeOxygene.makeGeOxygene(wktResult);
085: } catch (Exception e) {
086: e.printStackTrace();
087: return null;
088: }
089: }
090:
091: private native String symDifference(String wkt1, String wkt2);
092:
093: public GM_Object symDifference(GM_Object geom1, GM_Object geom2) {
094: try {
095: String wkt1 = WktGeOxygene.makeWkt(geom1);
096: String wkt2 = WktGeOxygene.makeWkt(geom2);
097: String wktResult = symDifference(wkt1, wkt2);
098: return WktGeOxygene.makeGeOxygene(wktResult);
099: } catch (Exception e) {
100: e.printStackTrace();
101: return null;
102: }
103: }
104:
105: private native String buffer(String wkt, double distance);
106:
107: public GM_Object buffer(GM_Object geom, double distance) {
108: try {
109: String wkt = WktGeOxygene.makeWkt(geom);
110: String wktResult = buffer(wkt, distance);
111: return WktGeOxygene.makeGeOxygene(wktResult);
112: } catch (Exception e) {
113: e.printStackTrace();
114: return null;
115: }
116: }
117:
118: public GM_Object buffer10(GM_Object geOxyGeom) {
119: return buffer(geOxyGeom, 10);
120: }
121:
122: private native String convexHull(String wkt);
123:
124: public GM_Object convexHull(GM_Object geOxyGeom) {
125: try {
126: String wkt = WktGeOxygene.makeWkt(geOxyGeom);
127: String wktResult = convexHull(wkt);
128: return WktGeOxygene.makeGeOxygene(wktResult);
129: } catch (Exception e) {
130: e.printStackTrace();
131: return null;
132: }
133: }
134:
135: private native boolean contains(String wkt1, String wkt2);
136:
137: public boolean contains(GM_Object geOxyGeom1, GM_Object geOxyGeom2) {
138: String wkt1 = WktGeOxygene.makeWkt(geOxyGeom1);
139: String wkt2 = WktGeOxygene.makeWkt(geOxyGeom2);
140: boolean result = contains(wkt1, wkt2);
141: return result;
142: }
143:
144: private native boolean intersects(String wkt1, String wkt2);
145:
146: public boolean intersects(GM_Object geOxyGeom1, GM_Object geOxyGeom2) {
147: String wkt1 = WktGeOxygene.makeWkt(geOxyGeom1);
148: String wkt2 = WktGeOxygene.makeWkt(geOxyGeom2);
149: boolean result = intersects(wkt1, wkt2);
150: return result;
151: }
152:
153: private native double distance(String wkt1, String wkt2);
154:
155: public double distance(GM_Object geOxyGeom1, GM_Object geOxyGeom2) {
156: String wkt1 = WktGeOxygene.makeWkt(geOxyGeom1);
157: String wkt2 = WktGeOxygene.makeWkt(geOxyGeom2);
158: double result = distance(wkt1, wkt2);
159: return result;
160: }
161:
162: private native double area(String wkt);
163:
164: public double area(GM_Object geOxyGeom1) {
165: String wkt1 = WktGeOxygene.makeWkt(geOxyGeom1);
166: double result = area(wkt1);
167: return result;
168: }
169:
170: private native String boundary(String wkt);
171:
172: public GM_Object boundary(GM_Object geOxyGeom1) {
173: return null;
174: }
175:
176: private native String coordinates(String wkt);
177:
178: public DirectPositionList coordinates(GM_Object geOxyGeom1) {
179: return null;
180: }
181:
182: private native String envelope(String wkt);
183:
184: public GM_Envelope envelope(GM_Object geOxyGeom) {
185: return null;
186: }
187:
188: private native boolean equals(String wkt1, String wkt2);
189:
190: public boolean equals(GM_Object geOxyGeom1, GM_Object geOxyGeom2) {
191: return false;
192: }
193:
194: private native boolean equalsExact(String wkt1, String wkt2);
195:
196: public boolean equalsExact(GM_Object geOxyGeom1,
197: GM_Object geOxyGeom2) {
198: return false;
199: }
200:
201: private native boolean crosses(String wkt1, String wkt2);
202:
203: public boolean crosses(GM_Object geOxyGeom1, GM_Object geOxyGeom2) {
204: return false;
205: }
206:
207: private native boolean disjoint(String wkt1, String wkt2);
208:
209: public boolean disjoint(GM_Object geOxyGeom1, GM_Object geOxyGeom2) {
210: return false;
211: }
212:
213: private native boolean within(String wkt1, String wkt2);
214:
215: public boolean within(GM_Object geOxyGeom1, GM_Object geOxyGeom2) {
216: return false;
217: }
218:
219: private native boolean overlaps(String wkt1, String wkt2);
220:
221: public boolean overlaps(GM_Object geOxyGeom1, GM_Object geOxyGeom2) {
222: return false;
223: }
224:
225: private native boolean touches(String wkt1, String wkt2);
226:
227: public boolean touches(GM_Object geOxyGeom1, GM_Object geOxyGeom2) {
228: return false;
229: }
230:
231: private native boolean isEmpty(String wkt);
232:
233: public boolean isEmpty(GM_Object geOxyGeom) {
234: return false;
235: }
236:
237: private native boolean isSimple(String wkt);
238:
239: public boolean isSimple(GM_Object geOxyGeom) {
240: return false;
241: }
242:
243: private native boolean isValid(String wkt);
244:
245: public boolean isValid(GM_Object geOxyGeom) {
246: return false;
247: }
248:
249: public int dimension(GM_Object geOxyGeom) {
250: return 0;
251: }
252:
253: public double length(GM_Object geOxyGeom) {
254: return 0;
255: }
256:
257: public int numPoints(GM_Object geOxyGeom) {
258: return 0;
259: }
260:
261: public GM_Object translate(GM_Object geom, double tx, double ty,
262: double tz) {
263: return null;
264: }
265:
266: public GM_Object centroid(GM_Object geom) {
267: return null;
268: }
269:
270: }
|