All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.heigit.ohsome.ohsomeapi.inputprocessing.ProcessingData Maven / Gradle / Ivy

There is a newer version: 1.10.4
Show newest version
package org.heigit.ohsome.ohsomeapi.inputprocessing;

import java.util.EnumSet;
import java.util.List;
import java.util.Optional;
import lombok.Getter;
import lombok.Setter;
import org.geojson.GeoJsonObject;
import org.heigit.bigspatialdata.oshdb.osm.OSMType;
import org.heigit.ohsome.filter.BinaryOperator;
import org.heigit.ohsome.filter.FilterExpression;
import org.heigit.ohsome.filter.GeometryTypeFilter;
import org.heigit.ohsome.ohsomeapi.executor.RequestParameters;
import org.locationtech.jts.geom.Geometry;

/** Holds the relevant objects for processing the request and creating the response. */
@Getter
@Setter
public class ProcessingData {
  @Getter
  @Setter
  private static Geometry dataPolyGeom;
  @Getter
  @Setter
  private static double timeout;
  @Getter
  @Setter
  private static int numberOfDataExtractionThreads = 1;
  private RequestParameters requestParameters;
  private String requestUrl;
  private BoundaryType boundaryType;
  private String[] boundaryValues;
  private String boundaryValuesGeoJson;
  private EnumSet osmTypes;
  private boolean showMetadata;
  private String format;
  private Geometry requestGeom;
  private List boundaryList;
  private GeoJsonObject[] geoJsonGeoms;
  private boolean isContainingSimpleFeatureTypes;
  private EnumSet simpleFeatureTypes;
  @Getter
  @Setter
  private static int numberOfClusterNodes;
  private boolean isRatio;
  private boolean isGroupByBoundary;
  private boolean isFullHistory;
  private FilterExpression filterExpression;

  public ProcessingData(RequestParameters requestParameters, String requestUrl) {
    this.requestParameters = requestParameters;
    this.requestUrl = requestUrl;
    this.isRatio = false;
    this.isGroupByBoundary = false;
    this.isFullHistory = false;
  }

  // Override @Getter of Lombok
  public Optional getFilterExpression() {
    return Optional.ofNullable(this.filterExpression);
  }

  /**
   * Checks if a given filter expression contains a geometry type check or not.
   *
   * @param expr the filter expression to check
   * @return true if the given filter expression contains at least one geometry type check
   */
  public static boolean filterContainsGeometryTypeCheck(FilterExpression expr) {
    if (expr instanceof GeometryTypeFilter) {
      return true;
    } else if (expr instanceof BinaryOperator) {
      return filterContainsGeometryTypeCheck(((BinaryOperator) expr).getLeftOperand())
          || filterContainsGeometryTypeCheck(((BinaryOperator) expr).getRightOperand());
    } else {
      return false;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy