Move expression creation to central factory classes

This commit is contained in:
Timo Westkämper 2015-03-15 00:46:57 +02:00
parent fa07c83658
commit f7dc65a124
25 changed files with 174 additions and 157 deletions

View File

@ -68,7 +68,7 @@ public abstract class CurveExpression<T extends Geometry> extends GeometryExpres
*/
public PointExpression<Point> startPoint() {
if (startPoint == null) {
startPoint = PointOperation.create(Point.class, SpatialOps.START_POINT, mixin);
startPoint = GeometryExpressions.pointOperation(SpatialOps.START_POINT, mixin);
}
return startPoint;
}
@ -80,7 +80,7 @@ public abstract class CurveExpression<T extends Geometry> extends GeometryExpres
*/
public PointExpression<Point> endPoint() {
if (endPoint == null) {
endPoint = PointOperation.create(Point.class, SpatialOps.END_POINT, mixin);
endPoint = GeometryExpressions.pointOperation(SpatialOps.END_POINT, mixin);
}
return endPoint;
}

View File

@ -60,7 +60,7 @@ public abstract class GeometryCollectionExpression<T extends GeometryCollection>
* @return
*/
public GeometryExpression<Geometry> geometryN(Integer n) {
return GeometryOperation.create(Geometry.class, SpatialOps.GEOMETRYN, mixin, ConstantImpl.create(n));
return GeometryExpressions.geometryOperation(SpatialOps.GEOMETRYN, mixin, ConstantImpl.create(n));
}
}

View File

@ -104,7 +104,7 @@ public abstract class GeometryExpression<T extends Geometry> extends SimpleExpre
*/
public GeometryExpression<Geometry> envelope() {
if (envelope == null) {
envelope = GeometryOperation.create(Geometry.class, SpatialOps.ENVELOPE, mixin);
envelope = GeometryExpressions.geometryOperation(SpatialOps.ENVELOPE, mixin);
}
return envelope;
}
@ -168,7 +168,7 @@ public abstract class GeometryExpression<T extends Geometry> extends SimpleExpre
*/
public GeometryExpression<Geometry> boundary() {
if (boundary == null) {
boundary = GeometryOperation.create(Geometry.class, SpatialOps.BOUNDARY, mixin);
boundary = GeometryExpressions.geometryOperation(SpatialOps.BOUNDARY, mixin);
}
return boundary;
}
@ -408,7 +408,7 @@ public abstract class GeometryExpression<T extends Geometry> extends SimpleExpre
* @return
*/
public GeometryExpression<Geometry> buffer(double distance) {
return GeometryOperation.create(Geometry.class, SpatialOps.BUFFER, mixin, ConstantImpl.create(distance));
return GeometryExpressions.geometryOperation(SpatialOps.BUFFER, mixin, ConstantImpl.create(distance));
}
/**
@ -420,7 +420,7 @@ public abstract class GeometryExpression<T extends Geometry> extends SimpleExpre
*/
public GeometryExpression<Geometry> convexHull() {
if (convexHull == null) {
convexHull = GeometryOperation.create(Geometry.class, SpatialOps.CONVEXHULL, mixin);
convexHull = GeometryExpressions.geometryOperation(SpatialOps.CONVEXHULL, mixin);
}
return convexHull;
}
@ -444,7 +444,7 @@ public abstract class GeometryExpression<T extends Geometry> extends SimpleExpre
* @return
*/
public GeometryExpression<Geometry> intersection(Expression<? extends Geometry> geometry) {
return GeometryOperation.create(Geometry.class, SpatialOps.INTERSECTION, mixin, geometry);
return GeometryExpressions.geometryOperation(SpatialOps.INTERSECTION, mixin, geometry);
}
/**
@ -466,7 +466,7 @@ public abstract class GeometryExpression<T extends Geometry> extends SimpleExpre
* @return
*/
public GeometryExpression<Geometry> union(Expression<? extends Geometry> geometry) {
return GeometryOperation.create(Geometry.class, SpatialOps.UNION, mixin, geometry);
return GeometryExpressions.geometryOperation(SpatialOps.UNION, mixin, geometry);
}
/**
@ -488,7 +488,7 @@ public abstract class GeometryExpression<T extends Geometry> extends SimpleExpre
* @return
*/
public GeometryExpression<Geometry> difference(Expression<? extends Geometry> geometry) {
return GeometryOperation.create(Geometry.class, SpatialOps.DIFFERENCE, mixin, geometry);
return GeometryExpressions.geometryOperation(SpatialOps.DIFFERENCE, mixin, geometry);
}
/**
@ -510,11 +510,11 @@ public abstract class GeometryExpression<T extends Geometry> extends SimpleExpre
* @return
*/
public GeometryExpression<Geometry> symDifference(Expression<? extends Geometry> geometry) {
return GeometryOperation.create(Geometry.class, SpatialOps.SYMDIFFERENCE, mixin, geometry);
return GeometryExpressions.geometryOperation(SpatialOps.SYMDIFFERENCE, mixin, geometry);
}
public GeometryExpression<Geometry> transform(int srid) {
return GeometryOperation.create(Geometry.class, SpatialOps.TRANSFORM, mixin, ConstantImpl.create(srid));
return GeometryExpressions.geometryOperation(SpatialOps.TRANSFORM, mixin, ConstantImpl.create(srid));
}
}

