Tabnine Logo
NearestVisitor
Code IndexAdd Tabnine to your IDE (free)

How to use
NearestVisitor
in
org.geotools.feature.visitor

Best Java code snippets using org.geotools.feature.visitor.NearestVisitor (Showing top 14 results out of 315)

origin: geotools/geotools

/**
 * Calculate nearest using {@link NearestVisitor}.
 *
 * @param Collection collection to calculate the maximum
 * @param Expression Single Expression argument
 * @param value Attribute value used for nearest search
 * @return An object containing the maximum value of the attributes
 * @throws IllegalFilterException
 * @throws IOException
 */
static Object near(SimpleFeatureCollection collection, Expression expression, Object value)
    throws IllegalFilterException, IOException {
  NearestVisitor visitor = new NearestVisitor(expression, value);
  collection.accepts(visitor, new NullProgressListener());
  return visitor.getNearestMatch();
}
origin: geotools/geotools

public void setValue(Object maxBelow, Object minAbove) {
  if (maxBelow == null) {
    this.nearest = minAbove;
  } else if (minAbove == null) {
    this.nearest = maxBelow;
  } else {
    NearestAccumulator accumulator = getAccumulator(maxBelow.getClass());
    accumulator.visit(maxBelow);
    accumulator.visit(minAbove);
    nearest = accumulator.getNearest();
  }
}
origin: geotools/geotools

