Skip to content

Commit

Permalink
Merge branch 'master' into express-serve
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey authored Jul 13, 2018
2 parents f4ccbfc + 5067f0d commit 96f491a
Show file tree
Hide file tree
Showing 31 changed files with 649 additions and 333 deletions.
21 changes: 10 additions & 11 deletions examples/common/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,9 @@ html(lang="en")
// include the main bundle
script(type='text/javascript', src=bundle, charset='UTF-8')

// include example sources
block exampleHeader
// Include example specific files
each css in exampleCss
link(rel="stylesheet", href=css)
each src in exampleJs
if(typeof src === "string")
script(type="text/javascript", src=src)
else
script&attributes(src)

// Include example specific css
each css in exampleCss
link(rel="stylesheet", href=css)
body
if !hideNavbar
// Add a navbar
Expand Down Expand Up @@ -70,3 +62,10 @@ html(lang="en")
// Add the default main content element
block mainContent
#map

// Include example specific scripts
each src in exampleJs
if(typeof src === "string")
script(type="text/javascript", src=src)
else
script&attributes(src)
21 changes: 19 additions & 2 deletions examples/contour/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@
"title": "Contour plot",
"exampleJs": ["main.js"],
"about": {
"text": "This example shows how to add contour features to a map. Contours color a region based on an array of scalar values."
}
"text": "This example shows how to add contour features to a map. Contours color a region based on an array of scalar values. If stepped colors are used, these are called isobands."
},
"tests": [{
"description": "contour feature loads small dataset",
"query": "url=../../data/oahu.json",
"wait": ["example.ready"],
"tests": [
"example.contour instanceof geo.contourFeature",
"example.contour._createContours().value.length === 1953"
]
}, {
"description": "contour feature loads dense dataset",
"query": "url=../../data/oahu-dense.json",
"wait": ["example.ready"],
"tests": [
"example.contour instanceof geo.contourFeature",
"example.contour._createContours().value.length === 194770"
]
}]
}
23 changes: 17 additions & 6 deletions examples/contour/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ $(function () {

// Define a function we will use to generate contours.
function makeContour(data, layer) {
/* There are two example data sets. One has a position array which
* consists of objects each with x, y, z values. The other has a values
* array which just has our contour values. */
// There are two example data sets. One has a position array which
// consists of objects each with x, y, z values. The other has a values
// array which just has our contour values.
var contour = layer.createFeature('contour')
.data(data.position || data.values)
.style({
Expand Down Expand Up @@ -47,8 +47,8 @@ $(function () {
value: function (d) { return d > -9999 ? d : null; }
})
.contour({
/* The geometry can be specified using 0-point coordinates and deltas
* since it is a regular grid. */
// The geometry can be specified using 0-point coordinates and deltas
// since it is a regular grid.
x0: data.x0, y0: data.y0, dx: data.dx, dy: data.dy
});
}
Expand Down Expand Up @@ -107,7 +107,18 @@ $(function () {
success: function (data) {
var contour = makeContour(data, contourLayer);
contour.draw();
/* After 10 second, load a denser data set */

// Make some values available in the global context to aid exploration
// and automated tests.
window.example = {
ready: true,
map: map,
contourLayer: contourLayer,
contour: contour,
data: data
};

// After 10 second, load a denser data set
if (!query.url) {
window.setTimeout(function () {
$.ajax({
Expand Down
10 changes: 9 additions & 1 deletion examples/isoline/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@
"exampleJs": ["main.js"],
"about": {
"text": "This example shows how to add isolines to a map."
}
},
"tests": [{
"description": "isoline feature is loaded and has text",
"wait": ["example.ready"],
"tests": [
"example.iso instanceof geo.isolineFeature",
"example.isolineLayer.children()[2].features()[0] instanceof geo.textFeature"
]
}]
}
114 changes: 56 additions & 58 deletions examples/isoline/main.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,61 @@
// Run after the DOM loads
$(function () {
'use strict';

// Create a map object with the OpenStreetMaps base layer.
var map = geo.map({
node: '#map',
center: {
x: -157.965,
y: 21.482
},
zoom: 11
});
// Create a map object with the OpenStreetMaps base layer.
var map = geo.map({
node: '#map',
center: {
x: -157.965,
y: 21.482
},
zoom: 11
});

// Add a faint osm layer
map.createLayer('osm', {opacity: 0.5});
// Add a faint osm layer
map.createLayer('osm', {opacity: 0.5});

// Create a feature layer that supports contours
var isolineLayer = map.createLayer('feature', {
features: ['isoline']
});
// Create a feature layer that supports contours
var isolineLayer = map.createLayer('feature', {
features: ['isoline']
});

// Load the data
$.get('../../data/oahu-dense.json').done(function (data) {
// Create an isoline feature
var iso = isolineLayer.createFeature('isoline', {
isoline: {
// Specify our grid data
gridWidth: data.gridWidth,
gridHeight: data.gridHeight,
x0: data.x0,
y0: data.y0,
dx: data.dx,
dy: data.dy,
// Don't plot any values less than zero
min: 0,
// Create a contour line every 50 meters
spacing: 50,
// Make every 4th line heavier and every 4*5 = 20th line heavier yet
levels: [4, 5]
},
style: {
// The data uses -9999 to represent no value; modify it to return null
// instead.
value: function (d) { return d > -9999 ? d : null; },
// level relates to the isoline importance, with 0 being the most
// common and, using the levels specified, a level of 1 being every
// fourth, and 2 every twentieth line. Color the lines differently
// depending on the level
strokeColor: function (v, vi, d) {
return ['grey', 'mediumblue', 'blue'][d.level];
}
// Load the data
$.get('../../data/oahu-dense.json').done(function (data) {
// Create an isoline feature
var iso = isolineLayer.createFeature('isoline', {
isoline: {
// Specify our grid data
gridWidth: data.gridWidth,
gridHeight: data.gridHeight,
x0: data.x0,
y0: data.y0,
dx: data.dx,
dy: data.dy,
// Don't plot any values less than zero
min: 0,
// Create a contour line every 50 meters
spacing: 50,
// Make every 4th line heavier and every 4*5 = 20th line heavier yet
levels: [4, 5]
},
style: {
// The data uses -9999 to represent no value; modify it to return null
// instead.
value: function (d) { return d > -9999 ? d : null; },
// level relates to the isoline importance, with 0 being the most
// common and, using the levels specified, a level of 1 being every
// fourth, and 2 every twentieth line. Color the lines differently
// depending on the level
strokeColor: function (v, vi, d) {
return ['grey', 'mediumblue', 'blue'][d.level];
}
}).data(data.values).draw();
// Make some values available in the global context so curious people can
// play with them.
window.example = {
map: map,
isolineLayer: isolineLayer,
iso: iso
};
});
}
}).data(data.values).draw();

// Make some values available in the global context to aid exploration and
// automated tests.
window.example = {
ready: true,
map: map,
isolineLayer: isolineLayer,
iso: iso
};

});
13 changes: 9 additions & 4 deletions src/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ var textFeature = require('./textFeature');

var annotationId = 0;

/**
* @alias geo.annotation.state
* @enum {string}
*/
var annotationState = {
create: 'create',
done: 'done',
Expand Down Expand Up @@ -68,14 +72,15 @@ var editHandleFeatureLevel = 3;
* @class
* @alias geo.annotation
* @param {string} type The type of annotation. These should be registered
* with geo.registerAnnotation and can be listed with geo.listAnnotations.
* with {@link geo.registerAnnotation} and can be listed with
* {@link geo.listAnnotations}.
* @param {object?} [args] Individual annotations have additional options.
* @param {string} [args.name] A name for the annotation. This defaults to
* the type with a unique ID suffixed to it.
* @param {geo.annotationLayer} [arg.layer] A reference to the controlling
* layer. This is used for coordinate transforms.
* @param {string} [args.state] Initial annotation state. One of the
* `geo.annotation.state` values.
* {@link geo.annotation.state} values.
* @param {boolean|string[]} [args.showLabel=true] `true` to show the
* annotation label on annotations in done or edit states. Alternately, a
* list of states in which to show the label. Falsy to not show the label.
Expand Down Expand Up @@ -217,7 +222,7 @@ var annotation = function (type, args) {

/**
* If the label should be shown, get a record of the label that can be used
* in a `geo.textFeature`.
* in a {@link geo.textFeature}.
*
* @returns {geo.annotationLayer.labelRecord|undefined} A label record, or
* `undefined` if it should not be shown.
Expand Down Expand Up @@ -284,7 +289,7 @@ var annotation = function (type, args) {
*
* @param {string|undefined} arg If `undefined`, return the state,
* otherwise change it. This should be one of the
* `geo.annotation.state` values.
* {@link geo.annotation.state} values.
* @returns {this|string} The current state or this annotation.
* @fires geo.event.annotation.state
*/
Expand Down
2 changes: 1 addition & 1 deletion src/annotationLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var textFeature = require('./textFeature');
* @property {string} text The text of the label
* @property {geo.geoPosition} position The position of the label in map gcs
* coordinates.
* @property {object} [style] A `geo.textFeature` style object.
* @property {object} [style] A {@link geo.textFeature} style object.
*/

/**
Expand Down
Loading

0 comments on commit 96f491a

Please sign in to comment.