View Javadoc
1   /*******************************************************************************
2    * Copyright (c) 2015 Voyager Search and MITRE
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Apache License, Version 2.0 which
5    * accompanies this distribution and is available at
6    *    http://www.apache.org/licenses/LICENSE-2.0.txt
7    ******************************************************************************/
8   
9   package org.locationtech.spatial4j.shape;
10  
11  /**
12   * A rectangle aligned with the axis (i.e. it is not at an angle).
13   * <p>
14   * In geospatial contexts, it may cross the international date line (-180
15   * longitude) if {@link #getCrossesDateLine()} however it cannot pass the poles
16   * although it may span the globe.  It spans the globe if the X coordinate
17   * (Longitude) goes from -180 to 180 as seen from {@link #getMinX()} and {@link
18   * #getMaxX()}.
19   */
20  public interface Rectangle extends Shape {
21  
22    /**
23     * Expert: Resets the state of this shape given the arguments. This is a
24     * performance feature to avoid excessive Shape object allocation as well as
25     * some argument error checking. Mutable shapes is error-prone so use with
26     * care.
27     */
28    public void reset(double minX, double maxX, double minY, double maxY);
29  
30    /**
31     * The width. In geospatial contexts, this is generally in degrees longitude
32     * and is aware of the dateline (aka anti-meridian).  It will always be &gt;= 0.
33     */
34    public double getWidth();
35  
36    /**
37     * The height. In geospatial contexts, this is in degrees latitude. It will
38     * always be &gt;= 0.
39     */
40    public double getHeight();
41  
42    /** The left edge of the X coordinate. */
43    public double getMinX();
44  
45    /** The bottom edge of the Y coordinate. */
46    public double getMinY();
47  
48    /** The right edge of the X coordinate. */
49    public double getMaxX();
50  
51    /** The top edge of the Y coordinate. */
52    public double getMaxY();
53  
54    /** Only meaningful for geospatial contexts. */
55    public boolean getCrossesDateLine();
56  
57    /**
58     * A specialization of {@link Shape#relate(Shape)}
59     * for a vertical line.
60     */
61    public SpatialRelation relateYRange(double minY, double maxY);
62  
63    /**
64     * A specialization of {@link Shape#relate(Shape)}
65     * for a horizontal line.
66     */
67    public SpatialRelation relateXRange(double minX, double maxX);
68  }