|
|
|
svn_geotools
|
Author: aaime
Date: 2009-10-25 00:23:12 -0400 (Sun, 25 Oct 2009) New Revision: 34230 Added: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/DefaultGeometryFactory.java Modified: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/AbstractDefaultGeometry.java branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/DefaultEnvelope.java branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/composite/DefaultCompositeCurve.java branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/curvesegments/DefaultArcByBulge.java branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/curvesegments/DefaultOffsetCurve.java branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/JTSPoints.java branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PackedPoints.java branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PointsArray.java branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PointsList.java branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PointsPoints.java branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/primitive/DefaultCurve.java branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/primitive/DefaultRing.java Log: Fixing Points implementations to take a CRS, adding a default geometry factory for the modified D3 implementation Modified: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/AbstractDefaultGeometry.java =================================================================== --- branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/AbstractDefaultGeometry.java 2009-10-25 04:21:07 UTC (rev 34229) +++ branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/AbstractDefaultGeometry.java 2009-10-25 04:23:12 UTC (rev 34230) @@ -303,17 +303,17 @@ geom = new DefaultPoint( null, crs, pm, new double[] { jtsPoint.getX(), jtsPoint.getY() } ); } else if ( jtsGeom instanceof com.vividsolutions.jts.geom.LinearRing ) { com.vividsolutions.jts.geom.LinearRing jtsLinearRing = (com.vividsolutions.jts.geom.LinearRing) jtsGeom; - geom = new DefaultLinearRing( null, crs, pm, getAsPoints( jtsLinearRing.getCoordinateSequence() ) ); + geom = new DefaultLinearRing( null, crs, pm, getAsPoints( jtsLinearRing.getCoordinateSequence(), crs ) ); } else if ( jtsGeom instanceof com.vividsolutions.jts.geom.LineString ) { com.vividsolutions.jts.geom.LineString jtsLineString = (com.vividsolutions.jts.geom.LineString) jtsGeom; - geom = new DefaultLineString( null, crs, pm, getAsPoints( jtsLineString.getCoordinateSequence() ) ); + geom = new DefaultLineString( null, crs, pm, getAsPoints( jtsLineString.getCoordinateSequence(), crs) ); } else if ( jtsGeom instanceof com.vividsolutions.jts.geom.Polygon ) { com.vividsolutions.jts.geom.Polygon jtsPolygon = (com.vividsolutions.jts.geom.Polygon) jtsGeom; - Points exteriorPoints = getAsPoints( jtsPolygon.getExteriorRing().getCoordinateSequence() ); + Points exteriorPoints = getAsPoints( jtsPolygon.getExteriorRing().getCoordinateSequence(), crs ); LinearRing exteriorRing = new DefaultLinearRing( null, crs, pm, exteriorPoints ); List<Ring> interiorRings = new ArrayList<Ring>( jtsPolygon.getNumInteriorRing() ); for ( int i = 0; i < interiorRings.size(); i++ ) { - Points interiorPoints = getAsPoints( jtsPolygon.getInteriorRingN( i ).getCoordinateSequence() ); + Points interiorPoints = getAsPoints( jtsPolygon.getInteriorRingN( i ).getCoordinateSequence(), crs ); interiorRings.add( new DefaultLinearRing( null, crs, pm, interiorPoints ) ); } geom = new DefaultPolygon( null, crs, pm, exteriorRing, interiorRings ); @@ -373,8 +373,8 @@ throw new RuntimeException( "Cannot convert Geometry to AbstractDefaultGeometry." ); } - private Points getAsPoints( CoordinateSequence seq ) { - return new JTSPoints( seq ); + private Points getAsPoints( CoordinateSequence seq, CRS crs ) { + return new JTSPoints( seq, crs ); } protected CoordinateSequence toCoordinateSequence(Points points) { Modified: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/DefaultEnvelope.java =================================================================== --- branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/DefaultEnvelope.java 2009-10-25 04:21:07 UTC (rev 34229) +++ branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/DefaultEnvelope.java 2009-10-25 04:23:12 UTC (rev 34230) @@ -67,8 +67,8 @@ * @param min * @param max */ - public DefaultEnvelope( Point min, Point max ) { - this( null, null, null, min, max ); + public DefaultEnvelope( Point min, Point max, CRS crs) { + this( null, crs, null, min, max ); } /** @@ -166,7 +166,7 @@ protected com.vividsolutions.jts.geom.Polygon buildJTSGeometry() { Points points = new PackedPoints( new double[] { min.get0(), min.get1(), max.get0(), min.get1(), max.get0(), - max.get1(), min.get0(), max.get1(), min.get0(), min.get1() }, 2 ); + max.get1(), min.get0(), max.get1(), min.get0(), min.get1() }, 2, crs); com.vividsolutions.jts.geom.LinearRing shell = jtsFactory.createLinearRing(toCoordinateSequence( points ) ); return jtsFactory.createPolygon( shell, null ); } Added: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/DefaultGeometryFactory.java =================================================================== --- branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/DefaultGeometryFactory.java (rev 0) +++ branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/DefaultGeometryFactory.java 2009-10-25 04:23:12 UTC (rev 34230) @@ -0,0 +1,714 @@ +package org.deegree.geometry.standard; + +import java.util.Arrays; +import java.util.List; + +import org.deegree.geometry.standard.composite.DefaultCompositeCurve; +import org.deegree.geometry.standard.composite.DefaultCompositeGeometry; +import org.deegree.geometry.standard.composite.DefaultCompositeSolid; +import org.deegree.geometry.standard.composite.DefaultCompositeSurface; +import org.deegree.geometry.standard.curvesegments.DefaultArc; +import org.deegree.geometry.standard.curvesegments.DefaultArcByBulge; +import org.deegree.geometry.standard.curvesegments.DefaultArcByCenterPoint; +import org.deegree.geometry.standard.curvesegments.DefaultArcString; +import org.deegree.geometry.standard.curvesegments.DefaultArcStringByBulge; +import org.deegree.geometry.standard.curvesegments.DefaultBSpline; +import org.deegree.geometry.standard.curvesegments.DefaultBezier; +import org.deegree.geometry.standard.curvesegments.DefaultCircle; +import org.deegree.geometry.standard.curvesegments.DefaultCircleByCenterPoint; +import org.deegree.geometry.standard.curvesegments.DefaultClothoid; +import org.deegree.geometry.standard.curvesegments.DefaultCubicSpline; +import org.deegree.geometry.standard.curvesegments.DefaultGeodesic; +import org.deegree.geometry.standard.curvesegments.DefaultGeodesicString; +import org.deegree.geometry.standard.curvesegments.DefaultLineStringSegment; +import org.deegree.geometry.standard.curvesegments.DefaultOffsetCurve; +import org.deegree.geometry.standard.multi.DefaultMultiCurve; +import org.deegree.geometry.standard.multi.DefaultMultiGeometry; +import org.deegree.geometry.standard.multi.DefaultMultiLineString; +import org.deegree.geometry.standard.multi.DefaultMultiPoint; +import org.deegree.geometry.standard.multi.DefaultMultiPolygon; +import org.deegree.geometry.standard.multi.DefaultMultiSolid; +import org.deegree.geometry.standard.multi.DefaultMultiSurface; +import org.deegree.geometry.standard.points.PackedPoints; +import org.deegree.geometry.standard.points.PointsList; +import org.deegree.geometry.standard.primitive.DefaultCurve; +import org.deegree.geometry.standard.primitive.DefaultLineString; +import org.deegree.geometry.standard.primitive.DefaultLinearRing; +import org.deegree.geometry.standard.primitive.DefaultOrientableCurve; +import org.deegree.geometry.standard.primitive.DefaultOrientableSurface; +import org.deegree.geometry.standard.primitive.DefaultPoint; +import org.deegree.geometry.standard.primitive.DefaultPolygon; +import org.deegree.geometry.standard.primitive.DefaultPolyhedralSurface; +import org.deegree.geometry.standard.primitive.DefaultRing; +import org.deegree.geometry.standard.primitive.DefaultSolid; +import org.deegree.geometry.standard.primitive.DefaultSurface; +import org.deegree.geometry.standard.primitive.DefaultTin; +import org.deegree.geometry.standard.primitive.DefaultTriangulatedSurface; +import org.deegree.geometry.standard.surfacepatches.DefaultCone; +import org.deegree.geometry.standard.surfacepatches.DefaultCylinder; +import org.deegree.geometry.standard.surfacepatches.DefaultPolygonPatch; +import org.deegree.geometry.standard.surfacepatches.DefaultRectangle; +import org.deegree.geometry.standard.surfacepatches.DefaultSphere; +import org.deegree.geometry.standard.surfacepatches.DefaultTriangle; +import org.osgeo.commons.crs.CRS; +import org.osgeo.commons.uom.Angle; +import org.osgeo.commons.uom.Length; +import org.osgeo.geometry.Envelope; +import org.osgeo.geometry.Geometry; +import org.osgeo.geometry.GeometryFactory; +import org.osgeo.geometry.composite.CompositeCurve; +import org.osgeo.geometry.composite.CompositeGeometry; +import org.osgeo.geometry.composite.CompositeSolid; +import org.osgeo.geometry.composite.CompositeSurface; +import org.osgeo.geometry.multi.MultiCurve; +import org.osgeo.geometry.multi.MultiGeometry; +import org.osgeo.geometry.multi.MultiLineString; +import org.osgeo.geometry.multi.MultiPoint; +import org.osgeo.geometry.multi.MultiPolygon; +import org.osgeo.geometry.multi.MultiSolid; +import org.osgeo.geometry.multi.MultiSurface; +import org.osgeo.geometry.points.Points; +import org.osgeo.geometry.precision.PrecisionModel; +import org.osgeo.geometry.primitive.Curve; +import org.osgeo.geometry.primitive.GeometricPrimitive; +import org.osgeo.geometry.primitive.LineString; +import org.osgeo.geometry.primitive.LinearRing; +import org.osgeo.geometry.primitive.OrientableCurve; +import org.osgeo.geometry.primitive.OrientableSurface; +import org.osgeo.geometry.primitive.Point; +import org.osgeo.geometry.primitive.Polygon; +import org.osgeo.geometry.primitive.PolyhedralSurface; +import org.osgeo.geometry.primitive.Ring; +import org.osgeo.geometry.primitive.Solid; +import org.osgeo.geometry.primitive.Surface; +import org.osgeo.geometry.primitive.Tin; +import org.osgeo.geometry.primitive.TriangulatedSurface; +import org.osgeo.geometry.primitive.patches.Cone; +import org.osgeo.geometry.primitive.patches.Cylinder; +import org.osgeo.geometry.primitive.patches.PolygonPatch; +import org.osgeo.geometry.primitive.patches.Rectangle; +import org.osgeo.geometry.primitive.patches.Sphere; +import org.osgeo.geometry.primitive.patches.SurfacePatch; +import org.osgeo.geometry.primitive.patches.Triangle; +import org.osgeo.geometry.primitive.segments.AffinePlacement; +import org.osgeo.geometry.primitive.segments.Arc; +import org.osgeo.geometry.primitive.segments.ArcByBulge; +import org.osgeo.geometry.primitive.segments.ArcByCenterPoint; +import org.osgeo.geometry.primitive.segments.ArcString; +import org.osgeo.geometry.primitive.segments.ArcStringByBulge; +import org.osgeo.geometry.primitive.segments.BSpline; +import org.osgeo.geometry.primitive.segments.Bezier; +import org.osgeo.geometry.primitive.segments.Circle; +import org.osgeo.geometry.primitive.segments.CircleByCenterPoint; +import org.osgeo.geometry.primitive.segments.Clothoid; +import org.osgeo.geometry.primitive.segments.CubicSpline; +import org.osgeo.geometry.primitive.segments.CurveSegment; +import org.osgeo.geometry.primitive.segments.Geodesic; +import org.osgeo.geometry.primitive.segments.GeodesicString; +import org.osgeo.geometry.primitive.segments.Knot; +import org.osgeo.geometry.primitive.segments.LineStringSegment; +import org.osgeo.geometry.primitive.segments.OffsetCurve; + +public class DefaultGeometryFactory implements GeometryFactory { + + /** + * Creates a segmented {@link Curve} from one or more {@link CurveSegment}s. The last {@link Point} of segment + * <code>i</code> must equal the first {@link Point} of segment <code>i+1</code>. + * + * @param id + * identifier of the new geometry instance + * @param segments + * segments a curve shall be created from + * @param crs + * coordinate reference system + * @return created {@link Curve} + */ + public Curve curve( String id, CurveSegment[] segments, CRS crs ) { + return new DefaultCurve( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, Arrays.asList( segments ) ); + } + + /** + * Creates a {@link LineStringSegment} curve segment. + * + * @param points + * points to create the {@link LineStringSegment} from + * @return created {@link CurveSegment} + */ + public LineStringSegment lineStringSegment( Points points ) { + return new DefaultLineStringSegment( points ); + } + + /** + * Creates an {@link Arc} curve segment. + * + * @param p1 + * first control point + * @param p2 + * second control point + * @param p3 + * third control point + * + * @return created {@link Arc} + */ + public Arc arc( Point p1, Point p2, Point p3 ) { + return new DefaultArc( p1, p2, p3 ); + } + + /** + * Creates an {@link ArcByBulge} curve segment. + * + * @param p1 + * first control point + * @param p2 + * second control point + * @param bulge + * height of the arc (multiplier for the normals) + * @param normal + * normal vector, in 2D only one coordinate is necessary + * @return created {@link ArcStringByBulge} + */ + public ArcByBulge arcByBulge( Point p1, Point p2, double bulge, Point normal ) { + return new DefaultArcByBulge( p1, p2, bulge, normal ); + } + + /** + * Creates an {@link ArcByCenterPoint} curve segment. + * + * @param midPoint + * @param radius + * @param startAngle + * @param endAngle + * @return created {@link ArcByCenterPoint} + */ + public ArcByCenterPoint arcByCenterPoint( Point midPoint, Length radius, Angle startAngle, Angle endAngle ) { + return new DefaultArcByCenterPoint( midPoint, radius, startAngle, endAngle ); + } + + /** + * Creates an {@link ArcString} curve segment. + * + * @param points + * control points, must contain <code>2 * k + 1</code> points + * @return created {@link ArcString} + */ + public ArcString arcString( Points points ) { + return new DefaultArcString( points ); + } + + /** + * Creates an {@link ArcStringByBulge} curve segment. + * <p> + * This variant of the arc computes the mid points of the arcs instead of storing the coordinates directly. The + * control point sequence consists of the start and end points of each arc plus the bulge. + * + * @param points + * list of control points, must contain at least two points + * @param bulges + * heights of the arcs (multipliers for the normals) + * @param normals + * normal vectors + * @return created {@link ArcStringByBulge} + */ + public ArcStringByBulge arcStringByBulge( Points points, double[] bulges, Points normals ) { + return new DefaultArcStringByBulge( points, bulges, normals ); + } + + /** + * Creates a {@link Bezier} curve segment. + * + * @param points + * list of control points + * @param degree + * polynomial degree of the spline + * @param knot1 + * first of the two knots that define the spline basis functions + * @param knot2 + * second of the two knots that define the spline basis functions + * @return created {@link Bezier} + */ + public Bezier bezier( Points points, int degree, Knot knot1, Knot knot2 ) { + return new DefaultBezier( points, degree, knot1, knot2 ); + } + + /** + * Creates a {@link BSpline} curve segment. + * + * @param points + * list of control points + * @param degree + * polynomial degree of the spline + * @param knots + * sequence of distinct knots that define the spline basis functions + * @param isPolynomial + * set to true if this is a polynomial spline, otherwise it's a rational spline + * @return created {@link BSpline} + */ + public BSpline bSpline( Points points, int degree, List<Knot> knots, boolean isPolynomial ) { + return new DefaultBSpline( points, degree, knots, isPolynomial ); + } + + /** + * Creates a {@link Circle} curve segment. + * + * @param p1 + * first control point + * @param p2 + * second control point + * @param p3 + * third control point + * + * @return created {@link Arc} + */ + public Circle circle( Point p1, Point p2, Point p3 ) { + return new DefaultCircle( p1, p2, p3 ); + } + + /** + * Creates an {@link CircleByCenterPoint} curve segment. + * + * @param midPoint + * @param radius + * @param startAngle + * @return created {@link CircleByCenterPoint} + */ + public CircleByCenterPoint circleByCenterPoint( Point midPoint, Length radius, Angle startAngle ) { + return new DefaultCircleByCenterPoint( midPoint, radius, startAngle ); + } + + /** + * Creates a {@link Geodesic} curve segment. + * + * @param p1 + * first control point + * @param p2 + * second control point + * @return created {@link Geodesic} + */ + public Geodesic geodesic( Point p1, Point p2 ) { + return new DefaultGeodesic( p1, p2 ); + } + + /** + * Creates a {@link GeodesicString} curve segment. + * + * @param points + * control points, at least two + * @return created {@link GeodesicString} + */ + public GeodesicString geodesicString( Points points ) { + return new DefaultGeodesicString( points ); + } + + /** + * Creates an {@link OffsetCurve} curve segment. + * + * @param baseCurve + * the base geometry + * @param direction + * the direction of the offset + * @param distance + * the distance from the base curve + * @return created {@link GeodesicString} + */ + public OffsetCurve offsetCurve( Curve baseCurve, Point direction, Length distance ) { + return new DefaultOffsetCurve( baseCurve, direction, distance ); + } + + /** + * Creates a {@link Surface} that consists of a number of {@link SurfacePatch} instances. The passed patches must + * touch in a topological sense to form a valid {@link Surface}. + * + * @param id + * identifier of the new geometry instance + * @param patches + * patches to create a surface + * @param crs + * coordinate reference system, may be null + * @return created {@link Surface} + */ + public Surface surface( String id, List<SurfacePatch> patches, CRS crs ) { + return new DefaultSurface( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, patches ); + } + + /** + * Creates a {@link PolygonPatch} surface patch. + * + * @param exteriorRing + * ring that defines the outer boundary, this may be null (see section 9.2.2.5 of GML spec) + * @param interiorRings + * list of rings that define the inner boundaries, may be empty or null + * @return created {@link PolygonPatch} + */ + public PolygonPatch polygonPatch( Ring exteriorRing, List<Ring> interiorRings ) { + return new DefaultPolygonPatch( exteriorRing, interiorRings ); + } + + /** + * Creates a {@link Ring} from a list of passed {@link Curve}s. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param members + * the <code>Curve</code>s that compose the <code>Ring</code> + * @return created {@link Ring} + */ + public Ring ring( String id, CRS crs, List<Curve> members ) { + return new DefaultRing( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, members ); + } + + /** + * Creates a simple {@link LinearRing} from a list of passed {@link Point}s. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param points + * control points + * @return created {@link Ring} + */ + public LinearRing linearRing( String id, CRS crs, Points points ) { + return new DefaultLinearRing( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, points ); + } + + /** + * Creates an {@link OrientableCurve}. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param baseCurve + * base curve + * @param isReversed + * set to true, if the orientation of the base curve shall be reversed in the created geometry + * @return created {@link OrientableCurve} + */ + public OrientableCurve orientableCurve( String id, CRS crs, Curve baseCurve, boolean isReversed ) { + return new DefaultOrientableCurve( id, crs, baseCurve, isReversed ); + } + + /** + * Creates a {@link Triangle} surface patch. + * + * @param exterior + * ring that contains exactly four planar points, the first and last point must be coincident + * @return created {@link Triangle} + */ + public Triangle triangle( LinearRing exterior ) { + return new DefaultTriangle( exterior ); + } + + /** + * Creates a {@link Rectangle} surface patch. + * + * @param exterior + * ring that contains exactly five planar points, the first and last point must match + * @return created {@link Rectangle} + */ + public Rectangle rectangle( LinearRing exterior ) { + return new DefaultRectangle( exterior ); + } + + /** + * Creates an {@link OrientableSurface}. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param baseSurface + * base surface + * @param isReversed + * set to true, if the orientation of the base surface shall be reversed + * @return created {@link OrientableCurve} + */ + public OrientableSurface orientableSurface( String id, CRS crs, Surface baseSurface, boolean isReversed ) { + return new DefaultOrientableSurface( id, crs, baseSurface, isReversed ); + } + + /** + * Creates a {@link PolyhedralSurface}. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param memberPatches + * patches that constitute the surface + * @return created {@link PolyhedralSurface} + */ + public PolyhedralSurface polyhedralSurface( String id, CRS crs, List<PolygonPatch> memberPatches ) { + return new DefaultPolyhedralSurface( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, memberPatches ); + } + + /** + * Creates a {@link TriangulatedSurface}. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param memberPatches + * patches that constitute the surface + * @return created {@link TriangulatedSurface} + */ + public TriangulatedSurface triangulatedSurface( String id, CRS crs, List<Triangle> memberPatches ) { + return new DefaultTriangulatedSurface( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, memberPatches ); + } + + /** + * Creates a {@link Tin}. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param stopLines + * @param breakLines + * @param maxLength + * @param controlPoints + * @param patches + * @return created {@link Tin} + */ + public Tin tin( String id, CRS crs, List<List<LineStringSegment>> stopLines, + List<List<LineStringSegment>> breakLines, Length maxLength, Points controlPoints, + List<Triangle> patches ) { + return new DefaultTin( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, stopLines, breakLines, maxLength, controlPoints, patches ); + } + + /** + * Creates a {@link Clothoid} curve segment. + * + * @param referenceLocation + * the affine mapping that places the curve defined by the Fresnel Integrals into the coordinate + * reference system of this object + * @param scaleFactor + * the value for the constant in the Fresnel's integrals + * @param startParameter + * the arc length distance from the inflection point that will be the start point for this curve segment + * @param endParameter + * the arc length distance from the inflection point that will be the end point for this curve segment + * @return created {@link Clothoid} + */ + public Clothoid clothoid( AffinePlacement referenceLocation, double scaleFactor, double startParameter, + double endParameter ) { + return new DefaultClothoid( referenceLocation, scaleFactor, startParameter, endParameter ); + } + + /** + * Creates a {@link Cone} surface patch. + * + * @param grid + * the grid of control points that defines the Cone + * @return created {@link Cone} + */ + public Cone cone( List<Points> grid ) { + return new DefaultCone( grid ); + } + + /** + * Creates a {@link Cylinder} surface patch. + * + * @param grid + * the grid of control points that defines the Cylinder + * @return created {@link Cylinder} + */ + public Cylinder cylinder( List<Points> grid ) { + return new DefaultCylinder( grid ); + } + + /** + * Creates a {@link Sphere} surface patch. + * + * @param grid + * the grid of control points that defines the Sphere + * @return created {@link Sphere} + */ + public Sphere sphere( List<Points> grid ) { + return new DefaultSphere( grid ); + } + + /** + * Creates a {@link Clothoid} curve segment. + * + * @param points + * control points, at least two + * @param vectorAtStart + * the unit tangent vector at the start point of the spline + * @param vectorAtEnd + * the unit tangent vector at the end point of the spline + * @return created {@link Clothoid} + */ + public CubicSpline cubicSpline( Points points, Point vectorAtStart, Point vectorAtEnd ) { + return new DefaultCubicSpline( points, vectorAtStart, vectorAtEnd ); + } + + /** + * Creates a {@link Solid}. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param exteriorSurface + * the exterior surface (shell) of the solid, may be null + * @param interiorSurfaces + * the interior surfaces of the solid, may be null or empty + * @return created {@link Solid} + */ + public Solid solid( String id, CRS crs, Surface exteriorSurface, List<Surface> interiorSurfaces ) { + return new DefaultSolid( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, exteriorSurface, interiorSurfaces ); + } + + /** + * Creates a {@link MultiCurve} from a list of passed {@link Curve}s. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param members + * curves that constitute the collection + * @return created {@link MultiCurve} + */ + public MultiCurve multiCurve( String id, CRS crs, List<Curve> members ) { + return new DefaultMultiCurve( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, members ); + } + + /** + * Creates a {@link MultiSurface} from a list of passed {@link Surface}s. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param members + * surfaces that constitute the collection + * @return created {@link MultiSurface} + */ + public MultiSurface multiSurface( String id, CRS crs, List<Surface> members ) { + return new DefaultMultiSurface( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, members ); + } + + /** + * Creates a {@link MultiSolid} from a list of passed {@link Solid}s. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param members + * solids that constitute the collection + * @return created {@link MultiSolid} + */ + public MultiSolid multiSolid( String id, CRS crs, List<Solid> members ) { + return new DefaultMultiSolid( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, members ); + } + + /** + * Creates a {@link CompositeCurve} from a list of passed {@link Curve}s. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param members + * curves that constitute the composited curve, each curve must end at the start point of the subsequent + * curve in the list + * @return created {@link CompositeCurve} + */ + public CompositeCurve compositeCurve( String id, CRS crs, List<Curve> members ) { + return new DefaultCompositeCurve( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, members ); + } + + /** + * Creates a {@link CompositeSurface} from a list of passed {@link Surface}s. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param memberSurfaces + * surfaces that constitute the composited surface, the surfaces must join in pairs on common boundary + * curves and must, when considered as a whole, form a single surface + * @return created {@link CompositeSurface} + */ + public CompositeSurface compositeSurface( String id, CRS crs, List<Surface> memberSurfaces ) { + return new DefaultCompositeSurface( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, memberSurfaces ); + } + + /** + * Creates a {@link CompositeSolid} from a list of passed {@link Solid}s. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param memberSolids + * solids that constitute the composited solid, the solids must join in pairs on common boundary surfaces + * and which, when considered as a whole, form a single solid + * @return created {@link CompositeSolid} + */ + public CompositeSolid compositeSolid( String id, CRS crs, List<Solid> memberSolids ) { + return new DefaultCompositeSolid( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, memberSolids ); + } + + /** + * Creates a general {@link CompositeGeometry} from a list of primitive geometries. + * + * @param id + * identifier, may be null + * @param crs + * coordinate reference system, may be null + * @param memberPrimitives + * @return created {@link CompositeGeometry} + */ + public CompositeGeometry<GeometricPrimitive> compositeGeometry( String id, CRS crs, + List<GeometricPrimitive> memberPrimitives ) { + return new DefaultCompositeGeometry( id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, memberPrimitives ); + } + + public Envelope envelope(Point lowerCorner, Point upperCorner, CRS crs) { + return new DefaultEnvelope(lowerCorner, upperCorner, crs); + } + + public LineString lineString(String id, CRS crs, Points points) { + return new DefaultLineString(null, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, points); + } + + public MultiGeometry<Geometry> multiGeometry(String id, CRS crs, List<Geometry> members) { + return new DefaultMultiGeometry<Geometry>(null, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, members); + } + + public MultiLineString multiLineString(String id, CRS crs, List<LineString> members) { + return new DefaultMultiLineString(null, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, members); + } + + public MultiPoint multiPoint(String id, CRS crs, List<Point> members) { + return new DefaultMultiPoint(null, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, members); + } + + public MultiPolygon multiPolygon(String id, CRS crs, List<Polygon> members) { + return new DefaultMultiPolygon(null, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, members); + } + + public Point point(String id, double[] coordinates, CRS crs) { + return new DefaultPoint(id, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, coordinates); + } + + public Points points(double[] coordinates, int dimensions, CRS crs) { + return new PackedPoints(coordinates, dimensions, crs); + } + + public Polygon polygon(String id, CRS crs, Ring exteriorRing, List<Ring> interiorRings) { + return new DefaultPolygon(null, crs, PrecisionModel.DEFAULT_PRECISION_MODEL, exteriorRing, interiorRings); + } + + public Points points(List<Point> list, CRS crs) { + return new PointsList(list, crs); + } + +} Modified: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/composite/DefaultCompositeCurve.java =================================================================== --- branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/composite/DefaultCompositeCurve.java 2009-10-25 04:21:07 UTC (rev 34229) +++ branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/composite/DefaultCompositeCurve.java 2009-10-25 04:23:12 UTC (rev 34230) @@ -50,7 +50,6 @@ import org.osgeo.commons.uom.Measure; import org.osgeo.commons.uom.Unit; import org.osgeo.geometry.composite.CompositeCurve; -import org.osgeo.geometry.multi.MultiLineString; import org.osgeo.geometry.points.Points; import org.osgeo.geometry.precision.PrecisionModel; import org.osgeo.geometry.primitive.Curve; @@ -260,6 +259,6 @@ for ( Curve curve : memberCurves ) { pointsList.add( curve.getControlPoints() ); } - return new PointsPoints( pointsList ); + return new PointsPoints( pointsList, crs); } } Modified: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/curvesegments/DefaultArcByBulge.java =================================================================== --- branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/curvesegments/DefaultArcByBulge.java 2009-10-25 04:21:07 UTC (rev 34229) +++ branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/curvesegments/DefaultArcByBulge.java 2009-10-25 04:23:12 UTC (rev 34230) @@ -103,7 +103,7 @@ @SuppressWarnings("unchecked") public Points getNormals() { - return new PointsList( Collections.singletonList( normal ) ); + return new PointsList( Collections.singletonList( normal ), normal.getCoordinateSystem() ); } Modified: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/curvesegments/DefaultOffsetCurve.java =================================================================== --- branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/curvesegments/DefaultOffsetCurve.java 2009-10-25 04:21:07 UTC (rev 34229) +++ branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/curvesegments/DefaultOffsetCurve.java 2009-10-25 04:23:12 UTC (rev 34230) @@ -36,6 +36,7 @@ package org.deegree.geometry.standard.curvesegments; import org.deegree.commons.uom.DefaultMeasure; +import org.osgeo.commons.uom.Length; import org.osgeo.commons.uom.Unit; import org.osgeo.geometry.primitive.Curve; import org.osgeo.geometry.primitive.Point; @@ -55,7 +56,7 @@ private Point direction; - private DefaultMeasure distance; + private Length distance; /** * Creates a new <code>DefaultOffsetCurve</code> instance from the given parameters. @@ -67,7 +68,7 @@ * @param distance * the distance from the base curve */ - public DefaultOffsetCurve( Curve baseCurve, Point direction, DefaultMeasure distance ) { + public DefaultOffsetCurve( Curve baseCurve, Point direction, Length distance ) { this.baseCurve = baseCurve; this.direction = direction; this.distance = distance; @@ -84,7 +85,7 @@ } - public DefaultMeasure getDistance( Unit requestedUnits ) { + public Length getDistance( Unit requestedUnits ) { return distance; } Modified: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/JTSPoints.java =================================================================== --- branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/JTSPoints.java 2009-10-25 04:21:07 UTC (rev 34229) +++ branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/JTSPoints.java 2009-10-25 04:23:12 UTC (rev 34230) @@ -39,6 +39,7 @@ import java.util.NoSuchElementException; import org.deegree.geometry.standard.primitive.DefaultPoint; +import org.osgeo.commons.crs.CRS; import org.osgeo.geometry.Geometry; import org.osgeo.geometry.points.Points; import org.osgeo.geometry.primitive.Point; @@ -60,10 +61,16 @@ public class JTSPoints implements Points, CoordinateSequence { private final CoordinateSequence seq; + protected CRS crs; - public JTSPoints( CoordinateSequence seq ) { + public JTSPoints( CoordinateSequence seq, CRS crs ) { this.seq = seq; + this.crs = crs; } + + public CRS getCRS() { + return crs; + } public int getDimension() { Modified: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PackedPoints.java =================================================================== --- branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PackedPoints.java 2009-10-25 04:21:07 UTC (rev 34229) +++ branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PackedPoints.java 2009-10-25 04:23:12 UTC (rev 34230) @@ -39,6 +39,7 @@ import java.util.NoSuchElementException; import org.deegree.geometry.standard.primitive.DefaultPoint; +import org.osgeo.commons.crs.CRS; import org.osgeo.geometry.points.Points; import org.osgeo.geometry.primitive.Point; @@ -61,11 +62,18 @@ private int dimension; private double[] coordinates; + + protected CRS crs; - public PackedPoints( double[] coordinates, int coordinatesDimension ) { + public PackedPoints( double[] coordinates, int coordinatesDimension, CRS crs ) { this.coordinates = coordinates; this.dimension = coordinatesDimension; + this.crs = crs; } + + public CRS getCRS() { + return crs; + } public int getDimension() { Modified: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PointsArray.java =================================================================== --- branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PointsArray.java 2009-10-25 04:21:07 UTC (rev 34229) +++ branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PointsArray.java 2009-10-25 04:23:12 UTC (rev 34230) @@ -38,6 +38,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; +import org.osgeo.commons.crs.CRS; import org.osgeo.geometry.points.Points; import org.osgeo.geometry.primitive.Point; @@ -63,15 +64,30 @@ public class PointsArray implements Points, CoordinateSequence { private Point[] points; + protected CRS crs; /** * Creates a new {@link PointsArray} instance based on the given array. * * @param points */ - public PointsArray( Point... points ) { + public PointsArray( Point[] points, CRS crs) { this.points = points; + this.crs = crs; } + + /** + * Creates a new {@link PointsArray} instance based on the given array. + * + * @param points + */ + public PointsArray( Point... points) { + this.points = points; + } + + public CRS getCRS() { + return crs; + } public int getDimension() { Modified: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PointsList.java =================================================================== --- branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PointsList.java 2009-10-25 04:21:07 UTC (rev 34229) +++ branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PointsList.java 2009-10-25 04:23:12 UTC (rev 34230) @@ -38,6 +38,7 @@ import java.util.Iterator; import java.util.List; +import org.osgeo.commons.crs.CRS; import org.osgeo.geometry.points.Points; import org.osgeo.geometry.primitive.Point; @@ -63,15 +64,21 @@ public class PointsList implements Points, CoordinateSequence { protected List<Point> points; + protected CRS crs; /** * Creates a new {@link PointsList} instance based on the given list. * * @param points */ - public PointsList( List<Point> points ) { + public PointsList( List<Point> points, CRS crs) { this.points = points; + this.crs = crs; } + + public CRS getCRS() { + return crs; + } public int getDimension() { Modified: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PointsPoints.java =================================================================== --- branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PointsPoints.java 2009-10-25 04:21:07 UTC (rev 34229) +++ branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/points/PointsPoints.java 2009-10-25 04:23:12 UTC (rev 34230) @@ -40,6 +40,7 @@ import java.util.List; import java.util.NoSuchElementException; +import org.osgeo.commons.crs.CRS; import org.osgeo.geometry.points.Points; import org.osgeo.geometry.primitive.Point; @@ -58,15 +59,21 @@ public class PointsPoints implements Points, CoordinateSequence { private List<Points> pointsList; + protected CRS crs; /** * Creates a new {@link PointsPoints} instance from the given list of {@link Points}. * * @param pointsList */ - public PointsPoints( List<Points> pointsList ) { + public PointsPoints( List<Points> pointsList, CRS crs ) { this.pointsList = pointsList; + this.crs = crs; } + + public CRS getCRS() { + return crs; + } public Point get( int i ) { Modified: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/primitive/DefaultCurve.java =================================================================== --- branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/primitive/DefaultCurve.java 2009-10-25 04:21:07 UTC (rev 34229) +++ branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/primitive/DefaultCurve.java 2009-10-25 04:23:12 UTC (rev 34230) @@ -164,7 +164,7 @@ throw new IllegalArgumentException( "CURVE_CONTAINS_LINEAR_SEGMENTS" ); } } - return new PointsPoints( pointsList ); + return new PointsPoints( pointsList, crs); } Modified: branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/primitive/DefaultRing.java =================================================================== --- branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/primitive/DefaultRing.java 2009-10-25 04:21:07 UTC (rev 34229) +++ branches/geometry/spike/geometry/src/main/java/org/deegree/geometry/standard/primitive/DefaultRing.java 2009-10-25 04:23:12 UTC (rev 34230) @@ -217,7 +217,7 @@ throw new IllegalArgumentException( "RING_CONTAINS_LINEAR_SEGMENTS" ); } } - return new PointsPoints( pointsList ); + return new PointsPoints( pointsList, crs ); } ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ GeoTools-commits mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/geotools-commits |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |