Interactive interface for browsing global, full-resolution satellite imagery
remove great circle toggle
Jason Kent86997ce831cf
diff --git a/web/js/components/measure-tool/measure-menu.js b/web/js/components/measure-tool/measure-menu.jsindex cad0a58f7..c1eba24c8 100644--- a/web/js/components/measure-tool/measure-menu.js+++ b/web/js/components/measure-tool/measure-menu.js@@ -3,8 +3,8 @@ import { connect } from 'react-redux';import React, { Component } from 'react';import { onToggle } from '../../modules/modal/actions';import IconList from '../util/list';-import { changeUnits, useGreatCircle } from '../../modules/measure/actions';-import { Form, FormGroup, Label, Input, Tooltip } from 'reactstrap';+import { changeUnits } from '../../modules/measure/actions';+import { Form } from 'reactstrap';const OPTIONS_ARRAY = [{@@ -32,8 +32,7 @@ class MeasureMenu extends Component {super(props);this.state = {showAlert: false,- tooltipOpen: false,- useGreatCircleMeasurements: props.useGreatCircleMeasurements+ tooltipOpen: false};this.tooltipToggle = this.tooltipToggle.bind(this);}@@ -50,11 +49,6 @@ class MeasureMenu extends Component {this.props.onToggleUnits(units);}- useGreatCircle(evt) {- const { checked } = evt.target;- this.props.onToggleUseGreatCircle(checked);- }-tooltipToggle() {this.setState({tooltipOpen: !this.state.tooltipOpen@@ -67,26 +61,6 @@ class MeasureMenu extends Component {return (<><Form>- <FormGroup check>- <Label check>- <Input- id="great-circle-toggle"- type="checkbox"- onChange={this.useGreatCircle.bind(this)}- defaultChecked={this.props.useGreatCircleMeasurements}- />- {' '} Use Great Circle- </Label>- <i id="great-circle-info" className="fas fa-info-circle"></i>- <Tooltip- placement="top"- isOpen={this.state.tooltipOpen}- target="great-circle-info"- toggle={this.tooltipToggle}>- If enabled, lines will be drawn as great circle arcs which represent- the shortest real world distance between two points.- </Tooltip>- </FormGroup><div className="measure-unit-toggle custom-control custom-switch"><inputid="unit-toggle"@@ -121,9 +95,6 @@ const mapDispatchToProps = (dispatch, ownProps) => ({onToggleUnits: (units) => {dispatch(changeUnits(units));},- onToggleUseGreatCircle: (value) => {- dispatch(useGreatCircle(value));- },onCloseModal: (eventName) => {dispatch(onToggle());}@@ -139,7 +110,5 @@ MeasureMenu.propTypes = {map: PropTypes.object,onCloseModal: PropTypes.func,onToggleUnits: PropTypes.func,- onToggleUseGreatCircle: PropTypes.func,- units: PropTypes.string,- useGreatCircleMeasurements: PropTypes.bool+ units: PropTypes.string};diff --git a/web/js/map/measure/ui.js b/web/js/map/measure/ui.jsindex 67fbf7582..fbff5aa82 100644--- a/web/js/map/measure/ui.js+++ b/web/js/map/measure/ui.js@@ -175,7 +175,7 @@ export function measure(map, mapUiEvents, store) {/*** Go through every tooltip and recalculate the measurement based on- * current settings of unit of measurement and great circle+ * current settings of unit of measurement*/function recalculateAllMeasurements() {for (const id in allMeasureTooltips) {diff --git a/web/js/map/measure/util.js b/web/js/map/measure/util.jsindex 0b7c5d44a..2491e8c05 100644--- a/web/js/map/measure/util.js+++ b/web/js/map/measure/util.js@@ -4,7 +4,7 @@ import {} from 'ol/geom';import geographiclib from 'geographiclib';-const { Inverse, InverseLine, Polygon } = geographiclib.Geodesic.WGS84;+const geod = geographiclib.Geodesic.WGS84;const geographicProj = 'EPSG:4326';const metersPerKilometer = 1000;const ftPerMile = 5280;@@ -23,7 +23,7 @@ export function transformLineStringArc(geom, projection) {const distance = 10000; // meters between segmentsconst transformedGeom = geom.clone().transform(projection, geographicProj);transformedGeom.forEachSegment((segStart, segEnd) => {- const line = InverseLine(segStart[1], segStart[0], segEnd[1], segEnd[0]);+ const line = geod.InverseLine(segStart[1], segStart[0], segEnd[1], segEnd[0]);const n = Math.ceil(line.s13 / distance);for (let i = 0; i <= n; ++i) {const s = Math.min(distance * i, line.s13);@@ -45,7 +45,7 @@ export function transformPolygonArc(geom, projection) {const distance = 10000; // meters between segmentsconst polyCoords = transformedGeom.getCoordinates()[0];for (let i = 0; i < polyCoords.length - 1; i++) {- const line = InverseLine(+ const line = geod.InverseLine(polyCoords[i][1],polyCoords[i][0],polyCoords[i + 1][1],@@ -111,7 +111,7 @@ export function getFormattedArea(polygon, projection, unitOfMeasure) {export function getGeographicLibArea(polygon) {const coordinates = polygon.getCoordinates()[0];if (coordinates.length < 3) return 0;- const geoPoly = Polygon(false);+ const geoPoly = geod.Polygon(false);coordinates.forEach(coord => {// flip lat/lon positiongeoPoly.AddPoint(coord[1], coord[0]);@@ -128,7 +128,7 @@ export function getGeographicLibArea(polygon) {export function getGeographicLibDistance(line) {let totalDistance = 0;line.forEachSegment((segStart, segEnd) => {- const r = Inverse(segStart[1], segStart[0], segEnd[1], segEnd[0]);+ const r = geod.Inverse(segStart[1], segStart[0], segEnd[1], segEnd[0]);totalDistance += r.s12;});return totalDistance;diff --git a/web/js/map/measure/util.test.js b/web/js/map/measure/util.test.jsindex d8a994bc7..9611fc350 100644--- a/web/js/map/measure/util.test.js+++ b/web/js/map/measure/util.test.js@@ -18,14 +18,13 @@ test('two different triangles of the same size return the same measurement', ()const tri1 = [[0, 90], [-150, 80], [150, 80], [0, 90]];// triangle does NOT anti-meridianconst tri2 = [[0, 90], [-150, 80], [-90, 80], [0, 90]];- const greatCircleMeasure = false;const tri1poly = new Polygon([tri1]);const tri2poly = new Polygon([tri2]);- const tri1AreaKm = getFormattedArea(tri1poly, 'EPSG:4326', kilos, greatCircleMeasure);- const tri2AreaKm = getFormattedArea(tri2poly, 'EPSG:4326', kilos, greatCircleMeasure);- const tri1AreaMiles = getFormattedArea(tri1poly, 'EPSG:4326', miles, greatCircleMeasure);- const tri2AreaMiles = getFormattedArea(tri2poly, 'EPSG:4326', miles, greatCircleMeasure);+ const tri1AreaKm = getFormattedArea(tri1poly, 'EPSG:4326', kilos);+ const tri2AreaKm = getFormattedArea(tri2poly, 'EPSG:4326', kilos);+ const tri1AreaMiles = getFormattedArea(tri1poly, 'EPSG:4326', miles);+ const tri2AreaMiles = getFormattedArea(tri2poly, 'EPSG:4326', miles);expect(tri1AreaKm).toBe(tri2AreaKm);expect(tri1AreaMiles).toBe(tri2AreaMiles);@@ -46,9 +45,9 @@ test('area measurement that includes coordinates outisde of "normal" extents retconst geoTriPoly = new Polygon([geoTri1]);const shiftedTriPoly = new Polygon([shiftedTri1]);- const normalTriArea = getFormattedArea(normalTriPoly, 'EPSG:4326', kilos, true);- const geoTriArea = getFormattedArea(geoTriPoly, 'EPSG:4326', kilos, true);- const shiftedTriArea = getFormattedArea(shiftedTriPoly, 'EPSG:4326', kilos, true);+ const normalTriArea = getFormattedArea(normalTriPoly, 'EPSG:4326', kilos);+ const geoTriArea = getFormattedArea(geoTriPoly, 'EPSG:4326', kilos);+ const shiftedTriArea = getFormattedArea(shiftedTriPoly, 'EPSG:4326', kilos);expect(normalTriArea).toBe(geoTriArea);expect(normalTriArea).toBe(shiftedTriArea);});diff --git a/web/js/modules/measure/actions.js b/web/js/modules/measure/actions.jsindex 64de0cec9..1fcfb2aef 100644--- a/web/js/modules/measure/actions.js+++ b/web/js/modules/measure/actions.js@@ -1,4 +1,4 @@-import { CHANGE_UNITS, USE_GREAT_CIRCLE, TOGGLE_MEASURE_ACTIVE } from './constants';+import { CHANGE_UNITS, TOGGLE_MEASURE_ACTIVE } from './constants';export function changeUnits(units) {return {@@ -6,13 +6,6 @@ export function changeUnits(units) {value: units};}-export function useGreatCircle(value) {- return {- type: USE_GREAT_CIRCLE,- value- };-}-export function toggleMeasureActive(isActive) {return {type: TOGGLE_MEASURE_ACTIVE,diff --git a/web/js/modules/measure/constants.js b/web/js/modules/measure/constants.jsindex 33b6747ef..a859f9bee 100644--- a/web/js/modules/measure/constants.js+++ b/web/js/modules/measure/constants.js@@ -1,3 +1,2 @@export const CHANGE_UNITS = 'MEASURE/CHANGE_UNITS';-export const USE_GREAT_CIRCLE = 'MEASURE/USE_GREAT_CIRCLE';export const TOGGLE_MEASURE_ACTIVE = 'MEASURE/TOGGLE_MEASURE_ACTIVE';diff --git a/web/js/modules/measure/reducers.js b/web/js/modules/measure/reducers.jsindex 5800398f4..8b46b0acc 100644--- a/web/js/modules/measure/reducers.js+++ b/web/js/modules/measure/reducers.js@@ -1,5 +1,5 @@import { assign as lodashAssign } from 'lodash';-import { CHANGE_UNITS, USE_GREAT_CIRCLE, TOGGLE_MEASURE_ACTIVE } from './constants';+import { CHANGE_UNITS, TOGGLE_MEASURE_ACTIVE } from './constants';const defaultState = {isActive: false,@@ -13,10 +13,6 @@ export default function measureReducer(state = defaultState, action) {return lodashAssign({}, state, {units: action.value});- case USE_GREAT_CIRCLE:- return lodashAssign({}, state, {- useGreatCircleMeasurements: action.value- });case TOGGLE_MEASURE_ACTIVE:return lodashAssign({}, state, {isActive: action.value