Object targetValue = nearest.getValueToMatch();
Expression expr = nearest.getExpression();
String attribute = null;
if (maxBelow != null && maxBelow.equals(targetValue)) {
  nearest.setValue(maxBelow, null);
} else {
  handleVisitor(qAbove, min);
  Comparable minAbove = (Comparable) min.getResult().getValue();
  nearest.setValue(maxBelow, minAbove);
origin: geotools/geotools

NearestVisitor vis = new NearestVisitor(ff.property("bar"), Integer.valueOf(0));
verify(delegate);
vis = new NearestVisitor(ff.property("baz"), "abc");
origin: org.geotools/gt-solr

} else if (visitor instanceof NearestVisitor) {
  NearestVisitor nearestVisitor = (NearestVisitor) visitor;
  Expression exp = nearestVisitor.getExpression();
  if (!(nearestVisitor.getValueToMatch() instanceof Date)) {
    return false;
      factory.property(
          "abs(ms("
              + dateFormatUTC.format(nearestVisitor.getValueToMatch())
              + ","
              + propName.getPropertyName()
origin: org.geoserver/gs-wms

      || ((Range) value).getMinValue().equals(((Range) value).getMaxValue()))) {
Date date = (Date) (value instanceof Range ? ((Range) value).getMinValue() : value);
NearestVisitor visitor = new NearestVisitor(attribute, date);
Filter filter = Filter.INCLUDE;
if (acceptableRange != null) {
Object result = visitor.getResult().getValue();
if (date.equals(result)) {
  return value;
origin: geotools/geotools

  @Override
  public Object getValue() {
    return NearestVisitor.this.getNearestMatch();
  }
};
origin: locationtech/geogig

    exp = ((NearestVisitor) visitor).getExpression();
  } else {
    FeatureAttributeVisitor fav = (FeatureAttributeVisitor) visitor;
} else if (NearestVisitor.class.isInstance(visitor)) {
  NearestVisitor ne = (NearestVisitor) visitor;
  Object valueToMatch = ne.getValueToMatch();
  Object maxBelow = uniqueValues.floor(valueToMatch);
  Object minAbove = uniqueValues.ceiling(valueToMatch);
  ne.setValue(maxBelow, minAbove);
origin: locationtech/geogig

public @Test void handleNearestVisitorNotIndexed() {
  final int valueToMatch = 2050;
  Integer expectedResult = Integer.valueOf(2000);
  testVisitor(new NearestVisitor(ff.property("ip"), valueToMatch), expectedResult);
}
origin: locationtech/geogig

/**
 * @see GeogigFeatureVisitorHandler
 */
public @Test void handleNearestVisitorMaterializedAttribute() {
  NodeRef typeRef = pointsSource.delegate.getTypeRef();
  createIndex(typeRef, Collections.singletonList("ip"));
  final int valueToMatch = 2050;
  Integer expectedResult = Integer.valueOf(2000);
  testVisitor(new NearestVisitor(ff.property("ip"), valueToMatch), expectedResult);
}
origin: geotools/geotools

  private void testNearest(
      SimpleFeatureCollection fc, String attributeName, Object target, Object... validResults)
      throws IOException {
    PropertyName expr = ff.property(attributeName);
    NearestVisitor visitor = new NearestVisitor(expr, target);
    fc.accepts(visitor, null);
    Object nearestMatch = visitor.getNearestMatch();
    if (validResults.length == 0) {
      assertNull(nearestMatch);
    } else {
      boolean found = false;
      for (Object object : validResults) {
        found |= object != null ? (object.equals(nearestMatch)) : nearestMatch == null;
      }

      assertTrue(
          "Could match nearest "
              + nearestMatch
              + " among valid values "
              + Arrays.asList(validResults),
          found);
    }
  }
}
origin: geotools/geotools

/**
 * Visitor function, which looks at each feature and finds the value of the attribute given
 * attribute nearest to the given comparison value.
 *
 * @param feature the feature to be visited
 */
@SuppressWarnings("unchecked")
public void visit(org.opengis.feature.Feature feature) {
  // bail out immediately if we have already found an exact match
  if (visited) {
    return;
  }
  if (attributeClass == null) {
    PropertyDescriptor desc = (PropertyDescriptor) expr.evaluate(feature.getType());
    attributeClass = desc.getType().getBinding();
    if (accumulator == null) {
      accumulator = getAccumulator(attributeClass);
    }
  }
  // extract the value
  Object attribValue = expr.evaluate(feature);
  if (attribValue == null) {
    return;
  } else {
    visited |= accumulator.visit(attribValue);
  }
}
origin: org.geoserver/gs-wms

@Override
public Object getDefaultValue(
    ResourceInfo resource, String dimensionName, DimensionInfo dimension, Class clz) {
  String attrName = dimension.getAttribute();
  Class<?> attrType = String.class;
  if (resource instanceof FeatureTypeInfo) {
    List<AttributeTypeInfo> attrTypes;
    try {
      attrTypes = ((FeatureTypeInfo) resource).attributes();
      for (AttributeTypeInfo attr : attrTypes) {
        if (attr.getName().equals(attrName)) {
          attrType = attr.getBinding();
          break;
        }
      }
    } catch (IOException e) {
    }
  }
  final FeatureCalc nearest =
      new NearestVisitor(ff.property(dimension.getAttribute()), this.toMatch);
  CalcResult res = getCalculatedResult((FeatureTypeInfo) resource, dimension, nearest);
  if (res.equals(CalcResult.NULL_RESULT)) {
    return null;
  } else {
    return Converters.convert(res.getValue(), clz);
  }
}
origin: org.geoserver.community/gs-dyndimension

private FeatureCalc getFeatureCalcForStrategy(
    DimensionDefaultValueSelectionStrategy delegateStrategy, DimensionDescriptor dd) {
  String sa = dd.getStartAttribute();
  String ea = dd.getEndAttribute();
  if (delegateStrategy instanceof CoverageMaximumValueSelectionStrategyImpl) {
    if (ea != null) {
      return new MaxVisitor(ea);
    } else {
      return new MaxVisitor(sa);
    }
  } else if (delegateStrategy instanceof CoverageMinimumValueSelectionStrategyImpl) {
    return new MinVisitor(sa);
  } else if (delegateStrategy instanceof CoverageNearestValueSelectionStrategyImpl) {
    CoverageNearestValueSelectionStrategyImpl impl =
        (CoverageNearestValueSelectionStrategyImpl) delegateStrategy;
    Object targetValue = impl.getTargetValue();
    return new NearestVisitor(ff.property(sa), targetValue);
  } else {
    throw new ServiceException(
        "Don't konw how to restrict the domain for strategy " + delegateStrategy);
  }
}
org.geotools.feature.visitorNearestVisitor

Javadoc

Finds the nearest value to the provided one in the attribute domain.

Most used methods

  • <init>
  • getExpression
  • getValueToMatch
  • getNearestMatch
    Returns the match after #visit.
  • setValue
  • getAccumulator
  • getResult
  • visit
    Visitor function, which looks at each feature and finds the value of the attribute given attribute n

Popular in Java

  • Making http requests using okhttp
  • requestLocationUpdates (LocationManager)
  • getSharedPreferences (Context)
  • putExtra (Intent)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • JFrame (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now