Skip to content

Commit 8c4721b

Browse files
committed
move constants/geo_constants to plots/geo/constants:
- plot-type-specific constants should be in their corresponding plot type directory
1 parent af675c6 commit 8c4721b

File tree

9 files changed

+164
-8
lines changed

9 files changed

+164
-8
lines changed

src/lib/topojson_utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
var topojsonUtils = module.exports = {};
1313

14-
var locationmodeToLayer = require('../constants/geo_constants').locationmodeToLayer,
14+
var locationmodeToLayer = require('../plots/geo/constants').locationmodeToLayer,
1515
topojsonFeature = require('topojson').feature;
1616

1717

src/plots/geo/constants.js

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/**
2+
* Copyright 2012-2016, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
10+
'use strict';
11+
12+
var params = module.exports = {};
13+
14+
// projection names to d3 function name
15+
params.projNames = {
16+
// d3.geo.projection
17+
'equirectangular': 'equirectangular',
18+
'mercator': 'mercator',
19+
'orthographic': 'orthographic',
20+
'natural earth': 'naturalEarth',
21+
'kavrayskiy7': 'kavrayskiy7',
22+
'miller': 'miller',
23+
'robinson': 'robinson',
24+
'eckert4': 'eckert4',
25+
'azimuthal equal area': 'azimuthalEqualArea',
26+
'azimuthal equidistant': 'azimuthalEquidistant',
27+
'conic equal area': 'conicEqualArea',
28+
'conic conformal': 'conicConformal',
29+
'conic equidistant': 'conicEquidistant',
30+
'gnomonic': 'gnomonic',
31+
'stereographic': 'stereographic',
32+
'mollweide': 'mollweide',
33+
'hammer': 'hammer',
34+
'transverse mercator': 'transverseMercator',
35+
'albers usa': 'albersUsa',
36+
'winkel tripel': 'winkel3'
37+
};
38+
39+
// name of the axes
40+
params.axesNames = ['lonaxis', 'lataxis'];
41+
42+
// max longitudinal angular span (EXPERIMENTAL)
43+
params.lonaxisSpan = {
44+
'orthographic': 180,
45+
'azimuthal equal area': 360,
46+
'azimuthal equidistant': 360,
47+
'conic conformal': 180,
48+
'gnomonic': 160,
49+
'stereographic': 180,
50+
'transverse mercator': 180,
51+
'*': 360
52+
};
53+
54+
// max latitudinal angular span (EXPERIMENTAL)
55+
params.lataxisSpan = {
56+
'conic conformal': 150,
57+
'stereographic': 179.5,
58+
'*': 180
59+
};
60+
61+
// defaults for each scope
62+
params.scopeDefaults = {
63+
world: {
64+
lonaxisRange: [-180, 180],
65+
lataxisRange: [-90, 90],
66+
projType: 'equirectangular',
67+
projRotate: [0, 0, 0]
68+
},
69+
usa: {
70+
lonaxisRange: [-180, -50],
71+
lataxisRange: [15, 80],
72+
projType: 'albers usa'
73+
},
74+
europe: {
75+
lonaxisRange: [-30, 60],
76+
lataxisRange: [30, 80],
77+
projType: 'conic conformal',
78+
projRotate: [15, 0, 0],
79+
projParallels: [0, 60]
80+
},
81+
asia: {
82+
lonaxisRange: [22, 160],
83+
lataxisRange: [-15, 55],
84+
projType: 'mercator',
85+
projRotate: [0, 0, 0]
86+
},
87+
africa: {
88+
lonaxisRange: [-30, 60],
89+
lataxisRange: [-40, 40],
90+
projType: 'mercator',
91+
projRotate: [0, 0, 0]
92+
},
93+
'north america': {
94+
lonaxisRange: [-180, -45],
95+
lataxisRange: [5, 85],
96+
projType: 'conic conformal',
97+
projRotate: [-100, 0, 0],
98+
projParallels: [29.5, 45.5]
99+
},
100+
'south america': {
101+
lonaxisRange: [-100, -30],
102+
lataxisRange: [-60, 15],
103+
projType: 'mercator',
104+
projRotate: [0, 0, 0]
105+
}
106+
};
107+
108+
// angular pad to avoid rounding error around clip angles
109+
params.clipPad = 1e-3;
110+
111+
// map projection precision
112+
params.precision = 0.1;
113+
114+
// default land and water fill colors
115+
params.landColor = '#F0DC82';
116+
params.waterColor = '#3399FF';
117+
118+
// locationmode to layer name
119+
params.locationmodeToLayer = {
120+
'ISO-3': 'countries',
121+
'USA-states': 'subunits',
122+
'country names': 'countries'
123+
};
124+
125+
// SVG element for a sphere (use to frame maps)
126+
params.sphereSVG = {type: 'Sphere'};
127+
128+
// N.B. base layer names must be the same as in the topojson files
129+
130+
// base layer with a fill color
131+
params.fillLayers = ['ocean', 'land', 'lakes'];
132+
133+
// base layer with a only a line color
134+
params.lineLayers = ['subunits', 'countries', 'coastlines', 'rivers', 'frame'];
135+
136+
// all base layers - in order
137+
params.baseLayers = [
138+
'ocean', 'land', 'lakes',
139+
'subunits', 'countries', 'coastlines', 'rivers',
140+
'lataxis', 'lonaxis',
141+
'frame'
142+
];
143+
144+
params.layerNameToAdjective = {
145+
ocean: 'ocean',
146+
land: 'land',
147+
lakes: 'lake',
148+
subunits: 'subunit',
149+
countries: 'country',
150+
coastlines: 'coastline',
151+
rivers: 'river',
152+
frame: 'frame'
153+
};
154+
155+
// base layers drawn over choropleth
156+
params.baseLayersOverChoropleth = ['rivers', 'lakes'];

src/plots/geo/geo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ var addProjectionsToD3 = require('./projections');
2323
var createGeoScale = require('./set_scale');
2424
var createGeoZoom = require('./zoom');
2525
var createGeoZoomReset = require('./zoom_reset');
26+
var constants = require('./constants');
2627

2728
var xmlnsNamespaces = require('../../constants/xmlns_namespaces');
28-
var constants = require('../../constants/geo_constants');
2929
var topojsonUtils = require('../../lib/topojson_utils');
3030
var topojsonFeature = require('topojson').feature;
3131

src/plots/geo/layout/axis_defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'use strict';
1111

1212
var Lib = require('../../../lib');
13-
var constants = require('../../../constants/geo_constants');
13+
var constants = require('../constants');
1414
var axisAttributes = require('./axis_attributes');
1515

1616

src/plots/geo/layout/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'use strict';
1111

1212
var handleSubplotDefaults = require('../../subplot_defaults');
13-
var constants = require('../../../constants/geo_constants');
13+
var constants = require('../constants');
1414
var layoutAttributes = require('./layout_attributes');
1515
var supplyGeoAxisLayoutDefaults = require('./axis_defaults');
1616

src/plots/geo/layout/layout_attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'use strict';
1010

1111
var colorAttrs = require('../../../components/color/attributes');
12-
var constants = require('../../../constants/geo_constants');
12+
var constants = require('../constants');
1313
var geoAxesAttrs = require('./axis_attributes');
1414

1515

src/plots/geo/set_scale.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
var d3 = require('d3');
1313

14-
var clipPad = require('../../constants/geo_constants').clipPad;
14+
var clipPad = require('./constants/').clipPad;
1515

1616
function createGeoScale(geoLayout, graphSize) {
1717
var projLayout = geoLayout.projection,

src/traces/choropleth/plot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var getTopojsonFeatures = require('../../lib/topojson_utils').getTopojsonFeature
2222
var locationToFeature = require('../../lib/geo_location_utils').locationToFeature;
2323
var arrayToCalcItem = require('../../lib/array_to_calc_item');
2424

25-
var constants = require('../../constants/geo_constants');
25+
var constants = require('../../plots/geo/constants');
2626
var attributes = require('./attributes');
2727

2828
var plotChoropleth = module.exports = {};

test/jasmine/tests/geoaxes_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var params = require('@src/constants/geo_constants');
1+
var params = require('@src/plots/geo/constants');
22
var supplyLayoutDefaults = require('@src/plots/geo/layout/axis_defaults');
33

44

0 commit comments

Comments
 (0)