57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
import FeatureLayer3D from "./FeatureLayer3D";
|
|
import { getPolygonHierarchy } from "../utils/cesutil";
|
|
import { zindex2d } from "../../zindex";
|
|
import Style from "ol/style/Style";
|
|
import FillStyle from "ol/style/Fill";
|
|
|
|
const { Cesium } = window;
|
|
|
|
export default class RainLayer3D extends FeatureLayer3D {
|
|
static LayerName = 'RainLayer';
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
this.rowKey = 'gml_id';
|
|
}
|
|
|
|
getLayerName() {
|
|
return RainLayer3D.LayerName;
|
|
}
|
|
|
|
async dataPromise() {
|
|
const rainData = await fetch(`${process.env.PUBLIC_URL}/data/rainfallCenter/建始县20210810.geojson`)
|
|
.then(resp => resp.json())
|
|
.then(data => data.features)
|
|
.then(features => features.map(o => ({ ...o.properties, geometry: o.geometry, type: 'rain' })))
|
|
.catch(() => []);
|
|
|
|
//console.log("rainData 33++++",rainData);
|
|
|
|
return rainData;
|
|
}
|
|
|
|
addFeature(record) {
|
|
if (!record.geometry) {
|
|
return;
|
|
}
|
|
const coordsArr = getPolygonHierarchy(record.geometry);
|
|
if (!coordsArr) {
|
|
return null;
|
|
}
|
|
const ret = [];
|
|
for (const coords of coordsArr) {
|
|
const ent = this._viewer.entities.add({
|
|
show: this.isVisible(),
|
|
polygon: {
|
|
hierarchy: coords,
|
|
material: Cesium.Color.fromCssColorString(record.fill).withAlpha(1),
|
|
zIndex: zindex2d.sx
|
|
}
|
|
});
|
|
ret.push(ent);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
}
|