zoukankan      html  css  js  c++  java
  • arcgis 4 与deckgl 整合 (二)

    针对deckgl TripsLayer

    我们构建采集器,目的是支持多种数据类型到 TripsLayer, 并且支持arcgis 服务

    • const axios = require('axios')
    •  
    • export default class TripsLayerParser {
    • static getDataFromUrl(url: string) {
    • return new Promise((resolve => {
    • const queryUrl = `${url}/query?where=1%3D1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=%5B%5D&returnGeometry=true&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&resultOffset=&resultRecordCount=&queryByDistance=&returnExtentsOnly=false&datumTransformation=&parameterValues=&rangeValues=&f=geojson`;
    • axios.get(queryUrl).then((r: any) => {
    • let data = this.getTimestampFromGeoJson(r.data);
    • resolve(data);
    • });
    • }));
    • }
    •  
    • static getDataFromJsonUrl(url: string) {
    • return new Promise((resolve => {
    • axios.get(url).then((r: any) => {
    • let data = this.getTimestampFromGeoJson(r.data);
    • resolve(data);
    • });
    • }));
    • }
    •  
    • static getDataFromArray(array: any) {
    • return this.getTimestampFromArray(array);
    • }
    •  
    • private static getTimestampFromArray(lines: any) {
    • let data: any = [];
    • lines.forEach((line: any) => {
    • data.push({
    • path: line.geometry,
    • timestamps: this.getRandomTimestamp(line.geometry.length)
    • });
    • });
    • return data;
    • }
    •  
    • private static getTimestampFromGeoJson(dataArray: any) {
    • let lines = dataArray.features;
    •  
    • let data: any = [];
    • lines.forEach((line: any) => {
    • if (line.geometry.type === "MultiLineString") {
    • for (let item of line.geometry.coordinates) {
    • data.push({
    • path: item,
    • timestamps: this.getRandomTimestamp(item.length)
    • });
    • }
    • } else {
    • data.push({
    • path: line.geometry.coordinates,
    • timestamps: this.getRandomTimestamp(line.geometry.coordinates.length)
    • });
    • }
    • });
    • return data;
    • }
    •  
    • private static getRandomTimestamp(length: number) {
    • let timestamps: any = [];
    • for (let i = 0; i < length; i++) {
    • timestamps.push(i * 100);
    • }
    • return timestamps;
    • }
    • }

    封装的
    ```javascript
    import BaseLayer from "./BaseLayer";
    import TripsLayerParser from "./TripsLayerParser";
    import ColorManager from "./ColorManager";
    const {TripsLayer} = require("@deck.gl/geo-layers");

    export default class DeckTripsLayer extends BaseLayer {

    view: any;
    options: any;

  • 相关阅读:
    初始mysql语句
    MySQL 数据库 的安装和基本管理
    POJ 3685
    总结-LCT
    $亲属关系$
    一:包装好和吹出去 二:三国心得
    创业心得
    阿里前CEO卫哲的万字长文:被马云骂醒,看透B2B 10大核心问题!
    英雄不问出处, 看看商界大佬年轻时受过的苦
    最应该富养的,不是孩子是妻子!
  • 原文地址:https://www.cnblogs.com/haibalai/p/15828980.html
Copyright © 2011-2022 走看看