geoportal-data-viewer-app/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/ClickDataInfo.java

266 lines
3.7 KiB
Java

package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
// TODO: Auto-generated Javadoc
/**
* The Class ClickDataInfo.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 27, 2020
*/
public class ClickDataInfo {
public static enum TYPE {
POINT,
BOX
}
/** The Constant THRESHOLD_AREA. */
private static final double THRESHOLD_AREA = 300;
/** The h. */
private int x, y, w, h;
/** The bbox. */
private String bbox;
/** The type. */
private TYPE type=null;
/** The x 1. */
private double x1;
/** The y 1. */
private double y1;
/** The x 2. */
private double x2;
/** The y 2. */
private double y2;
/** The limit. */
//ADDED BY FRANCESCO M.
private int limit = Integer.MAX_VALUE;
/**
* Instantiates a new click data info.
*
* @param x the x
* @param y the y
* @param w the w
* @param h the h
* @param bbox the bbox
*/
public ClickDataInfo(int x, int y, int w, int h, String bbox) {
super();
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.bbox = bbox;
this.type = TYPE.POINT;
// System.out.println("POINT SELECTED: x="+x+", y="+y+", w="+w+", h="+h+", bbox="+bbox);
}
/**
* Instantiates a new click data info.
*
* @param x1 the x 1
* @param y1 the y 1
* @param x2 the x 2
* @param y2 the y 2
*/
public ClickDataInfo(double x1, double y1, double x2, double y2) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
// note: the bounding box is left,lower,right,upper
this.bbox = y1 +","+ x1 +","+ y2 +","+ x2;
this.type = TYPE.BOX;
double area = (x2-x1) * (y2-y1);
// System.out.println("BOX SELECTED: BBOX="+bbox + ", AREA="+area);
}
/**
* Gets the x.
*
* @return the x
*/
public int getX() {
return x;
}
/**
* Sets the x.
*
* @param x the new x
*/
public void setX(int x) {
this.x = x;
}
/**
* Gets the y.
*
* @return the y
*/
public int getY() {
return y;
}
/**
* Sets the y.
*
* @param y the new y
*/
public void setY(int y) {
this.y = y;
}
/**
* Gets the w.
*
* @return the w
*/
public int getW() {
return w;
}
/**
* Sets the w.
*
* @param w the new w
*/
public void setW(int w) {
this.w = w;
}
/**
* Gets the h.
*
* @return the h
*/
public int getH() {
return h;
}
/**
* Sets the h.
*
* @param h the new h
*/
public void setH(int h) {
this.h = h;
}
/**
* Gets the bbox.
*
* @return the bbox
*/
public String getBbox() {
return bbox;
}
/**
* Sets the bbox.
*
* @param bbox the new bbox
*/
public void setBbox(String bbox) {
this.bbox = bbox;
}
/**
* Checks if is point.
*
* @return true, if is point
*/
public boolean isPoint() {
return this.type==TYPE.POINT;
}
/**
* Checks if is box.
*
* @return true, if is box
*/
public boolean isBox() {
return this.type==TYPE.BOX;
}
/**
* Checks if is hard query.
*
* @return true, if is hard query
*/
public boolean isHardQuery() {
if (this.isPoint())
return false;
else {
double area = (x2-x1) * (y2-y1);
return (area > THRESHOLD_AREA);
}
}
/**
* Gets the x1.
*
* @return the x1
*/
public double getX1() {
return x1;
}
/**
* Gets the x2.
*
* @return the x2
*/
public double getX2() {
return x2;
}
/**
* Gets the y1.
*
* @return the y1
*/
public double getY1() {
return y1;
}
/**
* Gets the y2.
*
* @return the y2
*/
public double getY2() {
return y2;
}
/**
* Gets the limit.
*
* @return the limit
*/
public int getLimit() {
return limit;
}
/**
* Sets the limit.
*
* @param limit the new limit
*/
public void setLimit(int limit) {
this.limit = limit;
}
}