|
@@ -23,17 +23,27 @@ function getCircleRegions(circle) {
|
|
|
function getCircles(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
function getCircles(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
let circles = [];
|
|
let circles = [];
|
|
|
if (!Array.isArray(airspaceInfos)) {
|
|
if (!Array.isArray(airspaceInfos)) {
|
|
|
- return { circles };
|
|
|
|
|
|
|
+ return circles;
|
|
|
}
|
|
}
|
|
|
//通过该方法获取样式
|
|
//通过该方法获取样式
|
|
|
let circleStyle = setStyle('circle');
|
|
let circleStyle = setStyle('circle');
|
|
|
for (let i = 0; i < airspaceInfos.length; i++) {
|
|
for (let i = 0; i < airspaceInfos.length; i++) {
|
|
|
let tmpCircle = airspaceInfos[i]
|
|
let tmpCircle = airspaceInfos[i]
|
|
|
- if (tmpCircle.airspaceType == Global.airspaceType.circle && currentAirspaceIndex != i) {
|
|
|
|
|
|
|
+ let airspaceTypeFix;
|
|
|
|
|
+ if (tmpCircle.airspaceType)
|
|
|
|
|
+ airspaceTypeFix = 'airspaceType';
|
|
|
|
|
+ else
|
|
|
|
|
+ airspaceTypeFix = 'airspace_type';
|
|
|
|
|
+ if (tmpCircle[airspaceTypeFix] == Global.airspaceType.circle && currentAirspaceIndex != i) {
|
|
|
let coordinate = {};
|
|
let coordinate = {};
|
|
|
- coordinate.latitude = latLngDegreesToDecimal(tmpCircle.lat);
|
|
|
|
|
- coordinate.longitude = latLngDegreesToDecimal(tmpCircle.lng);
|
|
|
|
|
- let radius = tmpCircle.radius;
|
|
|
|
|
|
|
+ if (tmpCircle.center_point_of_flying) {
|
|
|
|
|
+ coordinate.latitude = tmpCircle.center_point_of_flying.lat;
|
|
|
|
|
+ coordinate.longitude = tmpCircle.center_point_of_flying.lng;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ coordinate.latitude = latLngDegreesToDecimal(tmpCircle.lat);
|
|
|
|
|
+ coordinate.longitude = latLngDegreesToDecimal(tmpCircle.lng);
|
|
|
|
|
+ }
|
|
|
|
|
+ let radius = tmpCircle.radius_of_flying;
|
|
|
let circle = {
|
|
let circle = {
|
|
|
lineWidth: circleStyle.lineWidth ? circleStyle.lineWidth : Global.amapLineWidth,
|
|
lineWidth: circleStyle.lineWidth ? circleStyle.lineWidth : Global.amapLineWidth,
|
|
|
strokeColor: circleStyle.strokeColor ? circleStyle.strokeColor : Global.amapStrokeColor,
|
|
strokeColor: circleStyle.strokeColor ? circleStyle.strokeColor : Global.amapStrokeColor,
|
|
@@ -114,22 +124,45 @@ function getLinesRouter(lineProps, lineAndMarkerStyle) {
|
|
|
let markers = new Array();
|
|
let markers = new Array();
|
|
|
let lines = []
|
|
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'));
|
|
|
|
|
|
|
+ let startPointFix;
|
|
|
|
|
+ if (lineProps.start_point)
|
|
|
|
|
+ startPointFix = 'start_point';
|
|
|
|
|
+ else
|
|
|
|
|
+ startPointFix = 'dep';
|
|
|
|
|
+ if (hasLine(lineProps[startPointFix])) {
|
|
|
|
|
+ coordinates.push(startPointFix == 'dep' ? drawLineConfig(lineProps[startPointFix].lat, lineProps[startPointFix].lng) : { latitude: lineProps[startPointFix].lat, longitude: lineProps[startPointFix].lng });
|
|
|
|
|
+ markers.push(startPointFix == 'dep' ? addOvalPointConfig(lineProps[startPointFix].lat, lineProps[startPointFix].lng, lineAndMarkerStyle.imageName ? lineAndMarkerStyle.imageName : 'BA_oval') : { coordinate: { latitude: lineProps[startPointFix].lat, longitude: lineProps[startPointFix].lng }, imageName: lineAndMarkerStyle.imageName ? lineAndMarkerStyle.imageName : 'BA_oval' });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (Array.isArray(lineProps.passPoints)) {
|
|
|
|
|
- for (let i = 0; i < lineProps.passPoints.length; i++) {
|
|
|
|
|
- let obj = lineProps.passPoints[i]
|
|
|
|
|
|
|
+ let passingPointsFix;
|
|
|
|
|
+ if (lineProps.passing_points)
|
|
|
|
|
+ passingPointsFix = 'passing_points';
|
|
|
|
|
+ else
|
|
|
|
|
+ passingPointsFix = 'passPoints';
|
|
|
|
|
+
|
|
|
|
|
+ let endPointFix;
|
|
|
|
|
+ if (lineProps.end_point)
|
|
|
|
|
+ endPointFix = 'end_point';
|
|
|
|
|
+ else
|
|
|
|
|
+ endPointFix = 'arrive'
|
|
|
|
|
+
|
|
|
|
|
+ if (Array.isArray(lineProps[passingPointsFix])) {
|
|
|
|
|
+ for (let i = 0; i < lineProps[passingPointsFix].length; i++) {
|
|
|
|
|
+ let obj = lineProps[passingPointsFix][i]
|
|
|
if (isObject(obj)) {
|
|
if (isObject(obj)) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- 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'));
|
|
|
|
|
|
|
+ let pointTypeFix;
|
|
|
|
|
+ if (obj.point_type)
|
|
|
|
|
+ pointTypeFix = 'point_type';
|
|
|
|
|
+ else
|
|
|
|
|
+ pointTypeFix = 'pointType'
|
|
|
|
|
+
|
|
|
|
|
+ if (obj[pointTypeFix] == Global.pointTypes.point
|
|
|
|
|
+ || obj[pointTypeFix] == Global.pointTypes.nav) {
|
|
|
|
|
+ coordinates.push(pointTypeFix == 'pointType' ? drawLineConfig(obj.lat, obj.lng) : { latitude: obj.lat, longitude: obj.lng });
|
|
|
|
|
+ markers.push(pointTypeFix == 'pointType' ? addOvalPointConfig(obj.lat, obj.lng, lineAndMarkerStyle.imageName ? lineAndMarkerStyle.imageName : 'BA_oval') : { coordinate: { latitude: obj.lat, longitude: obj.lng }, imageName: lineAndMarkerStyle.imageName ? lineAndMarkerStyle.imageName : 'BA_oval' });
|
|
|
} else {
|
|
} else {
|
|
|
// 遇到一个航线,不需要和前前面的点连起来
|
|
// 遇到一个航线,不需要和前前面的点连起来
|
|
|
if (coordinates.length > 1) {
|
|
if (coordinates.length > 1) {
|
|
@@ -142,17 +175,17 @@ function getLinesRouter(lineProps, lineAndMarkerStyle) {
|
|
|
|
|
|
|
|
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]
|
|
|
|
|
|
|
+ const pointBefore = i == 0 ? lineProps[startPointFix] : lineProps[passingPointsFix][i - 1]
|
|
|
|
|
+ const pointAfter = i == lineProps[passingPointsFix].length - 1 ? lineProps[endPointFix] : lineProps[passingPointsFix][i + 1]
|
|
|
|
|
|
|
|
lines.push(getAirwayLine(obj, pointBefore, pointAfter, lineAndMarkerStyle))
|
|
lines.push(getAirwayLine(obj, pointBefore, pointAfter, lineAndMarkerStyle))
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- 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 (hasLine(lineProps[endPointFix])) {
|
|
|
|
|
+ coordinates.push(endPointFix == 'arrive' ? drawLineConfig(lineProps[endPointFix].lat, lineProps[endPointFix].lng) : { latitude: lineProps[endPointFix].lat, longitude: lineProps[endPointFix].lng });
|
|
|
|
|
+ markers.push(endPointFix == 'arrive' ? addOvalPointConfig(lineProps[endPointFix].lat, lineProps[endPointFix].lng, lineAndMarkerStyle.imageName ? lineAndMarkerStyle.imageName : 'BA_oval') : { coordinate: { latitude: lineProps[endPointFix].lat, longitude: lineProps[endPointFix].lng }, imageName: lineAndMarkerStyle.imageName ? lineAndMarkerStyle.imageName : 'BA_oval' });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (coordinates.length > 1) {
|
|
if (coordinates.length > 1) {
|
|
@@ -176,7 +209,12 @@ function getLinesAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
let lineStyle = setStyle('line');
|
|
let lineStyle = setStyle('line');
|
|
|
for (let i = 0; i < airspaceInfos.length; i++) {
|
|
for (let i = 0; i < airspaceInfos.length; i++) {
|
|
|
let tmpLine = airspaceInfos[i]
|
|
let tmpLine = airspaceInfos[i]
|
|
|
- if (tmpLine.airspaceType == Global.airspaceType.line && currentAirspaceIndex != i) {
|
|
|
|
|
|
|
+ let airspaceTypeFix;
|
|
|
|
|
+ if (tmpLine.airspaceType)
|
|
|
|
|
+ airspaceTypeFix = 'airspaceType';
|
|
|
|
|
+ else
|
|
|
|
|
+ airspaceTypeFix = 'airspace_type';
|
|
|
|
|
+ if (tmpLine[airspaceTypeFix] == Global.airspaceType.line && currentAirspaceIndex != i) {
|
|
|
let { lines, markers } = getLinesRouter(tmpLine, lineStyle);
|
|
let { lines, markers } = getLinesRouter(tmpLine, lineStyle);
|
|
|
retMarkers.push(...markers);
|
|
retMarkers.push(...markers);
|
|
|
retLines.push(...lines);
|
|
retLines.push(...lines);
|
|
@@ -200,13 +238,19 @@ function getPolygon(polygonProps, polygonAndMarkerStyle) {
|
|
|
let coordinates = new Array();
|
|
let coordinates = new Array();
|
|
|
let markers = new Array();
|
|
let markers = new Array();
|
|
|
|
|
|
|
|
- if (Array.isArray(polygonProps.polygonPoints)) {
|
|
|
|
|
- for (let obj of polygonProps.polygonPoints) {
|
|
|
|
|
|
|
+ let pointsFix;
|
|
|
|
|
+ if (polygonProps.points)
|
|
|
|
|
+ pointsFix = 'points';
|
|
|
|
|
+ else
|
|
|
|
|
+ pointsFix = 'polygonPoints';
|
|
|
|
|
+
|
|
|
|
|
+ if (Array.isArray(polygonProps[pointsFix])) {
|
|
|
|
|
+ for (let obj of polygonProps[pointsFix]) {
|
|
|
if (!hasPoint(obj)) {
|
|
if (!hasPoint(obj)) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- coordinates.push(drawLineConfig(obj.lat, obj.lng));
|
|
|
|
|
- markers.push(addOvalPointConfig(obj.lat, obj.lng, polygonAndMarkerStyle.imageName ? polygonAndMarkerStyle.imageName : 'BA_oval'));
|
|
|
|
|
|
|
+ coordinates.push(pointsFix == 'polygonPoints' ? drawLineConfig(obj.lat, obj.lng) : { latitude: obj.lat, longitude: obj.lng });
|
|
|
|
|
+ markers.push(pointsFix == 'polygonPoints' ? addOvalPointConfig(obj.lat, obj.lng, polygonAndMarkerStyle.imageName ? polygonAndMarkerStyle.imageName : 'BA_oval') : { coordinate: { latitude: obj.lat, longitude: obj.lng }, imageName: polygonAndMarkerStyle.imageName ? polygonAndMarkerStyle.imageName : 'BA_oval' });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -232,7 +276,12 @@ function getPolygonsAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
let polygonAndMarkerStyle = setStyle('polygon');
|
|
let polygonAndMarkerStyle = setStyle('polygon');
|
|
|
for (let i = 0; i < airspaceInfos.length; i++) {
|
|
for (let i = 0; i < airspaceInfos.length; i++) {
|
|
|
let polygon = airspaceInfos[i]
|
|
let polygon = airspaceInfos[i]
|
|
|
- if (polygon.airspaceType == Global.airspaceType.polygon && currentAirspaceIndex != i) {
|
|
|
|
|
|
|
+ let airspaceTypeFix;
|
|
|
|
|
+ if (polygon.airspaceType)
|
|
|
|
|
+ airspaceTypeFix = 'airspaceType';
|
|
|
|
|
+ else
|
|
|
|
|
+ airspaceTypeFix = 'airspace_type';
|
|
|
|
|
+ if (polygon[airspaceTypeFix] == Global.airspaceType.polygon && currentAirspaceIndex != i) {
|
|
|
let retObj = getPolygon(polygon, polygonAndMarkerStyle);
|
|
let retObj = getPolygon(polygon, polygonAndMarkerStyle);
|
|
|
markers.push(...retObj.markers);
|
|
markers.push(...retObj.markers);
|
|
|
polygons.push(retObj.polygon);
|
|
polygons.push(retObj.polygon);
|
|
@@ -272,17 +321,21 @@ function getMarkerSelector(polygonAndMarkers, lineAndMarkers) {
|
|
|
|
|
|
|
|
function getRegionPoints(circles, lineAndMarkers, polygonAndMarkers) {
|
|
function getRegionPoints(circles, lineAndMarkers, polygonAndMarkers) {
|
|
|
let regionPoints = new Array();
|
|
let regionPoints = new Array();
|
|
|
|
|
+
|
|
|
for (let i = 0; i < circles.length; i++) {
|
|
for (let i = 0; i < circles.length; i++) {
|
|
|
regionPoints.push(getCircleRegions(circles[i]));
|
|
regionPoints.push(getCircleRegions(circles[i]));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
let lines = lineAndMarkers.lines;
|
|
let lines = lineAndMarkers.lines;
|
|
|
for (let i = 0; i < lines.length; i++) {
|
|
for (let i = 0; i < lines.length; i++) {
|
|
|
regionPoints.push(lines[i].coordinates);
|
|
regionPoints.push(lines[i].coordinates);
|
|
|
}
|
|
}
|
|
|
- let polygons = getPolygonsAndMarkers.polygons;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ let polygons = polygonAndMarkers.polygons;
|
|
|
for (let i = 0; i < polygons.length; i++) {
|
|
for (let i = 0; i < polygons.length; i++) {
|
|
|
regionPoints.push(polygons.coordinates);
|
|
regionPoints.push(polygons.coordinates);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
return regionPoints;
|
|
return regionPoints;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -317,13 +370,20 @@ function getPolygonSelector(polygonAndMarkers) {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+let setStyle = (style) => {
|
|
|
|
|
+ if (!style)
|
|
|
|
|
+ return (shapeName) => { return {key:0} }
|
|
|
|
|
+ else
|
|
|
|
|
+ return (shapeName) => style[shapeName]
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
//获取selector
|
|
//获取selector
|
|
|
-export function getShapesSelector(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
|
|
|
|
+export function getShapesSelector(airspaceInfos, style, currentAirspaceIndex) {
|
|
|
currentAirspaceIndex = currentAirspaceIndex ? currentAirspaceIndex : () => -1;
|
|
currentAirspaceIndex = currentAirspaceIndex ? currentAirspaceIndex : () => -1;
|
|
|
- let circles = getCircleSelector(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
|
|
- let lineAndMarkers = getLineAndMarkerSelector(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
|
|
|
|
+ let circles = getCircleSelector(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
|
|
+ let lineAndMarkers = getLineAndMarkerSelector(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
let lines = getLineSelector(lineAndMarkers);
|
|
let lines = getLineSelector(lineAndMarkers);
|
|
|
- let polygonAndMarkers = getPolygonAndMarkerSelector(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
|
|
|
|
+ let polygonAndMarkers = getPolygonAndMarkerSelector(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
let polygons = getPolygonSelector(polygonAndMarkers);
|
|
let polygons = getPolygonSelector(polygonAndMarkers);
|
|
|
let markers = getMarkerSelector(polygonAndMarkers, lineAndMarkers);
|
|
let markers = getMarkerSelector(polygonAndMarkers, lineAndMarkers);
|
|
|
let regionPoints = getRegionPointsSelector(circles, lineAndMarkers, polygonAndMarkers);
|
|
let regionPoints = getRegionPointsSelector(circles, lineAndMarkers, polygonAndMarkers);
|
|
@@ -336,13 +396,13 @@ export function getShapesSelector(airspaceInfos, setStyle, currentAirspaceIndex)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//获取数组
|
|
//获取数组
|
|
|
-export function getShapes(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
|
|
|
|
+export function getShapes(airspaceInfos, style, currentAirspaceIndex) {
|
|
|
currentAirspaceIndex = currentAirspaceIndex ? currentAirspaceIndex : () => -1;
|
|
currentAirspaceIndex = currentAirspaceIndex ? currentAirspaceIndex : () => -1;
|
|
|
- let circles = getCircles(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
|
|
- let lineAndMarkers = getLinesAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
|
|
|
|
+ let circles = getCircles(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
|
|
+ let lineAndMarkers = getLinesAndMarkers(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
let lines = getLines(lineAndMarkers);
|
|
let lines = getLines(lineAndMarkers);
|
|
|
- let polygonAndMarkers = getPolygonsAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex);
|
|
|
|
|
- let polygons = getPolygons(getPolygonsAndMarkers);
|
|
|
|
|
|
|
+ let polygonAndMarkers = getPolygonsAndMarkers(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
|
|
+ let polygons = getPolygons(polygonAndMarkers);
|
|
|
let markers = getMarkers(polygonAndMarkers, lineAndMarkers);
|
|
let markers = getMarkers(polygonAndMarkers, lineAndMarkers);
|
|
|
let regionPoints = getRegionPoints(circles, lineAndMarkers, polygonAndMarkers);
|
|
let regionPoints = getRegionPoints(circles, lineAndMarkers, polygonAndMarkers);
|
|
|
return {
|
|
return {
|