-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add buttons & actions to DrawToolView; use CZML
- Switch from GeoJson to CZML (improves ability to draw around poles) - Set up the DrawTool for actions like deleting & moving points, running a callback with user-created points as argument Issue #2180
- Loading branch information
Showing
7 changed files
with
370 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"use strict"; | ||
|
||
define(["backbone", "models/maps/GeoUtilities"], function ( | ||
Backbone, | ||
GeoUtilities | ||
) { | ||
/** | ||
* @class GeoUtilities | ||
* @classdesc The GeoUtilities model has methods foe handling spatial data | ||
* that are used across multiple models/collections/views, and that don't | ||
* belong in any one of them. | ||
* @classcategory Models/Maps | ||
* @name GeoUtilities | ||
* @since x.x.x | ||
* @extends Backbone.Model | ||
*/ | ||
var GeoUtilities = Backbone.Model.extend( | ||
/** @lends GeoUtilities.prototype */ { | ||
/** | ||
* The type of model this is. | ||
* @type {String} | ||
*/ | ||
type: "GeoUtilities", | ||
|
||
/** | ||
* Convert geodetic coordinates to Earth-Centered, Earth-Fixed (ECEF) | ||
* coordinates. Currently this function assumes the WGS-84 ellipsoid, | ||
* and does not account for altitude/height (it's assumed the coordinate | ||
* is at sea level) | ||
* @param {Array} coord The geodetic coordinates in the form [longitude, | ||
* latitude]. | ||
* @returns {Array} The ECEF coordinates. | ||
*/ | ||
geodeticToECEF: function (coord) { | ||
const a = 6378137; // WGS-84 semi-major axis (meters) | ||
const f = 1 / 298.257223563; // WGS-84 flattening | ||
const e2 = 2 * f - f * f; // Square of eccentricity | ||
|
||
const lon = coord[0] * (Math.PI / 180); // Convert longitude to radians | ||
const lat = coord[1] * (Math.PI / 180); // Convert latitude to radians | ||
const alt = 10000; | ||
const sinLon = Math.sin(lon); | ||
const cosLon = Math.cos(lon); | ||
const sinLat = Math.sin(lat); | ||
const cosLat = Math.cos(lat); | ||
|
||
const N = a / Math.sqrt(1 - e2 * sinLat * sinLat); // Prime vertical radius of curvature | ||
const x = (N + alt) * cosLat * cosLon; | ||
const y = (N + alt) * cosLat * sinLon; | ||
const z = (N * (1 - e2) + alt) * sinLat; | ||
|
||
return [x, y, z]; | ||
}, | ||
} | ||
); | ||
|
||
return GeoUtilities; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.