/** * Parses a given distance and converts it to this unit. * * @param distance String defining a distance (value and unit) * @param defaultUnit unit to expect if none if provided * @return parsed distance */ public double parse(String distance, DistanceUnit defaultUnit) { return parse(distance, defaultUnit, this); }
/** * Calculate the number of levels needed for a specific precision. GeoHash * cells will not exceed the specified size (diagonal) of the precision. * @param distance Maximum size of cells as unit string (must greater or equal to zero) * @return levels need to achieve precision */ public static int geoHashLevelsForPrecision(String distance) { return geoHashLevelsForPrecision(DistanceUnit.METERS.parse(distance, DistanceUnit.DEFAULT)); }
/** * Calculate the number of levels needed for a specific precision. QuadTree * cells will not exceed the specified size (diagonal) of the precision. * @param distance Maximum size of cells as unit string (must greater or equal to zero) * @return levels need to achieve precision */ public static int quadTreeLevelsForPrecision(String distance) { return quadTreeLevelsForPrecision(DistanceUnit.METERS.parse(distance, DistanceUnit.DEFAULT)); }
/** * Set the precision use o make suggestions * * @param precision * precision as distance with {@link DistanceUnit}. Default: * meters * @return this */ public Builder precision(String precision) { return precision(DistanceUnit.parse(precision, DistanceUnit.METERS, DistanceUnit.METERS)); }
/** Sets the distance from the center for this query. */ public GeoDistanceQueryBuilder distance(String distance, DistanceUnit unit) { if (Strings.isEmpty(distance)) { throw new IllegalArgumentException("distance must not be null or empty"); } if (unit == null) { throw new IllegalArgumentException("distance unit must not be null"); } double newDistance = DistanceUnit.parse(distance, unit, DistanceUnit.DEFAULT); if (newDistance <= 0.0) { throw new IllegalArgumentException("distance must be greater than zero"); } this.distance = newDistance; return this; }
DecayFunctionBuilder.SCALE); double scale = DistanceUnit.DEFAULT.parse(scaleString, DistanceUnit.DEFAULT); double offset = DistanceUnit.DEFAULT.parse(offsetString, DistanceUnit.DEFAULT); IndexGeoPointFieldData indexFieldData = context.getForField(fieldType); return new GeoFieldDataScoreFunction(origin, scale, decay, offset, getDecayFunction(), indexFieldData, mode);
/** * Parses a given distance and converts it to this unit. * * @param distance String defining a distance (value and unit) * @param defaultUnit unit to expect if none if provided * @return parsed distance */ public double parse(String distance, DistanceUnit defaultUnit) { return parse(distance, defaultUnit, this); }
/** * Parses a given distance and converts it to this unit. * * @param distance String defining a distance (value and unit) * @param defaultUnit unit to expect if none if provided * @return parsed distance */ public double parse(String distance, DistanceUnit defaultUnit) { return parse(distance, defaultUnit, this); }
/** * Parses a given distance and converts it to this unit. * * @param distance String defining a distance (value and unit) * @param defaultUnit unit to expect if none if provided * @return parsed distance */ public double parse(String distance, DistanceUnit defaultUnit) { return parse(distance, defaultUnit, this); }
/** * Parses a given distance and converts it to this unit. * * @param distance String defining a distance (value and unit) * @param defaultUnit unit to expect if none if provided * @return parsed distance */ public double parse(String distance, DistanceUnit defaultUnit) { return parse(distance, defaultUnit, this); }
private void setupFieldTypeDeprecatedParameters() { GeoShapeFieldType ft = fieldType(); if (deprecatedParameters.strategy != null) { ft.setStrategy(deprecatedParameters.strategy); } if (deprecatedParameters.tree != null) { ft.setTree(deprecatedParameters.tree); } if (deprecatedParameters.treeLevels != null) { ft.setTreeLevels(deprecatedParameters.treeLevels); } if (deprecatedParameters.precision != null) { // precision is only set iff: a. treeLevel is not explicitly set, b. its explicitly set ft.setPrecisionInMeters(DistanceUnit.parse(deprecatedParameters.precision, DistanceUnit.DEFAULT, DistanceUnit.DEFAULT)); } if (deprecatedParameters.distanceErrorPct != null) { ft.setDistanceErrorPct(deprecatedParameters.distanceErrorPct); } if (deprecatedParameters.pointsOnly != null) { ft.setPointsOnly(deprecatedParameters.pointsOnly); } GeoShapeFieldType geoShapeFieldType = (GeoShapeFieldType)fieldType; if (geoShapeFieldType.treeLevels() == 0 && geoShapeFieldType.precisionInMeters() < 0) { geoShapeFieldType.setDefaultDistanceErrorPct(DeprecatedParameters.Defaults.DISTANCE_ERROR_PCT); } }
/** * Set the precision use o make suggestions * * @param precision * precision as distance with {@link DistanceUnit}. Default: * meters * @return this */ public Builder precision(String precision) { return precision(DistanceUnit.parse(precision, DistanceUnit.METERS, DistanceUnit.METERS)); }
/** * Calculate the number of levels needed for a specific precision. QuadTree * cells will not exceed the specified size (diagonal) of the precision. * @param distance Maximum size of cells as unit string (must greater or equal to zero) * @return levels need to achieve precision */ public static int quadTreeLevelsForPrecision(String distance) { return quadTreeLevelsForPrecision(DistanceUnit.METERS.parse(distance, DistanceUnit.DEFAULT)); }
/** * Set the precision use o make suggestions * * @param precision * precision as distance with {@link DistanceUnit}. Default: * meters * @return this */ public Builder precision(String precision) { return precision(DistanceUnit.parse(precision, DistanceUnit.METERS, DistanceUnit.METERS)); }
/** * Calculate the number of levels needed for a specific precision. QuadTree * cells will not exceed the specified size (diagonal) of the precision. * @param distance Maximum size of cells as unit string (must greater or equal to zero) * @return levels need to achieve precision */ public static int quadTreeLevelsForPrecision(String distance) { return quadTreeLevelsForPrecision(DistanceUnit.METERS.parse(distance, DistanceUnit.DEFAULT)); }
/** * Calculate the number of levels needed for a specific precision. QuadTree * cells will not exceed the specified size (diagonal) of the precision. * @param distance Maximum size of cells as unit string (must greater or equal to zero) * @return levels need to achieve precision */ public static int quadTreeLevelsForPrecision(String distance) { return quadTreeLevelsForPrecision(DistanceUnit.METERS.parse(distance, DistanceUnit.DEFAULT)); }
/** * Calculate the number of levels needed for a specific precision. QuadTree * cells will not exceed the specified size (diagonal) of the precision. * @param distance Maximum size of cells as unit string (must greater or equal to zero) * @return levels need to achieve precision */ public static int quadTreeLevelsForPrecision(String distance) { return quadTreeLevelsForPrecision(DistanceUnit.METERS.parse(distance, DistanceUnit.DEFAULT)); }
/** * Calculate the number of levels needed for a specific precision. GeoHash * cells will not exceed the specified size (diagonal) of the precision. * @param distance Maximum size of cells as unit string (must greater or equal to zero) * @return levels need to achieve precision */ public static int geoHashLevelsForPrecision(String distance) { return geoHashLevelsForPrecision(DistanceUnit.METERS.parse(distance, DistanceUnit.DEFAULT)); }
/** * Calculate the number of levels needed for a specific precision. GeoHash * cells will not exceed the specified size (diagonal) of the precision. * @param distance Maximum size of cells as unit string (must greater or equal to zero) * @return levels need to achieve precision */ public static int geoHashLevelsForPrecision(String distance) { return geoHashLevelsForPrecision(DistanceUnit.METERS.parse(distance, DistanceUnit.DEFAULT)); }
/** * Calculate the number of levels needed for a specific precision. GeoHash * cells will not exceed the specified size (diagonal) of the precision. * @param distance Maximum size of cells as unit string (must greater or equal to zero) * @return levels need to achieve precision */ public static int geoHashLevelsForPrecision(String distance) { return geoHashLevelsForPrecision(DistanceUnit.METERS.parse(distance, DistanceUnit.DEFAULT)); }