|
|
@@ -9,8 +9,16 @@ import {
|
|
|
hasLine,
|
|
|
hasPoint
|
|
|
} from './Utils'
|
|
|
-
|
|
|
-
|
|
|
+let LatLon = require('geodesy').LatLonSpherical;
|
|
|
+
|
|
|
+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)
|
|
|
+ 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 getCircles(airspaceInfos, setStyle, currentAirspaceIndex) {
|
|
|
let circles = [];
|
|
|
@@ -262,31 +270,60 @@ function getMarkerSelector(polygonAndMarkers, lineAndMarkers) {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+function getRegionPoints(circles, lineAndMarkers, polygonAndMarkers) {
|
|
|
+ let regionPoints = new Array();
|
|
|
+ for (let i = 0; i < circles.length; i++) {
|
|
|
+ regionPoints.push(getCircleRegions(circles[i]));
|
|
|
+ }
|
|
|
+ let lines = lineAndMarkers.lines;
|
|
|
+ for (let i = 0; i < lines.length; i++) {
|
|
|
+ regionPoints.push(lines[i].coordinates);
|
|
|
+ }
|
|
|
+ let polygons = getPolygonsAndMarkers.polygons;
|
|
|
+ for (let i = 0; i < polygons.length; i++) {
|
|
|
+ regionPoints.push(polygons.coordinates);
|
|
|
+ }
|
|
|
+ return regionPoints;
|
|
|
+}
|
|
|
|
|
|
+function getRegionPointsSelector(circles, lineAndMarkers, polygonAndMarkers) {
|
|
|
+ return createSelector(
|
|
|
+ circles,
|
|
|
+ lineAndMarkers,
|
|
|
+ polygonAndMarkers,
|
|
|
+ getRegionPoints
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+//获取selector
|
|
|
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);
|
|
|
+ let regionPoints = getRegionPointsSelector(circles, lineAndMarkers, polygonAndMarkers);
|
|
|
return {
|
|
|
markers,
|
|
|
circles,
|
|
|
lineAndMarkers,
|
|
|
- polygonAndMarkers
|
|
|
+ polygonAndMarkers,
|
|
|
+ regionPoints
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+//获取数组
|
|
|
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);
|
|
|
+ let regionPoints = getRegionPoints(circles, lineAndMarkers, polygonAndMarkers);
|
|
|
return {
|
|
|
markers,
|
|
|
circles,
|
|
|
lineAndMarkers,
|
|
|
- polygonAndMarkers
|
|
|
+ polygonAndMarkers,
|
|
|
+ regionPoints
|
|
|
}
|
|
|
}
|