Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Jakub Vavrik 2013-10-09 18:39:25 +02:00
commit 61d8114513
3 changed files with 29 additions and 29 deletions

View File

@ -128,9 +128,9 @@ class CriteriaFilterProcessor {
case BBOX: { case BBOX: {
filter = geoBoundingBoxFilter(fieldName); filter = geoBoundingBoxFilter(fieldName);
Assert.isTrue(value instanceof Object[], "Value of a bbox filter should be an array of one or two values."); Assert.isTrue(value instanceof Object[], "Value of a boundedBy filter should be an array of one or two values.");
Object[] valArray = (Object[]) value; Object[] valArray = (Object[]) value;
Assert.noNullElements(valArray, "Geo bbox filter takes a not null element array as parameter."); Assert.noNullElements(valArray, "Geo boundedBy filter takes a not null element array as parameter.");
if (valArray.length == 1) { if (valArray.length == 1) {
//GeoEnvelop //GeoEnvelop
@ -141,7 +141,7 @@ class CriteriaFilterProcessor {
twoParameterBBox((GeoBoundingBoxFilterBuilder) filter, valArray); twoParameterBBox((GeoBoundingBoxFilterBuilder) filter, valArray);
} else { } else {
//error //error
Assert.isTrue(false, "Geo distance filter takes a 1-elements array(GeoEnvelop) or 2-elements array(GeoPoints or Strings(geohash))."); Assert.isTrue(false, "Geo distance filter takes a 1-elements array(GeoBox) or 2-elements array(GeoPoints or Strings(format lat,lon or geohash)).");
} }
break; break;
} }
@ -152,7 +152,7 @@ class CriteriaFilterProcessor {
} }
private void oneParameterBBox(GeoBoundingBoxFilterBuilder filter, Object value) { private void oneParameterBBox(GeoBoundingBoxFilterBuilder filter, Object value) {
Assert.isTrue(value instanceof GeoBox, "single-element of a geo bbox filter must be type of GeoEnvelop"); Assert.isTrue(value instanceof GeoBox, "single-element of boundedBy filter must be type of GeoBox");
GeoBox geoBBox = (GeoBox) value; GeoBox geoBBox = (GeoBox) value;
filter.topLeft(geoBBox.getTopLeft().getLat(), geoBBox.getTopLeft().getLon()); filter.topLeft(geoBBox.getTopLeft().getLat(), geoBBox.getTopLeft().getLon());
filter.bottomRight(geoBBox.getBottomRight().getLat(), geoBBox.getBottomRight().getLon()); filter.bottomRight(geoBBox.getBottomRight().getLat(), geoBBox.getBottomRight().getLon());
@ -168,7 +168,7 @@ class CriteriaFilterProcessor {
} }
private void twoParameterBBox(GeoBoundingBoxFilterBuilder filter, Object[] values) { private void twoParameterBBox(GeoBoundingBoxFilterBuilder filter, Object[] values) {
Assert.isTrue(isType(values, GeoPoint.class) || isType(values, String.class), " both elements of geo bbox filter must be type of GeoPoint or String(geohash)"); Assert.isTrue(isType(values, GeoPoint.class) || isType(values, String.class), " both elements of boundedBy filter must be type of GeoPoint or String(format lat,lon or geohash)");
if (values[0] instanceof GeoPoint) { if (values[0] instanceof GeoPoint) {
GeoPoint topLeft = (GeoPoint) values[0]; GeoPoint topLeft = (GeoPoint) values[0];
GeoPoint bottomRight = (GeoPoint) values[1]; GeoPoint bottomRight = (GeoPoint) values[1];

View File

@ -385,14 +385,14 @@ public class Criteria {
} }
/** /**
* Creates new CriteriaEntry for {@code location BBOX bounding box} * Creates new CriteriaEntry for {@code location GeoBox bounding box}
* *
* @param bbox {@link org.springframework.data.elasticsearch.core.geo.GeoBox} bounding box(left top corner + right bottom corner) * @param boundingBox {@link org.springframework.data.elasticsearch.core.geo.GeoBox} bounding box(left top corner + right bottom corner)
* @return Criteria the chaind criteria with the new 'bbox' criteria included. * @return Criteria the chaind criteria with the new 'boundingBox' criteria included.
*/ */
public Criteria bbox(GeoBox bbox) { public Criteria boundedBy(GeoBox boundingBox) {
Assert.notNull(bbox, "bbox value for bbox criteria must not be null"); Assert.notNull(boundingBox, "boundingBox value for boundedBy criteria must not be null");
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{bbox})); filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{boundingBox}));
return this; return this;
} }
@ -400,28 +400,28 @@ public class Criteria {
/** /**
* Creates new CriteriaEntry for bounding box created from points * Creates new CriteriaEntry for bounding box created from points
* *
* @param topLeft left top corner of bounding box * @param topLeftPoint left top corner of bounding box
* @param bottomRight right bottom corner of bounding box * @param bottomRightPoint right bottom corner of bounding box
* @return Criteria the chaind criteria with the new 'bbox' criteria included. * @return Criteria the chaind criteria with the new 'boundedBy' criteria included.
*/ */
public Criteria bbox(String topLeft, String bottomRight) { public Criteria boundedBy(String topLeftPoint, String bottomRightPoint) {
Assert.isTrue(StringUtils.isNotBlank(topLeft), "topLeft point must not be empty"); Assert.isTrue(StringUtils.isNotBlank(topLeftPoint), "topLeftPoint must not be empty");
Assert.isTrue(StringUtils.isNotBlank(bottomRight), "bottomRight point must not be empty"); Assert.isTrue(StringUtils.isNotBlank(bottomRightPoint), "bottomRightPoint must not be empty");
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{topLeft, bottomRight})); filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{topLeftPoint, bottomRightPoint}));
return this; return this;
} }
/** /**
* Creates new CriteriaEntry for bounding box created from points * Creates new CriteriaEntry for bounding box created from points
* *
* @param topLeft left top corner of bounding box * @param topLeftPoint left top corner of bounding box
* @param bottomRight right bottom corner of bounding box * @param bottomRightPoint right bottom corner of bounding box
* @return Criteria the chaind criteria with the new 'bbox' criteria included. * @return Criteria the chaind criteria with the new 'boundedBy' criteria included.
*/ */
public Criteria bbox(GeoPoint topLeft, GeoPoint bottomRight) { public Criteria boundedBy(GeoPoint topLeftPoint, GeoPoint bottomRightPoint) {
Assert.notNull(topLeft, "topLeft point must not be null"); Assert.notNull(topLeftPoint, "topLeftPoint must not be null");
Assert.notNull(bottomRight, "bottomRight point must not be null"); Assert.notNull(bottomRightPoint, "bottomRightPoint must not be null");
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{topLeft, bottomRight})); filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{topLeftPoint, bottomRightPoint}));
return this; return this;
} }

