svn - r34213 - branches/geometry/spike/geometry/src/main/java/org/osgeo/geometry

1 message Options
Embed this post
Permalink
svn_geotools

svn - r34213 - branches/geometry/spike/geometry/src/main/java/org/osgeo/geometry

Reply Threaded More More options
Print post
Permalink
Author: jive
Date: 2009-10-24 21:59:03 -0400 (Sat, 24 Oct 2009)
New Revision: 34213

Modified:
   branches/geometry/spike/geometry/src/main/java/org/osgeo/geometry/GeometryFactory.java
   branches/geometry/spike/geometry/src/main/java/org/osgeo/geometry/SimpleGeometryBuilder.java
Log:
die die die

Modified: branches/geometry/spike/geometry/src/main/java/org/osgeo/geometry/GeometryFactory.java
===================================================================
--- branches/geometry/spike/geometry/src/main/java/org/osgeo/geometry/GeometryFactory.java 2009-10-25 01:47:15 UTC (rev 34212)
+++ branches/geometry/spike/geometry/src/main/java/org/osgeo/geometry/GeometryFactory.java 2009-10-25 01:59:03 UTC (rev 34213)
@@ -83,45 +83,14 @@
  * @author Jody Garnett
  */
 public interface GeometryFactory {
-    // Simple
-    
+    // Simple    
     /**
-     * Creates a {@link Point} in 2D space.
-     *
+     * Creates a {@link Point} with provided coordinates and CRS.
+     * <p>The order of the coordiantes are described by the CRS; so both the
+     * order and number of the coordinates should match the CRS axis order.
+     * </p>
      * @param id
      *            identifier, may be null
-     * @param x
-     *            value for first coordinate
-     * @param y
-     *            value for second coordinate
-     * @param crs
-     *            coordinate reference system, may be null
-     * @return created {@link Point}
-     */
-    public Point point( String id, double x, double y, CRS crs );
-
-    /**
-     * Creates a {@link Point} in 3D space.
-     *
-     * @param id
-     *            identifier, may be null
-     * @param x
-     *            value for first coordinate
-     * @param y
-     *            value for second coordinate
-     * @param z
-     *            value for third coordinate
-     * @param crs
-     *            coordinate reference system, may be null
-     * @return created {@link Point}
-     */
-    public Point point( String id, double x, double y, double z, CRS crs );
-
-    /**
-     * Creates a {@link Point} with an arbitrary number of coordinates.
-     *
-     * @param id
-     *            identifier, may be null
      * @param coordinates
      *            coordinate values
      * @param crs
@@ -415,7 +384,7 @@
      *            control points, at least two
      * @return created {@link GeodesicString}
      */
-    public GeodesicString feodesicString(Points points);
+    public GeodesicString geodesicString(Points points);
 
     /**
      * Creates an {@link OffsetCurve} curve segment.

Modified: branches/geometry/spike/geometry/src/main/java/org/osgeo/geometry/SimpleGeometryBuilder.java
===================================================================
--- branches/geometry/spike/geometry/src/main/java/org/osgeo/geometry/SimpleGeometryBuilder.java 2009-10-25 01:47:15 UTC (rev 34212)
+++ branches/geometry/spike/geometry/src/main/java/org/osgeo/geometry/SimpleGeometryBuilder.java 2009-10-25 01:59:03 UTC (rev 34213)
@@ -1,10 +1,230 @@
 package org.osgeo.geometry;
 
+import java.util.List;
+
+import org.osgeo.commons.crs.CRS;
+import org.osgeo.geometry.points.Points;
+import org.osgeo.geometry.primitive.LineString;
+import org.osgeo.geometry.primitive.Point;
+import org.osgeo.geometry.primitive.Polygon;
+import org.osgeo.geometry.primitive.Ring;
+
 /**
  * GeometryBuilder that is method compatible with the deegree requirements.
  *
  * @author Jody Garnett
  */
 public class SimpleGeometryBuilder {
+
+    private GeometryFactory factory;
+
+    public SimpleGeometryBuilder( GeometryFactory factory ){
+        this.factory = factory;
+    }
     
+    
+    /**
+     * Creates a {@link Point} in 2D space.
+     *
+     * @param id
+     *            identifier, may be null
+     * @param x
+     *            value for first coordinate
+     * @param y
+     *            value for second coordinate
+     * @param crs
+     *            coordinate reference system, may be null
+     * @return created {@link Point}
+     */
+    public Point createPoint( String id, double x, double y, CRS crs ) {        
+        // check crs has 2 axis
+        return factory.point(id, new double[]{x,y}, crs);
+    }
+
+    /**
+     * Creates a {@link Point} in 3D space.
+     *
+     * @param id
+     *            identifier, may be null
+     * @param x
+     *            value for first coordinate
+     * @param y
+     *            value for second coordinate
+     * @param z
+     *            value for third coordinate
+     * @param crs
+     *            coordinate reference system, may be null
+     * @return created {@link Point}
+     */
+    public Point createPoint( String id, double x, double y, double z, CRS crs ) {
+        return factory.point(id, new double[]{x,y,z}, crs);
+    }
+
+    /**
+     * Creates a {@link Point} with an arbitrary number of coordinates.
+     *
+     * @param id
+     *            identifier, may be null
+     * @param coordinates
+     *            coordinate values
+     * @param crs
+     *            coordinate reference system, may be null
+     * @return created {@link Point}
+     */
+    public Point createPoint( String id, double[] coordinates, CRS crs ) {
+        return factory.point(id, coordinates, crs);
+    }  
+
+    /**
+     * Creates a {@link Polygon} surface.
+     *
+     * @param id
+     *            identifier of the new geometry instance
+     * @param crs
+     *            coordinate reference system, may be null
+     * @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 Polygon}
+     */
+    public Polygon createPolygon( String id, CRS crs, Ring exteriorRing, List<Ring> interiorRings ) {
+        return factory.polygon(id, crs, exteriorRing, interiorRings);
+    }    
+
+    /**
+     * Creates a {@link LineString} geometry.
+     *
+     * @param id
+     *            identifier, may be null
+     * @param crs
+     *            coordinate reference system
+     * @param points
+     *            control points
+     * @return created {@link LineString}
+     */
+    public LineString createLineString( String id, CRS crs, Points points ) {
+        return factory.lineString(id, crs, points);
+    }
+
+
+    /**
+     * Creates an {@link Envelope}.
+     *
+     * @param min
+     *            minimum corner coordinates
+     * @param max
+     *            maximum corner coordinates
+     * @param crs
+     *            coordinate reference system, may be null
+     * @return created {@link Envelope}
+     */
+    public Envelope createEnvelope( double[] min, double[] max, CRS crs ) {
+        return factory.envelope(
+        return new DefaultEnvelope( null, crs, pm, new DefaultPoint( null, crs, pm, min ),
+                new DefaultPoint( null, crs,
+                                                                                                             pm, max ) );
+    }
+
+    /**
+     * Creates an {@link Envelope} in 2D space.
+     *
+     * @param minx
+     *            minimum x corner coordinate
+     * @param miny
+     *            minimum y corner coordinate
+     * @param maxx
+     *            maximum x corner coordinate
+     * @param maxy
+     *            maximum y corner coordinate
+     * @param crs
+     *            coordinate reference system, may be null
+     * @return created {@link Envelope}
+     */
+    public Envelope createEnvelope( double minx, double miny, double maxx, double maxy, CRS crs ) {
+        return createEnvelope( new double[] { minx, miny }, new double[] { maxx, maxy }, crs );
+    }
+
+    /**
+     * Create an {@link Envelope} from a list of Doubles.
+     *
+     * @param lowerCorner
+     * @param upperCorner
+     * @param crs
+     *            coordinate reference system, may be null
+     * @return the envelope
+     */
+    public Envelope createEnvelope( List<Double> lowerCorner, List<Double> upperCorner, CRS crs ) {
+        if ( lowerCorner.size() != upperCorner.size() ) {
+            throw new IllegalArgumentException( "LowerCorner must be of same dimension as upperCorner." );
+        }
+        double[] lc = new double[lowerCorner.size()];
+        double[] uc = new double[upperCorner.size()];
+        for ( int i = 0; i < lc.length; ++i ) {
+            lc[i] = lowerCorner.get( i );
+            uc[i] = upperCorner.get( i );
+        }
+        return createEnvelope( lc, uc, crs );
+    }    
+
+    /**
+     * Creates an untyped multi geometry from a list of {@link Geometry}s.
+     *
+     * @param id
+     *            identifier, may be null
+     * @param crs
+     *            coordinate reference system, may be null
+     * @param members
+     * @return created {@link MultiGeometry}
+     */
+    public MultiGeometry<Geometry> createMultiGeometry( String id, CRS crs, List<Geometry> members ) {
+        return new DefaultMultiGeometry<Geometry>( id, crs, pm, members );
+    }
+
+    /**
+     * Creates a {@link MultiPoint} from a list of passed {@link Point}s.
+     *
+     * @param id
+     *            identifier, may be null
+     * @param crs
+     *            coordinate reference system, may be null
+     * @param members
+     *            points that constitute the collection
+     * @return created {@link MultiPoint}
+     */
+    public MultiPoint createMultiPoint( String id, CRS crs, List<Point> members ) {
+        return new DefaultMultiPoint( id, crs, pm, members );
+    }
+
+    /**
+     * Creates a {@link MultiCurve} from a list of passed {@link LineString}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 MultiLineString}
+     */
+    public MultiLineString createMultiLineString( String id, CRS crs, List<LineString> members ) {
+        return new DefaultMultiLineString( id, crs, pm, members );
+    }
+
+    /**
+     * Creates a {@link MultiPolygon} from a list of passed {@link Polygon}s.
+     *
+     * @param id
+     *            identifier, may be null
+     * @param crs
+     *            coordinate reference system, may be null
+     * @param members
+     *            polygons that constitute the collection
+     * @return created {@link MultiPolygon}
+     */
+    public MultiPolygon createMultiPolygon( String id, CRS crs, List<Polygon> members ) {
+        return new DefaultMultiPolygon( id, crs, pm, members );
+    }
 }
+
+}


------------------------------------------------------------------------------
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