lkk 5 mesiacov pred
rodič
commit
4d04ef2052

+ 1 - 1
index.html

@@ -27,7 +27,7 @@
     <script src="./static/js/echarts.min.js"></script>
     <script src="./static/js/echarts-gl.min.js"></script>
     <script src="./static/js/shp.js"></script>
-
+    <script src="./static/js/sunrise-sunset-js/dist/sunrise-sunset.js"></script>
     <style>
         .cesium-performanceDisplay-defaultContainer {
             clear: both;

+ 3 - 3
src/views/ConstructionApplication3D/SunlightAnalysis/SunlightAnalysis.vue

@@ -232,7 +232,7 @@ import {
   getVectorContour,
   drawCanvasContour,
 } from "kriging-contour/dist/kriging-contour.js";
-import { getSunrise, getSunset } from "sunrise-sunset-js";
+// import { getSunrise, getSunset } from "sunrise-sunset-js";
 import {
   cartesian3ToWGS84,
   mapQuery,
@@ -961,12 +961,12 @@ export default {
       var polygonPs = polygon([trufpolygons]);
 
       debugger;
-      var sunriseDate = getSunrise(
+      var sunriseDate = SunriseSunsetJS.getSunrise(
         18.31723463241332,
         109.5112252162011,
         this.form.selDate
       );
-      var sunsetdate = getSunset(
+      var sunsetdate = SunriseSunsetJS.getSunset(
         18.31723463241332,
         109.5112252162011,
         this.form.selDate

+ 83 - 0
static/js/sunrise-sunset-js/README.MD

@@ -0,0 +1,83 @@
+# Sunrise-Sunset-Js
+
+Calculate sunrise and sunset times in Javascript.
+Based loosely and indirectly on Kevin Boone's SunTimes Java implementation of the US Naval Observatory's algorithm.
+Works on both browser (IE11+) and Node.js, ~1kb minified.
+
+[![Build Status](https://travis-ci.org/udivankin/sunrise-sunset.svg?branch=master)](https://travis-ci.org/udivankin/sunrise-sunset)
+[![Coverage Status](https://coveralls.io/repos/github/udivankin/sunrise-sunset/badge.svg?branch=master)](https://coveralls.io/github/udivankin/sunrise-sunset?branch=master)
+
+### Install
+Via npm:
+
+```bash
+npm install --save sunrise-sunset-js
+```
+
+Via script tag:
+```html
+<script src="sunrise-sunset.js">
+```
+
+### Usage
+
+```javascript
+import { getSunrise, getSunset } from 'sunrise-sunset-js';
+// Or if you use CommonJS imports:
+// const { getSunrise, getSunset } = require('sunrise-sunset-js')
+
+/** 
+ * Sunset tonight at the Triggertrap office for today
+ */
+const sunset = getSunset(51.4541, -2.5920);
+
+
+/** 
+ * Sunrise at Stonehenge on midsummer's day 2000
+ */
+const sunrise = getSunrise(51.1788, -1.8262, new Date("2000-06-21"));
+
+/** 
+ * Combined with geolocation. Sunset tonight at your location.
+ */
+navigator.geolocation.getCurrentPosition(function(position) {
+  console.log(getSunset(position.coords.latitude, position.coords.longitude));
+});
+
+/** 
+ * Get all solar events for given year (sorted by time of occurrence)
+ */
+function getSolarEventsForYear(latitude, longitude, year) {
+  const result = [];
+  const start = new Date(year, 0, 1).getTime();
+  for (let i = 0; i < 366; i++) {
+    const d = new Date(start + (i * 24 * 60 * 60 * 1000));
+    if (d.getFullYear() > year) break; // For non-leap year
+    result.push(['sunrise', getSunrise(latitude, longitude, d)]);
+    result.push(['sunset', getSunset(latitude, longitude, d)]);
+  }
+  return result.filter(event => Boolean(event[1])).sort((a, b) => a - b);
+}
+getSolarEventsForYear(51.1788, -1.8262, 2019);
+```
+
+For those who still don't use js bundlers, there's global SunriseSunsetJS object,
+which exposes the same getSunset and getSunrise methods (must include dist/index.js in your html first)
+
+```javascript
+var sunset = SunriseSunsetJS.getSunset(51.4541, -2.5920);
+var sunrise = SunriseSunsetJS.getSunrise(51.4541, -2.5920, new Date("2000-06-21"));
+```
+
+By Matt Kane (@ascorbic). Copyright © 2012 Triggertrap Ltd. All Rights Reserved.
+
+This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
+Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
+any later version.
+This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied
+warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+details.
+You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA,
+or connect to: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+```

+ 4 - 0
static/js/sunrise-sunset-js/dist/index.d.ts

@@ -0,0 +1,4 @@
+declare module 'sunrise-sunset-js' {
+  export function getSunrise(latitude: number, longitude: number, date?: Date): Date;
+  export function getSunset(latitude: number, longitude: number, date?: Date): Date;
+}

+ 127 - 0
static/js/sunrise-sunset-js/dist/index.js

@@ -0,0 +1,127 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+/**
+ * Sunrise/sunset script. By Matt Kane. Adopted for NPM use by Alexey Udivankin.
+ *
+ * Based loosely and indirectly on Kevin Boone's SunTimes Java implementation
+ * of the US Naval Observatory's algorithm.
+ *
+ * Copyright © 2012 Triggertrap Ltd. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+ * details.
+ * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA,
+ * or connect to: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+ */
+/**
+ * Default zenith
+ */
+const DEFAULT_ZENITH = 90.8333;
+/**
+ * Degrees per hour
+ */
+const DEGREES_PER_HOUR = 360 / 24;
+/**
+ * Msec in hour
+ */
+const MSEC_IN_HOUR = 60 * 60 * 1000;
+/**
+ * Get day of year
+ */
+function getDayOfYear(date) {
+    return Math.ceil((date.getTime() - new Date(date.getFullYear(), 0, 1).getTime()) / 8.64e7);
+}
+/**
+ * Get sin of value in deg
+ */
+function sinDeg(deg) {
+    return Math.sin(deg * 2.0 * Math.PI / 360.0);
+}
+/**
+ * Get acos of value in deg
+ */
+function acosDeg(x) {
+    return Math.acos(x) * 360.0 / (2 * Math.PI);
+}
+/**
+ * Get asin of value in deg
+ */
+function asinDeg(x) {
+    return Math.asin(x) * 360.0 / (2 * Math.PI);
+}
+/**
+ * Get tan of value in deg
+ */
+function tanDeg(deg) {
+    return Math.tan(deg * 2.0 * Math.PI / 360.0);
+}
+/**
+ * Get cos of value in deg
+ */
+function cosDeg(deg) {
+    return Math.cos(deg * 2.0 * Math.PI / 360.0);
+}
+/**
+ * Get ramainder
+ */
+function mod(a, b) {
+    const result = a % b;
+    return result < 0
+        ? result + b
+        : result;
+}
+/**
+ * Calculate Date for either sunrise or sunset
+ */
+function calculate(latitude, longitude, isSunrise, zenith, date) {
+    const dayOfYear = getDayOfYear(date);
+    const hoursFromMeridian = longitude / DEGREES_PER_HOUR;
+    const approxTimeOfEventInDays = isSunrise
+        ? dayOfYear + ((6 - hoursFromMeridian) / 24)
+        : dayOfYear + ((18.0 - hoursFromMeridian) / 24);
+    const sunMeanAnomaly = (0.9856 * approxTimeOfEventInDays) - 3.289;
+    const sunTrueLongitude = mod(sunMeanAnomaly + (1.916 * sinDeg(sunMeanAnomaly)) + (0.020 * sinDeg(2 * sunMeanAnomaly)) + 282.634, 360);
+    const ascension = 0.91764 * tanDeg(sunTrueLongitude);
+    let rightAscension;
+    rightAscension = 360 / (2 * Math.PI) * Math.atan(ascension);
+    rightAscension = mod(rightAscension, 360);
+    const lQuadrant = Math.floor(sunTrueLongitude / 90) * 90;
+    const raQuadrant = Math.floor(rightAscension / 90) * 90;
+    rightAscension = rightAscension + (lQuadrant - raQuadrant);
+    rightAscension /= DEGREES_PER_HOUR;
+    const sinDec = 0.39782 * sinDeg(sunTrueLongitude);
+    const cosDec = cosDeg(asinDeg(sinDec));
+    const cosLocalHourAngle = ((cosDeg(zenith)) - (sinDec * (sinDeg(latitude)))) / (cosDec * (cosDeg(latitude)));
+    const localHourAngle = isSunrise
+        ? 360 - acosDeg(cosLocalHourAngle)
+        : acosDeg(cosLocalHourAngle);
+    const localHour = localHourAngle / DEGREES_PER_HOUR;
+    const localMeanTime = localHour + rightAscension - (0.06571 * approxTimeOfEventInDays) - 6.622;
+    const time = mod(localMeanTime - (longitude / DEGREES_PER_HOUR), 24);
+    const utcMidnight = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate());
+    // Created date will be set to local (system) time zone.
+    return new Date(utcMidnight + (time * MSEC_IN_HOUR));
+}
+/**
+ * Calculate Sunrise time for given longitude, latitude, zenith and date
+ */
+function getSunrise(latitude, longitude, date = new Date()) {
+    return calculate(latitude, longitude, true, DEFAULT_ZENITH, date);
+}
+/**
+ * Calculate Sunset time for given longitude, latitude, zenith and date
+ */
+function getSunset(latitude, longitude, date = new Date()) {
+    return calculate(latitude, longitude, false, DEFAULT_ZENITH, date);
+}
+
+exports.getSunrise = getSunrise;
+exports.getSunset = getSunset;

+ 1 - 0
static/js/sunrise-sunset-js/dist/sunrise-sunset.js

@@ -0,0 +1 @@
+var SunriseSunsetJS=function(t){"use strict";var e=90.8333;function n(t){return Math.sin(2*t*Math.PI/360)}function a(t){return 360*Math.acos(t)/(2*Math.PI)}function r(t){return Math.cos(2*t*Math.PI/360)}function u(t,e){var n=t%e;return n<0?n+e:n}function i(t,e,i,o,M){var h,c,f=function(t){return Math.ceil((t.getTime()-new Date(t.getFullYear(),0,1).getTime())/864e5)}(M),s=e/15,l=i?f+(6-s)/24:f+(18-s)/24,g=.9856*l-3.289,v=u(g+1.916*n(g)+.02*n(2*g)+282.634,360),P=.91764*(h=v,Math.tan(2*h*Math.PI/360));c=u(c=360/(2*Math.PI)*Math.atan(P),360),c+=90*Math.floor(v/90)-90*Math.floor(c/90),c/=15;var D,I=.39782*n(v),S=r((D=I,360*Math.asin(D)/(2*Math.PI))),d=(r(o)-I*n(t))/(S*r(t)),w=u((i?360-a(d):a(d))/15+c-.06571*l-6.622-e/15,24),T=Date.UTC(M.getFullYear(),M.getMonth(),M.getDate());return new Date(T+36e5*w)}return t.getSunrise=function(t,n,a){return void 0===a&&(a=new Date),i(t,n,!0,e,a)},t.getSunset=function(t,n,a){return void 0===a&&(a=new Date),i(t,n,!1,e,a)},Object.defineProperty(t,"__esModule",{value:!0}),t}({});

+ 85 - 0
static/js/sunrise-sunset-js/package.json

@@ -0,0 +1,85 @@
+{
+  "_from": "sunrise-sunset-js@^2.2.1",
+  "_id": "sunrise-sunset-js@2.2.1",
+  "_inBundle": false,
+  "_integrity": "sha512-ErsvmxoTCZRacVPtlchkrTAR8qxypBy0BDrrv9LMugLuF0AykcS5pQsP1EhQJHgumxrTTSI8N8KJkQMVJ6dEPw==",
+  "_location": "/sunrise-sunset-js",
+  "_phantomChildren": {},
+  "_requested": {
+    "type": "range",
+    "registry": true,
+    "raw": "sunrise-sunset-js@^2.2.1",
+    "name": "sunrise-sunset-js",
+    "escapedName": "sunrise-sunset-js",
+    "rawSpec": "^2.2.1",
+    "saveSpec": null,
+    "fetchSpec": "^2.2.1"
+  },
+  "_requiredBy": [
+    "#USER",
+    "/"
+  ],
+  "_resolved": "https://registry.npmmirror.com/sunrise-sunset-js/-/sunrise-sunset-js-2.2.1.tgz",
+  "_shasum": "bf541aab71b9215901fb6dee260e946fb3c7a80a",
+  "_spec": "sunrise-sunset-js@^2.2.1",
+  "_where": "E:\\项目总文件\\svncode30\\yfb\\海南项目\\正式代码\\前端\\real3d-portalsite-V2.0",
+  "author": {
+    "name": "Aleksei Udivankin",
+    "email": "allx@mail.ru",
+    "url": "https://github.com/udivankin"
+  },
+  "bugs": {
+    "url": "https://github.com/udivankin/sunrise-sunset/issues"
+  },
+  "bundleDependencies": false,
+  "deprecated": false,
+  "description": "Sunrise and sunset time calculation for given coordinates",
+  "devDependencies": {
+    "@babel/core": "7.12.9",
+    "@babel/preset-env": "7.12.7",
+    "@rollup/plugin-babel": "5.2.2",
+    "@rollup/plugin-commonjs": "17.0.0",
+    "@rollup/plugin-typescript": "8.0.0",
+    "babel-jest": "26.6.3",
+    "coveralls": "3.1.0",
+    "jest-cli": "26.6.3",
+    "pico-static-server": "3.0.3",
+    "rollup": "2.34.2",
+    "rollup-plugin-copy": "3.3.0",
+    "rollup-plugin-livereload": "2.0.0",
+    "rollup-plugin-terser": "7.0.2",
+    "rollup-watch": "4.3.1",
+    "tslib": "2.0.3",
+    "typescript": "4.1.2"
+  },
+  "directories": {
+    "test": "tests"
+  },
+  "homepage": "https://github.com/udivankin/sunrise-sunset#readme",
+  "jest": {
+    "cache": false,
+    "transform": {
+      "^.+\\.js$": "babel-jest"
+    }
+  },
+  "keywords": [
+    "sunrise",
+    "sunset",
+    "sun",
+    "suncalc",
+    "day",
+    "events"
+  ],
+  "license": "ISC",
+  "main": "dist/index.js",
+  "name": "sunrise-sunset-js",
+  "repository": {
+    "type": "git",
+    "url": "git+https://udivankin@github.com/udivankin/sunrise-sunset.git"
+  },
+  "scripts": {
+    "build": "rollup -c ./rollup.config.js",
+    "test": "jest"
+  },
+  "version": "2.2.1"
+}