| 1 |
/* Copyright 2015 Bloomberg Finance L.P. |
| 2 |
* |
| 3 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
* you may not use this file except in compliance with the License. |
| 5 |
* You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software |
| 10 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
* See the License for the specific language governing permissions and |
| 13 |
* limitations under the License. |
| 14 |
*/ |
| 15 |
|
| 16 |
import * as d3 from 'd3'; |
| 17 |
// var d3 =Object.assign({}, require("d3-geo")); |
| 18 |
import * as widgets from '@jupyter-widgets/base'; |
| 19 |
import { GeoScaleModel } from './GeoScaleModel'; |
| 20 |
|
| 21 |
export class GeoScale extends widgets.WidgetView { |
| 22 |
render() { |
| 23 |
this.set_projection(); |
| 24 |
this.listenTo(this.model, 'attribute_changed', this.reset_scale); |
| 25 |
} |
| 26 |
|
| 27 |
set_projection() { |
| 28 |
this.path = d3.geoPath().projection(this.model.projection); |
| 29 |
this.scale = this.model.projection; |
| 30 |
} |
| 31 |
|
| 32 |
reset_scale() { |
| 33 |
this.set_projection(); |
| 34 |
this.trigger('domain_changed', null); |
| 35 |
} |
| 36 |
|
| 37 |
path: d3.GeoPath<any, d3.GeoPermissibleObjects>; |
| 38 |
scale: d3.GeoProjection; |
| 39 |
|
| 40 |
model: GeoScaleModel; |
| 41 |
} |
| 42 |
|
| 43 |
export class Mercator extends GeoScale {} |
| 44 |
|
| 45 |
export class Albers extends GeoScale {} |
| 46 |
|
| 47 |
export class AlbersUSA extends GeoScale {} |
| 48 |
|
| 49 |
export class EquiRectangular extends GeoScale {} |
| 50 |
|
| 51 |
export class Orthographic extends GeoScale {} |
| 52 |
|
| 53 |
export class Gnomonic extends GeoScale {} |
| 54 |
|
| 55 |
export class Stereographic extends GeoScale {} |