import { Geometry , CoordinateType } from "./geometry" ; import { Bound } from "../util/bound" ; import { Projection } from "../projection/projection" ; import { PointSymbol , SimpleMarkerSymbol , SimplePointSymbol , Symbol } from "../symbol/symbol" ; import { WebMercator } from "../projection/web-mercator" ; export class Point extends Geometry { static RADIUS : number = 10 ; private _lng : number ; private _lat : number ; private _x : number ; private _y : number ; private _screenX : number ; private _screenY : number ; private _symbol : PointSymbol ; constructor ( lng , lat ) { super ( ) ; this . _lng = lng ; this . _lat = lat ; } ; project ( projection ) { this . _projection = projection ; [ this . _x , this . _y ] = this . _projection . project ( [ this . _lng , this . _lat ] ) ; this . _bound = new Bound ( this . _x , this . _y , this . _x , this . _y ) ; this . _projected = true ; } async draw ( ctx , projection = new WebMercator ( ) , extent = projection . bound , symbol = new SimplePointSymbol ( ) ) { if ( ! this . _projected ) this . project ( projection ) ; if ( ! extent . intersect ( this . _bound ) ) return ; const matrix = ( ctx as any ) . getTransform ( ) ; this . _screenX = ( matrix . a * this . _x + matrix . e ) ; this . _screenY = ( matrix . d * this . _y + matrix . f ) ; this . _symbol = symbol ; this . _symbol . draw ( ctx , this . _screenX , this . _screenY ) ; } ; getCenter ( type = CoordinateType . Latlng , projection = new WebMercator ( ) ) { if ( ! this . _projected ) this . project ( projection ) ; if ( type === CoordinateType . Latlng ) { return [ this . _lng , this . _lat ] ; } else { return [ this . _x , this . _y ] ; } } }