View File

@ -1,10 +1,14 @@
package com.querydsl.spatial;
import org.geolatte.geom.*;
import com.querydsl.core.types.ConstantImpl;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.dsl.*;
import org.geolatte.geom.Geometry;
import org.geolatte.geom.GeometryCollection;
import com.querydsl.core.types.Operator;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.NumberExpression;
import com.querydsl.core.types.dsl.StringExpression;
/**
* GeometryExpressions contains static functions for GEO operations
@ -28,7 +32,7 @@ public final class GeometryExpressions {
* @return
*/
public static GeometryExpression<?> fromText(String text) {
return GeometryOperation.create(Geometry.class, SpatialOps.GEOM_FROM_TEXT, ConstantImpl.create(text));
return geometryOperation(SpatialOps.GEOM_FROM_TEXT, ConstantImpl.create(text));
}
/**
@ -38,7 +42,7 @@ public final class GeometryExpressions {
* @return
*/
public static GeometryExpression<?> fromText(Expression<String> text) {
return GeometryOperation.create(Geometry.class, SpatialOps.GEOM_FROM_TEXT, text);
return geometryOperation(SpatialOps.GEOM_FROM_TEXT, text);
}
/**
@ -50,7 +54,7 @@ public final class GeometryExpressions {
* @return
*/
public static <T extends Geometry> GeometryExpression<T> setSRID(Expression<T> expr, int srid) {
return (GeometryExpression)GeometryOperation.create(expr.getType(), SpatialOps.SET_SRID,
return (GeometryExpression)geometryOperation(expr.getType(), SpatialOps.SET_SRID,
expr, ConstantImpl.create(srid));
}
@ -129,7 +133,7 @@ public final class GeometryExpressions {
* @return
*/
public static GeometryExpression<?> extent(Expression<? extends GeometryCollection> collection) {
return GeometryOperation.create(Geometry.class, SpatialOps.EXTENT, collection);
return geometryOperation(SpatialOps.EXTENT, collection);
}
/**
@ -139,7 +143,7 @@ public final class GeometryExpressions {
* @return
*/
public static GeometryExpression<?> collect(Expression<? extends GeometryCollection> collection) {
return GeometryOperation.create(Geometry.class, SpatialOps.COLLECT, collection);
return geometryOperation(SpatialOps.COLLECT, collection);
}
/**
@ -150,7 +154,7 @@ public final class GeometryExpressions {
* @return
*/
public static GeometryExpression<?> collect(Expression<? extends Geometry> expr1, Expression<? extends Geometry> expr2) {
return GeometryOperation.create(Geometry.class, SpatialOps.COLLECT2, expr1, expr2);
return geometryOperation(SpatialOps.COLLECT2, expr1, expr2);
}
/**
@ -163,7 +167,7 @@ public final class GeometryExpressions {
* @return
*/
public static <T extends Geometry> GeometryExpression<T> translate(Expression<T> expr, float deltax, float deltay) {
return (GeometryExpression)GeometryOperation.create(expr.getType(), SpatialOps.TRANSLATE,
return (GeometryExpression)geometryOperation(expr.getType(), SpatialOps.TRANSLATE,
expr, ConstantImpl.create(deltax), ConstantImpl.create(deltay));
}
@ -178,9 +182,64 @@ public final class GeometryExpressions {
* @return
*/
public static <T extends Geometry> GeometryExpression<T> translate(Expression<T> expr, float deltax, float deltay, float deltaz) {
return (GeometryExpression)GeometryOperation.create(expr.getType(), SpatialOps.TRANSLATE2,
return (GeometryExpression)geometryOperation(expr.getType(), SpatialOps.TRANSLATE2,
expr, ConstantImpl.create(deltax), ConstantImpl.create(deltay), ConstantImpl.create(deltaz));
}
/**
* Create a new Geometry operation expression
*
* @param op
* @param args
* @return
*/
public static GeometryExpression<Geometry> geometryOperation(Operator op, Expression<?>... args) {
return new GeometryOperation<Geometry>(Geometry.class, op, args);
}
/**
* Create a new Geometry operation expression
*
* @param op
* @param args
* @return
*/
public static <T extends Geometry> GeometryExpression<T> geometryOperation(Class<T> type, Operator op, Expression<?>... args) {
return new GeometryOperation<T>(type, op, args);
}
/**
* Create a new LineString operation expression
*
* @param op
* @param args
* @return
*/
public static LineStringExpression<LineString> lineStringOperation(Operator op, Expression<?>... args) {
return new LineStringOperation<LineString>(LineString.class, op, args);
}
/**
* Create a new Point operation expression
*
* @param op
* @param args
* @return
*/
public static PointExpression<Point> pointOperation(Operator op, Expression<?>... args) {
return new PointOperation<Point>(Point.class, op, args);
}
/**
* Create a new Polygon operation expression
*
* @param op
* @param args
* @return
*/
public static PolygonExpression<Polygon> polygonOperation(Operator op, Expression<?>... args) {
return new PolygonOperation<Polygon>(Polygon.class, op, args);
}
private GeometryExpressions() {}
}

View File

@ -33,18 +33,6 @@ public class GeometryOperation<T extends Geometry> extends GeometryExpression<T>
private static final long serialVersionUID = 3433471874808633698L;
public static <D extends Geometry> GeometryOperation<D> create(Class<D> type, Operator op, Expression<?> one) {
return new GeometryOperation<D>(type, op, ImmutableList.<Expression<?>>of(one));
}
public static <D extends Geometry> GeometryOperation<D> create(Class<D> type, Operator op, Expression<?> one, Expression<?> two) {
return new GeometryOperation<D>(type, op, ImmutableList.of(one, two));
}
public static <D extends Geometry> GeometryOperation<D> create(Class<D> type, Operator op, Expression<?>... args) {
return new GeometryOperation<D>(type, op, args);
}
private final OperationImpl< T> opMixin;
protected GeometryOperation(Class<T> type, Operator op, Expression<?>... args) {

View File

@ -61,7 +61,7 @@ public abstract class LineStringExpression<T extends LineString> extends CurveEx
* @return
*/
public PointExpression<Point> pointN(int idx) {
return PointOperation.create(Point.class, SpatialOps.POINTN, mixin, ConstantImpl.create(idx));
return GeometryExpressions.pointOperation(SpatialOps.POINTN, mixin, ConstantImpl.create(idx));
}
}

View File

@ -33,18 +33,6 @@ public class LineStringOperation<T extends LineString> extends LineStringExpress
private static final long serialVersionUID = 3433471874808633698L;
public static <D extends LineString> LineStringOperation<D> create(Class<D> type, Operator op, Expression<?> one) {
return new LineStringOperation<D>(type, op, ImmutableList.<Expression<?>>of(one));
}
public static <D extends LineString> LineStringOperation<D> create(Class<D> type, Operator op, Expression<?> one, Expression<?> two) {
return new LineStringOperation<D>(type, op, ImmutableList.of(one, two));
}
public static <D extends LineString> LineStringOperation<D> create(Class<D> type, Operator op, Expression<?>... args) {
return new LineStringOperation<D>(type, op, args);
}
private final OperationImpl< T> opMixin;
protected LineStringOperation(Class<T> type, Operator op, Expression<?>... args) {

View File

@ -67,7 +67,7 @@ public abstract class MultiSurfaceExpression<T extends GeometryCollection> exten
*/
public PointExpression<Point> centroid() {
if (centroid == null) {
centroid = PointOperation.create(Point.class, SpatialOps.CENTROID, mixin);
centroid = GeometryExpressions.pointOperation(SpatialOps.CENTROID, mixin);
}
return centroid;
}
@ -79,7 +79,7 @@ public abstract class MultiSurfaceExpression<T extends GeometryCollection> exten
*/
public PointExpression<Point> pointOnSurface() {
if (pointOnSurface == null) {
pointOnSurface = PointOperation.create(Point.class, SpatialOps.POINT_ON_SURFACE, mixin);
pointOnSurface = GeometryExpressions.pointOperation(SpatialOps.POINT_ON_SURFACE, mixin);
}
return pointOnSurface;
}

View File

@ -33,18 +33,6 @@ public class PointOperation<T extends Point> extends PointExpression<T> implemen
private static final long serialVersionUID = 3433471874808633698L;
public static <D extends Point> PointOperation<D> create(Class<D> type, Operator op, Expression<?> one) {
return new PointOperation<D>(type, op, ImmutableList.<Expression<?>>of(one));
}
public static <D extends Point> PointOperation<D> create(Class<D> type, Operator op, Expression<?> one, Expression<?> two) {
return new PointOperation<D>(type, op, ImmutableList.of(one, two));
}
public static <D extends Point> PointOperation<D> create(Class<D> type, Operator op, Expression<?>... args) {
return new PointOperation<D>(type, op, args);
}
private final OperationImpl< T> opMixin;
protected PointOperation(Class<T> type, Operator op, Expression<?>... args) {

View File

@ -53,7 +53,7 @@ public abstract class PolygonExpression<T extends Polygon> extends SurfaceExpres
*/
public LineStringExpression<?> exteriorRing() {
if (exterorRing == null) {
exterorRing = LineStringOperation.create(LineString.class, SpatialOps.EXTERIOR_RING, mixin);
exterorRing = GeometryExpressions.lineStringOperation(SpatialOps.EXTERIOR_RING, mixin);
}
return exterorRing;
}
@ -77,6 +77,6 @@ public abstract class PolygonExpression<T extends Polygon> extends SurfaceExpres
* @return
*/
public LineStringExpression<LineString> interiorRingN(int idx) {
return LineStringOperation.create(LineString.class, SpatialOps.INTERIOR_RINGN, mixin, ConstantImpl.create(idx));
return GeometryExpressions.lineStringOperation(SpatialOps.INTERIOR_RINGN, mixin, ConstantImpl.create(idx));
}
}

View File

@ -33,18 +33,6 @@ public class PolygonOperation<T extends Polygon> extends PolygonExpression<T> im
private static final long serialVersionUID = 3433471874808633698L;
public static <D extends Polygon> PolygonOperation<D> create(Class<D> type, Operator op, Expression<?> one) {
return new PolygonOperation<D>(type, op, ImmutableList.<Expression<?>>of(one));
}
public static <D extends Polygon> PolygonOperation<D> create(Class<D> type, Operator op, Expression<?> one, Expression<?> two) {
return new PolygonOperation<D>(type, op, ImmutableList.of(one, two));
}
public static <D extends Polygon> PolygonOperation<D> create(Class<D> type, Operator op, Expression<?>... args) {
return new PolygonOperation<D>(type, op, args);
}
private final OperationImpl< T> opMixin;
protected PolygonOperation(Class<T> type, Operator op, Expression<?>... args) {

View File

@ -16,7 +16,6 @@ package com.querydsl.spatial;
import javax.annotation.Nullable;
import org.geolatte.geom.PolyHedralSurface;
import org.geolatte.geom.Polygon;
import com.querydsl.core.types.ConstantImpl;
import com.querydsl.core.types.Expression;
@ -67,7 +66,7 @@ public abstract class PolyhedralSurfaceExpression<T extends PolyHedralSurface> e
* @return
*/
public PolygonExpression<?> patchN(int n) {
return PolygonOperation.create(Polygon.class, SpatialOps.SURFACE, mixin, ConstantImpl.create(n));
return GeometryExpressions.polygonOperation(SpatialOps.SURFACE, mixin, ConstantImpl.create(n));
}
/**

View File

@ -63,7 +63,7 @@ public abstract class SurfaceExpression<T extends Geometry> extends GeometryExpr
*/
public PointExpression<Point> centroid() {
if (centroid == null) {
centroid = PointOperation.create(Point.class, SpatialOps.CENTROID, mixin);
centroid = GeometryExpressions.pointOperation(SpatialOps.CENTROID, mixin);
}
return centroid;
}
@ -75,7 +75,7 @@ public abstract class SurfaceExpression<T extends Geometry> extends GeometryExpr
*/
public PointExpression<Point> pointOnSurface() {
if (pointOnSurface == null) {
pointOnSurface = PointOperation.create(Point.class, SpatialOps.POINT_ON_SURFACE, mixin);
pointOnSurface = GeometryExpressions.pointOperation(SpatialOps.POINT_ON_SURFACE, mixin);
}
return pointOnSurface;
}

View File

@ -68,7 +68,7 @@ public abstract class JTSCurveExpression<T extends Geometry> extends JTSGeometry
*/
public JTSPointExpression<Point> startPoint() {
if (startPoint == null) {
startPoint = JTSPointOperation.create(Point.class, SpatialOps.START_POINT, mixin);
startPoint = JTSGeometryExpressions.pointOperation(SpatialOps.START_POINT, mixin);
}
return startPoint;
}
@ -80,7 +80,7 @@ public abstract class JTSCurveExpression<T extends Geometry> extends JTSGeometry
*/
public JTSPointExpression<Point> endPoint() {
if (endPoint == null) {
endPoint = JTSPointOperation.create(Point.class, SpatialOps.END_POINT, mixin);
endPoint = JTSGeometryExpressions.pointOperation(SpatialOps.END_POINT, mixin);
}
return endPoint;
}

View File

@ -60,7 +60,7 @@ public abstract class JTSGeometryCollectionExpression<T extends GeometryCollecti
* @return
*/
public JTSGeometryExpression<Geometry> geometryN(Integer n) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.GEOMETRYN, mixin, ConstantImpl.create(n));
return JTSGeometryExpressions.geometryOperation(SpatialOps.GEOMETRYN, mixin, ConstantImpl.create(n));
}
}

View File

@ -104,7 +104,7 @@ public abstract class JTSGeometryExpression<T extends Geometry> extends SimpleEx
*/
public JTSGeometryExpression<Geometry> envelope() {
if (envelope == null) {
envelope = JTSGeometryOperation.create(Geometry.class, SpatialOps.ENVELOPE, mixin);
envelope = JTSGeometryExpressions.geometryOperation(SpatialOps.ENVELOPE, mixin);
}
return envelope;
}
@ -168,7 +168,7 @@ public abstract class JTSGeometryExpression<T extends Geometry> extends SimpleEx
*/
public JTSGeometryExpression<Geometry> boundary() {
if (boundary == null) {
boundary = JTSGeometryOperation.create(Geometry.class, SpatialOps.BOUNDARY, mixin);
boundary = JTSGeometryExpressions.geometryOperation(SpatialOps.BOUNDARY, mixin);
}
return boundary;
}
@ -408,7 +408,7 @@ public abstract class JTSGeometryExpression<T extends Geometry> extends SimpleEx
* @return
*/
public JTSGeometryExpression<Geometry> buffer(double distance) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.BUFFER, mixin, ConstantImpl.create(distance));
return JTSGeometryExpressions.geometryOperation(SpatialOps.BUFFER, mixin, ConstantImpl.create(distance));
}
/**
@ -420,7 +420,7 @@ public abstract class JTSGeometryExpression<T extends Geometry> extends SimpleEx
*/
public JTSGeometryExpression<Geometry> convexHull() {
if (convexHull == null) {
convexHull = JTSGeometryOperation.create(Geometry.class, SpatialOps.CONVEXHULL, mixin);
convexHull = JTSGeometryExpressions.geometryOperation(SpatialOps.CONVEXHULL, mixin);
}
return convexHull;
}
@ -444,7 +444,7 @@ public abstract class JTSGeometryExpression<T extends Geometry> extends SimpleEx
* @return
*/
public JTSGeometryExpression<Geometry> intersection(Expression<? extends Geometry> geometry) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.INTERSECTION, mixin, geometry);
return JTSGeometryExpressions.geometryOperation(SpatialOps.INTERSECTION, mixin, geometry);
}
/**
@ -466,7 +466,7 @@ public abstract class JTSGeometryExpression<T extends Geometry> extends SimpleEx
* @return
*/
public JTSGeometryExpression<Geometry> union(Expression<? extends Geometry> geometry) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.UNION, mixin, geometry);
return JTSGeometryExpressions.geometryOperation(SpatialOps.UNION, mixin, geometry);
}
/**
@ -488,7 +488,7 @@ public abstract class JTSGeometryExpression<T extends Geometry> extends SimpleEx
* @return
*/
public JTSGeometryExpression<Geometry> difference(Expression<? extends Geometry> geometry) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.DIFFERENCE, mixin, geometry);
return JTSGeometryExpressions.geometryOperation(SpatialOps.DIFFERENCE, mixin, geometry);
}
/**
@ -510,11 +510,11 @@ public abstract class JTSGeometryExpression<T extends Geometry> extends SimpleEx
* @return
*/
public JTSGeometryExpression<Geometry> symDifference(Expression<? extends Geometry> geometry) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.SYMDIFFERENCE, mixin, geometry);
return JTSGeometryExpressions.geometryOperation(SpatialOps.SYMDIFFERENCE, mixin, geometry);
}
public JTSGeometryExpression<Geometry> transform(int srid) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.TRANSFORM, mixin, ConstantImpl.create(srid));
return JTSGeometryExpressions.geometryOperation(SpatialOps.TRANSFORM, mixin, ConstantImpl.create(srid));
}
}

