Browse Source
Removed: - Box - Circle - CustomMetric - Distance - GeoPage - GeoResult - GeoResults - Metric - Metrics - Point - Polygon - Shape Updated api doc. Removed deprecation warnings.pull/217/merge
30 changed files with 38 additions and 1298 deletions
@ -1,75 +0,0 @@
@@ -1,75 +0,0 @@
|
||||
/* |
||||
* Copyright 2010-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.data.geo.Point; |
||||
|
||||
/** |
||||
* Represents a geospatial box value. |
||||
* |
||||
* @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Box}. This class is scheduled to be |
||||
* removed in the next major release. |
||||
* @author Mark Pollack |
||||
* @author Oliver Gierke |
||||
* @author Thomas Darimont |
||||
*/ |
||||
@Deprecated |
||||
public class Box extends org.springframework.data.geo.Box implements Shape { |
||||
|
||||
public static final String COMMAND = "$box"; |
||||
|
||||
public Box(Point lowerLeft, Point upperRight) { |
||||
super(lowerLeft, upperRight); |
||||
} |
||||
|
||||
public Box(double[] lowerLeft, double[] upperRight) { |
||||
super(lowerLeft, upperRight); |
||||
} |
||||
|
||||
/* |
||||
* (non-Javadoc) |
||||
* @see org.springframework.data.mongodb.core.geo.Shape#asList() |
||||
*/ |
||||
public List<? extends Object> asList() { |
||||
|
||||
List<List<Double>> list = new ArrayList<List<Double>>(); |
||||
|
||||
list.add(Arrays.asList(getFirst().getX(), getFirst().getY())); |
||||
list.add(Arrays.asList(getSecond().getX(), getSecond().getY())); |
||||
|
||||
return list; |
||||
} |
||||
|
||||
public org.springframework.data.mongodb.core.geo.Point getLowerLeft() { |
||||
return new org.springframework.data.mongodb.core.geo.Point(getFirst()); |
||||
} |
||||
|
||||
public org.springframework.data.mongodb.core.geo.Point getUpperRight() { |
||||
return new org.springframework.data.mongodb.core.geo.Point(getSecond()); |
||||
} |
||||
|
||||
/* |
||||
* (non-Javadoc) |
||||
* @see org.springframework.data.mongodb.core.geo.Shape#getCommand() |
||||
*/ |
||||
public String getCommand() { |
||||
return COMMAND; |
||||
} |
||||
} |
||||
@ -1,154 +0,0 @@
@@ -1,154 +0,0 @@
|
||||
/* |
||||
* Copyright 2010-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.data.annotation.PersistenceConstructor; |
||||
import org.springframework.data.geo.Distance; |
||||
import org.springframework.data.geo.Metrics; |
||||
import org.springframework.data.geo.Point; |
||||
import org.springframework.util.Assert; |
||||
|
||||
/** |
||||
* Represents a geospatial circle value. |
||||
* <p> |
||||
* Note: We deliberately do not extend org.springframework.data.geo.Circle because introducing it's distance concept |
||||
* would break the clients that use the old Circle API. |
||||
* |
||||
* @author Mark Pollack |
||||
* @author Oliver Gierke |
||||
* @author Thomas Darimont |
||||
* @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Circle}. This class is scheduled to be |
||||
* removed in the next major release. |
||||
*/ |
||||
@Deprecated |
||||
public class Circle implements Shape { |
||||
|
||||
public static final String COMMAND = "$center"; |
||||
|
||||
private final Point center; |
||||
private final double radius; |
||||
|
||||
/** |
||||
* Creates a new {@link Circle} from the given {@link Point} and radius. |
||||
* |
||||
* @param center must not be {@literal null}. |
||||
* @param radius must be greater or equal to zero. |
||||
*/ |
||||
@PersistenceConstructor |
||||
public Circle(Point center, double radius) { |
||||
|
||||
Assert.notNull(center); |
||||
Assert.isTrue(radius >= 0, "Radius must not be negative!"); |
||||
|
||||
this.center = center; |
||||
this.radius = radius; |
||||
} |
||||
|
||||
/** |
||||
* Creates a new {@link Circle} from the given coordinates and radius as {@link Distance} with a |
||||
* {@link Metrics#NEUTRAL}. |
||||
* |
||||
* @param centerX |
||||
* @param centerY |
||||
* @param radius must be greater or equal to zero. |
||||
*/ |
||||
public Circle(double centerX, double centerY, double radius) { |
||||
this(new Point(centerX, centerY), radius); |
||||
} |
||||
|
||||
/** |
||||
* Returns the center of the {@link Circle}. |
||||
* |
||||
* @return will never be {@literal null}. |
||||
*/ |
||||
public Point getCenter() { |
||||
return center; |
||||
} |
||||
|
||||
/** |
||||
* Returns the radius of the {@link Circle}. |
||||
* |
||||
* @return |
||||
*/ |
||||
public double getRadius() { |
||||
return radius; |
||||
} |
||||
|
||||
/* |
||||
* (non-Javadoc) |
||||
* @see org.springframework.data.mongodb.core.geo.Shape#asList() |
||||
*/ |
||||
public List<Object> asList() { |
||||
|
||||
List<Object> result = new ArrayList<Object>(); |
||||
result.add(Arrays.asList(getCenter().getX(), getCenter().getY())); |
||||
result.add(getRadius()); |
||||
|
||||
return result; |
||||
} |
||||
|
||||
/* |
||||
* (non-Javadoc) |
||||
* @see org.springframework.data.mongodb.core.geo.Shape#getCommand() |
||||
*/ |
||||
public String getCommand() { |
||||
return COMMAND; |
||||
} |
||||
|
||||
/* |
||||
* (non-Javadoc) |
||||
* @see java.lang.Object#toString() |
||||
*/ |
||||
@Override |
||||
public String toString() { |
||||
return String.format("Circle [center=%s, radius=%f]", center, radius); |
||||
} |
||||
|
||||
/* (non-Javadoc) |
||||
* @see java.lang.Object#equals(java.lang.Object) |
||||
*/ |
||||
@Override |
||||
public boolean equals(Object obj) { |
||||
|
||||
if (this == obj) { |
||||
return true; |
||||
} |
||||
|
||||
if (obj == null || !getClass().equals(obj.getClass())) { |
||||
return false; |
||||
} |
||||
|
||||
Circle that = (Circle) obj; |
||||
|
||||
return this.center.equals(that.center) && this.radius == that.radius; |
||||
} |
||||
|
||||
/* |
||||
* (non-Javadoc) |
||||
* @see java.lang.Object#hashCode() |
||||
*/ |
||||
@Override |
||||
public int hashCode() { |
||||
int result = 17; |
||||
result += 31 * center.hashCode(); |
||||
result += 31 * radius; |
||||
return result; |
||||
} |
||||
} |
||||
@ -1,37 +0,0 @@
@@ -1,37 +0,0 @@
|
||||
/* |
||||
* Copyright 2013-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
/** |
||||
* Value object to create custom {@link Metric}s on the fly. |
||||
* |
||||
* @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Metric}. This class is scheduled to be |
||||
* removed in the next major release. |
||||
* @author Oliver Gierke |
||||
* @author Thomas Darimont |
||||
*/ |
||||
@Deprecated |
||||
public class CustomMetric extends org.springframework.data.geo.CustomMetric implements Metric { |
||||
|
||||
/** |
||||
* Creates a custom {@link Metric} using the given multiplier. |
||||
* |
||||
* @param multiplier |
||||
*/ |
||||
public CustomMetric(double multiplier) { |
||||
super(multiplier); |
||||
} |
||||
} |
||||
@ -1,44 +0,0 @@
@@ -1,44 +0,0 @@
|
||||
/* |
||||
* Copyright 2010-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import org.springframework.data.geo.Metric; |
||||
import org.springframework.data.geo.Metrics; |
||||
|
||||
/** |
||||
* Value object to represent distances in a given metric. |
||||
* |
||||
* @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Distance}. This class is scheduled to |
||||
* be removed in the next major release. |
||||
* @author Oliver Gierke |
||||
* @author Thomas Darimont |
||||
*/ |
||||
@Deprecated |
||||
public class Distance extends org.springframework.data.geo.Distance { |
||||
|
||||
/** |
||||
* Creates a new {@link Distance}. |
||||
* |
||||
* @param value |
||||
*/ |
||||
public Distance(double value) { |
||||
this(value, Metrics.NEUTRAL); |
||||
} |
||||
|
||||
public Distance(double value, Metric metric) { |
||||
super(value, metric); |
||||
} |
||||
} |
||||
@ -1,54 +0,0 @@
@@ -1,54 +0,0 @@
|
||||
/* |
||||
* Copyright 2011-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import org.springframework.data.domain.Page; |
||||
import org.springframework.data.domain.Pageable; |
||||
|
||||
/** |
||||
* Custom {@link Page} to carry the average distance retrieved from the {@link GeoResults} the {@link GeoPage} is set up |
||||
* from. |
||||
* |
||||
* @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.GeoPage}. This class is scheduled to |
||||
* be removed in the next major release. |
||||
* @author Oliver Gierke |
||||
* @author Thomas Darimont |
||||
*/ |
||||
@Deprecated |
||||
public class GeoPage<T> extends org.springframework.data.geo.GeoPage<T> { |
||||
|
||||
private static final long serialVersionUID = 23421312312412L; |
||||
|
||||
/** |
||||
* Creates a new {@link GeoPage} from the given {@link GeoResults}. |
||||
* |
||||
* @param content must not be {@literal null}. |
||||
*/ |
||||
public GeoPage(GeoResults<T> results) { |
||||
super(results); |
||||
} |
||||
|
||||
/** |
||||
* Creates a new {@link GeoPage} from the given {@link GeoResults}, {@link Pageable} and total. |
||||
* |
||||
* @param results must not be {@literal null}. |
||||
* @param pageable must not be {@literal null}. |
||||
* @param total |
||||
*/ |
||||
public GeoPage(GeoResults<T> results, Pageable pageable, long total) { |
||||
super(results, pageable, total); |
||||
} |
||||
} |
||||
@ -1,38 +0,0 @@
@@ -1,38 +0,0 @@
|
||||
/* |
||||
* Copyright 2011-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
/** |
||||
* Calue object capturing some arbitrary object plus a distance. |
||||
* |
||||
* @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.GeoResult}. This class is scheduled to |
||||
* be removed in the next major release. |
||||
* @author Oliver Gierke |
||||
* @author Thomas Darimont |
||||
*/ |
||||
@Deprecated |
||||
public class GeoResult<T> extends org.springframework.data.geo.GeoResult<T> { |
||||
|
||||
/** |
||||
* Creates a new {@link GeoResult} for the given content and distance. |
||||
* |
||||
* @param content must not be {@literal null}. |
||||
* @param distance must not be {@literal null}. |
||||
*/ |
||||
public GeoResult(T content, Distance distance) { |
||||
super(content, distance); |
||||
} |
||||
} |
||||
@ -1,60 +0,0 @@
@@ -1,60 +0,0 @@
|
||||
/* |
||||
* Copyright 2011-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.springframework.data.annotation.PersistenceConstructor; |
||||
import org.springframework.data.geo.Distance; |
||||
import org.springframework.data.geo.GeoResult; |
||||
import org.springframework.data.geo.Metric; |
||||
|
||||
/** |
||||
* Value object to capture {@link GeoResult}s as well as the average distance they have. |
||||
* |
||||
* @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.GeoResults}. This class is scheduled |
||||
* to be removed in the next major release. |
||||
* @author Oliver Gierke |
||||
* @author Thomas Darimont |
||||
*/ |
||||
@Deprecated |
||||
public class GeoResults<T> extends org.springframework.data.geo.GeoResults<T> { |
||||
|
||||
/** |
||||
* Creates a new {@link GeoResults} instance manually calculating the average distance from the distance values of the |
||||
* given {@link GeoResult}s. |
||||
* |
||||
* @param results must not be {@literal null}. |
||||
*/ |
||||
public GeoResults(List<? extends GeoResult<T>> results) { |
||||
super(results); |
||||
} |
||||
|
||||
public GeoResults(List<? extends GeoResult<T>> results, Metric metric) { |
||||
super(results, metric); |
||||
} |
||||
|
||||
/** |
||||
* Creates a new {@link GeoResults} instance from the given {@link GeoResult}s and average distance. |
||||
* |
||||
* @param results must not be {@literal null}. |
||||
* @param averageDistance |
||||
*/ |
||||
@PersistenceConstructor |
||||
public GeoResults(List<? extends GeoResult<T>> results, Distance averageDistance) { |
||||
super(results, averageDistance); |
||||
} |
||||
} |
||||
@ -1,27 +0,0 @@
@@ -1,27 +0,0 @@
|
||||
/* |
||||
* Copyright 2011-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
/** |
||||
* Interface for {@link Metric}s that can be applied to a base scale. |
||||
* |
||||
* @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Metric}. This class is scheduled to be |
||||
* removed in the next major release. |
||||
* @author Oliver Gierke |
||||
* @author Thomas Darimont |
||||
*/ |
||||
@Deprecated |
||||
public interface Metric extends org.springframework.data.geo.Metric {} |
||||
@ -1,48 +0,0 @@
@@ -1,48 +0,0 @@
|
||||
/* |
||||
* Copyright 2011-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import org.springframework.data.mongodb.core.query.NearQuery; |
||||
|
||||
/** |
||||
* Commonly used {@link Metrics} for {@link NearQuery}s. |
||||
* |
||||
* @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Metrics}. This class is scheduled to |
||||
* be removed in the next major release. |
||||
* @author Oliver Gierke |
||||
* @author Thomas Darimont |
||||
*/ |
||||
@Deprecated |
||||
public enum Metrics implements Metric { |
||||
|
||||
KILOMETERS(org.springframework.data.geo.Metrics.KILOMETERS.getMultiplier()), //
|
||||
MILES(org.springframework.data.geo.Metrics.MILES.getMultiplier()), //
|
||||
NEUTRAL(org.springframework.data.geo.Metrics.NEUTRAL.getMultiplier()); //
|
||||
|
||||
private final double multiplier; |
||||
|
||||
private Metrics(double multiplier) { |
||||
this.multiplier = multiplier; |
||||
} |
||||
|
||||
/* |
||||
* (non-Javadoc) |
||||
* @see org.springframework.data.mongodb.core.geo.Metric#getMultiplier() |
||||
*/ |
||||
public double getMultiplier() { |
||||
return multiplier; |
||||
} |
||||
} |
||||
@ -1,55 +0,0 @@
@@ -1,55 +0,0 @@
|
||||
/* |
||||
* Copyright 2010-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.data.annotation.PersistenceConstructor; |
||||
|
||||
/** |
||||
* Represents a geospatial point value. |
||||
* |
||||
* @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Point}. This class is scheduled to be |
||||
* removed in the next major release. |
||||
* @author Mark Pollack |
||||
* @author Oliver Gierke |
||||
* @author Thomas Darimont |
||||
*/ |
||||
@Deprecated |
||||
public class Point extends org.springframework.data.geo.Point { |
||||
|
||||
@PersistenceConstructor |
||||
public Point(double x, double y) { |
||||
super(x, y); |
||||
} |
||||
|
||||
public Point(org.springframework.data.geo.Point point) { |
||||
super(point); |
||||
} |
||||
|
||||
public double[] asArray() { |
||||
return new double[] { getX(), getY() }; |
||||
} |
||||
|
||||
public List<Double> asList() { |
||||
return asList(this); |
||||
} |
||||
|
||||
public static List<Double> asList(org.springframework.data.geo.Point point) { |
||||
return Arrays.asList(point.getX(), point.getY()); |
||||
} |
||||
} |
||||
@ -1,92 +0,0 @@
@@ -1,92 +0,0 @@
|
||||
/* |
||||
* Copyright 2011-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.data.geo.Point; |
||||
|
||||
/** |
||||
* Simple value object to represent a {@link Polygon}. |
||||
* |
||||
* @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Point}. This class is scheduled to be |
||||
* removed in the next major release. |
||||
* @author Oliver Gierke |
||||
* @author Thomas Darimont |
||||
*/ |
||||
@Deprecated |
||||
public class Polygon extends org.springframework.data.geo.Polygon implements Shape { |
||||
|
||||
public static final String COMMAND = "$polygon"; |
||||
|
||||
/** |
||||
* Creates a new {@link Polygon} for the given Points. |
||||
* |
||||
* @param x |
||||
* @param y |
||||
* @param z |
||||
* @param others |
||||
*/ |
||||
public <P extends Point> Polygon(P x, P y, P z, P... others) { |
||||
super(x, y, z, others); |
||||
} |
||||
|
||||
/** |
||||
* Creates a new {@link Polygon} for the given Points. |
||||
* |
||||
* @param points |
||||
*/ |
||||
public <P extends Point> Polygon(List<P> points) { |
||||
super(points); |
||||
} |
||||
|
||||
/* |
||||
* (non-Javadoc) |
||||
* @see org.springframework.data.mongodb.core.geo.Shape#getCommand() |
||||
*/ |
||||
public String getCommand() { |
||||
return COMMAND; |
||||
} |
||||
|
||||
/* |
||||
* (non-Javadoc) |
||||
* @see org.springframework.data.mongodb.core.geo.Shape#asList() |
||||
*/ |
||||
@Override |
||||
public List<? extends Object> asList() { |
||||
return asList(this); |
||||
} |
||||
|
||||
/** |
||||
* Returns a {@link List} of x,y-coordinate tuples of {@link Point}s from the given {@link Polygon}. |
||||
* |
||||
* @param polygon |
||||
* @return |
||||
*/ |
||||
public static List<? extends Object> asList(org.springframework.data.geo.Polygon polygon) { |
||||
|
||||
List<Point> points = polygon.getPoints(); |
||||
List<List<Double>> tuples = new ArrayList<List<Double>>(points.size()); |
||||
|
||||
for (Point point : points) { |
||||
tuples.add(Arrays.asList(point.getX(), point.getY())); |
||||
} |
||||
|
||||
return tuples; |
||||
} |
||||
} |
||||
@ -1,45 +0,0 @@
@@ -1,45 +0,0 @@
|
||||
/* |
||||
* Copyright 2011-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Common interface for all shapes. Allows building MongoDB representations of them. |
||||
* |
||||
* @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Shape}. This class is scheduled to be |
||||
* removed in the next major release. |
||||
* @author Oliver Gierke |
||||
* @author Thomas Darimont |
||||
*/ |
||||
@Deprecated |
||||
public interface Shape extends org.springframework.data.geo.Shape { |
||||
|
||||
/** |
||||
* Returns the {@link Shape} as a list of usually {@link Double} or {@link List}s of {@link Double}s. Wildcard bound |
||||
* to allow implementations to return a more concrete element type. |
||||
* |
||||
* @return |
||||
*/ |
||||
List<? extends Object> asList(); |
||||
|
||||
/** |
||||
* Returns the command to be used to create the {@literal $within} criterion. |
||||
* |
||||
* @return |
||||
*/ |
||||
String getCommand(); |
||||
} |
||||
@ -1,49 +0,0 @@
@@ -1,49 +0,0 @@
|
||||
/* |
||||
* Copyright 2011-2014 by the original author(s). |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import static org.hamcrest.CoreMatchers.*; |
||||
import static org.junit.Assert.*; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* Unit tests for {@link Box}. |
||||
* |
||||
* @author Oliver Gierke |
||||
*/ |
||||
@SuppressWarnings("deprecation") |
||||
public class BoxUnitTests { |
||||
|
||||
Box first = new Box(new Point(1d, 1d), new Point(2d, 2d)); |
||||
Box second = new Box(new Point(1d, 1d), new Point(2d, 2d)); |
||||
Box third = new Box(new Point(3d, 3d), new Point(1d, 1d)); |
||||
|
||||
@Test |
||||
public void equalsWorksCorrectly() { |
||||
|
||||
assertThat(first.equals(second), is(true)); |
||||
assertThat(second.equals(first), is(true)); |
||||
assertThat(first.equals(third), is(false)); |
||||
} |
||||
|
||||
@Test |
||||
public void hashCodeWorksCorrectly() { |
||||
|
||||
assertThat(first.hashCode(), is(second.hashCode())); |
||||
assertThat(first.hashCode(), is(not(third.hashCode()))); |
||||
} |
||||
} |
||||
@ -1,55 +0,0 @@
@@ -1,55 +0,0 @@
|
||||
/* |
||||
* Copyright 2011-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import static org.hamcrest.CoreMatchers.*; |
||||
import static org.junit.Assert.*; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* Unit tests for {@link Circle}. |
||||
* |
||||
* @author Oliver Gierke |
||||
*/ |
||||
@SuppressWarnings("deprecation") |
||||
public class CircleUnitTests { |
||||
|
||||
@Test(expected = IllegalArgumentException.class) |
||||
public void rejectsNullOrigin() { |
||||
new Circle(null, 0); |
||||
} |
||||
|
||||
@Test(expected = IllegalArgumentException.class) |
||||
public void rejectsNegativeRadius() { |
||||
new Circle(1, 1, -1); |
||||
} |
||||
|
||||
@Test |
||||
public void considersTwoCirclesEqualCorrectly() { |
||||
|
||||
Circle left = new Circle(1, 1, 1); |
||||
Circle right = new Circle(1, 1, 1); |
||||
|
||||
assertThat(left, is(right)); |
||||
assertThat(right, is(left)); |
||||
|
||||
right = new Circle(new Point(1, 1), 1); |
||||
|
||||
assertThat(left, is(right)); |
||||
assertThat(right, is(left)); |
||||
} |
||||
} |
||||
@ -1,58 +0,0 @@
@@ -1,58 +0,0 @@
|
||||
/* |
||||
* Copyright 2011-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import static org.hamcrest.CoreMatchers.*; |
||||
import static org.junit.Assert.*; |
||||
import static org.springframework.data.mongodb.core.geo.Metrics.*; |
||||
|
||||
import org.junit.Test; |
||||
import org.springframework.data.geo.Metric; |
||||
|
||||
/** |
||||
* Unit tests for {@link Distance}. |
||||
* |
||||
* @author Oliver Gierke |
||||
* @author Thomas Darimont |
||||
*/ |
||||
@SuppressWarnings("deprecation") |
||||
public class DistanceUnitTests { |
||||
|
||||
@Test |
||||
public void defaultsMetricToNeutralOne() { |
||||
|
||||
assertThat(new Distance(2.5).getMetric(), is((Metric) org.springframework.data.geo.Metrics.NEUTRAL)); |
||||
assertThat(new Distance(2.5, null).getMetric(), is((Metric) org.springframework.data.geo.Metrics.NEUTRAL)); |
||||
} |
||||
|
||||
@Test |
||||
public void addsDistancesWithoutExplicitMetric() { |
||||
|
||||
Distance left = new Distance(2.5, KILOMETERS); |
||||
Distance right = new Distance(2.5, KILOMETERS); |
||||
|
||||
assertThat(left.add(right), is(new org.springframework.data.geo.Distance(5.0, KILOMETERS))); |
||||
} |
||||
|
||||
@Test |
||||
public void addsDistancesWithExplicitMetric() { |
||||
|
||||
Distance left = new Distance(2.5, KILOMETERS); |
||||
Distance right = new Distance(2.5, KILOMETERS); |
||||
|
||||
assertThat(left.add(right, MILES), is(new org.springframework.data.geo.Distance(3.106856281073925, MILES))); |
||||
} |
||||
} |
||||
@ -1,57 +0,0 @@
@@ -1,57 +0,0 @@
|
||||
/* |
||||
* Copyright 2011-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import static org.hamcrest.CoreMatchers.*; |
||||
import static org.junit.Assert.*; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* Unit tests for {@link GeoResult}. |
||||
* |
||||
* @author Oliver Gierke |
||||
*/ |
||||
@SuppressWarnings("deprecation") |
||||
public class GeoResultUnitTests { |
||||
|
||||
GeoResult<String> first = new GeoResult<String>("Foo", new Distance(2.5)); |
||||
GeoResult<String> second = new GeoResult<String>("Foo", new Distance(2.5)); |
||||
GeoResult<String> third = new GeoResult<String>("Bar", new Distance(2.5)); |
||||
GeoResult<String> fourth = new GeoResult<String>("Foo", new Distance(5.2)); |
||||
|
||||
@Test |
||||
public void considersSameInstanceEqual() { |
||||
|
||||
assertThat(first.equals(first), is(true)); |
||||
} |
||||
|
||||
@Test |
||||
public void considersSameValuesAsEqual() { |
||||
assertThat(first.equals(second), is(true)); |
||||
assertThat(second.equals(first), is(true)); |
||||
assertThat(first.equals(third), is(false)); |
||||
assertThat(third.equals(first), is(false)); |
||||
assertThat(first.equals(fourth), is(false)); |
||||
assertThat(fourth.equals(first), is(false)); |
||||
} |
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" }) |
||||
@Test(expected = IllegalArgumentException.class) |
||||
public void rejectsNullContent() { |
||||
new GeoResult(null, new Distance(2.5)); |
||||
} |
||||
} |
||||
@ -1,44 +0,0 @@
@@ -1,44 +0,0 @@
|
||||
/* |
||||
* Copyright 2011-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import static org.hamcrest.CoreMatchers.*; |
||||
import static org.junit.Assert.*; |
||||
|
||||
import java.util.Arrays; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* Unit tests for {@link GeoResults}. |
||||
* |
||||
* @author Oliver Gierke |
||||
* @author Thomas Darimont |
||||
*/ |
||||
@SuppressWarnings("deprecation") |
||||
public class GeoResultsUnitTests { |
||||
|
||||
@Test |
||||
@SuppressWarnings("unchecked") |
||||
public void calculatesAverageForGivenGeoResults() { |
||||
|
||||
GeoResult<Object> first = new GeoResult<Object>(new Object(), new Distance(2)); |
||||
GeoResult<Object> second = new GeoResult<Object>(new Object(), new Distance(5)); |
||||
GeoResults<Object> geoResults = new GeoResults<Object>(Arrays.asList(first, second)); |
||||
|
||||
assertThat(geoResults.getAverageDistance(), is(new org.springframework.data.geo.Distance(3.5))); |
||||
} |
||||
} |
||||
@ -1,47 +0,0 @@
@@ -1,47 +0,0 @@
|
||||
/* |
||||
* Copyright 2011-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import static org.hamcrest.CoreMatchers.*; |
||||
import static org.junit.Assert.*; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* Unit tests for {@link Point}. |
||||
* |
||||
* @author Oliver Gierke |
||||
*/ |
||||
@SuppressWarnings("deprecation") |
||||
public class PointUnitTests { |
||||
|
||||
@Test(expected = IllegalArgumentException.class) |
||||
public void rejectsNullforCopyConstructor() { |
||||
new Point(null); |
||||
} |
||||
|
||||
@Test |
||||
public void equalsIsImplementedCorrectly() { |
||||
assertThat(new Point(1.5, 1.5), is(equalTo(new Point(1.5, 1.5)))); |
||||
assertThat(new Point(1.5, 1.5), is(not(equalTo(new Point(2.0, 2.0))))); |
||||
assertThat(new Point(2.0, 2.0), is(not(equalTo(new Point(1.5, 1.5))))); |
||||
} |
||||
|
||||
@Test |
||||
public void invokingToStringWorksCorrectly() { |
||||
new Point(1.5, 1.5).toString(); |
||||
} |
||||
} |
||||
@ -1,55 +0,0 @@
@@ -1,55 +0,0 @@
|
||||
/* |
||||
* Copyright 2011-2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.geo; |
||||
|
||||
import static org.hamcrest.CoreMatchers.*; |
||||
import static org.junit.Assert.*; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* Unit tests for {@link Polygon}. |
||||
* |
||||
* @author Oliver Gierke |
||||
*/ |
||||
@SuppressWarnings("deprecation") |
||||
public class PolygonUnitTests { |
||||
|
||||
Point first = new Point(1, 1); |
||||
Point second = new Point(2, 2); |
||||
Point third = new Point(3, 3); |
||||
|
||||
@Test(expected = IllegalArgumentException.class) |
||||
public void rejectsNullPoints() { |
||||
new Polygon(null, null, null); |
||||
} |
||||
|
||||
@Test |
||||
public void createsSimplePolygon() { |
||||
Polygon polygon = new Polygon(third, second, first); |
||||
assertThat(polygon, is(notNullValue())); |
||||
} |
||||
|
||||
@Test |
||||
public void isEqualForSamePoints() { |
||||
|
||||
Polygon left = new Polygon(third, second, first); |
||||
Polygon right = new Polygon(third, second, first); |
||||
|
||||
assertThat(left, is(right)); |
||||
assertThat(right, is(left)); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue