// Path: src/main/java/nl/esciencecenter/ahn/pointcloud/core/Selection.java
// @ValidSelection
// public class Selection {
//     @NotNull
//     @JsonProperty
//     @ApiModelProperty(value="Most left or minimum x coordinate", example = "124931.360")
//     private Double left;
// 
//     @NotNull
//     @JsonProperty
//     @ApiModelProperty(value="Most bottom or minimum y coordinate", example = "484567.840")
//     private Double bottom;
// 
//     @NotNull
//     @JsonProperty
//     @ApiModelProperty(value="Most right or maximum x coordinate", example = "126241.760")
//     private Double right;
// 
//     @NotNull
//     @JsonProperty
//     @ApiModelProperty(value="Most top or maximum x coordinate", example = "485730.400")
//     private Double top;
// 
//     public Selection(Double left, Double bottom, Double right, Double top) {
//         this.left = left;
//         this.bottom = bottom;
//         this.right = right;
//         this.top = top;
//     }
// 
//     protected Selection() {
//     }
// 
//     public Double getLeft() {
//         return left;
//     }
// 
//     public Double getBottom() {
//         return bottom;
//     }
// 
//     public Double getRight() {
//         return right;
//     }
// 
//     public Double getTop() {
//         return top;
//     }
// 
//     public void setLeft(Double left) {
//         this.left = left;
//     }
// 
//     public void setBottom(Double bottom) {
//         this.bottom = bottom;
//     }
// 
//     public void setRight(Double right) {
//         this.right = right;
//     }
// 
//     public void setTop(Double top) {
//         this.top = top;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) {return true;}
//         if (o == null || getClass() != o.getClass()) {return false;}
//         Selection selection = (Selection) o;
//         return Objects.equals(getLeft(), selection.getLeft()) &&
//                 Objects.equals(getBottom(), selection.getBottom()) &&
//                 Objects.equals(getRight(), selection.getRight()) &&
//                 Objects.equals(getTop(), selection.getTop());
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(getLeft(), getBottom(), getRight(), getTop());
//     }
// }


import nl.esciencecenter.ahn.pointcloud.core.Selection;
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.BindBean;
import org.skife.jdbi.v2.sqlobject.SqlQuery;
package nl.esciencecenter.ahn.pointcloud.db;



public interface PotreeExtentsDOA {
    @SqlQuery("SELECT "
            + "  FLOOR(SUM(numberpoints * (ST_Area(ST_Intersection(geom, qgeom)) /ST_Area(geom)))) AS numpoints "
            + "FROM "
            + "  extent_potree, "
            + "  (SELECT ST_SetSRID(ST_MakeBox2D(ST_Point(:b.left, :b.bottom),ST_Point(:b.right, :b.top)), :srid) AS qgeom) AS B "
            + "WHERE level = :level "
            + "AND geom && qgeom "
            + "AND ST_Area(geom) != 0")
    long getNumberOfPoints(@Bind("level") int level,
// Path: src/main/java/nl/esciencecenter/ahn/pointcloud/core/Selection.java
// @ValidSelection
// public class Selection {
//     @NotNull
//     @JsonProperty
//     @ApiModelProperty(value="Most left or minimum x coordinate", example = "124931.360")
//     private Double left;
// 
//     @NotNull
//     @JsonProperty
//     @ApiModelProperty(value="Most bottom or minimum y coordinate", example = "484567.840")
//     private Double bottom;
// 
//     @NotNull
//     @JsonProperty
//     @ApiModelProperty(value="Most right or maximum x coordinate", example = "126241.760")
//     private Double right;
// 
//     @NotNull
//     @JsonProperty
//     @ApiModelProperty(value="Most top or maximum x coordinate", example = "485730.400")
//     private Double top;
// 
//     public Selection(Double left, Double bottom, Double right, Double top) {
//         this.left = left;
//         this.bottom = bottom;
//         this.right = right;
//         this.top = top;
//     }
// 
//     protected Selection() {
//     }
// 
//     public Double getLeft() {
//         return left;
//     }
// 
//     public Double getBottom() {
//         return bottom;
//     }
// 
//     public Double getRight() {
//         return right;
//     }
// 
//     public Double getTop() {
//         return top;
//     }
// 
//     public void setLeft(Double left) {
//         this.left = left;
//     }
// 
//     public void setBottom(Double bottom) {
//         this.bottom = bottom;
//     }
// 
//     public void setRight(Double right) {
//         this.right = right;
//     }
// 
//     public void setTop(Double top) {
//         this.top = top;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) {return true;}
//         if (o == null || getClass() != o.getClass()) {return false;}
//         Selection selection = (Selection) o;
//         return Objects.equals(getLeft(), selection.getLeft()) &&
//                 Objects.equals(getBottom(), selection.getBottom()) &&
//                 Objects.equals(getRight(), selection.getRight()) &&
//                 Objects.equals(getTop(), selection.getTop());
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(getLeft(), getBottom(), getRight(), getTop());
//     }
// }


// Path: src/main/java/nl/esciencecenter/ahn/pointcloud/db/PotreeExtentsDOA.java
import nl.esciencecenter.ahn.pointcloud.core.Selection;
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.BindBean;
import org.skife.jdbi.v2.sqlobject.SqlQuery;

package nl.esciencecenter.ahn.pointcloud.db;



public interface PotreeExtentsDOA {
    @SqlQuery("SELECT "
            + "  FLOOR(SUM(numberpoints * (ST_Area(ST_Intersection(geom, qgeom)) /ST_Area(geom)))) AS numpoints "
            + "FROM "
            + "  extent_potree, "
            + "  (SELECT ST_SetSRID(ST_MakeBox2D(ST_Point(:b.left, :b.bottom),ST_Point(:b.right, :b.top)), :srid) AS qgeom) AS B "
            + "WHERE level = :level "
            + "AND geom && qgeom "
            + "AND ST_Area(geom) != 0")
    long getNumberOfPoints(@Bind("level") int level,
                           @BindBean("b") Selection bbox,