|
|
@@ -1,302 +1,292 @@
|
|
|
import { createSelector } from 'reselect';
|
|
|
import Global from './Common';
|
|
|
-import { latLngDegreesToDecimal } from './Utils'
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- function _getCircles(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
- let circles = [];
|
|
|
- if (!Array.isArray(airspaceInfos)) {
|
|
|
- return { circles };
|
|
|
- }
|
|
|
- //通过该方法获取样式
|
|
|
- let circleStyle = setStyle('circle');
|
|
|
- for (let i = 0; i < airspaceInfos.length; i++) {
|
|
|
- let tmpCircle = airspaceInfos[i]
|
|
|
- if (tmpCircle.airspaceType == Global.airspaceType.circle && currentAirspaceIndex != i) {
|
|
|
- let coordinate = {};
|
|
|
- coordinate.latitude = latLngDegreesToDecimal(tmpCircle.lat);
|
|
|
- coordinate.longitude = latLngDegreesToDecimal(tmpCircle.lng);
|
|
|
- let radius = tmpCircle.radius;
|
|
|
- let circle = {
|
|
|
- lineWidth: circleStyle.lineWidth ? circleStyle.lineWidth : Global.amapLineWidth,
|
|
|
- strokeColor: circleStyle.strokeColor ? circleStyle.strokeColor : Global.amapStrokeColor,
|
|
|
- fillColor: circleStyle.fillColor ? circleStyle.fillColor : Global.amapFillColor,
|
|
|
- radius,
|
|
|
- coordinate
|
|
|
- }
|
|
|
- circles.push(circle);
|
|
|
+import {
|
|
|
+ latLngDegreesToDecimal,
|
|
|
+ isObject,
|
|
|
+ isUndefined,
|
|
|
+ isString,
|
|
|
+ isSafeString,
|
|
|
+ hasLine,
|
|
|
+ hasPoint
|
|
|
+} from './Utils'
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function getCircles(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
+ let circles = [];
|
|
|
+ if (!Array.isArray(airspaceInfos)) {
|
|
|
+ return { circles };
|
|
|
+ }
|
|
|
+ //通过该方法获取样式
|
|
|
+ let circleStyle = setStyle('circle');
|
|
|
+ for (let i = 0; i < airspaceInfos.length; i++) {
|
|
|
+ let tmpCircle = airspaceInfos[i]
|
|
|
+ if (tmpCircle.airspaceType == Global.airspaceType.circle && currentAirspaceIndex != i) {
|
|
|
+ let coordinate = {};
|
|
|
+ coordinate.latitude = latLngDegreesToDecimal(tmpCircle.lat);
|
|
|
+ coordinate.longitude = latLngDegreesToDecimal(tmpCircle.lng);
|
|
|
+ let radius = tmpCircle.radius;
|
|
|
+ let circle = {
|
|
|
+ lineWidth: circleStyle.lineWidth ? circleStyle.lineWidth : Global.amapLineWidth,
|
|
|
+ strokeColor: circleStyle.strokeColor ? circleStyle.strokeColor : Global.amapStrokeColor,
|
|
|
+ fillColor: circleStyle.fillColor ? circleStyle.fillColor : Global.amapFillColor,
|
|
|
+ radius,
|
|
|
+ coordinate
|
|
|
}
|
|
|
+ circles.push(circle);
|
|
|
}
|
|
|
-
|
|
|
- return { circles }
|
|
|
- }
|
|
|
-
|
|
|
- function _getCircleSelector(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
- return createSelector(
|
|
|
- airspaceInfos,
|
|
|
- () => setStyle,
|
|
|
- currentAirspaceIndex,
|
|
|
- _getCircles
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- function _isObject(arg) {
|
|
|
- return typeof arg === 'object' && arg !== null;
|
|
|
}
|
|
|
|
|
|
+ return circles;
|
|
|
+}
|
|
|
|
|
|
- function _hasLine(obj) {
|
|
|
- return (isObject(obj)
|
|
|
- && isSafeString(obj.addr)
|
|
|
- && isSafeString(obj.lat)
|
|
|
- && isSafeString(obj.lng));
|
|
|
- }
|
|
|
-
|
|
|
- function _hasPoint(obj) {
|
|
|
- return (isObject(obj)
|
|
|
- && isSafeString(obj.lat)
|
|
|
- && isSafeString(obj.lng));
|
|
|
- }
|
|
|
+function getCircleSelector(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
+ return createSelector(
|
|
|
+ airspaceInfos,
|
|
|
+ () => setStyle,
|
|
|
+ currentAirspaceIndex,
|
|
|
+ getCircles
|
|
|
+ );
|
|
|
+}
|
|
|
|
|
|
|
|
|
- function _drawLineConfig(lat, lng) {
|
|
|
- let coordinate = {};
|
|
|
- coordinate.latitude = latLngDegreesToDecimal(lat);
|
|
|
- coordinate.longitude = latLngDegreesToDecimal(lng);
|
|
|
- return coordinate;
|
|
|
- }
|
|
|
+function drawLineConfig(lat, lng) {
|
|
|
+ let coordinate = {};
|
|
|
+ coordinate.latitude = latLngDegreesToDecimal(lat);
|
|
|
+ coordinate.longitude = latLngDegreesToDecimal(lng);
|
|
|
+ return coordinate;
|
|
|
+}
|
|
|
|
|
|
- function _addOvalPointConfig(lat, lng, imageName) {
|
|
|
- let coordinate = {};
|
|
|
- coordinate.latitude = latLngDegreesToDecimal(lat);
|
|
|
- coordinate.longitude = latLngDegreesToDecimal(lng);
|
|
|
+function addOvalPointConfig(lat, lng, imageName) {
|
|
|
+ let coordinate = {};
|
|
|
+ coordinate.latitude = latLngDegreesToDecimal(lat);
|
|
|
+ coordinate.longitude = latLngDegreesToDecimal(lng);
|
|
|
|
|
|
- let annotationConfig = {};
|
|
|
- annotationConfig.coordinate = coordinate;
|
|
|
- annotationConfig.imageName = imageName;
|
|
|
+ let annotationConfig = {};
|
|
|
+ annotationConfig.coordinate = coordinate;
|
|
|
+ annotationConfig.imageName = imageName;
|
|
|
|
|
|
- return annotationConfig
|
|
|
- }
|
|
|
+ return annotationConfig
|
|
|
+}
|
|
|
|
|
|
|
|
|
- function _getAirwayLine(airway, pointBefore, pointAfter, lineAndMarkerStyle) {
|
|
|
- let found = 0
|
|
|
- let points = []
|
|
|
+function getAirwayLine(airway, pointBefore, pointAfter, lineAndMarkerStyle) {
|
|
|
+ let found = 0
|
|
|
+ let points = []
|
|
|
|
|
|
- for (let point of airway.points) {
|
|
|
- if (pointBefore.point_id == point.point_id || pointAfter.point_id == point.point_id) {
|
|
|
- found++
|
|
|
- points.push(Object.assign({}, point))
|
|
|
- continue
|
|
|
- }
|
|
|
-
|
|
|
- if (found == 1) {
|
|
|
- points.push(Object.assign({}, point))
|
|
|
- }
|
|
|
+ for (let point of airway.points) {
|
|
|
+ if (pointBefore.point_id == point.point_id || pointAfter.point_id == point.point_id) {
|
|
|
+ found++
|
|
|
+ points.push(Object.assign({}, point))
|
|
|
+ continue
|
|
|
}
|
|
|
|
|
|
- if (!(points.length > 0 && found == 2)) {
|
|
|
- // 如果两个点不全在航线上面,那么画全部航线
|
|
|
- points = airway.points
|
|
|
+ if (found == 1) {
|
|
|
+ points.push(Object.assign({}, point))
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- let line = {
|
|
|
- lineWidth: lineAndMarkerStyle.lineWidth ? lineAndMarkerStyle.lineWidth : Global.amapLineWidth,
|
|
|
- strokeColor: lineAndMarkerStyle.strokeColor ? lineAndMarkerStyle.strokeColor : Global.amapStrokeColor,
|
|
|
- coordinates: points
|
|
|
- }
|
|
|
- return { line };
|
|
|
+ if (!(points.length > 0 && found == 2)) {
|
|
|
+ // 如果两个点不全在航线上面,那么画全部航线
|
|
|
+ points = airway.points
|
|
|
}
|
|
|
|
|
|
+ let line = {
|
|
|
+ lineWidth: lineAndMarkerStyle.lineWidth ? lineAndMarkerStyle.lineWidth : Global.amapLineWidth,
|
|
|
+ strokeColor: lineAndMarkerStyle.strokeColor ? lineAndMarkerStyle.strokeColor : Global.amapStrokeColor,
|
|
|
+ coordinates: points
|
|
|
+ }
|
|
|
+ return { line };
|
|
|
+}
|
|
|
|
|
|
|
|
|
- function _getLinesRouter(lineProps, lineAndMarkerStyle) {
|
|
|
- let coordinates = new Array();
|
|
|
- let markers = new Array();
|
|
|
- let lines = []
|
|
|
|
|
|
- if (_hasLine(lineProps.dep)) {
|
|
|
- coordinates.push(_drawLineConfig(lineProps.dep.lat, lineProps.dep.lng));
|
|
|
- markers.push(_addOvalPointConfig(lineProps.dep.lat, lineProps.dep.lng, lineAndMarkerStyle.imageName ? lineAndMarkerStyle.imageName : 'BA_oval'));
|
|
|
- }
|
|
|
+function getLinesRouter(lineProps, lineAndMarkerStyle) {
|
|
|
+ let coordinates = new Array();
|
|
|
+ let markers = new Array();
|
|
|
+ let lines = []
|
|
|
|
|
|
- if (Array.isArray(lineProps.passPoints)) {
|
|
|
- for (let i = 0; i < lineProps.passPoints.length; i++) {
|
|
|
- let obj = lineProps.passPoints[i]
|
|
|
- if (_isObject(obj)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ if (hasLine(lineProps.dep)) {
|
|
|
+ coordinates.push(drawLineConfig(lineProps.dep.lat, lineProps.dep.lng));
|
|
|
+ markers.push(addOvalPointConfig(lineProps.dep.lat, lineProps.dep.lng, lineAndMarkerStyle.imageName ? lineAndMarkerStyle.imageName : 'BA_oval'));
|
|
|
+ }
|
|
|
|
|
|
- if (obj.pointType == Global.pointTypes.point
|
|
|
- || obj.pointType == Global.pointTypes.nav) {
|
|
|
- coordinates.push(_drawLineConfig(obj.lat, obj.lng));
|
|
|
- markers.push(_addOvalPointConfig(obj.lat, obj.lng, lineAndMarkerStyle.imageName ? lineAndMarkerStyle.imageName : 'BA_oval'));
|
|
|
- } else {
|
|
|
- // 遇到一个航线,不需要和前前面的点连起来
|
|
|
- if (coordinates.length > 1) {
|
|
|
- lines.push({
|
|
|
- lineWidth: lineAndMarkerStyle.lineWidth ? lineAndMarkerStyle.lineWidth : Global.amapLineWidth,
|
|
|
- strokeColor: lineAndMarkerStyle.strokeColor ? lineAndMarkerStyle.strokeColor : Global.amapStrokeColor,
|
|
|
- coordinates: coordinates
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- coordinates = []
|
|
|
-
|
|
|
- const pointBefore = i == 0 ? lineProps.dep : lineProps.passPoints[i - 1]
|
|
|
- const pointAfter = i == lineProps.passPoints.length - 1 ? lineProps.arrive : lineProps.passPoints[i + 1]
|
|
|
-
|
|
|
- lines.push(_getAirwayLine(obj, pointBefore, pointAfter, lineAndMarkerStyle))
|
|
|
- }
|
|
|
+ if (Array.isArray(lineProps.passPoints)) {
|
|
|
+ for (let i = 0; i < lineProps.passPoints.length; i++) {
|
|
|
+ let obj = lineProps.passPoints[i]
|
|
|
+ if (isObject(obj)) {
|
|
|
+ continue;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if (_hasLine(lineProps.arrive)) {
|
|
|
- coordinates.push(_drawLineConfig(lineProps.arrive.lat, lineProps.arrive.lng));
|
|
|
- markers.push(_addOvalPointConfig(lineProps.arrive.lat, lineProps.arrive.lng, lineAndMarkerStyle.imageName ? lineAndMarkerStyle.imageName : 'BA_oval'));
|
|
|
- }
|
|
|
|
|
|
- if (coordinates.length > 1) {
|
|
|
- lines.push({
|
|
|
- lineWidth: lineAndMarkerStyle.lineWidth ? lineAndMarkerStyle.lineWidth : Global.amapLineWidth,
|
|
|
- strokeColor: lineAndMarkerStyle.strokeColor ? lineAndMarkerStyle.strokeColor : Global.amapStrokeColor,
|
|
|
- coordinates: coordinates
|
|
|
- });
|
|
|
- }
|
|
|
+ if (obj.pointType == Global.pointTypes.point
|
|
|
+ || obj.pointType == Global.pointTypes.nav) {
|
|
|
+ coordinates.push(drawLineConfig(obj.lat, obj.lng));
|
|
|
+ markers.push(addOvalPointConfig(obj.lat, obj.lng, lineAndMarkerStyle.imageName ? lineAndMarkerStyle.imageName : 'BA_oval'));
|
|
|
+ } else {
|
|
|
+ // 遇到一个航线,不需要和前前面的点连起来
|
|
|
+ if (coordinates.length > 1) {
|
|
|
+ lines.push({
|
|
|
+ lineWidth: lineAndMarkerStyle.lineWidth ? lineAndMarkerStyle.lineWidth : Global.amapLineWidth,
|
|
|
+ strokeColor: lineAndMarkerStyle.strokeColor ? lineAndMarkerStyle.strokeColor : Global.amapStrokeColor,
|
|
|
+ coordinates: coordinates
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
- return { lines, markers };
|
|
|
+ coordinates = []
|
|
|
|
|
|
- }
|
|
|
+ const pointBefore = i == 0 ? lineProps.dep : lineProps.passPoints[i - 1]
|
|
|
+ const pointAfter = i == lineProps.passPoints.length - 1 ? lineProps.arrive : lineProps.passPoints[i + 1]
|
|
|
|
|
|
- function _getLinesAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
- let retLines = [];
|
|
|
- let retMarkers = [];
|
|
|
- if (!Array.isArray(airspaceInfos)) {
|
|
|
- return { lines: retLines, markers: retMarkers };
|
|
|
- }
|
|
|
- let lineStyle = setStyle('line');
|
|
|
- for (let i = 0; i < airspaceInfos.length; i++) {
|
|
|
- let tmpLine = airspaceInfos[i]
|
|
|
- if (tmpLine.airspaceType == Global.airspaceType.line && currentAirspaceIndex != i) {
|
|
|
- let { lines, markers } = _getLinesRouter(tmpLine, lineStyle);
|
|
|
- retMarkers.push(...markers);
|
|
|
- retLines.push(...lines);
|
|
|
+ lines.push(getAirwayLine(obj, pointBefore, pointAfter, lineAndMarkerStyle))
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- return { lines: retLines, markers: retMarkers };
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- function _getLineAndMarkerSelector(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
- return createSelector(
|
|
|
- airspaceInfos,
|
|
|
- () => setStyle,
|
|
|
- currentAirspaceIndex,
|
|
|
- _getLinesAndMarkers
|
|
|
- );
|
|
|
+ if (hasLine(lineProps.arrive)) {
|
|
|
+ coordinates.push(drawLineConfig(lineProps.arrive.lat, lineProps.arrive.lng));
|
|
|
+ markers.push(addOvalPointConfig(lineProps.arrive.lat, lineProps.arrive.lng, lineAndMarkerStyle.imageName ? lineAndMarkerStyle.imageName : 'BA_oval'));
|
|
|
}
|
|
|
|
|
|
- function _getPolygon(polygonProps, polygonAndMarkerStyle) {
|
|
|
- let coordinates = new Array();
|
|
|
- let markers = new Array();
|
|
|
+ if (coordinates.length > 1) {
|
|
|
+ lines.push({
|
|
|
+ lineWidth: lineAndMarkerStyle.lineWidth ? lineAndMarkerStyle.lineWidth : Global.amapLineWidth,
|
|
|
+ strokeColor: lineAndMarkerStyle.strokeColor ? lineAndMarkerStyle.strokeColor : Global.amapStrokeColor,
|
|
|
+ coordinates: coordinates
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- if (Array.isArray(polygonProps.polygonPoints)) {
|
|
|
- for (let obj of polygonProps.polygonPoints) {
|
|
|
- if (!_hasPoint(obj)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- coordinates.push(_drawLineConfig(obj.lat, obj.lng));
|
|
|
- markers.push(_addOvalPointConfig(obj.lat, obj.lng, polygonAndMarkerStyle.imageName ? polygonAndMarkerStyle.imageName : 'BA_oval'));
|
|
|
- }
|
|
|
- }
|
|
|
+ return { lines, markers };
|
|
|
|
|
|
- if (coordinates.length > 0) {
|
|
|
- let polygon = {
|
|
|
- lineWidth: polygonAndMarkerStyle.lineWidth ? polygonAndMarkerStyle.lineWidth : Global.amapLineWidth,
|
|
|
- strokeColor: polygonAndMarkerStyle.strokeColor ? polygonAndMarkerStyle.strokeColor : Global.amapStrokeColor,
|
|
|
- fillColor: polygonAndMarkerStyle.fillColor ? polygonAndMarkerStyle.fillColor : Global.amapFillColor,
|
|
|
- coordinates: coordinates
|
|
|
- };
|
|
|
+}
|
|
|
|
|
|
- return { markers, polygon };
|
|
|
+function getLinesAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
+ let retLines = [];
|
|
|
+ let retMarkers = [];
|
|
|
+ if (!Array.isArray(airspaceInfos)) {
|
|
|
+ return { lines: retLines, markers: retMarkers };
|
|
|
+ }
|
|
|
+ let lineStyle = setStyle('line');
|
|
|
+ for (let i = 0; i < airspaceInfos.length; i++) {
|
|
|
+ let tmpLine = airspaceInfos[i]
|
|
|
+ if (tmpLine.airspaceType == Global.airspaceType.line && currentAirspaceIndex != i) {
|
|
|
+ let { lines, markers } = getLinesRouter(tmpLine, lineStyle);
|
|
|
+ retMarkers.push(...markers);
|
|
|
+ retLines.push(...lines);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ return { lines: retLines, markers: retMarkers };
|
|
|
+}
|
|
|
|
|
|
- function _getPolygonsAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
- let markers = [];
|
|
|
- let polygons = [];
|
|
|
- if (!Array.isArray(airspaceInfos)) {
|
|
|
- return { markers, polygons };
|
|
|
- }
|
|
|
- let polygonAndMarkerStyle = setStyle('polygon');
|
|
|
- for (let i = 0; i < airspaceInfos.length; i++) {
|
|
|
- let polygon = airspaceInfos[i]
|
|
|
- if (polygon.airspaceType == Global.flyingTypes.polygon && currentAirspaceIndex != i) {
|
|
|
- let retObj = _getPolygon(polygon)
|
|
|
- markers.push(...retObj.markers);
|
|
|
- polygons.push(retObj.polygon);
|
|
|
- }
|
|
|
- }
|
|
|
- return { markers, polygons };
|
|
|
|
|
|
- }
|
|
|
+function getLineAndMarkerSelector(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
+ return createSelector(
|
|
|
+ airspaceInfos,
|
|
|
+ () => setStyle,
|
|
|
+ currentAirspaceIndex,
|
|
|
+ getLinesAndMarkers
|
|
|
+ );
|
|
|
+}
|
|
|
|
|
|
- function _getPolygonAndMarkerSelector(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
- return createSelector(
|
|
|
- airspaceInfos,
|
|
|
- () => setStyle,
|
|
|
- currentAirspaceIndex,
|
|
|
- _getPolygonsAndMarkers
|
|
|
- );
|
|
|
- }
|
|
|
+function getPolygon(polygonProps, polygonAndMarkerStyle) {
|
|
|
+ let coordinates = new Array();
|
|
|
+ let markers = new Array();
|
|
|
|
|
|
- function _getMarkers(polygonAndMarkers,lineAndMarkers){
|
|
|
- let markers = [];
|
|
|
- if (polygonAndMarkers) {
|
|
|
- markers = [...polygonAndMarkers.markers]
|
|
|
- }
|
|
|
- if (lineAndMarkers) {
|
|
|
- markers = [...markers, ...lineAndMarkers.markers]
|
|
|
+ if (Array.isArray(polygonProps.polygonPoints)) {
|
|
|
+ for (let obj of polygonProps.polygonPoints) {
|
|
|
+ if (!hasPoint(obj)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ coordinates.push(drawLineConfig(obj.lat, obj.lng));
|
|
|
+ markers.push(addOvalPointConfig(obj.lat, obj.lng, polygonAndMarkerStyle.imageName ? polygonAndMarkerStyle.imageName : 'BA_oval'));
|
|
|
}
|
|
|
- return markers
|
|
|
}
|
|
|
|
|
|
- function _getMarkerSelector(polygonAndMarkers,lineAndMarkers) {
|
|
|
- return createSelector(
|
|
|
- polygonAndMarkers,
|
|
|
- lineAndMarkers,
|
|
|
- _getMarkers
|
|
|
- )
|
|
|
+ if (coordinates.length > 0) {
|
|
|
+ let polygon = {
|
|
|
+ lineWidth: polygonAndMarkerStyle.lineWidth ? polygonAndMarkerStyle.lineWidth : Global.amapLineWidth,
|
|
|
+ strokeColor: polygonAndMarkerStyle.strokeColor ? polygonAndMarkerStyle.strokeColor : Global.amapStrokeColor,
|
|
|
+ fillColor: polygonAndMarkerStyle.fillColor ? polygonAndMarkerStyle.fillColor : Global.amapFillColor,
|
|
|
+ coordinates: coordinates
|
|
|
+ };
|
|
|
+
|
|
|
+ return { markers, polygon };
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
|
|
|
- export function getShapesSelect(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
- currentAirspaceIndex = currentAirspaceIndex ? currentAirspaceIndex : () => -1;
|
|
|
- let circles = _getCircleSelector(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
- let lineAndMarkers = _getLineAndMarkerSelector(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
- let polygonAndMarkers = _getPolygonAndMarkerSelector(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
- let markers = _getMarkerSelector(polygonAndMarkers,lineAndMarkers);
|
|
|
- return {
|
|
|
- markers,
|
|
|
- circles,
|
|
|
- lineAndMarkers,
|
|
|
- polygonAndMarkers
|
|
|
- }
|
|
|
+function getPolygonsAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
+ let markers = [];
|
|
|
+ let polygons = [];
|
|
|
+ if (!Array.isArray(airspaceInfos)) {
|
|
|
+ return { markers, polygons };
|
|
|
}
|
|
|
-
|
|
|
- export function getShapes(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
- currentAirspaceIndex = currentAirspaceIndex ? currentAirspaceIndex : () => -1;
|
|
|
- let circles = _getCircles(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
- let lineAndMarkers = _getLinesAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
- let polygonAndMarkers = _getPolygonsAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
- let markers = _getMarkers(polygonAndMarkers,lineAndMarkers);
|
|
|
- return {
|
|
|
- markers,
|
|
|
- circles,
|
|
|
- lineAndMarkers,
|
|
|
- polygonAndMarkers
|
|
|
+ let polygonAndMarkerStyle = setStyle('polygon');
|
|
|
+ for (let i = 0; i < airspaceInfos.length; i++) {
|
|
|
+ let polygon = airspaceInfos[i]
|
|
|
+ if (polygon.airspaceType == Global.airspaceType.polygon && currentAirspaceIndex != i) {
|
|
|
+ let retObj = getPolygon(polygon, polygonAndMarkerStyle);
|
|
|
+ markers.push(...retObj.markers);
|
|
|
+ polygons.push(retObj.polygon);
|
|
|
}
|
|
|
}
|
|
|
+ return { markers, polygons };
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function getPolygonAndMarkerSelector(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
+ return createSelector(
|
|
|
+ airspaceInfos,
|
|
|
+ () => setStyle,
|
|
|
+ currentAirspaceIndex,
|
|
|
+ getPolygonsAndMarkers
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+function getMarkers(polygonAndMarkers, lineAndMarkers) {
|
|
|
+ let markers = [];
|
|
|
+ if (polygonAndMarkers) {
|
|
|
+ markers = [...polygonAndMarkers.markers]
|
|
|
+ }
|
|
|
+ if (lineAndMarkers) {
|
|
|
+ markers = [...markers, ...lineAndMarkers.markers]
|
|
|
+ }
|
|
|
+ return markers
|
|
|
+}
|
|
|
+
|
|
|
+function getMarkerSelector(polygonAndMarkers, lineAndMarkers) {
|
|
|
+ return createSelector(
|
|
|
+ polygonAndMarkers,
|
|
|
+ lineAndMarkers,
|
|
|
+ getMarkers
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+export function getShapesSelect(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
+ currentAirspaceIndex = currentAirspaceIndex ? currentAirspaceIndex : () => -1;
|
|
|
+ let circles = getCircleSelector(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
+ let lineAndMarkers = getLineAndMarkerSelector(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
+ let polygonAndMarkers = getPolygonAndMarkerSelector(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
+ let markers = getMarkerSelector(polygonAndMarkers, lineAndMarkers);
|
|
|
+ return {
|
|
|
+ markers,
|
|
|
+ circles,
|
|
|
+ lineAndMarkers,
|
|
|
+ polygonAndMarkers
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export function getShapes(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
+ currentAirspaceIndex = currentAirspaceIndex ? currentAirspaceIndex : () => -1;
|
|
|
+ let circles = getCircles(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
+ let lineAndMarkers = getLinesAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
+ let polygonAndMarkers = getPolygonsAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
+ let markers = getMarkers(polygonAndMarkers, lineAndMarkers);
|
|
|
+ return {
|
|
|
+ markers,
|
|
|
+ circles,
|
|
|
+ lineAndMarkers,
|
|
|
+ polygonAndMarkers
|
|
|
+ }
|
|
|
+}
|