rapid-sdk
    Preparing search index...

    Extent class for creating bounding boxes

    All of the Extent methods are designed to be used in an immutable programming style, and return new Extents instead of modifying the original object.

    Index

    Constructors

    • Constructs a new Extent

      Parameters

      Returns Extent

      const e1 = new Extent();                // construct an initially empty extent
      const e2 = new Extent([0, 0]); // construct as a point (min and max both [0, 0])
      const e3 = new Extent([0, 0], [5, 5]); // construct as a point with given min and max
      const e4 = new Extent(e3); // copy an Extent to a new Extent

    Properties

    max: Vec2 = ...

    Maximum corner coordinate for the extent

    min: Vec2 = ...

    Minimum corner coordinate for the extent

    Methods

    • Returns the area of an extent

      Returns number

      area

      new Extent([0, 0], [5, 10]).area();  // returns 50
      
    • Returns an Object with minX, minY, maxX, maxY properties.

      Returns BBox

      bbox

      new Extent([0, 0], [5, 10]).bbox();  // returns { minX: 0, minY: 0, maxX: 5, maxY: 10 };
      
    • Returns the center point of an extent

      Returns Vec2

      Center point of the extent

      new Extent([0, 0], [5, 10]).center();  // returns [2.5, 5]
      
    • Test whether this extent contains another extent

      Parameters

      Returns boolean

      True if this extent contains other, false if not

      const a = new Extent([0, 0], [5, 5]);
      const b = new Extent([1, 1], [2, 2]);
      a.contains(b); // returns true
      b.contains(a); // returns false
    • Test whether extent equals to another extent

      Parameters

      Returns boolean

      True if equal, false if unequal

      const a = new Extent([0, 0], [10, 10]);
      const b = new Extent([0, 0], [10, 10]);
      const c = new Extent([0, 0], [12, 12]);
      a.equals(b); // returns true
      a.equals(c); // returns false
    • Extend the bounds of an extent, returning a new Extent

      Parameters

      Returns Extent

      new Extent

      const a = new Extent([0, 0], [5, 10]);
      const b = new Extent([4, -1], [5, 10]);
      const c = a.extend(b); // returns new Extent { min: [ 0, -1 ], max: [ 5, 10 ] }
    • Extend the bounds of an extent, modifying self This is like extend but modifies self, instead of returning a new Extent This option is slightly more performant for situations where you don't mind mutating the Extent.

      Parameters

      Returns Extent

      this Extent

      const a = new Extent([0, 0], [5, 10]);
      const b = new Extent([4, -1], [5, 10]);
      const c = a.extendSelf(b); // a is extended, { min: [ 0, -1 ], max: [ 5, 10 ] }, b unchanged
    • Returns a new Extent representing the intersection of this and other extents

      Parameters

      Returns Extent

      new Extent containing the intersection of this and other

      const a = new Extent([0, 0], [5, 5]);
      const b = new Extent([1, 1], [6, 6]);
      a.intersection(b); // returns new Extent { min: [ 1, 1 ], max: [ 5, 5 ] }
      b.intersection(a); // returns new Extent { min: [ 1, 1 ], max: [ 5, 5 ] }
    • Test whether this extent intersects another extent

      Parameters

      Returns boolean

      True if this extent intersects other, false if not

      const a = new Extent([0, 0], [5, 5]);
      const b = new Extent([1, 1], [6, 6]);
      a.intersects(b); // returns true
      b.intersects(a); // returns true
    • Returns a new Extent representing the current extent (assumed to be defined in WGS84 geographic coordinates) padded by given meters

      Parameters

      • meters: number

      Returns Extent

      new Extent containing this padded by given meters

    • Returns the percent of other extent contained within this extent, by area

      Parameters

      Returns number

      percent of other extent contained within this extent

      const a = new Extent([0, 0], [4, 1]);
      const b = new Extent([3, 0], [4, 2]);
      a.percentContainedIn(b); // returns 0.25
      b.percentContainedIn(a); // returns 0.5
    • Returns a polygon representing the extent wound counterclockwise.

      Returns Quad

      Polygon array

      new Extent([0, 0], [5, 10]).polygon();  // returns [[0, 0], [5, 0], [5, 10], [0, 10], [0, 0]]
      
    • Returns an array rectangle as [minX, minY, maxX, maxY]

      Returns Vec4

      rectangle

      new Extent([0, 0], [5, 10]).rectangle();  // returns [0, 0, 5, 10]
      
    • Returns a string representation of this extent's rectangle formatted as "minX,minY,maxX,maxY"

      Returns string

      rectangle

      new Extent([0, 0], [5, 10]).toParam();  // returns '0,0,5,10'