|
@@ -15,21 +15,44 @@ function getCircleRegions(circle) {
|
|
|
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 }]
|
|
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 = Global.amapLineWidth
|
|
|
|
|
+ let strokeColor = Global.amapStrokeColor
|
|
|
|
|
+ let fillColor = Global.amapFillColor
|
|
|
|
|
+
|
|
|
|
|
+ return {imageName, lineWidth, strokeColor, fillColor}
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
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 {lineWidth, strokeColor, fillColor} = getDefaultStyle()
|
|
|
|
|
+
|
|
|
|
|
+ if(circleStyle) {
|
|
|
|
|
+ lineWidth = circleStyle.lineWidth
|
|
|
|
|
+ strokeColor = circleStyle.strokeColor
|
|
|
|
|
+ fillColor = circleStyle.fillColor
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//通过该方法获取样式
|
|
//通过该方法获取样式
|
|
|
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]
|
|
|
- let airspaceTypeFix;
|
|
|
|
|
- if (tmpCircle.airspaceType)
|
|
|
|
|
|
|
+ let airspaceTypeFix, radiusFix
|
|
|
|
|
+ if (tmpCircle.airspaceType) {
|
|
|
airspaceTypeFix = 'airspaceType';
|
|
airspaceTypeFix = 'airspaceType';
|
|
|
- else
|
|
|
|
|
|
|
+ radiusFix = 'radius'
|
|
|
|
|
+ } else {
|
|
|
airspaceTypeFix = 'airspace_type';
|
|
airspaceTypeFix = 'airspace_type';
|
|
|
|
|
+ radiusFix = 'radius_of_flying'
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (tmpCircle[airspaceTypeFix] == Global.airspaceType.circle && currentAirspaceIndex != i) {
|
|
if (tmpCircle[airspaceTypeFix] == Global.airspaceType.circle && currentAirspaceIndex != i) {
|
|
|
|
|
+
|
|
|
let coordinate = {};
|
|
let coordinate = {};
|
|
|
if (tmpCircle.center_point_of_flying) {
|
|
if (tmpCircle.center_point_of_flying) {
|
|
|
coordinate.latitude = tmpCircle.center_point_of_flying.lat;
|
|
coordinate.latitude = tmpCircle.center_point_of_flying.lat;
|
|
@@ -38,14 +61,9 @@ function getCircles(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
coordinate.latitude = latLngDegreesToDecimal(tmpCircle.lat);
|
|
coordinate.latitude = latLngDegreesToDecimal(tmpCircle.lat);
|
|
|
coordinate.longitude = latLngDegreesToDecimal(tmpCircle.lng);
|
|
coordinate.longitude = latLngDegreesToDecimal(tmpCircle.lng);
|
|
|
}
|
|
}
|
|
|
- let radius = tmpCircle.radius_of_flying;
|
|
|
|
|
- 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
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ let radius = tmpCircle[radiusFix];
|
|
|
|
|
+ let circle = {lineWidth, strokeColor, fillColor, radius, coordinate}
|
|
|
circles.push(circle);
|
|
circles.push(circle);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -103,7 +121,7 @@ function getAirwayPoints(airway, pointBefore, pointAfter) {
|
|
|
|
|
|
|
|
let pointTypeFix, pointsFix
|
|
let pointTypeFix, pointsFix
|
|
|
|
|
|
|
|
- if (points in airway) {
|
|
|
|
|
|
|
+ if ('points' in airway) {
|
|
|
pointTypeFix = 'point_type';
|
|
pointTypeFix = 'point_type';
|
|
|
pointsFix = 'points'
|
|
pointsFix = 'points'
|
|
|
} else {
|
|
} else {
|
|
@@ -147,9 +165,7 @@ function getLinesRouter(lineProps, lineAndMarkerStyle) {
|
|
|
let markers = new Array();
|
|
let markers = new Array();
|
|
|
let lines = []
|
|
let lines = []
|
|
|
|
|
|
|
|
- let imageName = 'BA_oval'
|
|
|
|
|
- let lineWidth = Global.amapLineWidth
|
|
|
|
|
- let strokeColor = Global.amapStrokeColor
|
|
|
|
|
|
|
+ let {imageName, lineWidth, strokeColor} = getDefaultStyle()
|
|
|
|
|
|
|
|
if (lineAndMarkerStyle) {
|
|
if (lineAndMarkerStyle) {
|
|
|
imageName = lineAndMarkerStyle.imageName
|
|
imageName = lineAndMarkerStyle.imageName
|
|
@@ -259,25 +275,32 @@ function getPolygon(polygonProps, polygonAndMarkerStyle) {
|
|
|
let coordinates = new Array();
|
|
let coordinates = new Array();
|
|
|
let markers = new Array();
|
|
let markers = new Array();
|
|
|
|
|
|
|
|
- let pointsFix;
|
|
|
|
|
- if (polygonProps.points)
|
|
|
|
|
|
|
+ let {imageName, lineWidth, strokeColor, fillColor} = getDefaultStyle()
|
|
|
|
|
+
|
|
|
|
|
+ if (polygonAndMarkerStyle) {
|
|
|
|
|
+ imageName = polygonAndMarkerStyle.imageName
|
|
|
|
|
+ lineWidth = polygonAndMarkerStyle.lineWidth
|
|
|
|
|
+ strokeCOlor = polygonAndMarkerStyle.strokeColor
|
|
|
|
|
+ fillColor = polygonAndMarkerStyle.fillColor
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let pointsFix, dataType;
|
|
|
|
|
+ if (polygonProps.points) {
|
|
|
pointsFix = 'points';
|
|
pointsFix = 'points';
|
|
|
- else
|
|
|
|
|
|
|
+ dataType = 2
|
|
|
|
|
+ } else {
|
|
|
pointsFix = 'polygonPoints';
|
|
pointsFix = 'polygonPoints';
|
|
|
|
|
+ dataType = 1 // 驼峰模式
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (Array.isArray(polygonProps[pointsFix])) {
|
|
if (Array.isArray(polygonProps[pointsFix])) {
|
|
|
for (let obj of polygonProps[pointsFix]) {
|
|
for (let obj of polygonProps[pointsFix]) {
|
|
|
- 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' });
|
|
|
|
|
|
|
+ coordinates.push(drawLineConfig(obj.lat, obj.lng, dataType));
|
|
|
|
|
+ markers.push(addOvalPointConfig(obj.lat, obj.lng, imageName, dataType));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- 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
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ let polygon = {lineWidth, strokeColor, fillColor, coordinates};
|
|
|
|
|
|
|
|
return { markers, polygon };
|
|
return { markers, polygon };
|
|
|
|
|
|
|
@@ -298,6 +321,7 @@ function getPolygonsAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
airspaceTypeFix = 'airspaceType';
|
|
airspaceTypeFix = 'airspaceType';
|
|
|
else
|
|
else
|
|
|
airspaceTypeFix = 'airspace_type';
|
|
airspaceTypeFix = 'airspace_type';
|
|
|
|
|
+
|
|
|
if (polygon[airspaceTypeFix] == Global.airspaceType.polygon && currentAirspaceIndex != i) {
|
|
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);
|
|
@@ -412,21 +436,15 @@ export function getShapesSelector(airspaceInfos, style, currentAirspaceIndex) {
|
|
|
regionPoints
|
|
regionPoints
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
//获取数组
|
|
//获取数组
|
|
|
export function getShapes(airspaceInfos, style, currentAirspaceIndex) {
|
|
export function getShapes(airspaceInfos, style, currentAirspaceIndex) {
|
|
|
- currentAirspaceIndex = currentAirspaceIndex ? currentAirspaceIndex : () => -1;
|
|
|
|
|
- let circles = getCircles(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
|
|
- let lineAndMarkers = getLinesAndMarkers(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
|
|
- let lines = getLines(lineAndMarkers);
|
|
|
|
|
- let polygonAndMarkers = getPolygonsAndMarkers(airspaceInfos, setStyle(style), currentAirspaceIndex);
|
|
|
|
|
- let polygons = getPolygons(polygonAndMarkers);
|
|
|
|
|
- let markers = getMarkers(polygonAndMarkers, lineAndMarkers);
|
|
|
|
|
- let regionPoints = getRegionPoints(circles, lineAndMarkers, polygonAndMarkers);
|
|
|
|
|
|
|
+ let {markers, polygons, circles, lines, regionPoints} = getShapesSelector((airspaceInfos)=>airspaceInfos, style, currentAirspaceIndex)
|
|
|
return {
|
|
return {
|
|
|
- markers,
|
|
|
|
|
- circles,
|
|
|
|
|
- lines,
|
|
|
|
|
- polygons,
|
|
|
|
|
- regionPoints
|
|
|
|
|
|
|
+ markers: markers(airspaceInfos),
|
|
|
|
|
+ circles: circles(airspaceInfos),
|
|
|
|
|
+ lines: lines(airspaceInfos),
|
|
|
|
|
+ polygons: polygons(airspaceInfos),
|
|
|
|
|
+ regionPoints: regionPoints(airspaceInfos)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|