Execute the snap operation.

@param coordinate The original location.
@param distance   The maximum distance allowed for snapping.
@return The new location. If no snapping target was found, this may return the original location.
420075
public Coordinate snap(Coordinate coordinate, double distance) {
		// Some initialization:
		calculatedDistance = distance;
		hasSnapped = false;
		Coordinate snappingPoint = coordinate;

		// Go over all geometries and consider only the intersecting ones:
		for (Geometry geometry : geometries) {
			if (MathService.isWithin(geometry, coordinate)) {
				NearestVertexSnapAlgorithm nearestVertex = new NearestVertexSnapAlgorithm();
				nearestVertex.setGeometries(new Geometry[] { geometry });
				Coordinate temp = nearestVertex.snap(coordinate, calculatedDistance);
				if (nearestVertex.hasSnapped()) {
					hasSnapped = true;
					calculatedDistance = nearestVertex.getCalculatedDistance();
					snappingPoint = temp;
				}
			}
		}

		return snappingPoint;
	}
243566
@Override
	protected void checkBestDistance(KdTree.Node node, P target) {
		double distanceSq = distance.distance((P)node.point,target);
		if( distanceSq <= bestDistanceSq ) {
			if( bestNode == null || distanceSq < bestDistanceSq ) {
				bestDistanceSq = distanceSq;
				bestNode = node;
			}
		}
	}
271079
protected static double calculateReachDistance(LofPoint basePoint, LofPoint targetPoint)
    {
        double distance = MathUtils.distance(basePoint.getDataPoint(), targetPoint.getDataPoint());

        double reachDistance = (double) ComparatorUtils.max(distance, targetPoint.getkDistance(),
                ComparatorUtils.NATURAL_COMPARATOR);
        return reachDistance;
    }
936334
private void branch(int stackAdjust, Location location, byte opcode) {
        if (!(location instanceof InstructionList.LabelInstruction)) {
            throw new IllegalArgumentException("Branch location is not a label instruction");
        }
        mInstructions.new BranchInstruction(stackAdjust, opcode,
                                            (InstructionList.LabelInstruction)location);
    }
119158
@Override
	@Pure
	public double getDistance(Point2D<?, ?> point) {
		double dist = super.getDistance(point);
		dist -= this.radius;
		return dist;
	}
1011296
public AVIMConversationsQuery whereWithinRadians(String key, AVGeoPoint point, double maxDistance) {
    conditions.whereWithinRadians(key, point, maxDistance);
    return this;
  }
1351139
public Geometry execute(Geometry geometry) {
		if (geometry == null) {
			return null;
		}
		if (geometry instanceof LinearRing) {
			if (coordIndex <= 0) {
				coordIndex = 0;
			} else if (coordIndex > geometry.getNumPoints() - 1) {
				coordIndex = geometry.getNumPoints() - 1;
			}
			Coordinate[] coordinates = new Coordinate[geometry.getNumPoints() + 1];
			int count = 0;
			for (int i = 0; i < coordinates.length; i++) {
				if (i == coordIndex) {
					coordinates[i] = coordinate;
				} else if (i == coordinates.length - 1) {
					coordinates[i] = coordinates[0];
				} else {
					coordinates[i] = geometry.getCoordinates()[count++];
				}
			}
			return geometry.getGeometryFactory().createLinearRing(coordinates);
		} else if (geometry instanceof LineString) {
			if (coordIndex <= 0) {
				coordIndex = 0;
			} else if (coordIndex > geometry.getNumPoints()) {
				coordIndex = geometry.getNumPoints();
			}
			Coordinate[] coordinates = new Coordinate[geometry.getNumPoints() + 1];
			int count = 0;
			for (int i = 0; i < coordinates.length; i++) {
				if (i == coordIndex) {
					coordinates[i] = coordinate;
				} else {
					coordinates[i] = geometry.getCoordinates()[count++];
				}
			}
			return geometry.getGeometryFactory().createLineString(coordinates);
		}
		return null;
	}
1238517
public final void setLocation(String loc) {
        if (location == null && loc == null) {
            // no unnecessary property creation if everything is null
            return;
        }
        locationProperty().set(loc);
    }
952896
@Unit(NM)
    public static double radius(Location... location)
    {
        Location center = center(location);
        double max = 0;
        for (Location loc : location)
        {
            Distance distance = distance(loc, center);
            double miles = distance.getMiles();
            if (miles > max)
            {
                max = miles;
            }
        }
        return max;
    }
488263
public void setLocation(double x, double y)
    {
        final double dx = x - (mover.getX() + offset.getX());
        final double dy = y - (mover.getY() + offset.getY());
        moveLocation(1, dx, dy);
    }
296015
public boolean isNearTo(Double3D location, double distance) {
        if (this.is3DLocation()) {
            return this.getLocation3D().distance(location) < distance;
        } else {
            return false;
        }
    }
579364
public void update(Bbox mapBounds) {
		for (final SnappingRule condition : snappingRules) {
			condition.getSourceProvider().update(mapBounds);
			condition.getSourceProvider().getSnappingSources(new GeometryArrayFunction() {

				public void execute(Geometry[] geometries) {
					condition.getAlgorithm().setGeometries(geometries);
				}
			});
		}
	}
624473
public double getDistance(Coordinate coordinate) {
		double distance = Double.MAX_VALUE;
		if (!isEmpty()) {
			for (LineString lineString : lineStrings) {
				double d = lineString.getDistance(coordinate);
				if (d < distance) {
					distance = d;
				}
			}
		}
		return distance;
	}
5726
public void setLocation(Location location) {
        if (location != null) {
            this.location = location;
        } else {
            this.location = Location.Unspecified;
        }
    }
420042
public void setPosition(GeoLocationPoint position) {
		if ((this.position == null && position != null)
			|| (this.position != null && !this.position.equals(position))) {
			this.position = position;
			fireShapeChanged();
			checkPrimitiveValidity();
		}
	}
125558
public void setLocation(final Point2D LOCATION) {
        this.lon = LOCATION.getX();
        this.lat = LOCATION.getY();
        this.LOCATION.setLocation(LOCATION);
        this.LOCATION_XY.setLocation(toXY(this.lat, this.lon));
        adjustDirection();
    }
847948
public double getDistance(Coordinate coordinate) {
		double minDistance = Double.MAX_VALUE;

		if (!isEmpty()) {
			for (int i = 0; i < this.coordinates.length - 1; i++) {
				double dist = Mathlib.distance(this.coordinates[i], this.coordinates[i + 1], coordinate);
				if (dist < minDistance) {
					minDistance = dist;
				}
			}
		}
		return minDistance;
	}