View File

@ -186,11 +186,11 @@ public class ElasticsearchTemplateGeoTests {
} }
@Test @Test
public void shouldFindAuthorMarkersInBoxForGivenCriteriaQueryUsingGeoEnvelop() { public void shouldFindAuthorMarkersInBoxForGivenCriteriaQueryUsingGeoBox() {
//given //given
loadClassBaseEntities(); loadClassBaseEntities();
CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery( CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
new Criteria("location").bbox( new Criteria("location").boundedBy(
new GeoBox(new GeoPoint(53.5171d, 0), new GeoBox(new GeoPoint(53.5171d, 0),
new GeoPoint(49.5171d, 0.2062d)))); new GeoPoint(49.5171d, 0.2062d))));
//when //when
@ -206,7 +206,7 @@ public class ElasticsearchTemplateGeoTests {
//given //given
loadClassBaseEntities(); loadClassBaseEntities();
CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery( CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
new Criteria("location").bbox("53.5171d, 0", "49.5171d, 0.2062d")); new Criteria("location").boundedBy("53.5171d, 0", "49.5171d, 0.2062d"));
//when //when
List<AuthorMarkerEntity> geoAuthorsForGeoCriteria3 = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery3, AuthorMarkerEntity.class); List<AuthorMarkerEntity> geoAuthorsForGeoCriteria3 = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery3, AuthorMarkerEntity.class);
@ -220,7 +220,7 @@ public class ElasticsearchTemplateGeoTests {
//given //given
loadClassBaseEntities(); loadClassBaseEntities();
CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery( CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
new Criteria("location").bbox( new Criteria("location").boundedBy(
new GeoPoint(53.5171d, 0), new GeoPoint(53.5171d, 0),
new GeoPoint(49.5171d, 0.2062d))); new GeoPoint(49.5171d, 0.2062d)));
//when //when