org.springframework.data.geo.Distance.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中org.springframework.data.geo.Distance.<init>()方法的一些代码示例,展示了Distance.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Distance.<init>()方法的具体详情如下:
包路径:org.springframework.data.geo.Distance
类名称:Distance
方法名:<init>

Distance.<init>介绍

[英]Creates a new Distance with a neutral metric. This means the provided value needs to be in normalized form.
[中]使用中性度量创建新距离。这意味着提供的值需要采用规范化的形式。

代码示例

代码示例来源:origin: redisson/redisson

@Override
public Distance convert(Object obj) {
  return new Distance((Double)obj, metric);
}

代码示例来源:origin: redisson/redisson

@Override
public Distance convert(Object obj) {
  return new Distance((Double)obj, metric);
}

代码示例来源:origin: redisson/redisson

@Override
public Distance convert(Object obj) {
  return new Distance((Double)obj, metric);
}

代码示例来源:origin: spring-projects/spring-data-mongodb

/**
 * Creates a Sphere around the given center {@link Point} with the given radius.
 *
 * @param center
 * @param radius
 */
public Sphere(Point center, double radius) {
  this(center, new Distance(radius));
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
  public Distance convert(Double source) {
    return new Distance(source, metric);
  }
}

代码示例来源:origin: redisson/redisson

@Override
public GeoResults<GeoLocation<byte[]>> geoRadiusByMember(byte[] key, byte[] member, double radius) {
  return geoRadiusByMember(key, member, new Distance(radius, DistanceUnit.METERS));
}

代码示例来源:origin: redisson/redisson

@Override
public GeoResults<GeoLocation<byte[]>> geoRadiusByMember(byte[] key, byte[] member, double radius) {
  return geoRadiusByMember(key, member, new Distance(radius, DistanceUnit.METERS));
}

代码示例来源:origin: spring-projects/spring-data-redis

/**
 * Creates a new {@link GeoRadiusByMemberCommand} given a {@literal distance} in {@link DistanceUnit#FEET}.
 *
 * @param distance must not be {@literal null}.
 * @return a new {@link GeoRadiusByMemberCommand} for a {@literal distance} in {@link DistanceUnit#FEET}.
 */
public static GeoRadiusByMemberCommand withinFeet(double distance) {
  return within(new Distance(distance, DistanceUnit.FEET));
}

代码示例来源:origin: spring-projects/spring-data-redis

/**
 * Creates a new {@link GeoRadiusCommand} given a {@literal distance} in {@link DistanceUnit#METERS}.
 *
 * @param distance must not be {@literal null}.
 * @return a new {@link GeoRadiusCommand} for a {@literal distance} in {@link DistanceUnit#METERS}.
 */
public static GeoRadiusCommand withinMeters(double distance) {
  return within(new Distance(distance, DistanceUnit.METERS));
}

代码示例来源:origin: spring-projects/spring-data-redis

/**
 * Creates a new {@link GeoRadiusCommand} given a {@literal distance} in {@link DistanceUnit#FEET}.
 *
 * @param distance must not be {@literal null}.
 * @return a new {@link GeoRadiusCommand} for a {@literal distance} in {@link DistanceUnit#FEET}.
 */
public static GeoRadiusCommand withinFeet(double distance) {
  return within(new Distance(distance, DistanceUnit.FEET));
}

代码示例来源:origin: spring-projects/spring-data-redis

/**
 * Creates a new {@link GeoRadiusByMemberCommand} given a {@literal distance} in {@link DistanceUnit#MILES}.
 *
 * @param distance must not be {@literal null}.
 * @return a new {@link GeoRadiusByMemberCommand} for a {@literal distance} in {@link DistanceUnit#MILES}.
 */
public static GeoRadiusByMemberCommand withinMiles(double distance) {
  return within(new Distance(distance, DistanceUnit.MILES));
}

代码示例来源:origin: spring-projects/spring-data-mongodb

/**
 * Sets the maximum distance supplied in a given metric. Will normalize the distance but not reconfigure the query's
 * result {@link Metric} if one was configured before.
 *
 * @param maxDistance
 * @param metric must not be {@literal null}.
 * @return
 */
public NearQuery maxDistance(double maxDistance, Metric metric) {
  Assert.notNull(metric, "Metric must not be null!");
  return maxDistance(new Distance(maxDistance, metric));
}

代码示例来源:origin: spring-projects/spring-data-redis

/**
 * Creates a new {@link GeoRadiusCommand} given a {@literal distance} in {@link DistanceUnit#MILES}.
 *
 * @param distance must not be {@literal null}.
 * @return a new {@link GeoRadiusCommand} for a {@literal distance} in {@link DistanceUnit#MILES}.
 */
