Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2015, The Querydsl Team (http://www.querydsl.com/team)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mysema.query.spatial.jts;
import com.mysema.query.spatial.SpatialOps;
import com.mysema.query.types.ConstantImpl;
import com.mysema.query.types.Expression;
import com.mysema.query.types.expr.BooleanExpression;
import com.mysema.query.types.expr.BooleanOperation;
import com.mysema.query.types.expr.NumberExpression;
import com.mysema.query.types.expr.NumberOperation;
import com.mysema.query.types.expr.StringExpression;
import com.mysema.query.types.expr.StringOperation;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryCollection;
/**
* GeometryExpressions contains static functions for GEO operations
*/
public final class JTSGeometryExpressions {
/**
* Return a specified ST_Geometry value from Extended Well-Known Text representation (EWKT).
*
* @param expr
* @return
*/
public static StringExpression asEWKT(JTSGeometryExpression> expr) {
return StringOperation.create(SpatialOps.AS_EWKT, expr);
}
/**
* Return a specified ST_Geometry value from Well-Known Text representation (WKT).
*
* @param text
* @return
*/
public static JTSGeometryExpression> fromText(String text) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.GEOM_FROM_TEXT, ConstantImpl.create(text));
}
/**
* Return a specified ST_Geometry value from Well-Known Text representation (WKT).
*
* @param text
* @return
*/
public static JTSGeometryExpression> fromText(Expression text) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.GEOM_FROM_TEXT, text);
}
/**
* Sets the SRID on a geometry to a particular integer value.
*
* @param expr
* @param srid
* @param
* @return
*/
public static JTSGeometryExpression setSRID(Expression expr, int srid) {
return (JTSGeometryExpression)JTSGeometryOperation.create(expr.getType(), SpatialOps.SET_SRID,
expr, ConstantImpl.create(srid));
}
/**
* Returns X minima of a bounding box 2d or 3d or a geometry.
*
* @param expr
* @return
*/
public static NumberExpression xmin(JTSGeometryExpression> expr) {
return NumberOperation.create(Double.class, SpatialOps.XMIN, expr);
}
/**
* Returns X maxima of a bounding box 2d or 3d or a geometry.
*
* @param expr
* @return
*/
public static NumberExpression xmax(JTSGeometryExpression> expr) {
return NumberOperation.create(Double.class, SpatialOps.XMAX, expr);
}
/**
* Returns Y minima of a bounding box 2d or 3d or a geometry.
*
* @param expr
* @return
*/
public static NumberExpression ymin(JTSGeometryExpression> expr) {
return NumberOperation.create(Double.class, SpatialOps.YMIN, expr);
}
/**
* Returns Y maxima of a bounding box 2d or 3d or a geometry.
*
* @param expr
* @return
*/
public static NumberExpression ymax(JTSGeometryExpression> expr) {
return NumberOperation.create(Double.class, SpatialOps.YMAX, expr);
}
/**
* Returns true if the geometries are within the specified distance of one another.
* For geometry units are in those of spatial reference and For geography units are in meters.
*
* @param expr1
* @param expr2
* @param distance
* @return
*/
public static BooleanExpression dwithin(Expression extends Geometry> expr1,
Expression extends Geometry> expr2, Expression distance) {
return BooleanOperation.create(SpatialOps.DWITHIN, expr1, expr2, distance);
}
/**
* Returns true if the geometries are within the specified distance of one another.
* For geometry units are in those of spatial reference and For geography units are in meters.
*
* @param expr1
* @param expr2
* @param distance
* @return
*/
public static BooleanExpression dwithin(Expression extends Geometry> expr1,
Expression extends Geometry> expr2, double distance) {
return BooleanOperation.create(SpatialOps.DWITHIN, expr1, expr2, ConstantImpl.create(distance));
}
/**
* Returns the bounding box that bounds rows of geometries.
*
* @param collection
* @return
*/
public static JTSGeometryExpression> extent(Expression extends GeometryCollection> collection) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.EXTENT, collection);
}
/**
* Return a specified ST_Geometry value from a collection of other geometries.
*
* @param collection
* @return
*/
public static JTSGeometryExpression> collect(Expression extends GeometryCollection> collection) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.COLLECT, collection);
}
/**
* Return a specified ST_Geometry value from a collection of other geometries.
*
* @param expr1
* @param expr2
* @return
*/
public static JTSGeometryExpression> collect(Expression extends Geometry> expr1, Expression extends Geometry> expr2) {
return JTSGeometryOperation.create(Geometry.class, SpatialOps.COLLECT2, expr1, expr2);
}
/**
* Translates the geometry to a new location using the numeric parameters as offsets.
*
* @param expr
* @param deltax
* @param deltay
* @param
* @return
*/
public static JTSGeometryExpression translate(Expression expr, float deltax, float deltay) {
return (JTSGeometryExpression)JTSGeometryOperation.create(expr.getType(), SpatialOps.TRANSLATE,
expr, ConstantImpl.create(deltax), ConstantImpl.create(deltay));
}
/**
* Translates the geometry to a new location using the numeric parameters as offsets.
*
* @param expr
* @param deltax
* @param deltay
* @param deltaz
* @param
* @return
*/
public static JTSGeometryExpression translate(Expression expr, float deltax, float deltay, float deltaz) {
return (JTSGeometryExpression)JTSGeometryOperation.create(expr.getType(), SpatialOps.TRANSLATE2,
expr, ConstantImpl.create(deltax), ConstantImpl.create(deltay), ConstantImpl.create(deltaz));
}
private JTSGeometryExpressions() {}
}