View File

@ -2,13 +2,13 @@ package com.querydsl.spatial.jts;
import com.querydsl.core.types.ConstantImpl;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Operator;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.NumberExpression;
import com.querydsl.core.types.dsl.StringExpression;
import com.querydsl.spatial.SpatialOps;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryCollection;
import com.vividsolutions.jts.geom.*;
/**
* GeometryExpressions contains static functions for GEO operations
@ -32,7 +32,7 @@ public final class JTSGeometryExpressions {
* @return
*/
public static JTSGeometryExpression<?> fromText(String text) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.GEOM_FROM_TEXT, ConstantImpl.create(text));
return geometryOperation(SpatialOps.GEOM_FROM_TEXT, ConstantImpl.create(text));
}
/**
@ -42,7 +42,7 @@ public final class JTSGeometryExpressions {
* @return
*/
public static JTSGeometryExpression<?> fromText(Expression<String> text) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.GEOM_FROM_TEXT, text);
return geometryOperation(SpatialOps.GEOM_FROM_TEXT, text);
}
/**
@ -54,7 +54,7 @@ public final class JTSGeometryExpressions {
* @return
*/
public static <T extends Geometry> JTSGeometryExpression<T> setSRID(Expression<T> expr, int srid) {
return (JTSGeometryExpression)JTSGeometryOperation.create(expr.getType(), SpatialOps.SET_SRID,
return (JTSGeometryExpression)geometryOperation(expr.getType(), SpatialOps.SET_SRID,
expr, ConstantImpl.create(srid));
}
@ -133,7 +133,7 @@ public final class JTSGeometryExpressions {
* @return
*/
public static JTSGeometryExpression<?> extent(Expression<? extends GeometryCollection> collection) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.EXTENT, collection);
return geometryOperation(SpatialOps.EXTENT, collection);
}
/**
@ -143,7 +143,7 @@ public final class JTSGeometryExpressions {
* @return
*/
public static JTSGeometryExpression<?> collect(Expression<? extends GeometryCollection> collection) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.COLLECT, collection);
return geometryOperation(SpatialOps.COLLECT, collection);
}
/**
@ -154,7 +154,7 @@ public final class JTSGeometryExpressions {
* @return
*/
public static JTSGeometryExpression<?> collect(Expression<? extends Geometry> expr1, Expression<? extends Geometry> expr2) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.COLLECT2, expr1, expr2);
return geometryOperation(SpatialOps.COLLECT2, expr1, expr2);
}
/**
@ -167,7 +167,7 @@ public final class JTSGeometryExpressions {
* @return
*/
public static <T extends Geometry> JTSGeometryExpression<T> translate(Expression<T> expr, float deltax, float deltay) {
return (JTSGeometryExpression)JTSGeometryOperation.create(expr.getType(), SpatialOps.TRANSLATE,
return (JTSGeometryExpression)geometryOperation(expr.getType(), SpatialOps.TRANSLATE,
expr, ConstantImpl.create(deltax), ConstantImpl.create(deltay));
}
@ -182,9 +182,64 @@ public final class JTSGeometryExpressions {
* @return
*/
public static <T extends Geometry> JTSGeometryExpression<T> translate(Expression<T> expr, float deltax, float deltay, float deltaz) {
return (JTSGeometryExpression)JTSGeometryOperation.create(expr.getType(), SpatialOps.TRANSLATE2,
return (JTSGeometryExpression)geometryOperation(expr.getType(), SpatialOps.TRANSLATE2,
expr, ConstantImpl.create(deltax), ConstantImpl.create(deltay), ConstantImpl.create(deltaz));
}
/**
* Create a new Geometry operation expression
*
* @param op
* @param args
* @return
*/
public static JTSGeometryExpression<Geometry> geometryOperation(Operator op, Expression<?>... args) {
return new JTSGeometryOperation<Geometry>(Geometry.class, op, args);
}
/**
* Create a new Geometry operation expression
*
* @param op
* @param args
* @return
*/
public static <T extends Geometry> JTSGeometryExpression<T> geometryOperation(Class<T> type, Operator op, Expression<?>... args) {
return new JTSGeometryOperation<T>(type, op, args);
}
/**
* Create a new LineString operation expression
*
* @param op
* @param args
* @return
*/
public static JTSLineStringExpression<LineString> lineStringOperation(Operator op, Expression<?>... args) {
return new JTSLineStringOperation<LineString>(LineString.class, op, args);
}
/**
* Create a new Point operation expression
*
* @param op
* @param args
* @return
*/
public static JTSPointExpression<Point> pointOperation(Operator op, Expression<?>... args) {
return new JTSPointOperation<Point>(Point.class, op, args);
}
/**
* Create a new Polygon operation expression
*
* @param op
* @param args
* @return
*/
public static JTSPolygonExpression<Polygon> polygonOperation(Operator op, Expression<?>... args) {
return new JTSPolygonOperation<Polygon>(Polygon.class, op, args);
}
private JTSGeometryExpressions() {}
}

View File

@ -33,18 +33,6 @@ public class JTSGeometryOperation<T extends Geometry> extends JTSGeometryExpress
private static final long serialVersionUID = 3433471874808633698L;
public static <D extends Geometry> JTSGeometryOperation<D> create(Class<D> type, Operator op, Expression<?> one) {
return new JTSGeometryOperation<D>(type, op, ImmutableList.<Expression<?>>of(one));
}
public static <D extends Geometry> JTSGeometryOperation<D> create(Class<D> type, Operator op, Expression<?> one, Expression<?> two) {
return new JTSGeometryOperation<D>(type, op, ImmutableList.of(one, two));
}
public static <D extends Geometry> JTSGeometryOperation<D> create(Class<D> type, Operator op, Expression<?>... args) {
return new JTSGeometryOperation<D>(type, op, args);
}
private final OperationImpl< T> opMixin;
protected JTSGeometryOperation(Class<T> type, Operator op, Expression<?>... args) {

View File

@ -61,7 +61,7 @@ public abstract class JTSLineStringExpression<T extends LineString> extends JTSC
* @return
*/
public JTSPointExpression<Point> pointN(int idx) {
return JTSPointOperation.create(Point.class, SpatialOps.POINTN, mixin, ConstantImpl.create(idx));
return JTSGeometryExpressions.pointOperation(SpatialOps.POINTN, mixin, ConstantImpl.create(idx));
}
}

View File

@ -33,18 +33,6 @@ public class JTSLineStringOperation<T extends LineString> extends JTSLineStringE
private static final long serialVersionUID = 3433471874808633698L;
public static <D extends LineString> JTSLineStringOperation<D> create(Class<D> type, Operator op, Expression<?> one) {
return new JTSLineStringOperation<D>(type, op, ImmutableList.<Expression<?>>of(one));
}
public static <D extends LineString> JTSLineStringOperation<D> create(Class<D> type, Operator op, Expression<?> one, Expression<?> two) {
return new JTSLineStringOperation<D>(type, op, ImmutableList.of(one, two));
}
public static <D extends LineString> JTSLineStringOperation<D> create(Class<D> type, Operator op, Expression<?>... args) {
return new JTSLineStringOperation<D>(type, op, args);
}
private final OperationImpl< T> opMixin;
protected JTSLineStringOperation(Class<T> type, Operator op, Expression<?>... args) {

View File

@ -67,7 +67,7 @@ public abstract class JTSMultiSurfaceExpression<T extends GeometryCollection> ex
*/
public JTSPointExpression<Point> centroid() {
if (centroid == null) {
centroid = JTSPointOperation.create(Point.class, SpatialOps.CENTROID, mixin);
centroid = JTSGeometryExpressions.pointOperation(SpatialOps.CENTROID, mixin);
}
return centroid;
}
@ -79,7 +79,7 @@ public abstract class JTSMultiSurfaceExpression<T extends GeometryCollection> ex
*/
public JTSPointExpression<Point> pointOnSurface() {
if (pointOnSurface == null) {
pointOnSurface = JTSPointOperation.create(Point.class, SpatialOps.POINT_ON_SURFACE, mixin);
pointOnSurface = JTSGeometryExpressions.pointOperation(SpatialOps.POINT_ON_SURFACE, mixin);
}
return pointOnSurface;
}

View File

@ -33,18 +33,6 @@ public class JTSPointOperation<T extends Point> extends JTSPointExpression<T> im
private static final long serialVersionUID = 3433471874808633698L;
public static <D extends Point> JTSPointOperation<D> create(Class<D> type, Operator op, Expression<?> one) {
return new JTSPointOperation<D>(type, op, ImmutableList.<Expression<?>>of(one));
}
public static <D extends Point> JTSPointOperation<D> create(Class<D> type, Operator op, Expression<?> one, Expression<?> two) {
return new JTSPointOperation<D>(type, op, ImmutableList.of(one, two));
}
public static <D extends Point> JTSPointOperation<D> create(Class<D> type, Operator op, Expression<?>... args) {
return new JTSPointOperation<D>(type, op, args);
}
private final OperationImpl< T> opMixin;
protected JTSPointOperation(Class<T> type, Operator op, Expression<?>... args) {

View File

@ -53,7 +53,7 @@ public abstract class JTSPolygonExpression<T extends Polygon> extends JTSSurface
*/
public JTSLineStringExpression<?> exteriorRing() {
if (exteriorRing == null) {
exteriorRing = JTSLineStringOperation.create(LineString.class, SpatialOps.EXTERIOR_RING, mixin);
exteriorRing = JTSGeometryExpressions.lineStringOperation(SpatialOps.EXTERIOR_RING, mixin);
}
return exteriorRing;
}
@ -77,6 +77,6 @@ public abstract class JTSPolygonExpression<T extends Polygon> extends JTSSurface
* @return
*/
public JTSLineStringExpression<LineString> interiorRingN(int idx) {
return JTSLineStringOperation.create(LineString.class, SpatialOps.INTERIOR_RINGN, mixin, ConstantImpl.create(idx));
return JTSGeometryExpressions.lineStringOperation(SpatialOps.INTERIOR_RINGN, mixin, ConstantImpl.create(idx));
}
}

View File

@ -33,18 +33,6 @@ public class JTSPolygonOperation<T extends Polygon> extends JTSPolygonExpression
private static final long serialVersionUID = 3433471874808633698L;
public static <D extends Polygon> JTSPolygonOperation<D> create(Class<D> type, Operator op, Expression<?> one) {
return new JTSPolygonOperation<D>(type, op, ImmutableList.<Expression<?>>of(one));
}
public static <D extends Polygon> JTSPolygonOperation<D> create(Class<D> type, Operator op, Expression<?> one, Expression<?> two) {
return new JTSPolygonOperation<D>(type, op, ImmutableList.of(one, two));
}
public static <D extends Polygon> JTSPolygonOperation<D> create(Class<D> type, Operator op, Expression<?>... args) {
return new JTSPolygonOperation<D>(type, op, args);
}
private final OperationImpl< T> opMixin;
protected JTSPolygonOperation(Class<T> type, Operator op, Expression<?>... args) {

View File

@ -63,7 +63,7 @@ public abstract class JTSSurfaceExpression<T extends Geometry> extends JTSGeomet
*/
public JTSPointExpression<Point> centroid() {
if (centroid == null) {
centroid = JTSPointOperation.create(Point.class, SpatialOps.CENTROID, mixin);
centroid = JTSGeometryExpressions.pointOperation(SpatialOps.CENTROID, mixin);
}
return centroid;
}
@ -75,7 +75,7 @@ public abstract class JTSSurfaceExpression<T extends Geometry> extends JTSGeomet
*/
public JTSPointExpression<Point> pointOnSurface() {
if (pointOnSurface == null) {
pointOnSurface = JTSPointOperation.create(Point.class, SpatialOps.POINT_ON_SURFACE, mixin);
pointOnSurface = JTSGeometryExpressions.pointOperation(SpatialOps.POINT_ON_SURFACE, mixin);
}
return pointOnSurface;
}