import { Bound } from "../util/bound" ; import { Geometry } from "../geometry/geometry" ; import { Symbol , SimplePointSymbol , SimpleTextSymbol } from "../symbol/symbol" ; import { Projection } from "../projection/projection" ; import { WebMercator } from "../projection/web-mercator" ; import { Field } from "../data/field" ; export class Feature { private _geometry : Geometry ; private _properties : any ; private _symbol : Symbol ; private _text : SimpleTextSymbol ; public visible : boolean = true ; get symbol ( ) : Symbol { return this . _symbol ; } set symbol ( value ) { this . _symbol = value ; } get geometry ( ) : Geometry { return this . _geometry ; } get properties ( ) : any { return this . _properties ; } get bound ( ) : Bound { return this . _geometry ? this . _geometry . bound : null ; } get text ( ) : SimpleTextSymbol { return this . _text ; } set text ( value ) { this . _text = value ; } constructor ( geometry , properties , symbol ? ) { this . _geometry = geometry ; this . _properties = properties ; this . _symbol = symbol ; } draw ( ctx , projection = new WebMercator ( ) , extent = projection . bound , symbol = new SimplePointSymbol ( ) ) { if ( this . visible ) this . _geometry . draw ( ctx , projection , extent , ( this . _symbol || symbol ) ) ; } intersect ( projection = new WebMercator ( ) , extent = projection . bound ) { if ( this . visible ) return this . _geometry . intersect ( projection , extent ) ; } label ( field , ctx , projection = new WebMercator ( ) , symbol = new SimpleTextSymbol ( ) ) { if ( this . visible ) this . _geometry . label ( this . _properties [ field . name ] , ctx , projection , this . _text || symbol ) ; } }