|
|
@@ -1,78 +1,327 @@
|
|
|
"use strict";
|
|
|
-Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
-const reselect_1 = require("reselect");
|
|
|
-const Common_1 = require("./Common");
|
|
|
-const Utils_1 = require("./Utils");
|
|
|
+var __assign = (this && this.__assign) || function () {
|
|
|
+ __assign = Object.assign || function(t) {
|
|
|
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
|
+ s = arguments[i];
|
|
|
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
|
+ t[p] = s[p];
|
|
|
+ }
|
|
|
+ return t;
|
|
|
+ };
|
|
|
+ return __assign.apply(this, arguments);
|
|
|
+};
|
|
|
+exports.__esModule = true;
|
|
|
+var reselect_1 = require("reselect");
|
|
|
+var Common_1 = require("./Common");
|
|
|
+var Utils_1 = require("./Utils");
|
|
|
exports.latLngDegreesToDecimal = Utils_1.latLngDegreesToDecimal;
|
|
|
exports.latLngDecimalToDegrees = Utils_1.latLngDecimalToDegrees;
|
|
|
-let LatLon = require('geodesy').LatLonSpherical;
|
|
|
+var LatLon = require('geodesy').LatLonSpherical;
|
|
|
+function convertAirspaceInfoServerToLocal(airspaceInfo) {
|
|
|
+ var airspaceType = airspaceInfo.airspace_type;
|
|
|
+ if (airspaceType == Common_1["default"].airspaceType.circle) {
|
|
|
+ var ai = airspaceInfo;
|
|
|
+ return {
|
|
|
+ airspaceType: airspaceType,
|
|
|
+ airspaceId: ai.airspace_id,
|
|
|
+ name: ai.airspace_name,
|
|
|
+ note: ai.note,
|
|
|
+ addr: ai.center_loc,
|
|
|
+ lat: Utils_1.latLngDecimalToDegrees(ai.center_point_of_flying.lat),
|
|
|
+ lng: Utils_1.latLngDecimalToDegrees(ai.center_point_of_flying.lng),
|
|
|
+ radius: ai.radius_of_flying,
|
|
|
+ height: ai.altitude + "",
|
|
|
+ heightStandard: Common_1["default"].heightStandardsById.get(ai.unit)
|
|
|
+ };
|
|
|
+ }
|
|
|
+ if (airspaceType == Common_1["default"].airspaceType.line) {
|
|
|
+ var ai = airspaceInfo;
|
|
|
+ var dep = {
|
|
|
+ addr: ai.start_loc,
|
|
|
+ lat: Utils_1.latLngDecimalToDegrees(ai.start_point.lat),
|
|
|
+ lng: Utils_1.latLngDecimalToDegrees(ai.start_point.lng),
|
|
|
+ height: ai.start_point.altitude + "",
|
|
|
+ heightStandard: Common_1["default"].heightStandardsById.get(ai.start_point.unit)
|
|
|
+ };
|
|
|
+ var arrive = {
|
|
|
+ addr: ai.end_loc,
|
|
|
+ lat: Utils_1.latLngDecimalToDegrees(ai.end_point.lat),
|
|
|
+ lng: Utils_1.latLngDecimalToDegrees(ai.end_point.lng)
|
|
|
+ };
|
|
|
+ var passPoints = [];
|
|
|
+ if (Array.isArray(ai.passing_points)) {
|
|
|
+ for (var _i = 0, _a = ai.passing_points; _i < _a.length; _i++) {
|
|
|
+ var obj = _a[_i];
|
|
|
+ var point = void 0;
|
|
|
+ if (obj.point_type == Common_1["default"].pointTypes.point) {
|
|
|
+ var pp = obj;
|
|
|
+ var lat = Utils_1.latLngDecimalToDegrees(pp.lat);
|
|
|
+ var lng = Utils_1.latLngDecimalToDegrees(pp.lng);
|
|
|
+ point = {
|
|
|
+ pointType: pp.point_type,
|
|
|
+ addr: pp.point_name,
|
|
|
+ lat: lat, lng: lng
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else if (obj.point_type == Common_1["default"].pointTypes.nav) {
|
|
|
+ var pp = obj;
|
|
|
+ var lat = Utils_1.latLngDecimalToDegrees(pp.lat);
|
|
|
+ var lng = Utils_1.latLngDecimalToDegrees(pp.lng);
|
|
|
+ point = {
|
|
|
+ pointType: pp.point_type,
|
|
|
+ pointId: pp.point_id,
|
|
|
+ pointCode: pp.point_code,
|
|
|
+ pointName: pp.point_name,
|
|
|
+ lat: lat, lng: lng
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ var pp = obj;
|
|
|
+ point = {
|
|
|
+ pointType: pp.point_type,
|
|
|
+ airRouteId: pp.airway,
|
|
|
+ airlineCode: pp.air_route_code,
|
|
|
+ airlines: pp.points
|
|
|
+ };
|
|
|
+ }
|
|
|
+ if (Utils_1.isNumber(obj.altitude) && Utils_1.isNumber(obj.unit)) {
|
|
|
+ point.height = obj.altitude + "";
|
|
|
+ point.heightStandard = Common_1["default"].heightStandardsById.get(obj.unit);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ point.height = "";
|
|
|
+ point.heightStandard = Common_1["default"].heightStandards.keys().slice()[0];
|
|
|
+ }
|
|
|
+ passPoints.push(point);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return __assign({
|
|
|
+ airspaceType: airspaceType,
|
|
|
+ airspaceId: ai.airspace_id,
|
|
|
+ name: ai.airspace_name,
|
|
|
+ note: ai.note,
|
|
|
+ dep: dep,
|
|
|
+ arrive: arrive,
|
|
|
+ passPoints: passPoints
|
|
|
+ }, (ai.airline_width ? { airlineWidth: ai.airline_width } : {}));
|
|
|
+ }
|
|
|
+ if (airspaceType == Common_1["default"].airspaceType.polygon) {
|
|
|
+ var ai = airspaceInfo;
|
|
|
+ if (Array.isArray(ai.points)) {
|
|
|
+ var polygonPoints = new Array();
|
|
|
+ var defaultPointName = 'A';
|
|
|
+ for (var _b = 0, _c = ai.points; _b < _c.length; _b++) {
|
|
|
+ var obj = _c[_b];
|
|
|
+ var addr = obj.addr;
|
|
|
+ if (!addr) {
|
|
|
+ addr = defaultPointName;
|
|
|
+ defaultPointName = String.fromCharCode(defaultPointName.charCodeAt(0) + 1);
|
|
|
+ }
|
|
|
+ polygonPoints.push({ addr: addr, lat: Utils_1.latLngDecimalToDegrees(obj.lat), lng: Utils_1.latLngDecimalToDegrees(obj.lng) });
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ airspaceType: airspaceType,
|
|
|
+ airspaceId: ai.airspace_id,
|
|
|
+ name: ai.airspace_name,
|
|
|
+ note: ai.note,
|
|
|
+ height: ai.altitude + '',
|
|
|
+ heightStandard: Common_1["default"].heightStandardsById.get(ai.unit),
|
|
|
+ polygonPoints: polygonPoints
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+}
|
|
|
+exports.convertAirspaceInfoServerToLocal = convertAirspaceInfoServerToLocal;
|
|
|
+function convertAirspaceInfoLocalToServer(airspace) {
|
|
|
+ if (airspace.airspaceType == Common_1["default"].airspaceType.circle) {
|
|
|
+ var ai = airspace;
|
|
|
+ var circle = {
|
|
|
+ airspace_name: ai.name,
|
|
|
+ airspace_id: ai.airspaceId,
|
|
|
+ airspace_type: Common_1["default"].airspaceType.circle,
|
|
|
+ note: Utils_1.isSafeString(ai.note) ? ai.note : null,
|
|
|
+ radius_of_flying: parseInt(ai.radius + ''),
|
|
|
+ center_point_of_flying: {
|
|
|
+ lng: Utils_1.latLngDegreesToDecimal(ai.lng),
|
|
|
+ lat: Utils_1.latLngDegreesToDecimal(ai.lat)
|
|
|
+ },
|
|
|
+ center_loc: ai.addr,
|
|
|
+ altitude: parseInt(ai.height),
|
|
|
+ unit: Common_1["default"].heightStandards.get(ai.heightStandard)
|
|
|
+ };
|
|
|
+ return circle;
|
|
|
+ }
|
|
|
+ else if (airspace.airspaceType == Common_1["default"].airspaceType.line) {
|
|
|
+ var ai = airspace;
|
|
|
+ var line = {
|
|
|
+ airspace_name: ai.name,
|
|
|
+ airspace_id: ai.airspaceId,
|
|
|
+ airspace_type: Common_1["default"].airspaceType.line,
|
|
|
+ note: ai.note,
|
|
|
+ start_loc: ai.dep.addr,
|
|
|
+ start_point: {
|
|
|
+ lng: Utils_1.latLngDegreesToDecimal(ai.dep.lng),
|
|
|
+ lat: Utils_1.latLngDegreesToDecimal(ai.dep.lat),
|
|
|
+ altitude: parseInt(ai.dep.height),
|
|
|
+ unit: Common_1["default"].heightStandards.get(ai.dep.heightStandard)
|
|
|
+ },
|
|
|
+ end_loc: ai.arrive.addr,
|
|
|
+ end_point: {
|
|
|
+ lng: Utils_1.latLngDegreesToDecimal(ai.arrive.lng),
|
|
|
+ lat: Utils_1.latLngDegreesToDecimal(ai.arrive.lat)
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if (ai.airlineWidth) {
|
|
|
+ line['airline_width'] = ai.airlineWidth;
|
|
|
+ }
|
|
|
+ if (Array.isArray(ai.passPoints) && ai.passPoints.length > 0) {
|
|
|
+ var passing_points = [];
|
|
|
+ for (var _i = 0, _a = ai.passPoints; _i < _a.length; _i++) {
|
|
|
+ var obj = _a[_i];
|
|
|
+ var retObj = void 0;
|
|
|
+ if (obj.pointType == Common_1["default"].pointTypes.point && Utils_1.hasPoint(obj)) {
|
|
|
+ var pp = obj;
|
|
|
+ retObj = {
|
|
|
+ point_type: Common_1["default"].pointTypes.point,
|
|
|
+ point_name: pp.addr,
|
|
|
+ lat: Utils_1.latLngDegreesToDecimal(pp.lat),
|
|
|
+ lng: Utils_1.latLngDegreesToDecimal(pp.lng)
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else if (obj.pointType == Common_1["default"].pointTypes.nav) {
|
|
|
+ var pp = obj;
|
|
|
+ retObj = {
|
|
|
+ point_type: Common_1["default"].pointTypes.nav,
|
|
|
+ point_name: pp.pointName,
|
|
|
+ point_id: pp.pointId,
|
|
|
+ point_code: pp.pointCode,
|
|
|
+ lat: Utils_1.latLngDegreesToDecimal(pp.lat),
|
|
|
+ lng: Utils_1.latLngDegreesToDecimal(pp.lng)
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ var pp = obj;
|
|
|
+ retObj = {
|
|
|
+ point_type: Common_1["default"].pointTypes.line,
|
|
|
+ airway: pp.airRouteId,
|
|
|
+ air_route_code: pp.airlineCode,
|
|
|
+ points: pp.airlines
|
|
|
+ };
|
|
|
+ }
|
|
|
+ if (Utils_1.isSafeString(obj.height) && Utils_1.isSafeString(obj.heightStandard)) {
|
|
|
+ retObj.altitude = parseInt(obj.height);
|
|
|
+ // @ts-ignore
|
|
|
+ retObj.unit = Common_1["default"].heightStandards.get(obj.heightStandard);
|
|
|
+ }
|
|
|
+ passing_points.push(retObj);
|
|
|
+ }
|
|
|
+ line.passing_points = passing_points;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ line.passing_points = [];
|
|
|
+ }
|
|
|
+ return line;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ var ai = airspace;
|
|
|
+ var points = [];
|
|
|
+ for (var _b = 0, _c = ai.polygonPoints; _b < _c.length; _b++) {
|
|
|
+ var obj = _c[_b];
|
|
|
+ points.push({ addr: obj.addr, lat: Utils_1.latLngDegreesToDecimal(obj.lat), lng: Utils_1.latLngDegreesToDecimal(obj.lng) });
|
|
|
+ }
|
|
|
+ var polygon = {
|
|
|
+ airspace_name: ai.name,
|
|
|
+ airspace_id: ai.airspaceId,
|
|
|
+ airspace_type: Common_1["default"].airspaceType.polygon,
|
|
|
+ note: ai.note,
|
|
|
+ altitude: parseInt(ai.height),
|
|
|
+ unit: Common_1["default"].heightStandards.get(ai.heightStandard),
|
|
|
+ points: points
|
|
|
+ };
|
|
|
+ return polygon;
|
|
|
+ }
|
|
|
+}
|
|
|
+exports.convertAirspaceInfoLocalToServer = convertAirspaceInfoLocalToServer;
|
|
|
function getCircleRegions(circle) {
|
|
|
- let latlon = new LatLon(circle.coordinate.latitude, circle.coordinate.longitude);
|
|
|
- let d1 = latlon.destinationPoint(circle.radius, 0);
|
|
|
- let d2 = latlon.destinationPoint(circle.radius, 90);
|
|
|
- let d3 = latlon.destinationPoint(circle.radius, 180);
|
|
|
- let d4 = latlon.destinationPoint(circle.radius, 270);
|
|
|
+ var lat, lng;
|
|
|
+ if (circle.coordinate.latitude) {
|
|
|
+ var coord = circle.coordinate;
|
|
|
+ lat = coord.latitude;
|
|
|
+ lng = coord.longitude;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ var coord = circle.coordinate;
|
|
|
+ lat = coord.lat;
|
|
|
+ lng = coord.lng;
|
|
|
+ }
|
|
|
+ var latlon = new LatLon(lat, lng);
|
|
|
+ var d1 = latlon.destinationPoint(circle.radius, 0);
|
|
|
+ var d2 = latlon.destinationPoint(circle.radius, 90);
|
|
|
+ var d3 = latlon.destinationPoint(circle.radius, 180);
|
|
|
+ var d4 = latlon.destinationPoint(circle.radius, 270);
|
|
|
return [{ lat: d1.lat, lng: d1.lon }, { lat: d2.lat, lng: d2.lon }, { lat: d3.lat, lng: d3.lon }, { lat: d4.lat, lng: d4.lon }];
|
|
|
}
|
|
|
function getDefaultStyle() {
|
|
|
- let imageName = 'BA_oval';
|
|
|
- let lineWidth = Common_1.default.amapLineWidth;
|
|
|
- let strokeColor = Common_1.default.amapStrokeColor;
|
|
|
- let fillColor = Common_1.default.amapFillColor;
|
|
|
- return { imageName, lineWidth, strokeColor, fillColor };
|
|
|
+ var imageName = 'BA_oval';
|
|
|
+ var lineWidth = Common_1["default"].amapLineWidth;
|
|
|
+ var strokeColor = Common_1["default"].amapStrokeColor;
|
|
|
+ var fillColor = Common_1["default"].amapFillColor;
|
|
|
+ return { imageName: imageName, lineWidth: lineWidth, strokeColor: strokeColor, fillColor: fillColor };
|
|
|
}
|
|
|
function getCirclesAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
- let circles = [];
|
|
|
- let markers = [];
|
|
|
+ var circles = [];
|
|
|
+ var markers = [];
|
|
|
if (!Array.isArray(airspaceInfos)) {
|
|
|
- return { circles, markers };
|
|
|
+ return { circles: circles, markers: markers };
|
|
|
}
|
|
|
- let { imageName, lineWidth, strokeColor, fillColor } = getDefaultStyle();
|
|
|
+ var _a = getDefaultStyle(), imageName = _a.imageName, lineWidth = _a.lineWidth, strokeColor = _a.strokeColor, fillColor = _a.fillColor;
|
|
|
//通过该方法获取样式
|
|
|
- let circleStyle = setStyle('circle');
|
|
|
+ var circleStyle = setStyle('circle');
|
|
|
if (circleStyle) {
|
|
|
lineWidth = circleStyle.lineWidth;
|
|
|
strokeColor = circleStyle.strokeColor;
|
|
|
fillColor = circleStyle.fillColor;
|
|
|
imageName = circleStyle.imageName;
|
|
|
}
|
|
|
- for (let i = 0; i < airspaceInfos.length; i++) {
|
|
|
- let tmpCircle = airspaceInfos[i];
|
|
|
- let airspaceTypeFix, radiusFix, dataType;
|
|
|
+ for (var i = 0; i < airspaceInfos.length; i++) {
|
|
|
+ var tmpCircle = airspaceInfos[i];
|
|
|
+ var airspaceTypeFix = void 0, radiusFix = void 0;
|
|
|
if (tmpCircle.airspaceType) {
|
|
|
airspaceTypeFix = 'airspaceType';
|
|
|
radiusFix = 'radius';
|
|
|
- dataType = 1;
|
|
|
}
|
|
|
else {
|
|
|
airspaceTypeFix = 'airspace_type';
|
|
|
radiusFix = 'radius_of_flying';
|
|
|
- dataType = 2;
|
|
|
}
|
|
|
- if (tmpCircle[airspaceTypeFix] == Common_1.default.airspaceType.circle && currentAirspaceIndex != i) {
|
|
|
- let coordinate = {};
|
|
|
+ if (tmpCircle[airspaceTypeFix] == Common_1["default"].airspaceType.circle && currentAirspaceIndex != i) {
|
|
|
+ var coordinate = { latitude: 0, longitude: 0 };
|
|
|
if (tmpCircle.center_point_of_flying) {
|
|
|
- coordinate.latitude = tmpCircle.center_point_of_flying.lat;
|
|
|
- coordinate.longitude = tmpCircle.center_point_of_flying.lng;
|
|
|
+ var ai = tmpCircle;
|
|
|
+ coordinate.latitude = ai.center_point_of_flying.lat;
|
|
|
+ coordinate.longitude = ai.center_point_of_flying.lng;
|
|
|
}
|
|
|
else {
|
|
|
- coordinate.latitude = Utils_1.latLngDegreesToDecimal(tmpCircle.lat);
|
|
|
- coordinate.longitude = Utils_1.latLngDegreesToDecimal(tmpCircle.lng);
|
|
|
+ var ai = tmpCircle;
|
|
|
+ coordinate.latitude = Utils_1.latLngDegreesToDecimal(ai.lat);
|
|
|
+ coordinate.longitude = Utils_1.latLngDegreesToDecimal(ai.lng);
|
|
|
}
|
|
|
- let radius = tmpCircle[radiusFix];
|
|
|
+ var radius = tmpCircle[radiusFix];
|
|
|
if (radius) {
|
|
|
- let circle = { lineWidth, strokeColor, fillColor, radius, coordinate };
|
|
|
+ var circle = { lineWidth: lineWidth, strokeColor: strokeColor, fillColor: fillColor, radius: radius, coordinate: coordinate };
|
|
|
circles.push(circle);
|
|
|
}
|
|
|
else {
|
|
|
- markers.push(addOvalPointConfig(coordinate.latitude, coordinate.longitude, imageName, dataType));
|
|
|
+ // 这里的经纬度必定是数值, 所以最后一个参数是 2
|
|
|
+ markers.push(addOvalPointConfig(coordinate.latitude, coordinate.longitude, imageName, 2));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return { circles, markers };
|
|
|
+ return { circles: circles, markers: markers };
|
|
|
}
|
|
|
function getCircleAndMarkerSelector(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
- return reselect_1.createSelector(airspaceInfos, () => setStyle, currentAirspaceIndex, getCirclesAndMarkers);
|
|
|
+ return reselect_1.createSelector(airspaceInfos, function () { return setStyle; }, currentAirspaceIndex, getCirclesAndMarkers);
|
|
|
}
|
|
|
function getLatLng(latlng, dataType) {
|
|
|
if (dataType == 1) { // 驼峰模式,新建计划的时候的格式
|
|
|
@@ -98,13 +347,16 @@ function addOvalPointConfig(lat, lng, imageName, dataType) {
|
|
|
};
|
|
|
}
|
|
|
function pointCompare(point1, point2) {
|
|
|
- const pointId1 = point1.point_id || point1.pointId;
|
|
|
- const pointId2 = point2.point_id || point2.pointId;
|
|
|
+ if (!point1 || !point2) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ var pointId1 = point1.point_id;
|
|
|
+ var pointId2 = point2.point_id;
|
|
|
if (pointId1 == pointId2) {
|
|
|
return true;
|
|
|
}
|
|
|
- let [point1Lat, point1lng] = getFixedLatLng(point1);
|
|
|
- let [point2lat, point2lng] = getFixedLatLng(point2);
|
|
|
+ var _a = getFixedLatLng(point1), point1Lat = _a[0], point1lng = _a[1];
|
|
|
+ var _b = getFixedLatLng(point2), point2lat = _b[0], point2lng = _b[1];
|
|
|
if (myRound(point1Lat) == myRound(point2lat)
|
|
|
&& myRound(point1lng) == myRound(point2lng)) {
|
|
|
return true;
|
|
|
@@ -114,34 +366,41 @@ function pointCompare(point1, point2) {
|
|
|
}
|
|
|
}
|
|
|
function getCrossPoint(points1, points2) {
|
|
|
- for (let point1 of points1) {
|
|
|
- for (let point2 of points2) {
|
|
|
+ for (var _i = 0, points1_1 = points1; _i < points1_1.length; _i++) {
|
|
|
+ var point1 = points1_1[_i];
|
|
|
+ for (var _a = 0, points2_1 = points2; _a < points2_1.length; _a++) {
|
|
|
+ var point2 = points2_1[_a];
|
|
|
if (pointCompare(point1, point2))
|
|
|
return point1;
|
|
|
}
|
|
|
}
|
|
|
+ return undefined;
|
|
|
}
|
|
|
function getAirwayPoints(airway, pointBefore, pointAfter) {
|
|
|
- let found = 0;
|
|
|
- let points = [];
|
|
|
- let pointTypeFix, pointsFix;
|
|
|
+ var found = 0;
|
|
|
+ var points = [];
|
|
|
+ var pointTypeFix, pointsFix, airRoutePoint;
|
|
|
if ('points' in airway) {
|
|
|
pointTypeFix = 'point_type';
|
|
|
pointsFix = 'points';
|
|
|
+ airRoutePoint = airway['points'];
|
|
|
}
|
|
|
else {
|
|
|
pointTypeFix = 'pointType';
|
|
|
pointsFix = 'airlines';
|
|
|
+ airRoutePoint = airway['airlines'];
|
|
|
}
|
|
|
+ var crossPointBefore, crossPointAfter;
|
|
|
// 如果前后是其他航线,那么找到交叉点作为前后的点
|
|
|
- if (pointBefore[pointTypeFix] == Common_1.default.pointTypes.line) {
|
|
|
- pointBefore = getCrossPoint(airway[pointsFix], pointBefore[pointsFix]);
|
|
|
+ if (pointBefore[pointTypeFix] == Common_1["default"].pointTypes.line) {
|
|
|
+ crossPointBefore = getCrossPoint(airRoutePoint, pointBefore[pointsFix]);
|
|
|
}
|
|
|
- if (pointAfter[pointTypeFix] == Common_1.default.pointTypes.line) {
|
|
|
- pointAfter = getCrossPoint(airway[pointsFix], pointAfter[pointsFix]);
|
|
|
+ if (pointAfter[pointTypeFix] == Common_1["default"].pointTypes.line) {
|
|
|
+ crossPointAfter = getCrossPoint(airRoutePoint, pointAfter[pointsFix]);
|
|
|
}
|
|
|
- for (let point of airway[pointsFix]) {
|
|
|
- if (pointCompare(pointBefore, point) || pointCompare(pointAfter, point)) {
|
|
|
+ for (var _i = 0, airRoutePoint_1 = airRoutePoint; _i < airRoutePoint_1.length; _i++) {
|
|
|
+ var point = airRoutePoint_1[_i];
|
|
|
+ if (pointCompare(crossPointBefore, point) || pointCompare(crossPointAfter, point)) {
|
|
|
found++;
|
|
|
points.push(Object.assign({}, point));
|
|
|
continue;
|
|
|
@@ -152,62 +411,66 @@ function getAirwayPoints(airway, pointBefore, pointAfter) {
|
|
|
}
|
|
|
if (!(points.length > 0 && found == 2)) {
|
|
|
// 如果两个点不全在航线上面,那么画全部航线
|
|
|
- points = airway[pointsFix];
|
|
|
+ points = airRoutePoint;
|
|
|
}
|
|
|
return points;
|
|
|
}
|
|
|
function getLinesRouter(lineProps, lineAndMarkerStyle) {
|
|
|
- let coordinates = new Array();
|
|
|
- let markers = new Array();
|
|
|
- let lines = [];
|
|
|
- let { imageName, lineWidth, strokeColor } = getDefaultStyle();
|
|
|
+ var coordinates = new Array();
|
|
|
+ var markers = new Array();
|
|
|
+ var lines = [];
|
|
|
+ var _a = getDefaultStyle(), imageName = _a.imageName, lineWidth = _a.lineWidth, strokeColor = _a.strokeColor;
|
|
|
if (lineAndMarkerStyle) {
|
|
|
imageName = lineAndMarkerStyle.imageName;
|
|
|
lineWidth = lineAndMarkerStyle.lineWidth;
|
|
|
strokeColor = lineAndMarkerStyle.strokeColor;
|
|
|
}
|
|
|
- let startPoint, passPoints, endPoint, pointTypeFix, dataType, airlineWidth;
|
|
|
+ var startPoint, passPoints, endPoint, pointTypeFix, dataType, airlineWidth;
|
|
|
if (lineProps.start_point) {
|
|
|
+ var ll = lineProps;
|
|
|
dataType = 2; // 下划线模式
|
|
|
- startPoint = lineProps['start_point'];
|
|
|
- passPoints = lineProps['passing_points'];
|
|
|
- endPoint = lineProps['end_point'];
|
|
|
+ startPoint = ll['start_point'];
|
|
|
+ passPoints = ll['passing_points'];
|
|
|
+ endPoint = ll['end_point'];
|
|
|
pointTypeFix = 'point_type';
|
|
|
- airlineWidth = parseInt(lineProps['airline_width'], 10);
|
|
|
+ airlineWidth = parseInt(ll['airline_width'] + '', 10);
|
|
|
}
|
|
|
else {
|
|
|
+ var ll = lineProps;
|
|
|
dataType = 1; // 驼峰模式
|
|
|
- startPoint = lineProps['dep'];
|
|
|
- passPoints = lineProps['passPoints'];
|
|
|
- endPoint = lineProps['arrive'];
|
|
|
+ startPoint = ll['dep'];
|
|
|
+ passPoints = ll['passPoints'];
|
|
|
+ endPoint = ll['arrive'];
|
|
|
pointTypeFix = 'pointType';
|
|
|
- airlineWidth = parseInt(lineProps['airlineWidth'], 10);
|
|
|
+ airlineWidth = parseInt(ll['airlineWidth'] + '', 10);
|
|
|
}
|
|
|
if (startPoint) {
|
|
|
coordinates.push(drawLineConfig(startPoint.lat, startPoint.lng, dataType));
|
|
|
markers.push(addOvalPointConfig(startPoint.lat, startPoint.lng, imageName, dataType));
|
|
|
}
|
|
|
if (Array.isArray(passPoints)) {
|
|
|
- for (let i = 0; i < passPoints.length; i++) {
|
|
|
- let obj = passPoints[i];
|
|
|
+ for (var i = 0; i < passPoints.length; i++) {
|
|
|
+ var obj = passPoints[i];
|
|
|
if (!Utils_1.isObject(obj)) { // 所有的 points/airway 都必须是 obj
|
|
|
continue;
|
|
|
}
|
|
|
- let pointType = obj[pointTypeFix];
|
|
|
- if (pointType == Common_1.default.pointTypes.point
|
|
|
- || pointType == Common_1.default.pointTypes.nav) {
|
|
|
- coordinates.push(drawLineConfig(obj.lat, obj.lng, dataType));
|
|
|
- markers.push(addOvalPointConfig(obj.lat, obj.lng, imageName, dataType));
|
|
|
+ var pointType = obj[pointTypeFix];
|
|
|
+ if (pointType == Common_1["default"].pointTypes.point
|
|
|
+ || pointType == Common_1["default"].pointTypes.nav) {
|
|
|
+ var pp = obj;
|
|
|
+ coordinates.push(drawLineConfig(pp.lat, pp.lng, dataType));
|
|
|
+ markers.push(addOvalPointConfig(pp.lat, pp.lng, imageName, dataType));
|
|
|
}
|
|
|
else {
|
|
|
// 遇到一个航线,不需要和前前面的点连起来
|
|
|
+ var pp = obj;
|
|
|
if (coordinates.length > 1) {
|
|
|
- lines.push({ lineWidth, strokeColor, coordinates });
|
|
|
+ lines.push({ lineWidth: lineWidth, strokeColor: strokeColor, coordinates: coordinates });
|
|
|
}
|
|
|
coordinates = [];
|
|
|
- const pointBefore = i == 0 ? startPoint : passPoints[i - 1];
|
|
|
- const pointAfter = i == passPoints.length - 1 ? (endPoint ? endPoint : passPoints[passPoints.length - 1]) : passPoints[i + 1];
|
|
|
- lines.push({ lineWidth, strokeColor, coordinates: getAirwayPoints(obj, pointBefore, pointAfter) });
|
|
|
+ var pointBefore = i == 0 ? startPoint : passPoints[i - 1];
|
|
|
+ var pointAfter = i == passPoints.length - 1 ? (endPoint ? endPoint : passPoints[passPoints.length - 1]) : passPoints[i + 1];
|
|
|
+ lines.push({ lineWidth: lineWidth, strokeColor: strokeColor, coordinates: getAirwayPoints(pp, pointBefore, pointAfter) });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -216,20 +479,21 @@ function getLinesRouter(lineProps, lineAndMarkerStyle) {
|
|
|
markers.push(addOvalPointConfig(endPoint.lat, endPoint.lng, imageName, dataType));
|
|
|
}
|
|
|
if (coordinates.length > 1) {
|
|
|
- lines.push({ lineWidth, strokeColor, coordinates });
|
|
|
+ lines.push({ lineWidth: lineWidth, strokeColor: strokeColor, coordinates: coordinates });
|
|
|
}
|
|
|
if (airlineWidth > 0) {
|
|
|
// 有宽度的空域,需要线周围多画宽度的多边形
|
|
|
- let polygons = processAirlineWidth(lines, airlineWidth);
|
|
|
- return { lines, markers, polygons };
|
|
|
+ var polygons = processAirlineWidth(lines, airlineWidth);
|
|
|
+ return { lines: lines, markers: markers, polygons: polygons };
|
|
|
}
|
|
|
else {
|
|
|
- return { lines, markers, polygons: [] };
|
|
|
+ return { lines: lines, markers: markers, polygons: [] };
|
|
|
}
|
|
|
}
|
|
|
function getFixedLatLng(point) {
|
|
|
- let lat = point.latitude ? point.latitude : point.lat;
|
|
|
- let lng = point.longitude ? point.longitude : point.lng;
|
|
|
+ var pp = point;
|
|
|
+ var lat = pp.latitude ? pp.latitude : pp.lat;
|
|
|
+ var lng = pp.longitude ? pp.longitude : pp.lng;
|
|
|
// 复制计划的数据,有的点是度数模式如 38°35′17″
|
|
|
if (Utils_1.isSafeString(lat)) {
|
|
|
lat = Utils_1.latLngDegreesToDecimal(lat);
|
|
|
@@ -238,32 +502,33 @@ function getFixedLatLng(point) {
|
|
|
return [lat, lng];
|
|
|
}
|
|
|
function processAirlineWidth(lines, airlineWidth) {
|
|
|
- let polygons = [];
|
|
|
- let { strokeColor, fillColor } = getDefaultStyle();
|
|
|
- for (let line of lines) {
|
|
|
- let points = line.coordinates;
|
|
|
- for (let i = 0; i < points.length - 1; i++) {
|
|
|
- let [lat1, lng1] = getFixedLatLng(points[i]);
|
|
|
- let [lat2, lng2] = getFixedLatLng(points[i + 1]);
|
|
|
- let point1 = new LatLon(lat1, lng1);
|
|
|
- let point2 = new LatLon(lat2, lng2);
|
|
|
- let coordinates = getCirclePoints(point1, point2, airlineWidth);
|
|
|
- polygons.push({ lineWidth: 1, strokeColor, fillColor, coordinates });
|
|
|
+ var polygons = [];
|
|
|
+ var _a = getDefaultStyle(), strokeColor = _a.strokeColor, fillColor = _a.fillColor;
|
|
|
+ for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
|
|
|
+ var line = lines_1[_i];
|
|
|
+ var points = line.coordinates;
|
|
|
+ for (var i = 0; i < points.length - 1; i++) {
|
|
|
+ var _b = getFixedLatLng(points[i]), lat1 = _b[0], lng1 = _b[1];
|
|
|
+ var _c = getFixedLatLng(points[i + 1]), lat2 = _c[0], lng2 = _c[1];
|
|
|
+ var point1 = new LatLon(lat1, lng1);
|
|
|
+ var point2 = new LatLon(lat2, lng2);
|
|
|
+ var coordinates = getCirclePoints(point1, point2, airlineWidth);
|
|
|
+ polygons.push({ lineWidth: 1, strokeColor: strokeColor, fillColor: fillColor, coordinates: coordinates });
|
|
|
}
|
|
|
}
|
|
|
return polygons;
|
|
|
}
|
|
|
function getCirclePoints(point1, point2, width) {
|
|
|
- let percision = 10; // 半圆处理为多边形的时候,半圆上取几个点
|
|
|
- let step = 180 / percision;
|
|
|
- let bearing = (360 + point1.bearingTo(point2) - 90) % 360; // 取正值
|
|
|
- let points = [];
|
|
|
- for (let diff = 0; diff <= 180; diff += step) {
|
|
|
- let point = point2.destinationPoint(width, bearing + diff);
|
|
|
+ var percision = 10; // 半圆处理为多边形的时候,半圆上取几个点
|
|
|
+ var step = 180 / percision;
|
|
|
+ var bearing = (360 + point1.bearingTo(point2) - 90) % 360; // 取正值
|
|
|
+ var points = [];
|
|
|
+ for (var diff = 0; diff <= 180; diff += step) {
|
|
|
+ var point = point2.destinationPoint(width, bearing + diff);
|
|
|
points.push({ lat: point.lat, lng: point.lon });
|
|
|
}
|
|
|
- for (let diff = 180; diff <= 360; diff += step) {
|
|
|
- let point = point1.destinationPoint(width, bearing + diff);
|
|
|
+ for (var diff = 180; diff <= 360; diff += step) {
|
|
|
+ var point = point1.destinationPoint(width, bearing + diff);
|
|
|
points.push({ lat: point.lat, lng: point.lon });
|
|
|
}
|
|
|
return points;
|
|
|
@@ -274,43 +539,44 @@ function myRound(num, digits) {
|
|
|
return Math.round(num * Math.pow(10, digits)) / Math.pow(10, digits);
|
|
|
}
|
|
|
function getLinesPolygonsAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
- let retLines = [];
|
|
|
- let retMarkers = [];
|
|
|
- let retPolygons = [];
|
|
|
+ var retLines = [];
|
|
|
+ var retMarkers = [];
|
|
|
+ var retPolygons = [];
|
|
|
if (!Array.isArray(airspaceInfos)) {
|
|
|
return { lines: retLines, markers: retMarkers, polygons: retPolygons };
|
|
|
}
|
|
|
- let lineStyle = setStyle('line');
|
|
|
- for (let i = 0; i < airspaceInfos.length; i++) {
|
|
|
- let tmpLine = airspaceInfos[i];
|
|
|
- let airspaceTypeFix;
|
|
|
+ var lineStyle = setStyle('line');
|
|
|
+ for (var i = 0; i < airspaceInfos.length; i++) {
|
|
|
+ var tmpLine = airspaceInfos[i];
|
|
|
+ var airspaceTypeFix = void 0;
|
|
|
if (tmpLine.airspaceType)
|
|
|
airspaceTypeFix = 'airspaceType';
|
|
|
else
|
|
|
airspaceTypeFix = 'airspace_type';
|
|
|
- if (tmpLine[airspaceTypeFix] == Common_1.default.airspaceType.line && currentAirspaceIndex != i) {
|
|
|
- let { lines, markers, polygons } = getLinesRouter(tmpLine, lineStyle);
|
|
|
- retMarkers.push(...markers);
|
|
|
- retLines.push(...lines);
|
|
|
- retPolygons.push(...polygons);
|
|
|
+ if (tmpLine[airspaceTypeFix] == Common_1["default"].airspaceType.line && currentAirspaceIndex != i) {
|
|
|
+ var lineProps = tmpLine;
|
|
|
+ var _a = getLinesRouter(lineProps, lineStyle), lines = _a.lines, markers = _a.markers, polygons = _a.polygons;
|
|
|
+ retMarkers.push.apply(retMarkers, markers);
|
|
|
+ retLines.push.apply(retLines, lines);
|
|
|
+ retPolygons.push.apply(retPolygons, polygons);
|
|
|
}
|
|
|
}
|
|
|
return { lines: retLines, markers: retMarkers, polygons: retPolygons };
|
|
|
}
|
|
|
function getLinePolygonsAndMarkerSelector(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
- return reselect_1.createSelector(airspaceInfos, () => setStyle, currentAirspaceIndex, getLinesPolygonsAndMarkers);
|
|
|
+ return reselect_1.createSelector(airspaceInfos, function () { return setStyle; }, currentAirspaceIndex, getLinesPolygonsAndMarkers);
|
|
|
}
|
|
|
function getPolygon(polygonProps, polygonAndMarkerStyle) {
|
|
|
- let coordinates = new Array();
|
|
|
- let markers = new Array();
|
|
|
- let { imageName, lineWidth, strokeColor, fillColor } = getDefaultStyle();
|
|
|
+ var coordinates = new Array();
|
|
|
+ var markers = new Array();
|
|
|
+ var _a = getDefaultStyle(), imageName = _a.imageName, lineWidth = _a.lineWidth, strokeColor = _a.strokeColor, fillColor = _a.fillColor;
|
|
|
if (polygonAndMarkerStyle) {
|
|
|
imageName = polygonAndMarkerStyle.imageName;
|
|
|
lineWidth = polygonAndMarkerStyle.lineWidth;
|
|
|
strokeColor = polygonAndMarkerStyle.strokeColor;
|
|
|
fillColor = polygonAndMarkerStyle.fillColor;
|
|
|
}
|
|
|
- let pointsFix, dataType;
|
|
|
+ var pointsFix, dataType;
|
|
|
if (polygonProps.points) {
|
|
|
pointsFix = 'points';
|
|
|
dataType = 2;
|
|
|
@@ -320,7 +586,8 @@ function getPolygon(polygonProps, polygonAndMarkerStyle) {
|
|
|
dataType = 1; // 驼峰模式
|
|
|
}
|
|
|
if (Array.isArray(polygonProps[pointsFix])) {
|
|
|
- for (let obj of polygonProps[pointsFix]) {
|
|
|
+ for (var _i = 0, _b = polygonProps[pointsFix]; _i < _b.length; _i++) {
|
|
|
+ var obj = _b[_i];
|
|
|
if (!obj) {
|
|
|
continue;
|
|
|
}
|
|
|
@@ -328,44 +595,44 @@ function getPolygon(polygonProps, polygonAndMarkerStyle) {
|
|
|
markers.push(addOvalPointConfig(obj.lat, obj.lng, imageName, dataType));
|
|
|
}
|
|
|
}
|
|
|
- let polygon = { lineWidth, strokeColor, fillColor, coordinates };
|
|
|
- return { markers, polygon };
|
|
|
+ var polygon = { lineWidth: lineWidth, strokeColor: strokeColor, fillColor: fillColor, coordinates: coordinates };
|
|
|
+ return { markers: markers, polygon: polygon };
|
|
|
}
|
|
|
function getPolygonsAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
- let markers = [];
|
|
|
- let polygons = [];
|
|
|
+ var markers = [];
|
|
|
+ var polygons = [];
|
|
|
if (!Array.isArray(airspaceInfos)) {
|
|
|
- return { markers, polygons };
|
|
|
+ return { markers: markers, polygons: polygons };
|
|
|
}
|
|
|
- let polygonAndMarkerStyle = setStyle('polygon');
|
|
|
- for (let i = 0; i < airspaceInfos.length; i++) {
|
|
|
- let polygon = airspaceInfos[i];
|
|
|
- let airspaceTypeFix;
|
|
|
+ var polygonAndMarkerStyle = setStyle('polygon');
|
|
|
+ for (var i = 0; i < airspaceInfos.length; i++) {
|
|
|
+ var polygon = airspaceInfos[i];
|
|
|
+ var airspaceTypeFix = void 0;
|
|
|
if (polygon.airspaceType)
|
|
|
airspaceTypeFix = 'airspaceType';
|
|
|
else
|
|
|
airspaceTypeFix = 'airspace_type';
|
|
|
- if (polygon[airspaceTypeFix] == Common_1.default.airspaceType.polygon && currentAirspaceIndex != i) {
|
|
|
- let retObj = getPolygon(polygon, polygonAndMarkerStyle);
|
|
|
- markers.push(...retObj.markers);
|
|
|
+ if (polygon[airspaceTypeFix] == Common_1["default"].airspaceType.polygon && currentAirspaceIndex != i) {
|
|
|
+ var retObj = getPolygon(polygon, polygonAndMarkerStyle);
|
|
|
+ markers.push.apply(markers, retObj.markers);
|
|
|
polygons.push(retObj.polygon);
|
|
|
}
|
|
|
}
|
|
|
- return { markers, polygons };
|
|
|
+ return { markers: markers, polygons: polygons };
|
|
|
}
|
|
|
function getPolygonAndMarkerSelector(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
- return reselect_1.createSelector(airspaceInfos, () => setStyle, currentAirspaceIndex, getPolygonsAndMarkers);
|
|
|
+ return reselect_1.createSelector(airspaceInfos, function () { return setStyle; }, currentAirspaceIndex, getPolygonsAndMarkers);
|
|
|
}
|
|
|
function getMarkers(circlesAndMarkers, polygonAndMarkers, lineAndMarkers) {
|
|
|
- let markers = [];
|
|
|
+ var markers = [];
|
|
|
if (circlesAndMarkers) {
|
|
|
- markers = [...circlesAndMarkers.markers];
|
|
|
+ markers = circlesAndMarkers.markers.slice();
|
|
|
}
|
|
|
if (polygonAndMarkers) {
|
|
|
- markers = [...markers, ...polygonAndMarkers.markers];
|
|
|
+ markers = markers.concat(polygonAndMarkers.markers);
|
|
|
}
|
|
|
if (lineAndMarkers) {
|
|
|
- markers = [...markers, ...lineAndMarkers.markers];
|
|
|
+ markers = markers.concat(lineAndMarkers.markers);
|
|
|
}
|
|
|
return markers;
|
|
|
}
|
|
|
@@ -373,28 +640,28 @@ function getMarkerSelector(circlesAndMarkers, polygonAndMarkers, lineAndMarkers)
|
|
|
return reselect_1.createSelector(circlesAndMarkers, polygonAndMarkers, lineAndMarkers, getMarkers);
|
|
|
}
|
|
|
function getRegionPoints(circles, lineAndMarkers, polygonAndMarkers) {
|
|
|
- let regionPoints = new Array();
|
|
|
- for (let i = 0; i < circles.length; i++) {
|
|
|
- regionPoints.push(...getCircleRegions(circles[i]));
|
|
|
+ var regionPoints = new Array();
|
|
|
+ for (var i = 0; i < circles.length; i++) {
|
|
|
+ regionPoints.push.apply(regionPoints, getCircleRegions(circles[i]));
|
|
|
}
|
|
|
- let lines = lineAndMarkers.lines;
|
|
|
- for (let i = 0; i < lines.length; i++) {
|
|
|
- regionPoints.push(...lines[i].coordinates);
|
|
|
+ var lines = lineAndMarkers.lines;
|
|
|
+ for (var i = 0; i < lines.length; i++) {
|
|
|
+ regionPoints.push.apply(regionPoints, lines[i].coordinates);
|
|
|
}
|
|
|
- let polygons = polygonAndMarkers.polygons;
|
|
|
- for (let i = 0; i < polygons.length; i++) {
|
|
|
- regionPoints.push(...polygons[i].coordinates);
|
|
|
+ var polygons = polygonAndMarkers.polygons;
|
|
|
+ for (var i = 0; i < polygons.length; i++) {
|
|
|
+ regionPoints.push.apply(regionPoints, polygons[i].coordinates);
|
|
|
}
|
|
|
return regionPoints;
|
|
|
}
|
|
|
function getRegionPointsSelector(circles, lineAndMarkers, polygonAndMarkers) {
|
|
|
return reselect_1.createSelector(circles, lineAndMarkers, polygonAndMarkers, getRegionPoints);
|
|
|
}
|
|
|
-function getCircles(circleAndMarker) {
|
|
|
- return circleAndMarker.circles;
|
|
|
+function getCircles(circlesAndMarkers) {
|
|
|
+ return circlesAndMarkers.circles;
|
|
|
}
|
|
|
-function getCircleSelector(circleAndMarker) {
|
|
|
- return reselect_1.createSelector(circleAndMarker, getCircles);
|
|
|
+function getCircleSelector(circlesAndMarkers) {
|
|
|
+ return reselect_1.createSelector(circlesAndMarkers, getCircles);
|
|
|
}
|
|
|
function getLines(lineAndMarker) {
|
|
|
return lineAndMarker.lines;
|
|
|
@@ -403,40 +670,40 @@ function getLineSelector(lineAndMarker) {
|
|
|
return reselect_1.createSelector(lineAndMarker, getLines);
|
|
|
}
|
|
|
function getPolygons(polygonAndMarkers, linePolygonsAndMarkers) {
|
|
|
- return [...polygonAndMarkers.polygons, ...linePolygonsAndMarkers.polygons];
|
|
|
+ return polygonAndMarkers.polygons.concat(linePolygonsAndMarkers.polygons);
|
|
|
}
|
|
|
function getPolygonSelector(polygonAndMarkers, linePolygonsAndMarkers) {
|
|
|
return reselect_1.createSelector(polygonAndMarkers, linePolygonsAndMarkers, getPolygons);
|
|
|
}
|
|
|
-let setStyle = (style) => {
|
|
|
- if (!style)
|
|
|
- return () => { return null; };
|
|
|
+var setStyle = function (styles) {
|
|
|
+ if (!styles)
|
|
|
+ return function () { return null; };
|
|
|
else
|
|
|
- return (shapeName) => style[shapeName];
|
|
|
+ return function (shapeName) { return styles[shapeName]; };
|
|
|
};
|
|
|
//获取selector
|
|
|
function getShapesSelector(airspaceInfos, style, currentAirspaceIndex) {
|
|
|
- currentAirspaceIndex = currentAirspaceIndex ? currentAirspaceIndex : () => -1;
|
|
|
- let circlesAndMarkers = getCircleAndMarkerSelector(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
- let circles = getCircleSelector(circlesAndMarkers);
|
|
|
- let linePolygonsAndMarkers = getLinePolygonsAndMarkerSelector(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
- let lines = getLineSelector(linePolygonsAndMarkers);
|
|
|
- let polygonAndMarkers = getPolygonAndMarkerSelector(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
- let polygons = getPolygonSelector(polygonAndMarkers, linePolygonsAndMarkers);
|
|
|
- let markers = getMarkerSelector(circlesAndMarkers, polygonAndMarkers, linePolygonsAndMarkers);
|
|
|
- let regionPoints = getRegionPointsSelector(circles, linePolygonsAndMarkers, polygonAndMarkers);
|
|
|
+ currentAirspaceIndex = currentAirspaceIndex ? currentAirspaceIndex : function () { return -1; };
|
|
|
+ var circlesAndMarkers = getCircleAndMarkerSelector(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
+ var circles = getCircleSelector(circlesAndMarkers);
|
|
|
+ var linePolygonsAndMarkers = getLinePolygonsAndMarkerSelector(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
+ var lines = getLineSelector(linePolygonsAndMarkers);
|
|
|
+ var polygonAndMarkers = getPolygonAndMarkerSelector(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
+ var polygons = getPolygonSelector(polygonAndMarkers, linePolygonsAndMarkers);
|
|
|
+ var markers = getMarkerSelector(circlesAndMarkers, polygonAndMarkers, linePolygonsAndMarkers);
|
|
|
+ var regionPoints = getRegionPointsSelector(circles, linePolygonsAndMarkers, polygonAndMarkers);
|
|
|
return {
|
|
|
- markers,
|
|
|
- circles,
|
|
|
- lines,
|
|
|
- polygons,
|
|
|
- regionPoints
|
|
|
+ markers: markers,
|
|
|
+ circles: circles,
|
|
|
+ lines: lines,
|
|
|
+ polygons: polygons,
|
|
|
+ regionPoints: regionPoints
|
|
|
};
|
|
|
}
|
|
|
exports.getShapesSelector = getShapesSelector;
|
|
|
//获取数组
|
|
|
function getShapes(airspaceInfos, style, currentAirspaceIndex) {
|
|
|
- let { markers, polygons, circles, lines, regionPoints } = getShapesSelector((airspaceInfos) => airspaceInfos, style, (currentAirspaceIndex) => currentAirspaceIndex);
|
|
|
+ var _a = getShapesSelector(function () { return airspaceInfos; }, style, function () { return currentAirspaceIndex; }), markers = _a.markers, polygons = _a.polygons, circles = _a.circles, lines = _a.lines, regionPoints = _a.regionPoints;
|
|
|
return {
|
|
|
markers: markers(airspaceInfos),
|
|
|
circles: circles(airspaceInfos),
|
|
|
@@ -452,21 +719,22 @@ exports.getShapes = getShapes;
|
|
|
// 3. 传真格式
|
|
|
// 4. 用户端用的简化格式
|
|
|
// 5. 极简格式
|
|
|
-function getHeight(num, unit, type) {
|
|
|
- let shortNum;
|
|
|
+function getHeight(height, unit, type) {
|
|
|
+ var shortNum;
|
|
|
+ var num = +height; // to number
|
|
|
if (num >= 100) {
|
|
|
- shortNum = parseInt(num / 100).toString();
|
|
|
+ shortNum = parseInt(num / 100 + '').toString();
|
|
|
if (shortNum.length < 2) {
|
|
|
shortNum = '0' + shortNum;
|
|
|
}
|
|
|
}
|
|
|
- let heightStandard = Common_1.default.heightStandardsById.get(unit);
|
|
|
+ var heightStandard = Common_1["default"].heightStandardsById.get(unit);
|
|
|
if (!heightStandard) {
|
|
|
heightStandard = unit;
|
|
|
}
|
|
|
// 这里统一使用数字判断
|
|
|
- let standardUnit = Common_1.default.heightStandards.get(heightStandard);
|
|
|
- let heightDesc;
|
|
|
+ var standardUnit = Common_1["default"].heightStandards.get(heightStandard);
|
|
|
+ var heightDesc;
|
|
|
switch (standardUnit) {
|
|
|
case 1:
|
|
|
heightDesc = ['H*真', '真高*米'];
|
|
|
@@ -486,182 +754,192 @@ function getHeight(num, unit, type) {
|
|
|
}
|
|
|
else {
|
|
|
// 真高200米,真高200米(含以下)
|
|
|
- return heightDesc[1].replace('*', num);
|
|
|
+ return heightDesc[1].replace('*', height + '');
|
|
|
}
|
|
|
}
|
|
|
function getAirspaceName(airspaceInfo) {
|
|
|
if (airspaceInfo.airspace_name) {
|
|
|
- return airspaceInfo.airspace_name;
|
|
|
+ var ai = airspaceInfo;
|
|
|
+ return ai.airspace_name;
|
|
|
}
|
|
|
else {
|
|
|
- return airspaceInfo.name;
|
|
|
+ var ai = airspaceInfo;
|
|
|
+ return ai.name;
|
|
|
}
|
|
|
}
|
|
|
-function circleContent(airspaceInfo, type = 3) {
|
|
|
+function circleContent(airspaceInfo, type) {
|
|
|
+ if (type === void 0) { type = 3; }
|
|
|
if (type == 5)
|
|
|
return getAirspaceName(airspaceInfo);
|
|
|
if ('airspace_name' in airspaceInfo) {
|
|
|
- const lat = Utils_1.latLngDecimalToDegrees(airspaceInfo.center_point_of_flying.lat);
|
|
|
- const lng = Utils_1.latLngDecimalToDegrees(airspaceInfo.center_point_of_flying.lng);
|
|
|
- let content = [];
|
|
|
- let loc = `以${airspaceInfo.center_loc}`;
|
|
|
+ var lat = Utils_1.latLngDecimalToDegrees(airspaceInfo.center_point_of_flying.lat);
|
|
|
+ var lng = Utils_1.latLngDecimalToDegrees(airspaceInfo.center_point_of_flying.lng);
|
|
|
+ var content = [];
|
|
|
+ var loc = "\u4EE5" + airspaceInfo.center_loc;
|
|
|
if (type == 1 || type == 3)
|
|
|
- loc += `(E${lng}, N${lat})`;
|
|
|
- content.push(`${loc}为中心`);
|
|
|
- content.push(`半径${airspaceInfo.radius_of_flying}米`);
|
|
|
+ loc += "(E" + lng + ", N" + lat + ")";
|
|
|
+ content.push(loc + "\u4E3A\u4E2D\u5FC3");
|
|
|
+ content.push("\u534A\u5F84" + airspaceInfo.radius_of_flying + "\u7C73");
|
|
|
content.push(getHeight(airspaceInfo.altitude, airspaceInfo.unit, type));
|
|
|
if (airspaceInfo.note)
|
|
|
- content.push(`备注:${airspaceInfo.note}`);
|
|
|
- let result = content = content.join(',');
|
|
|
- return result;
|
|
|
+ content.push("\u5907\u6CE8\uFF1A" + airspaceInfo.note);
|
|
|
+ return content.join(',');
|
|
|
}
|
|
|
else {
|
|
|
- let content = [];
|
|
|
- let loc = `以${airspaceInfo.addr}`;
|
|
|
+ var content = [];
|
|
|
+ var loc = "\u4EE5" + airspaceInfo.addr;
|
|
|
if (type == 1 || type == 3)
|
|
|
- loc += `(E${airspaceInfo.lng}, N${airspaceInfo.lat})`;
|
|
|
- content.push(`${loc}为中心`);
|
|
|
- content.push(`半径${airspaceInfo.radius}米`);
|
|
|
+ loc += "(E" + airspaceInfo.lng + ", N" + airspaceInfo.lat + ")";
|
|
|
+ content.push(loc + "\u4E3A\u4E2D\u5FC3");
|
|
|
+ content.push("\u534A\u5F84" + airspaceInfo.radius + "\u7C73");
|
|
|
content.push(getHeight(airspaceInfo.height, airspaceInfo.heightStandard, type));
|
|
|
if (airspaceInfo.note)
|
|
|
- content.push(`备注:${airspaceInfo.note}`);
|
|
|
- content = content.join(',');
|
|
|
- return content;
|
|
|
+ content.push("\u5907\u6CE8\uFF1A" + airspaceInfo.note);
|
|
|
+ return content.join(',');
|
|
|
}
|
|
|
}
|
|
|
exports.circleContent = circleContent;
|
|
|
-function flyingCenter(item = {}) {
|
|
|
+function flyingCenter(item) {
|
|
|
+ if (item === void 0) { item = {}; }
|
|
|
if (item == {}) {
|
|
|
- return;
|
|
|
- }
|
|
|
- else {
|
|
|
- return ("(E" + Utils_1.latLngDecimalToDegrees(item.lng) +
|
|
|
- ', ' +
|
|
|
- "N" + Utils_1.latLngDecimalToDegrees(item.lat) + ")");
|
|
|
+ return "";
|
|
|
}
|
|
|
+ var pp = item;
|
|
|
+ return ("(E" + Utils_1.latLngDecimalToDegrees(pp.lng) +
|
|
|
+ ', ' +
|
|
|
+ "N" + Utils_1.latLngDecimalToDegrees(pp.lat) + ")");
|
|
|
}
|
|
|
-function lineContent(airspaceInfo, type = 3) {
|
|
|
+function lineContent(airspaceInfo, type) {
|
|
|
+ if (type === void 0) { type = 3; }
|
|
|
if (type == 5)
|
|
|
return getAirspaceName(airspaceInfo);
|
|
|
if ('airspace_name' in airspaceInfo) {
|
|
|
- let content = [];
|
|
|
- content.push(`${airspaceInfo.start_loc}`);
|
|
|
+ var content = [];
|
|
|
+ content.push("" + airspaceInfo.start_loc);
|
|
|
if (type == 1 || type == 3)
|
|
|
- content.push(`${flyingCenter(airspaceInfo.start_point)}`);
|
|
|
- content.push(` - `);
|
|
|
+ content.push("" + flyingCenter(airspaceInfo.start_point));
|
|
|
+ content.push(" - ");
|
|
|
content.push(getHeight(airspaceInfo.start_point.altitude, airspaceInfo.start_point.unit, type));
|
|
|
- const passing_points = airspaceInfo.passing_points;
|
|
|
+ var passing_points = airspaceInfo.passing_points;
|
|
|
if (Array.isArray(passing_points)) {
|
|
|
- for (let i = 0; i < passing_points.length; i++) {
|
|
|
- const obj = passing_points[i];
|
|
|
- const lat = Utils_1.latLngDecimalToDegrees(obj.lat);
|
|
|
- const lng = Utils_1.latLngDecimalToDegrees(obj.lng);
|
|
|
- if (obj.point_type == Common_1.default.pointTypes.point) {
|
|
|
- content.push(` - ${obj.point_name}`);
|
|
|
+ for (var i = 0; i < passing_points.length; i++) {
|
|
|
+ var obj = passing_points[i];
|
|
|
+ if (obj.point_type == Common_1["default"].pointTypes.point) {
|
|
|
+ var pp = obj;
|
|
|
+ var lat = Utils_1.latLngDecimalToDegrees(pp.lat);
|
|
|
+ var lng = Utils_1.latLngDecimalToDegrees(pp.lng);
|
|
|
+ content.push(" - " + pp.point_name);
|
|
|
if (type == 1 || type == 3)
|
|
|
- content.push(`(E${lng}, N${lat})`);
|
|
|
+ content.push("(E" + lng + ", N" + lat + ")");
|
|
|
}
|
|
|
- else if (obj.point_type == Common_1.default.pointTypes.nav) {
|
|
|
- content.push(` - ${obj.point_code}`);
|
|
|
+ else if (obj.point_type == Common_1["default"].pointTypes.nav) {
|
|
|
+ var pp = obj;
|
|
|
+ var lat = Utils_1.latLngDecimalToDegrees(pp.lat);
|
|
|
+ var lng = Utils_1.latLngDecimalToDegrees(pp.lng);
|
|
|
+ content.push(" - " + pp.point_code);
|
|
|
if (type == 1 || type == 3)
|
|
|
- content.push(`(E${lng}, N${lat})`);
|
|
|
+ content.push("(E" + lng + ", N" + lat + ")");
|
|
|
}
|
|
|
else {
|
|
|
- content.push(` - ${obj.air_route_code}`);
|
|
|
+ var pp = obj;
|
|
|
+ content.push(" - " + pp.air_route_code);
|
|
|
}
|
|
|
if (obj.altitude) {
|
|
|
- content.push(` - ${getHeight(obj.altitude, obj.unit, type)}`);
|
|
|
+ content.push(" - " + getHeight(obj.altitude, obj.unit, type));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- content.push(` - ${airspaceInfo.end_loc}`);
|
|
|
+ content.push(" - " + airspaceInfo.end_loc);
|
|
|
if (type == 1 || type == 3)
|
|
|
- content.push(`${flyingCenter(airspaceInfo.end_point)}`);
|
|
|
+ content.push("" + flyingCenter(airspaceInfo.end_point));
|
|
|
if (Utils_1.isSafeString(airspaceInfo.airline_width)) {
|
|
|
- content.push(`,宽度:${airspaceInfo.airline_width}米`);
|
|
|
+ content.push("\uFF0C\u5BBD\u5EA6\uFF1A" + airspaceInfo.airline_width + "\u7C73");
|
|
|
}
|
|
|
if (Utils_1.isSafeString(airspaceInfo.note)) {
|
|
|
- content.push(`,备注: ${airspaceInfo.note}`);
|
|
|
+ content.push("\uFF0C\u5907\u6CE8\uFF1A " + airspaceInfo.note);
|
|
|
}
|
|
|
- let result = content.join("");
|
|
|
+ var result = content.join("");
|
|
|
return result;
|
|
|
}
|
|
|
else {
|
|
|
- let content = [];
|
|
|
- content.push(`${airspaceInfo.dep.addr}`);
|
|
|
+ var content = [];
|
|
|
+ content.push("" + airspaceInfo.dep.addr);
|
|
|
if (type == 1 || type == 3)
|
|
|
- content.push(`(E${airspaceInfo.dep.lng}, N${airspaceInfo.dep.lat})`);
|
|
|
- content.push(` - ${getHeight(airspaceInfo.dep.height, airspaceInfo.dep.heightStandard, type)}`);
|
|
|
+ content.push("(E" + airspaceInfo.dep.lng + ", N" + airspaceInfo.dep.lat + ")");
|
|
|
+ content.push(" - " + getHeight(airspaceInfo.dep.height, airspaceInfo.dep.heightStandard, type));
|
|
|
if (Array.isArray(airspaceInfo.passPoints)) {
|
|
|
- let length = airspaceInfo.passPoints.length;
|
|
|
- for (let i = 0; i < length; i++) {
|
|
|
- let obj = airspaceInfo.passPoints[i];
|
|
|
- if (obj.pointType == Common_1.default.pointTypes.point) {
|
|
|
- content.push(` - ${obj.addr}`);
|
|
|
+ var length_1 = airspaceInfo.passPoints.length;
|
|
|
+ for (var i = 0; i < length_1; i++) {
|
|
|
+ var obj = airspaceInfo.passPoints[i];
|
|
|
+ if (obj.pointType == Common_1["default"].pointTypes.point) {
|
|
|
+ var pp = obj;
|
|
|
+ content.push(" - " + pp.addr);
|
|
|
if (type == 1 || type == 3)
|
|
|
- content.push(`(E${obj.lng}, N${obj.lat})`);
|
|
|
+ content.push("(E" + pp.lng + ", N" + pp.lat + ")");
|
|
|
}
|
|
|
- else if (obj.pointType == Common_1.default.pointTypes.nav) {
|
|
|
- content.push(` - ${obj.pointCode}`);
|
|
|
+ else if (obj.pointType == Common_1["default"].pointTypes.nav) {
|
|
|
+ var pp = obj;
|
|
|
+ content.push(" - " + pp.pointCode);
|
|
|
if (type == 1 || type == 3)
|
|
|
- content.push(`(E${obj.lng}, N${obj.lat})`);
|
|
|
+ content.push("(E" + pp.lng + ", N" + pp.lat + ")");
|
|
|
}
|
|
|
else {
|
|
|
- content.push(` - ${obj.airlineCode}`);
|
|
|
+ var pp = obj;
|
|
|
+ content.push(" - " + pp.airlineCode);
|
|
|
}
|
|
|
if (obj.height) {
|
|
|
- content.push(` - ${getHeight(obj.height, obj.heightStandard, type)}`);
|
|
|
+ content.push(" - " + getHeight(obj.height, obj.heightStandard, type));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- content.push(` - ${airspaceInfo.arrive.addr}`);
|
|
|
+ content.push(" - " + airspaceInfo.arrive.addr);
|
|
|
if (type == 1 || type == 3)
|
|
|
- content.push(`(E${airspaceInfo.arrive.lng}, N${airspaceInfo.arrive.lat})`);
|
|
|
+ content.push("(E" + airspaceInfo.arrive.lng + ", N" + airspaceInfo.arrive.lat + ")");
|
|
|
if (airspaceInfo.airlineWidth) {
|
|
|
- content.push(`,宽度:${airspaceInfo.airlineWidth}米`);
|
|
|
+ content.push("\uFF0C\u5BBD\u5EA6\uFF1A" + airspaceInfo.airlineWidth + "\u7C73");
|
|
|
}
|
|
|
if (airspaceInfo.note)
|
|
|
- content.push(`,备注:${airspaceInfo.note}`);
|
|
|
- content = content.join('');
|
|
|
- return content;
|
|
|
+ content.push("\uFF0C\u5907\u6CE8\uFF1A" + airspaceInfo.note);
|
|
|
+ return content.join('');
|
|
|
}
|
|
|
}
|
|
|
exports.lineContent = lineContent;
|
|
|
-function polygonContent(airspaceInfo, type = 3) {
|
|
|
+function polygonContent(airspaceInfo, type) {
|
|
|
+ if (type === void 0) { type = 3; }
|
|
|
if (type == 5)
|
|
|
return getAirspaceName(airspaceInfo);
|
|
|
if ('airspace_name' in airspaceInfo) {
|
|
|
- let res = [];
|
|
|
- let points = airspaceInfo.points;
|
|
|
- for (let i = 0; i < points.length; i++) {
|
|
|
- let c = `${points[i].addr ? points[i].addr : ''}`;
|
|
|
+ var res = [];
|
|
|
+ var points = airspaceInfo.points;
|
|
|
+ for (var i = 0; i < points.length; i++) {
|
|
|
+ var c = "" + (points[i].addr ? points[i].addr : '');
|
|
|
if (type == 1 || type == 3)
|
|
|
- c += `(E${Utils_1.latLngDecimalToDegrees(points[i].lng)}, N${Utils_1.latLngDecimalToDegrees(points[i].lat)})`;
|
|
|
+ c += "(E" + Utils_1.latLngDecimalToDegrees(points[i].lng) + ", N" + Utils_1.latLngDecimalToDegrees(points[i].lat) + ")";
|
|
|
res.push(c);
|
|
|
}
|
|
|
- let content = [res.join('、')];
|
|
|
- content.push(`${airspaceInfo.points.length}点连线范围内`);
|
|
|
- content.push(`,${getHeight(airspaceInfo.altitude, airspaceInfo.unit, type)}`);
|
|
|
+ var content = [res.join('、')];
|
|
|
+ content.push(airspaceInfo.points.length + "\u70B9\u8FDE\u7EBF\u8303\u56F4\u5185");
|
|
|
+ content.push("\uFF0C" + getHeight(airspaceInfo.altitude, airspaceInfo.unit, type));
|
|
|
if (Utils_1.isSafeString(airspaceInfo.note)) {
|
|
|
- content.push(`,备注:${airspaceInfo.note}`);
|
|
|
+ content.push("\uFF0C\u5907\u6CE8\uFF1A" + airspaceInfo.note);
|
|
|
}
|
|
|
return content.join('');
|
|
|
}
|
|
|
else {
|
|
|
- let content = [];
|
|
|
- let length = airspaceInfo.polygonPoints.length;
|
|
|
- for (let i = 0; i < length; i++) {
|
|
|
- let obj = airspaceInfo.polygonPoints[i];
|
|
|
- let c = `${obj.addr ? obj.addr : ''}`;
|
|
|
+ var content = [];
|
|
|
+ var length_2 = airspaceInfo.polygonPoints.length;
|
|
|
+ for (var i = 0; i < length_2; i++) {
|
|
|
+ var obj = airspaceInfo.polygonPoints[i];
|
|
|
+ var c = "" + (obj.addr ? obj.addr : '');
|
|
|
if (type == 1 || type == 3)
|
|
|
- c += `(E${obj.lng}, N${obj.lat})`;
|
|
|
+ c += "(E" + obj.lng + ", N" + obj.lat + ")";
|
|
|
content.push(c);
|
|
|
}
|
|
|
- content = content.join('、') + `${length}点连线范围内`;
|
|
|
- content += `,${getHeight(airspaceInfo.height, airspaceInfo.heightStandard, type)}`;
|
|
|
+ var cc = content.join('、') + (length_2 + "\u70B9\u8FDE\u7EBF\u8303\u56F4\u5185");
|
|
|
+ cc += "\uFF0C" + getHeight(airspaceInfo.height, airspaceInfo.heightStandard, type);
|
|
|
if (airspaceInfo.note)
|
|
|
- content = `${content},备注:${airspaceInfo.note}`;
|
|
|
- return content;
|
|
|
+ cc = content + "\uFF0C\u5907\u6CE8\uFF1A" + airspaceInfo.note;
|
|
|
+ return cc;
|
|
|
}
|
|
|
}
|
|
|
exports.polygonContent = polygonContent;
|