public static GeoRadiusCommand withinMiles(double distance) {
  return within(new Distance(distance, DistanceUnit.MILES));
}

代码示例来源:origin: spring-projects/spring-data-redis

/**
 * Creates a new {@link GeoRadiusByMemberCommand} given a {@literal distance} in {@link DistanceUnit#KILOMETERS}.
 *
 * @param distance must not be {@literal null}.
 * @return a new {@link GeoRadiusByMemberCommand} for a {@literal distance} in {@link DistanceUnit#KILOMETERS}.
 */
public static GeoRadiusByMemberCommand withinKiometers(double distance) {
  return within(new Distance(distance, DistanceUnit.KILOMETERS));
}

代码示例来源:origin: redisson/redisson

@Override
public GeoResults<GeoLocation<byte[]>> decode(List<Object> parts, State state) {
  List<GeoResult<GeoLocation<byte[]>>> result = new ArrayList<GeoResult<GeoLocation<byte[]>>>();
  for (Object object : parts) {
    if (object instanceof List) {
      List<Object> vals = ((List<Object>) object);
      
      if (metric != null) {
        GeoLocation<byte[]> location = new GeoLocation<byte[]>((byte[])vals.get(0), null);
        result.add(new GeoResult<GeoLocation<byte[]>>(location, new Distance((Double)vals.get(1), metric)));
      } else {
        GeoLocation<byte[]> location = new GeoLocation<byte[]>((byte[])vals.get(0), (Point)vals.get(1));
        result.add(new GeoResult<GeoLocation<byte[]>>(location, null));
      }
    } else {
      GeoLocation<byte[]> location = new GeoLocation<byte[]>((byte[])object, null);
      result.add(new GeoResult<GeoLocation<byte[]>>(location, new Distance(0)));
    }
  }
  return new GeoResults<GeoLocation<byte[]>>(result);
}

代码示例来源:origin: redisson/redisson

@Override
public GeoResults<GeoLocation<byte[]>> decode(List<Object> parts, State state) {
  List<GeoResult<GeoLocation<byte[]>>> result = new ArrayList<GeoResult<GeoLocation<byte[]>>>();
  for (Object object : parts) {
    if (object instanceof List) {
      List<Object> vals = ((List<Object>) object);
      
      if (metric != null) {
        GeoLocation<byte[]> location = new GeoLocation<byte[]>((byte[])vals.get(0), null);
        result.add(new GeoResult<GeoLocation<byte[]>>(location, new Distance((Double)vals.get(1), metric)));
      } else {
        GeoLocation<byte[]> location = new GeoLocation<byte[]>((byte[])vals.get(0), (Point)vals.get(1));
        result.add(new GeoResult<GeoLocation<byte[]>>(location, null));
      }
    } else {
      GeoLocation<byte[]> location = new GeoLocation<byte[]>((byte[])object, null);
      result.add(new GeoResult<GeoLocation<byte[]>>(location, new Distance(0)));
    }
  }
  return new GeoResults<GeoLocation<byte[]>>(result);
}

代码示例来源:origin: spring-projects/spring-data-mongodb

@Nullable
  public GeoResult<T> doWith(@Nullable Document object) {
    double distance = ((Double) object.get("dis")).doubleValue();
    Document content = (Document) object.get("obj");
    T doWith = delegate.doWith(content);
    return new GeoResult<>(doWith, new Distance(distance, metric));
  }
}

代码示例来源:origin: spring-projects/spring-data-mongodb

public GeoResult<T> doWith(Document object) {
    double distance = (Double) object.get("dis");
    Document content = (Document) object.get("obj");
    T doWith = delegate.doWith(content);
    return new GeoResult<>(doWith, new Distance(distance, metric));
  }
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Flux<GeoResult<GeoLocation<V>>> radius(K key, V member, double radius) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(member, "Member must not be null!");
  return createFlux(connection -> connection.geoRadiusByMember(rawKey(key), rawValue(member), new Distance(radius)) //
      .map(this::readGeoResult));
}

代码示例来源:origin: spring-projects/spring-data-redis

private Converter<GeoWithin<ByteBuffer>, GeoResult<GeoLocation<ByteBuffer>>> converter(Metric metric) {

    return (source) -> {

      Point point = LettuceConverters.geoCoordinatesToPoint(source.getCoordinates());

      return new GeoResult<>(new GeoLocation<>(source.getMember(), point),
          new Distance(source.getDistance() != null ? source.getDistance() : 0D, metric));
    };
  }
}

相关文章