How to use the cesium.PolylineCollection function in cesium

To help you get started, we’ve selected a few cesium examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codice / ddf / ui / packages / catalog-ui-search / src / main / webapp / js / widgets / cesium.polygon.js View on Github external
drawGeometry = model => {
    const json = model.toJSON()
    const isMultiPolygon = ShapeUtils.isArray3D(json.polygon)
    const polygons = isMultiPolygon ? json.polygon : [json.polygon]

    // first destroy old one
    if (this.primitive && !this.primitive.isDestroyed()) {
      this.map.scene.primitives.remove(this.primitive)
    }

    this.primitive = new Cesium.PolylineCollection()
    this.cameraMagnitude = this.map.camera.getMagnitude()
    ;(polygons || []).forEach(polygonPoints => {
      if (!polygonPoints || polygonPoints.length < 3) {
        return
      }
      if (
        polygonPoints[0].toString() !==
        polygonPoints[polygonPoints.length - 1].toString()
      ) {
        polygonPoints.push(polygonPoints[0])
      }
      polygonPoints.forEach(point => {
        point[0] = DistanceUtils.coordinateRound(point[0])
        point[1] = DistanceUtils.coordinateRound(point[1])
      })
github codice / ddf / ui / packages / catalog-ui-search / src / main / webapp / js / widgets / cesium.line.js View on Github external
return
    }

    const turfLine = Turf.lineString(setArr)
    let bufferedLine = turfLine
    this.cameraMagnitude = this.map.camera.getMagnitude()
    if (lineWidth > 100 || this.cameraMagnitude < CAMERA_MAGNITUDE_THRESHOLD) {
      bufferedLine = Turf.buffer(turfLine, Math.max(lineWidth, 1), 'meters')
    }

    // first destroy old one
    if (this.primitive && !this.primitive.isDestroyed()) {
      this.map.scene.primitives.remove(this.primitive)
    }

    this.primitive = new Cesium.PolylineCollection()
    this.primitive.add(
      this.constructLinePrimitive(bufferedLine.geometry.coordinates)
    )

    this.map.scene.primitives.add(this.primitive)
  }
}
github darwin-education / resium / src / PolylineCollection / PolylineCollection.ts View on Github external
create(context, props) {
    if (!context.primitiveCollection) return;
    const element = new CesiumPolylineCollection({
      modelMatrix: props.modelMatrix,
      debugShowBoundingVolume: props.debugShowBoundingVolume,
      length: props.length, //
      scene: context.scene,
    } as any);
    context.primitiveCollection.add(element);
    return element;
  },
  destroy(element, context) {
github codice / ddf / ui / packages / catalog-ui-search / src / main / webapp / component / visualization / maps / cesium / map.cesium.js View on Github external
addLine(line, options) {
      const lineObject = line.map(coordinate =>
        convertPointCoordinate(coordinate)
      )
      const cartPoints = _.map(lineObject, point =>
        Cesium.Cartographic.fromDegrees(
          point.longitude,
          point.latitude,
          point.altitude
        )
      )
      const cartesian = map.scene.globe.ellipsoid.cartographicArrayToCartesianArray(
        cartPoints
      )

      const polylineCollection = new Cesium.PolylineCollection()
      const polyline = polylineCollection.add({
        width: 8,
        material: Cesium.Material.fromType('PolylineOutline', {
          color: determineCesiumColor(options.color),
          outlineColor: Cesium.Color.WHITE,
          outlineWidth: 4,
        }),
        id: options.id,
        positions: cartesian,
      })

      if (map.scene.terrainProvider) {
        const promise = Cesium.sampleTerrain(
          map.scene.terrainProvider,
          5,
          cartPoints
github codice / ddf / ui / packages / catalog-ui-search / src / main / webapp / js / widgets / cesium.bbox.js View on Github external
return
    }

    this.destroyOldPrimitive()

    const coordinates = [
      [rectangle.east, rectangle.north],
      [rectangle.west, rectangle.north],
      [rectangle.west, rectangle.south],
      [rectangle.east, rectangle.south],
      [rectangle.east, rectangle.north],
    ]

    const color = this.model.get('color')

    this.primitive = new Cesium.PolylineCollection()
    this.primitive.add({
      width: 8,
      material: Cesium.Material.fromType('PolylineOutline', {
        color: color
          ? Cesium.Color.fromCssColorString(color)
          : Cesium.Color.KHAKI,
        outlineColor: Cesium.Color.WHITE,
        outlineWidth: 4,
      }),
      id: 'userDrawing',
      positions: Cesium.Cartesian3.fromRadiansArray(_.flatten(coordinates)),
    })

    this.options.map.scene.primitives.add(this.primitive)
    this.options.map.scene.requestRender()
  },
github darwin-education / resium / dist / resium.es.js View on Github external
create: function (cprops, props, context) {
        return new Cesium.PolylineCollection({
            modelMatrix: cprops.modelMatrix,
            debugShowBoundingVolume: cprops.debugShowBoundingVolume,
            length: cprops.length,
            scene: context.scene,
        });
    },
    mount: function (element, context) {
github codice / ddf / catalog / ui / catalog-ui-search / src / main / webapp / component / visualization / maps / cesium / shapes.js View on Github external
addLine: function (line, geocontroller, options) {
    var lineObject = line.map(function (coordinate) {
      return convertPointCoordinate(coordinate);
    });
    var cartPoints = _.map(lineObject, function (point) {
      return Cesium.Cartographic.fromDegrees(point.longitude, point.latitude, point.altitude);
    });
    var cartesian = geocontroller.ellipsoid.cartographicArrayToCartesianArray(cartPoints);

    var polylineCollection = new Cesium.PolylineCollection();
    var polyline = polylineCollection.add({
      width: 8,
      material: Cesium.Material.fromType('PolylineOutline', {
        color: determineCesiumColor(options.color),
        outlineColor: Cesium.Color.WHITE,
        outlineWidth: 4
      }),
      id: options.id,
      positions: cartesian
    });

    if (geocontroller.scene.terrainProvider) {
      var promise = Cesium.sampleTerrain(geocontroller.scene.terrainProvider, 5, cartPoints);
      Cesium.when(promise, function (updatedCartographic) {
        var positions = geocontroller.ellipsoid.cartographicArrayToCartesianArray(updatedCartographic);
        if (updatedCartographic[0].height && !options.view.isDestroyed) {
github codice / ddf / ui / packages / catalog-ui-search / src / main / webapp / js / widgets / cesium.circle.js View on Github external
}

    const color = this.model.get('color')

    const centerPt = Turf.point([modelProp.lon, modelProp.lat])
    const circleToCheck = new TurfCircle(
      centerPt,
      DistanceUtils.getDistanceInMeters(
        modelProp.radius,
        modelProp.radiusUnits
      ),
      64,
      'meters'
    )

    this.primitive = new Cesium.PolylineCollection()
    this.primitive.add({
      width: 8,
      material: Cesium.Material.fromType('PolylineOutline', {
        color: color
          ? Cesium.Color.fromCssColorString(color)
          : Cesium.Color.KHAKI,
        outlineColor: Cesium.Color.WHITE,
        outlineWidth: 4,
      }),
      id: 'userDrawing',
      positions: Cesium.Cartesian3.fromDegreesArray(
        _.flatten(circleToCheck.geometry.coordinates)
      ),
    })

    this.options.map.scene.primitives.add(this.primitive)