001: package org.geotools.geometry;
002:
003: import java.util.List;
004: import java.util.Set;
005:
006: import org.geotools.referencing.crs.DefaultGeographicCRS;
007: import org.opengis.geometry.Boundary;
008: import org.opengis.geometry.DirectPosition;
009: import org.opengis.geometry.Envelope;
010: import org.opengis.geometry.Geometry;
011: import org.opengis.geometry.MismatchedDimensionException;
012: import org.opengis.geometry.MismatchedReferenceSystemException;
013: import org.opengis.geometry.Precision;
014: import org.opengis.geometry.TransfiniteSet;
015: import org.opengis.geometry.UnmodifiableGeometryException;
016: import org.opengis.geometry.aggregate.MultiPrimitive;
017: import org.opengis.geometry.complex.Complex;
018: import org.opengis.geometry.complex.Composite;
019: import org.opengis.geometry.complex.CompositeCurve;
020: import org.opengis.geometry.coordinate.Arc;
021: import org.opengis.geometry.coordinate.ArcByBulge;
022: import org.opengis.geometry.coordinate.ArcString;
023: import org.opengis.geometry.coordinate.ArcStringByBulge;
024: import org.opengis.geometry.coordinate.BSplineCurve;
025: import org.opengis.geometry.coordinate.BSplineSurface;
026: import org.opengis.geometry.coordinate.Geodesic;
027: import org.opengis.geometry.coordinate.GeodesicString;
028: import org.opengis.geometry.coordinate.GeometryFactory;
029: import org.opengis.geometry.coordinate.KnotType;
030: import org.opengis.geometry.coordinate.LineSegment;
031: import org.opengis.geometry.coordinate.LineString;
032: import org.opengis.geometry.coordinate.ParamForPoint;
033: import org.opengis.geometry.coordinate.PointArray;
034: import org.opengis.geometry.coordinate.Polygon;
035: import org.opengis.geometry.coordinate.PolyhedralSurface;
036: import org.opengis.geometry.coordinate.Position;
037: import org.opengis.geometry.coordinate.Tin;
038: import org.opengis.geometry.primitive.Bearing;
039: import org.opengis.geometry.primitive.Curve;
040: import org.opengis.geometry.primitive.CurveBoundary;
041: import org.opengis.geometry.primitive.CurveInterpolation;
042: import org.opengis.geometry.primitive.CurveSegment;
043: import org.opengis.geometry.primitive.OrientablePrimitive;
044: import org.opengis.geometry.primitive.Point;
045: import org.opengis.geometry.primitive.Primitive;
046: import org.opengis.geometry.primitive.PrimitiveFactory;
047: import org.opengis.geometry.primitive.Ring;
048: import org.opengis.geometry.primitive.Solid;
049: import org.opengis.geometry.primitive.SolidBoundary;
050: import org.opengis.geometry.primitive.Surface;
051: import org.opengis.geometry.primitive.SurfaceBoundary;
052: import org.opengis.referencing.crs.CoordinateReferenceSystem;
053: import org.opengis.referencing.operation.MathTransform;
054: import org.opengis.referencing.operation.TransformException;
055:
056: /**
057: * Quick implementation for testing purposes.
058: *
059: * @author Jody
060: */
061: public class MockGeometryFactory implements GeometryFactory,
062: PrimitiveFactory {
063: CoordinateReferenceSystem crs;
064: public Precision precision;
065:
066: public MockGeometryFactory() {
067: this (DefaultGeographicCRS.WGS84);
068: }
069:
070: public MockGeometryFactory(CoordinateReferenceSystem crs) {
071: this .crs = crs;
072: }
073:
074: public Arc createArc(Position startPoint, Position midPoint,
075: Position endPoint)
076: throws MismatchedReferenceSystemException,
077: MismatchedDimensionException {
078: return null;
079: }
080:
081: public Arc createArc(Position startPoint, Position endPoint,
082: double bulge, double[] normal)
083: throws MismatchedReferenceSystemException,
084: MismatchedDimensionException {
085: return null;
086: }
087:
088: public ArcByBulge createArcByBulge(Position startPoint,
089: Position endPoint, double bulge, double[] normal)
090: throws MismatchedReferenceSystemException,
091: MismatchedDimensionException {
092: return null;
093: }
094:
095: public ArcString createArcString(List points)
096: throws MismatchedReferenceSystemException,
097: MismatchedDimensionException {
098: return null;
099: }
100:
101: public ArcStringByBulge createArcStringByBulge(List points,
102: double[] bulges, List normals)
103: throws MismatchedReferenceSystemException,
104: MismatchedDimensionException {
105: return null;
106: }
107:
108: public BSplineCurve createBSplineCurve(int degree,
109: PointArray points, List knots, KnotType knotSpec)
110: throws MismatchedReferenceSystemException,
111: MismatchedDimensionException {
112: return null;
113: }
114:
115: public BSplineSurface createBSplineSurface(List points,
116: int[] degree, List[] knots, KnotType knotSpec)
117: throws MismatchedReferenceSystemException,
118: MismatchedDimensionException {
119: return null;
120: }
121:
122: public DirectPosition createDirectPosition() {
123: return new MockDirectPosition();
124: }
125:
126: public DirectPosition createDirectPosition(double[] coordinates) {
127: return new MockDirectPosition(coordinates);
128: }
129:
130: class MockDirectPosition implements DirectPosition {
131: double[] coordinates;
132:
133: MockDirectPosition() {
134: this (new double[crs.getCoordinateSystem().getDimension()]);
135: }
136:
137: public MockDirectPosition(double[] coordinates) {
138: this .coordinates = coordinates;
139: }
140:
141: public MockDirectPosition(DirectPosition position) {
142: assert position.getCoordinateReferenceSystem() == crs;
143: coordinates = position.getCoordinates();
144: }
145:
146: public CoordinateReferenceSystem getCoordinateReferenceSystem() {
147: return crs;
148: }
149:
150: public double[] getCoordinates() {
151: double copy[] = new double[crs.getCoordinateSystem()
152: .getDimension()];
153: System.arraycopy(coordinates, 0, copy, 0, getDimension());
154: return copy;
155: }
156:
157: public int getDimension() {
158: return crs.getCoordinateSystem().getDimension();
159: }
160:
161: public double getOrdinate(int dimension)
162: throws IndexOutOfBoundsException {
163: return coordinates[dimension];
164: }
165:
166: public void setOrdinate(int dimension, double value)
167: throws IndexOutOfBoundsException {
168: coordinates[dimension] = value;
169:
170: }
171:
172: public DirectPosition getPosition() {
173: return this ;
174: }
175:
176: public Object clone() {
177: return new MockDirectPosition(this );
178: }
179: }
180:
181: public Envelope createEnvelope(final DirectPosition lowerCorner,
182: final DirectPosition upperCorner)
183: throws MismatchedReferenceSystemException,
184: MismatchedDimensionException {
185: return new Envelope() {
186: public double getCenter(int dimension) {
187: double lower = lowerCorner.getOrdinate(dimension);
188: double upper = upperCorner.getOrdinate(dimension);
189: return (upper + lower) / 2.0;
190: }
191:
192: public CoordinateReferenceSystem getCoordinateReferenceSystem() {
193: return crs;
194: }
195:
196: public int getDimension() {
197: return crs.getCoordinateSystem().getDimension();
198: }
199:
200: public double getLength(int dimension) {
201: double lower = lowerCorner.getOrdinate(dimension);
202: double upper = upperCorner.getOrdinate(dimension);
203: return Math.abs(upper - lower);
204: }
205:
206: public DirectPosition getLowerCorner() {
207: return lowerCorner;
208: }
209:
210: public double getMaximum(int dimension) {
211: return upperCorner.getOrdinate(dimension);
212: }
213:
214: public double getMinimum(int dimension) {
215: return lowerCorner.getOrdinate(dimension);
216: }
217:
218: public DirectPosition getUpperCorner() {
219: return upperCorner;
220: }
221: };
222: }
223:
224: public Geodesic createGeodesic(Position startPoint,
225: Position endPoint)
226: throws MismatchedReferenceSystemException,
227: MismatchedDimensionException {
228: // TODO Auto-generated method stub
229: return null;
230: }
231:
232: public GeodesicString createGeodesicString(List points)
233: throws MismatchedReferenceSystemException,
234: MismatchedDimensionException {
235: return null;
236: }
237:
238: public LineSegment createLineSegment(Position startPoint,
239: Position endPoint)
240: throws MismatchedReferenceSystemException,
241: MismatchedDimensionException {
242: return null;
243: }
244:
245: /** Takes a List<Position> ... */
246: public LineString createLineString(List points)
247: throws MismatchedReferenceSystemException,
248: MismatchedDimensionException {
249: return new LineString() {
250: PointArray points;
251:
252: public List asLineSegments() {
253: return null;
254: }
255:
256: public PointArray getControlPoints() {
257: return null;
258: }
259:
260: public CurveBoundary getBoundary() {
261: return null;
262: }
263:
264: public Curve getCurve() {
265: return null;
266: }
267:
268: public CurveInterpolation getInterpolation() {
269: return null;
270: }
271:
272: public int getNumDerivativesAtEnd() {
273: return 0;
274: }
275:
276: public int getNumDerivativesAtStart() {
277: return 0;
278: }
279:
280: public int getNumDerivativesInterior() {
281: return 0;
282: }
283:
284: public PointArray getSamplePoints() {
285: return null;
286: }
287:
288: public CurveSegment reverse() {
289: return null;
290: }
291:
292: public LineString asLineString(double maxSpacing,
293: double maxOffset) {
294: return this ;
295: }
296:
297: public DirectPosition forConstructiveParam(double cp) {
298: return null;
299: }
300:
301: public DirectPosition forParam(double s) {
302: return null;
303: }
304:
305: public double getEndConstructiveParam() {
306: return 0;
307: }
308:
309: public double getEndParam() {
310: return 0;
311: }
312:
313: public DirectPosition getEndPoint() {
314: return points
315: .getDirectPosition(points.size() - 1, null);
316: }
317:
318: public ParamForPoint getParamForPoint(DirectPosition p) {
319: return null;
320: }
321:
322: public double getStartConstructiveParam() {
323: return 0;
324: }
325:
326: public double getStartParam() {
327: return 0;
328: }
329:
330: public DirectPosition getStartPoint() {
331: return points.getDirectPosition(0, null);
332: }
333:
334: public double[] getTangent(double s) {
335: return null;
336: }
337:
338: public double length(Position point1, Position point2) {
339: return 0;
340: }
341:
342: public double length(double cparam1, double cparam2) {
343: return 0;
344: }
345: };
346: }
347:
348: public MultiPrimitive createMultiPrimitive() {
349: return null;
350: }
351:
352: public Polygon createPolygon(SurfaceBoundary boundary)
353: throws MismatchedReferenceSystemException,
354: MismatchedDimensionException {
355: return null;
356: }
357:
358: public Polygon createPolygon(SurfaceBoundary boundary,
359: Surface spanSurface)
360: throws MismatchedReferenceSystemException,
361: MismatchedDimensionException {
362: return null;
363: }
364:
365: public PolyhedralSurface createPolyhedralSurface(List tiles)
366: throws MismatchedReferenceSystemException,
367: MismatchedDimensionException {
368: return null;
369: }
370:
371: public Tin createTin(Set post, Set stopLines, Set breakLines,
372: double maxLength)
373: throws MismatchedReferenceSystemException,
374: MismatchedDimensionException {
375: return null;
376: }
377:
378: public CoordinateReferenceSystem getCoordinateReferenceSystem() {
379: return null;
380: }
381:
382: public Curve createCurve(final List segments)
383: throws MismatchedReferenceSystemException,
384: MismatchedDimensionException {
385: return new MockCurve(segments);
386: }
387:
388: class MockCurve implements Curve {
389: List segments;
390:
391: MockCurve(List segments) {
392: this .segments = segments;
393: }
394:
395: public List getSegments() {
396: return segments;
397: }
398:
399: public Object clone() {
400: return new MockCurve(getSegments());
401: }
402:
403: public Composite getComposite() {
404: return null;
405: }
406:
407: public int getOrientation() {
408: return 0;
409: }
410:
411: public Primitive getPrimitive() {
412: return this ;
413: }
414:
415: public Set getComplexes() {
416: return null;
417: }
418:
419: public Set getContainedPrimitives() {
420: // TODO Auto-generated method stub
421: return null;
422: }
423:
424: public Set getContainingPrimitives() {
425: return null;
426: }
427:
428: public OrientablePrimitive[] getProxy() {
429: return null;
430: }
431:
432: public Boundary getBoundary() {
433: return null;
434: }
435:
436: public Geometry getBuffer(double distance) {
437: return null;
438: }
439:
440: public DirectPosition getCentroid() {
441: return null;
442: }
443:
444: public Complex getClosure() {
445: return null;
446: }
447:
448: public Geometry getConvexHull() {
449: return null;
450: }
451:
452: public int getCoordinateDimension() {
453: return crs.getCoordinateSystem().getDimension();
454: }
455:
456: public CoordinateReferenceSystem getCoordinateReferenceSystem() {
457: return crs;
458: }
459:
460: public int getDimension(DirectPosition point) {
461: return 0;
462: }
463:
464: public double distance(Geometry geometry) {
465: return 0;
466: }
467:
468: public double getDistance(Geometry geometry) {
469: return distance(geometry);
470: }
471:
472: public Envelope getEnvelope() {
473: return null;
474: }
475:
476: public Set getMaximalComplex() {
477: return null;
478: }
479:
480: public Geometry getMbRegion() {
481: return null;
482: }
483:
484: public Precision getPrecision() {
485: return precision;
486: }
487:
488: public DirectPosition getRepresentativePoint() {
489: return null;
490: }
491:
492: public boolean isCycle() {
493: return false;
494: }
495:
496: public boolean isMutable() {
497: return false;
498: }
499:
500: public boolean isSimple() {
501: return false;
502: }
503:
504: public Geometry toImmutable() {
505: return this ;
506: }
507:
508: public Geometry transform(CoordinateReferenceSystem newCRS)
509: throws TransformException {
510: return null;
511: }
512:
513: public Geometry transform(CoordinateReferenceSystem newCRS,
514: MathTransform transform) throws TransformException {
515: return null;
516: }
517:
518: public boolean contains(TransfiniteSet pointSet) {
519: return false;
520: }
521:
522: public boolean contains(DirectPosition point) {
523: return false;
524: }
525:
526: public TransfiniteSet difference(TransfiniteSet pointSet) {
527: return null;
528: }
529:
530: public boolean equals(TransfiniteSet pointSet) {
531: return false;
532: }
533:
534: public TransfiniteSet intersection(TransfiniteSet pointSet) {
535: return null;
536: }
537:
538: public boolean intersects(TransfiniteSet pointSet) {
539: return false;
540: }
541:
542: public TransfiniteSet symmetricDifference(
543: TransfiniteSet pointSet) {
544: return null;
545: }
546:
547: public TransfiniteSet union(TransfiniteSet pointSet) {
548: return null;
549: }
550:
551: public LineString asLineString(double maxSpacing,
552: double maxOffset) {
553: return null;
554: }
555:
556: public DirectPosition forConstructiveParam(double cp) {
557: return null;
558: }
559:
560: public DirectPosition forParam(double s) {
561: return null;
562: }
563:
564: public double getEndConstructiveParam() {
565: return 0;
566: }
567:
568: public double getEndParam() {
569: return 0;
570: }
571:
572: public DirectPosition getEndPoint() {
573: return null;
574: }
575:
576: public ParamForPoint getParamForPoint(DirectPosition p) {
577: return null;
578: }
579:
580: public double getStartConstructiveParam() {
581: return 0;
582: }
583:
584: public double getStartParam() {
585: return 0;
586: }
587:
588: public DirectPosition getStartPoint() {
589: return null;
590: }
591:
592: public double[] getTangent(double s) {
593: return null;
594: }
595:
596: public double length(Position point1, Position point2) {
597: return 0;
598: }
599:
600: public double length(double cparam1, double cparam2) {
601: return 0;
602: }
603: }
604:
605: public Point createPoint(double[] coordinates)
606: throws MismatchedDimensionException {
607: return createPoint(createPoint(coordinates));
608: }
609:
610: public Point createPoint(Position position)
611: throws MismatchedReferenceSystemException,
612: MismatchedDimensionException {
613: return new MockPoint(position.getPosition());
614: }
615:
616: class MockPoint implements Point {
617: private DirectPosition position;
618:
619: MockPoint(DirectPosition position) {
620: this .position = position;
621: }
622:
623: public Object clone() {
624: return new MockPoint(new MockDirectPosition(position));
625: }
626:
627: public Composite getComposite() {
628: return null;
629: }
630:
631: public Bearing getBearing(Position toPoint) {
632: return null;
633: }
634:
635: public DirectPosition getPosition() {
636: return position;
637: }
638:
639: public void setPosition(DirectPosition position)
640: throws UnmodifiableGeometryException {
641: this .position = position;
642: }
643:
644: public Set getComplexes() {
645: return null;
646: }
647:
648: public Set getContainedPrimitives() {
649: return null;
650: }
651:
652: public Set getContainingPrimitives() {
653: return null;
654: }
655:
656: public OrientablePrimitive[] getProxy() {
657: return null;
658: }
659:
660: public Boundary getBoundary() {
661: return null;
662: }
663:
664: public Geometry getBuffer(double distance) {
665: return null;
666: }
667:
668: public DirectPosition getCentroid() {
669: return position;
670: }
671:
672: public Complex getClosure() {
673: return null;
674: }
675:
676: public Geometry getConvexHull() {
677: return null;
678: }
679:
680: public int getCoordinateDimension() {
681: return getCoordinateReferenceSystem().getCoordinateSystem()
682: .getDimension();
683: }
684:
685: public CoordinateReferenceSystem getCoordinateReferenceSystem() {
686: return crs;
687: }
688:
689: public int getDimension(DirectPosition point) {
690: return 0;
691: }
692:
693: public double distance(Geometry geometry) {
694: return 0;
695: }
696:
697: public double getDistance(Geometry geometry) {
698: return distance(geometry);
699: }
700:
701: public Envelope getEnvelope() {
702: return null;
703: }
704:
705: public Set getMaximalComplex() {
706: return null;
707: }
708:
709: public Geometry getMbRegion() {
710: return null;
711: }
712:
713: public Precision getPrecision() {
714: return precision;
715: }
716:
717: public DirectPosition getRepresentativePoint() {
718: return position;
719: }
720:
721: public boolean isCycle() {
722: return false;
723: }
724:
725: public boolean isMutable() {
726: return true;
727: }
728:
729: public boolean isSimple() {
730: return true;
731: }
732:
733: public Geometry toImmutable() {
734: return null;
735: }
736:
737: public Geometry transform(CoordinateReferenceSystem newCRS)
738: throws TransformException {
739: return null;
740: }
741:
742: public Geometry transform(CoordinateReferenceSystem newCRS,
743: MathTransform transform) throws TransformException {
744: return null;
745: }
746:
747: public boolean contains(TransfiniteSet pointSet) {
748: return pointSet.contains(position);
749: }
750:
751: public boolean contains(DirectPosition point) {
752: return point.equals(position);
753: }
754:
755: public TransfiniteSet difference(TransfiniteSet pointSet) {
756: return null;
757: }
758:
759: public boolean equals(TransfiniteSet pointSet) {
760: return false;
761: }
762:
763: public TransfiniteSet intersection(TransfiniteSet pointSet) {
764: return null;
765: }
766:
767: public boolean intersects(TransfiniteSet pointSet) {
768: return false;
769: }
770:
771: public TransfiniteSet symmetricDifference(
772: TransfiniteSet pointSet) {
773: return null;
774: }
775:
776: public TransfiniteSet union(TransfiniteSet pointSet) {
777: return null;
778: }
779: }
780:
781: public Primitive createPrimitive(Envelope envelope)
782: throws MismatchedReferenceSystemException,
783: MismatchedDimensionException {
784: // TODO Auto-generated method stub
785: return null;
786: }
787:
788: public Ring createRing(List curves)
789: throws MismatchedReferenceSystemException,
790: MismatchedDimensionException {
791: // TODO Auto-generated method stub
792: return null;
793: }
794:
795: public Solid createSolid(SolidBoundary boundary)
796: throws MismatchedReferenceSystemException,
797: MismatchedDimensionException {
798: // TODO Auto-generated method stub
799: return null;
800: }
801:
802: public Surface createSurface(List surfaces)
803: throws MismatchedReferenceSystemException,
804: MismatchedDimensionException {
805: // TODO Auto-generated method stub
806: return null;
807: }
808:
809: public Surface createSurface(SurfaceBoundary boundary)
810: throws MismatchedReferenceSystemException,
811: MismatchedDimensionException {
812: // TODO Auto-generated method stub
813: return null;
814: }
815:
816: public SurfaceBoundary createSurfaceBoundary(Ring exterior,
817: List interiors) throws MismatchedReferenceSystemException,
818: MismatchedDimensionException {
819: // TODO Auto-generated method stub
820: return null;
821: }
822: }
|