01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2004-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library 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 GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.geometry.jts;
17:
18: import org.opengis.referencing.operation.MathTransform;
19: import org.opengis.referencing.operation.MathTransform2D;
20: import org.opengis.referencing.operation.TransformException;
21:
22: import com.vividsolutions.jts.geom.CoordinateSequence;
23: import com.vividsolutions.jts.geom.CoordinateSequenceFactory;
24: import com.vividsolutions.jts.geom.DefaultCoordinateSequenceFactory;
25:
26: /**
27: * This coordinate sequence transformer will take a Geometry and transform in a set
28: * of curved lines that will be "flattened" in order to get back a set of straight segments.
29: * The error in the transform is linked to the "flattening", the higher the flattening,
30: * the bigger the error, but also, the lesser the number of points that will be used
31: * to represent the resulting coordinate sequence.
32: *
33: * @todo Not yet implemented.
34: *
35: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/geometry/jts/PreciseCoordinateSequenceTransformer.java $
36: */
37: public class PreciseCoordinateSequenceTransformer implements
38: CoordinateSequenceTransformer {
39: CoordinateSequenceFactory csFactory;
40: double flatness;
41:
42: public PreciseCoordinateSequenceTransformer() {
43: csFactory = DefaultCoordinateSequenceFactory.instance();
44: }
45:
46: /**
47: * @see org.geotools.geometry.jts.CoordinateSequenceTransformer#transform(com.vividsolutions.jts.geom.CoordinateSequence, org.geotools.ct.MathTransform2D)
48: */
49: public CoordinateSequence transform(CoordinateSequence cs,
50: MathTransform transform) throws TransformException {
51: // Coordinate[] scs = cs.toCoordinateArray();
52: // GeneralPath path = new GeneralPath();
53: // path.moveTo(scs[0].x, scs[0].y);
54: // for (int i = 0; i < scs.length; i++) {
55: // path.moveTo(scs[0].x, scs[0].y);
56: // }
57: // Shape transformed = transform.createTransformedShape(path);
58: // PathIterator iterator = transformed.getPathIterator(new AffineTransform(), flatness);
59: // ArrayList coords = new ArrayList(scs.length);
60: // double[] point = new double[6];
61: // while(!iterator.isDone()) {
62: // iterator.next();
63: // iterator.currentSegment(point);
64: // coords.add(new Coordinate(point[0], point[1]));
65: // }
66: // return csFactory.create(coords);
67: return null;
68: }
69:
70: public double getFlatness() {
71: return flatness;
72: }
73:
74: public void setFlatness(double flatness) {
75: this.flatness = flatness;
76: }
77: }
|