Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DPolygon

Hierarchy

  • DPolygon

Index

Constructors

Properties

holes: DPolygon[] = []
properties: Record<string, any> = {}
CAP_FLAT: number = CAP_FLAT

Specifies a flat line buffer end cap style.

CAP_ROUND: number = CAP_ROUND

Specifies a round line buffer end cap style.

CAP_SQUARE: number = CAP_SQUARE

Specifies a square line buffer end cap style.

WKT_LINESTRING: string = 'LINESTRING'
WKT_POLYGON: string = 'POLYGON'

Accessors

  • get area(): number
  • get closed(): boolean
  • get dX(): number
  • Difference between maxX and minX. Equal width (w)

    Returns number

  • get dY(): number
  • Difference between maxY and minY. Equal height (h)

    Returns number

  • get fullLength(): number
  • get fullLengthLatLon(): number
  • Get length of line string. For big distances in lat/lon.

    Returns number

  • get h(): number
  • Difference between maxY and minY. Equal ΔY (dY)

    Returns number

  • get isClockwise(): boolean
  • Check polygon direction

    For normal Cartesian coordinate system. The reason that's worth mentioning is that some common contexts, like HTML5 canvas, use an inverted Y-axis. Then the rule has to be flipped: if the area is negative, the curve is clockwise.

    Returns boolean

  • get length(): number
  • get maxX(): number
  • get maxY(): number
  • get minX(): number
  • get minY(): number
  • get perimeter(): number
  • get perimeterLatLon(): number
  • Get perimeter. For big distances in lat/lon.

    Returns number

  • get valid(): boolean
  • Check if polygon contain more than three points

    Returns boolean

  • get w(): number
  • Difference between maxX and minX. Equal ΔX (dX)

    Returns number

Methods

  • buffer(v: number, quadrantSegments?: number, type?: number): DPolygon
  • Parameters

    • v: number
    • quadrantSegments: number = 64
    • type: number = DPolygon.CAP_ROUND

    Returns DPolygon

  • clearPolygonOnCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): void
  • Parameters

    • canvas: HTMLCanvasElement | OffscreenCanvas

    Returns void

  • contain(p: DPoint, isBorderInside?: boolean): boolean
  • Check if contain point

    Parameters

    • p: DPoint
    • isBorderInside: boolean = false

    Returns boolean

  • divideToPieces(piecesCount: number, withAltitude?: boolean): DPolygon
  • Divide line string to pieces by length

    Parameters

    • piecesCount: number
    • withAltitude: boolean = false

    Returns DPolygon

  • drawPolygonOnCanvas(canvas: HTMLCanvasElement | OffscreenCanvas, fillColor?: string, strokeColor?: string, shadowColor?: string, lineWidth?: number, steps?: number): DPolygon
  • Parameters

    • canvas: HTMLCanvasElement | OffscreenCanvas
    • Optional fillColor: string
    • Optional strokeColor: string
    • Optional shadowColor: string
    • lineWidth: number = 1
    • steps: number = ...

    Returns DPolygon

  • fastHas(__namedParameters: DPoint): boolean
  • findIndex(p: DPoint): number
  • findIndex(f: ((p: DPoint) => boolean)): number
  • findIndex(f: ((p: DPoint, index: number) => boolean)): number
  • getTrianglesPointIndexes(): number[]
  • Divide polygon to triangles and return points indexes

    Returns number[]

  • getValue(): string
  • hasSimpleIntersection(p: DPolygon): boolean
  • insertAfter(index: number, ...points: DPoint[]): void
  • intersection(l: DLine, includeOnly?: boolean): DPoint[]
  • mapArray<T>(f: ((r: DPoint) => T)): T[]
  • mapArray<T>(f: ((r: DPoint, index: number) => T)): T[]
  • prepareToFastSearch(): void
  • push(...args: DPoint[]): number
  • reduce<T>(f: ((a: T, p: DPoint) => T), v: T): T
  • reduce<T>(f: ((a: T, p: DPoint, index: number) => T), v: T): T
  • Type Parameters

    • T

    Parameters

    Returns T

  • Type Parameters

    • T

    Parameters

    • f: ((a: T, p: DPoint, index: number) => T)
        • (a: T, p: DPoint, index: number): T
        • Parameters

          Returns T

    • v: T

    Returns T

  • removePart(index: number, count: number): DPoint[]
  • Check is polygons are same. They can be with different directions and different start points.

    Parameters

    Returns boolean

  • setGrowingHeight(from: number, to: number): DPolygon
  • setProperties(v: Record<string, any> | SetterFunction<Record<string, any>>): DPolygon
  • Return left and right buffers of polyline. With same direction as original line.

    For canvas: [left, right]

    For normal Cartesian coordinate system: [right, left]

    Parameters

    • v: number
    • quadrantSegments: number = 64

    Returns [DPolygon, DPolygon]

  • simpleInclude(p: DPoint): boolean
  • toArrayOfCoords(format?: string): DCoord[]
  • toGeoJSON(format?: string): LineString | Polygon
  • Parameters

    • format: string = DGeo.parseFormat

    Returns LineString | Polygon

  • toGeoJSONFeature(format?: string): Feature<LineString | Polygon, GeoJsonProperties>
  • Parameters

    • format: string = DGeo.parseFormat

    Returns Feature<LineString | Polygon, GeoJsonProperties>

  • toString(): string
  • toWKT(type?: string, withZ?: boolean): string
  • Parameters

    • type: string = DPolygon.WKT_POLYGON
    • withZ: boolean = false

    Returns string

  • unshift(...args: DPoint[]): number
  • arrayOfTrianglesToVertices(triangles: DPolygon[], height?: number): number[]
  • Transform array of triangles to Three.JS vertices

    const geometry = new THREE.BufferGeometry();
    // create a simple square shape. We duplicate the top left and bottom right
    // vertices because each vertex needs to appear once per triangle.
    const vertices = new Float32Array( DPolygon.arrayOfTrianglesToVertices(triangles, 10) );

    // itemSize = 3 because there are 3 values (components) per vertex
    geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
    const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
    mesh = new THREE.Mesh( geometry, material );

    scene.add( mesh );

    Parameters

    • triangles: DPolygon[]
    • Optional height: number

    Returns number[]

  • minAreaRectangleDirection(poly: DPolygon): number
  • Get min area rectangle direction

    Parameters

    • poly: DPolygon

      should be minAreaRectangle

    Returns number

  • parse(a: LatLng[], format?: string): DPolygon
  • parse(a: number[][], format?: string): DPolygon
  • parse(a: DCoord[], format?: string): DPolygon
  • parse(a: XYZ[], format?: string): DPolygon
  • parse(a: Geometry | FeatureCollection<LineString | Polygon, GeoJsonProperties> | Feature<Geometry, GeoJsonProperties>, format?: string): DPolygon | DeepArray<DPolygon>
  • toGeoJSONFeatureCollection(polygons: DPolygon[], format?: string): FeatureCollection<LineString | Polygon, GeoJsonProperties>
  • Parameters

    • polygons: DPolygon[]
    • format: string = DGeo.parseFormat

    Returns FeatureCollection<LineString | Polygon, GeoJsonProperties>

Generated using TypeDoc