Example usage for org.hibernate.spatial.criterion SpatialRestrictions within

List of usage examples for org.hibernate.spatial.criterion SpatialRestrictions within

Introduction

In this page you can find the example usage for org.hibernate.spatial.criterion SpatialRestrictions within.

Prototype

public static SpatialRelateExpression within(String propertyName, Geometry value) 

Source Link

Document

Apply a "spatially within" constraint to the named property

Usage

From source file:me.transit.dao.query.tuple.CircleTuple.java

License:Open Source License

/**
 * /*from  w  w w . ja v  a 2 s.  c  om*/
 */
public void getCriterion(Criteria crit) {
    Polygon range = makeCircle(center_, distanceInMeters_);

    if (getAlias() != null) {
        String name = getAlias().getSimpleName();
        crit.createAlias(name, name);

        StringBuilder builder = new StringBuilder(name);
        builder.append(".");
        builder.append(getField());
        crit.add(SpatialRestrictions.filter(builder.toString(), range));
        crit.add(SpatialRestrictions.within(builder.toString(), range));

    } else {

        crit.add(SpatialRestrictions.filter(getField(), range));
        crit.add(SpatialRestrictions.within(getField(), range));
    }

}

From source file:me.transit.dao.query.tuple.PolygonBoxTuple.java

License:Open Source License

/**
 * //  w  ww . jav a 2 s.c  o  m
 */
public void getCriterion(Criteria crit) {

    Polygon range = makePolygon(this.pointLine);

    if (getAlias() != null) {
        String name = getAlias().getSimpleName();
        crit.createAlias(name, name);

        StringBuilder builder = new StringBuilder(name);
        builder.append(".");
        builder.append(getField());
        crit.add(SpatialRestrictions.filter(builder.toString(), range));
        crit.add(SpatialRestrictions.within(builder.toString(), range));

    } else {

        crit.add(SpatialRestrictions.filter(getField(), range));
        crit.add(SpatialRestrictions.within(getField(), range));
    }

}